@ozguraltan/strapi-content-input 1.0.23 → 1.0.25

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.
@@ -3,9 +3,10 @@ const jsxRuntime = require("react/jsx-runtime");
3
3
  const React = require("react");
4
4
  const ReactDOM = require("react-dom");
5
5
  const admin = require("@strapi/strapi/admin");
6
- const index = require("./index-B9C8Qrfd.js");
6
+ const index = require("./index--fSIDKkt.js");
7
7
  const cloneDeep = require("lodash/cloneDeep");
8
8
  const _interopDefault = (e) => e && e.__esModule ? e : { default: e };
9
+ const React__default = /* @__PURE__ */ _interopDefault(React);
9
10
  const ReactDOM__default = /* @__PURE__ */ _interopDefault(ReactDOM);
10
11
  const cloneDeep__default = /* @__PURE__ */ _interopDefault(cloneDeep);
11
12
  const ROW_PRESETS = [
@@ -10890,6 +10891,1440 @@ const SurveyLivePreviewPane = ({
10890
10891
  }
10891
10892
  );
10892
10893
  };
10894
+ function triggerJsonDownload(filename, dataObj) {
10895
+ const jsonText = JSON.stringify(dataObj, null, 2);
10896
+ const blob = new Blob([jsonText], { type: "application/json;charset=utf-8" });
10897
+ const url = URL.createObjectURL(blob);
10898
+ const a = document.createElement("a");
10899
+ a.href = url;
10900
+ a.download = filename;
10901
+ document.body.appendChild(a);
10902
+ a.click();
10903
+ document.body.removeChild(a);
10904
+ URL.revokeObjectURL(url);
10905
+ }
10906
+ function sanitizeSurveyRecordForClientBundle(srv, rawResponses = []) {
10907
+ const cleanTitle = String(srv?.title || "Untitled Survey").trim();
10908
+ const cleanSlug = String(srv?.slug || "survey").trim();
10909
+ const sortedResponses = Array.isArray(rawResponses) ? [...rawResponses].sort((a, b) => {
10910
+ const ta = new Date(a?.submittedAt || a?.createdAt || 0).getTime();
10911
+ const tb = new Date(b?.submittedAt || b?.createdAt || 0).getTime();
10912
+ return ta - tb;
10913
+ }) : [];
10914
+ return {
10915
+ title: cleanTitle,
10916
+ titleI18n: srv?.titleI18n || { tr: cleanTitle, en: cleanTitle },
10917
+ slug: cleanSlug,
10918
+ description: srv?.description ?? { tr: "", en: "" },
10919
+ status: srv?.status || "published",
10920
+ displayMode: srv?.displayMode || "single_page",
10921
+ startsAt: srv?.startsAt || null,
10922
+ endsAt: srv?.endsAt || null,
10923
+ quotaLimit: srv?.quotaLimit ? Number(srv.quotaLimit) : null,
10924
+ submissionPolicy: srv?.submissionPolicy || "one_per_voter",
10925
+ anonymizeIp: srv?.anonymizeIp !== void 0 ? Boolean(srv.anonymizeIp) : true,
10926
+ showPublicResults: srv?.showPublicResults || "after_vote",
10927
+ allowBackNavigation: srv?.allowBackNavigation !== void 0 ? Boolean(srv.allowBackNavigation) : true,
10928
+ showProgressBar: srv?.showProgressBar !== void 0 ? Boolean(srv.showProgressBar) : true,
10929
+ useRecaptcha: srv?.useRecaptcha !== void 0 ? Boolean(srv.useRecaptcha) : false,
10930
+ recaptchaSiteKey: srv?.recaptchaSiteKey ? String(srv.recaptchaSiteKey) : "",
10931
+ steps: Array.isArray(srv?.steps) ? srv.steps : [],
10932
+ questions: Array.isArray(srv?.questions) ? srv.questions : [],
10933
+ settings: srv?.settings && typeof srv.settings === "object" ? srv.settings : {},
10934
+ version: Number(srv?.version || 1),
10935
+ responses: sortedResponses.map((r) => ({
10936
+ answers: r?.answers && typeof r.answers === "object" && !Array.isArray(r.answers) ? r.answers : {},
10937
+ otherTexts: r?.otherTexts && typeof r.otherTexts === "object" && !Array.isArray(r.otherTexts) ? r.otherTexts : {},
10938
+ score: typeof r?.score === "number" ? r.score : null,
10939
+ npsValue: typeof r?.npsValue === "number" ? r.npsValue : null,
10940
+ npsCategory: r?.npsCategory || null,
10941
+ locale: String(r?.locale || "en"),
10942
+ durationSeconds: Math.max(0, Number(r?.durationSeconds || 0) || 0),
10943
+ voterHash: r?.voterHash || null,
10944
+ respondentToken: r?.respondentToken || null,
10945
+ submittedAt: r?.submittedAt || r?.createdAt || (/* @__PURE__ */ new Date()).toISOString()
10946
+ }))
10947
+ };
10948
+ }
10949
+ function buildClientDraftBundle(draft) {
10950
+ const portableItem = sanitizeSurveyRecordForClientBundle(draft, []);
10951
+ return {
10952
+ filename: `${portableItem.slug}-structure.ci-survey.json`,
10953
+ bundle: {
10954
+ packageType: "strapi-content-input-survey-bundle",
10955
+ schemaVersion: 1,
10956
+ mode: "structure",
10957
+ exportedAt: (/* @__PURE__ */ new Date()).toISOString(),
10958
+ surveyCount: 1,
10959
+ totalResponses: 0,
10960
+ surveys: [portableItem]
10961
+ }
10962
+ };
10963
+ }
10964
+ function isRouteNotLoadedError(err) {
10965
+ const status = err?.status || err?.response?.status;
10966
+ const msg = String(
10967
+ err?.response?.data?.error?.message || err?.message || ""
10968
+ ).toLowerCase();
10969
+ return status === 404 && (msg === "not found" || msg.includes("not found"));
10970
+ }
10971
+ const SurveyExportModal = ({
10972
+ open,
10973
+ uiLocale = "en",
10974
+ targetSurvey,
10975
+ allowAllSurveys = false,
10976
+ defaultScope = "single",
10977
+ totalSurveysCount = 0,
10978
+ isUnsavedDraft = false,
10979
+ onClose
10980
+ }) => {
10981
+ const tr = uiLocale === "tr";
10982
+ const { get } = admin.useFetchClient();
10983
+ const [scope, setScope] = React.useState(
10984
+ !targetSurvey && allowAllSurveys ? "all" : defaultScope
10985
+ );
10986
+ const [mode, setMode] = React.useState("full");
10987
+ const [busy, setBusy] = React.useState(false);
10988
+ const [errorMsg, setErrorMsg] = React.useState("");
10989
+ React__default.default.useEffect(() => {
10990
+ if (open) {
10991
+ setScope(!targetSurvey && allowAllSurveys ? "all" : defaultScope);
10992
+ setMode(isUnsavedDraft ? "structure" : "full");
10993
+ setErrorMsg("");
10994
+ }
10995
+ }, [open, targetSurvey, allowAllSurveys, defaultScope, isUnsavedDraft]);
10996
+ if (!open || typeof document === "undefined") return null;
10997
+ const handleExport = async () => {
10998
+ setBusy(true);
10999
+ setErrorMsg("");
11000
+ try {
11001
+ if (scope === "single" && targetSurvey && isUnsavedDraft) {
11002
+ const localPkg = buildClientDraftBundle(targetSurvey);
11003
+ triggerJsonDownload(localPkg.filename, localPkg.bundle);
11004
+ onClose();
11005
+ return;
11006
+ }
11007
+ const targetParam = scope === "all" ? "all" : String(targetSurvey?.slug || targetSurvey?.id || "");
11008
+ if (!targetParam) {
11009
+ setErrorMsg(tr ? "Dışa aktarılacak anket bulunamadı." : "No survey selected.");
11010
+ return;
11011
+ }
11012
+ try {
11013
+ const res = await get(
11014
+ `/content-input/survey-bundle/export?target=${encodeURIComponent(
11015
+ targetParam
11016
+ )}&mode=${mode}`
11017
+ );
11018
+ const payload = res?.data;
11019
+ if (payload?.bundle) {
11020
+ triggerJsonDownload(
11021
+ payload.filename || `survey-${mode}.ci-survey.json`,
11022
+ payload.bundle
11023
+ );
11024
+ onClose();
11025
+ return;
11026
+ }
11027
+ } catch (bundleErr) {
11028
+ if (!isRouteNotLoadedError(bundleErr)) {
11029
+ throw bundleErr;
11030
+ }
11031
+ let list = [];
11032
+ if (scope === "all") {
11033
+ const allRes = await get("/content-input/surveys");
11034
+ list = Array.isArray(allRes?.data) ? allRes.data : [];
11035
+ } else {
11036
+ const oneRes = await get(
11037
+ `/content-input/surveys/${encodeURIComponent(targetParam)}`
11038
+ );
11039
+ if (oneRes?.data) list = [oneRes.data];
11040
+ }
11041
+ if (list.length === 0) {
11042
+ throw new Error(tr ? "Anket bulunamadı." : "Survey not found.");
11043
+ }
11044
+ let totalResponses = 0;
11045
+ const portableSurveys = [];
11046
+ for (const srv of list) {
11047
+ let rawResps = [];
11048
+ if (mode === "full" && srv?.slug) {
11049
+ const rRes = await get(
11050
+ `/content-input/surveys/${encodeURIComponent(srv.slug)}/responses?limit=500`
11051
+ );
11052
+ rawResps = Array.isArray(rRes?.data) ? rRes.data : [];
11053
+ }
11054
+ const item = sanitizeSurveyRecordForClientBundle(srv, rawResps);
11055
+ totalResponses += item.responses.length;
11056
+ portableSurveys.push(item);
11057
+ }
11058
+ const dateStamp = (/* @__PURE__ */ new Date()).toISOString().slice(0, 10);
11059
+ const modeSuffix = mode === "full" ? "full-backup" : "structure";
11060
+ const fallbackFilename = scope === "single" && portableSurveys[0]?.slug ? `${portableSurveys[0].slug}-${modeSuffix}.ci-survey.json` : `ci-surveys-all-${modeSuffix}-${dateStamp}.ci-survey.json`;
11061
+ triggerJsonDownload(fallbackFilename, {
11062
+ packageType: "strapi-content-input-survey-bundle",
11063
+ schemaVersion: 1,
11064
+ mode,
11065
+ exportedAt: (/* @__PURE__ */ new Date()).toISOString(),
11066
+ surveyCount: portableSurveys.length,
11067
+ totalResponses,
11068
+ surveys: portableSurveys
11069
+ });
11070
+ onClose();
11071
+ return;
11072
+ }
11073
+ } catch (err) {
11074
+ setErrorMsg(err?.message || (tr ? "Dışa aktarma başarısız oldu." : "Export failed."));
11075
+ } finally {
11076
+ setBusy(false);
11077
+ }
11078
+ };
11079
+ return ReactDOM.createPortal(
11080
+ /* @__PURE__ */ jsxRuntime.jsx(
11081
+ "div",
11082
+ {
11083
+ className: "ci-root",
11084
+ style: {
11085
+ position: "fixed",
11086
+ inset: 0,
11087
+ background: "rgba(15, 23, 42, 0.68)",
11088
+ zIndex: 310,
11089
+ display: "flex",
11090
+ alignItems: "center",
11091
+ justifyContent: "center",
11092
+ padding: 16
11093
+ },
11094
+ onClick: onClose,
11095
+ children: /* @__PURE__ */ jsxRuntime.jsxs(
11096
+ "div",
11097
+ {
11098
+ style: {
11099
+ width: "100%",
11100
+ maxWidth: 540,
11101
+ background: "#ffffff",
11102
+ borderRadius: 12,
11103
+ boxShadow: "0 24px 54px rgba(15, 23, 42, 0.4)",
11104
+ overflow: "hidden",
11105
+ fontFamily: "-apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Helvetica, Arial, sans-serif"
11106
+ },
11107
+ onClick: (e) => e.stopPropagation(),
11108
+ children: [
11109
+ /* @__PURE__ */ jsxRuntime.jsxs(
11110
+ "div",
11111
+ {
11112
+ style: {
11113
+ padding: "14px 18px",
11114
+ background: "#0f172a",
11115
+ color: "#ffffff",
11116
+ display: "flex",
11117
+ alignItems: "center",
11118
+ justifyContent: "space-between"
11119
+ },
11120
+ children: [
11121
+ /* @__PURE__ */ jsxRuntime.jsxs("div", { style: { display: "flex", alignItems: "center", gap: 8 }, children: [
11122
+ /* @__PURE__ */ jsxRuntime.jsx(index.MaterialIcon, { name: "download", size: 20, color: "#38bdf8" }),
11123
+ /* @__PURE__ */ jsxRuntime.jsx("span", { style: { fontSize: 14, fontWeight: 700 }, children: tr ? "Anket Paketi Dışa Aktar (.ci-survey.json)" : "Export Survey Package (.ci-survey.json)" })
11124
+ ] }),
11125
+ /* @__PURE__ */ jsxRuntime.jsx(
11126
+ "button",
11127
+ {
11128
+ type: "button",
11129
+ onClick: onClose,
11130
+ style: {
11131
+ border: "none",
11132
+ background: "transparent",
11133
+ color: "#cbd5e1",
11134
+ fontSize: 18,
11135
+ cursor: "pointer"
11136
+ },
11137
+ children: "×"
11138
+ }
11139
+ )
11140
+ ]
11141
+ }
11142
+ ),
11143
+ /* @__PURE__ */ jsxRuntime.jsxs("div", { style: { padding: 18, display: "flex", flexDirection: "column", gap: 14 }, children: [
11144
+ allowAllSurveys && /* @__PURE__ */ jsxRuntime.jsxs("div", { children: [
11145
+ /* @__PURE__ */ jsxRuntime.jsx(
11146
+ "div",
11147
+ {
11148
+ style: {
11149
+ fontSize: 11.5,
11150
+ fontWeight: 700,
11151
+ color: "#334155",
11152
+ marginBottom: 6
11153
+ },
11154
+ children: tr ? "1. Dışa Aktarım Kapsamı" : "1. Export Scope"
11155
+ }
11156
+ ),
11157
+ /* @__PURE__ */ jsxRuntime.jsxs("div", { style: { display: "grid", gridTemplateColumns: "1fr 1fr", gap: 8 }, children: [
11158
+ /* @__PURE__ */ jsxRuntime.jsxs(
11159
+ "button",
11160
+ {
11161
+ type: "button",
11162
+ disabled: !targetSurvey,
11163
+ onClick: () => setScope("single"),
11164
+ style: {
11165
+ padding: "9px 10px",
11166
+ borderRadius: 8,
11167
+ border: scope === "single" ? "2px solid #2563eb" : "1px solid #cbd5e1",
11168
+ background: scope === "single" ? "#eff6ff" : "#f8fafc",
11169
+ color: !targetSurvey ? "#94a3b8" : scope === "single" ? "#1e3a8a" : "#334155",
11170
+ fontSize: 12,
11171
+ fontWeight: 700,
11172
+ cursor: !targetSurvey ? "not-allowed" : "pointer",
11173
+ textAlign: "left"
11174
+ },
11175
+ children: [
11176
+ /* @__PURE__ */ jsxRuntime.jsx("div", { children: tr ? "Seçili Anket" : "Selected Survey" }),
11177
+ /* @__PURE__ */ jsxRuntime.jsx(
11178
+ "div",
11179
+ {
11180
+ style: {
11181
+ fontSize: 10.5,
11182
+ fontWeight: 500,
11183
+ color: "#64748b",
11184
+ marginTop: 2,
11185
+ overflow: "hidden",
11186
+ textOverflow: "ellipsis",
11187
+ whiteSpace: "nowrap"
11188
+ },
11189
+ children: targetSurvey ? targetSurvey.title : "-"
11190
+ }
11191
+ )
11192
+ ]
11193
+ }
11194
+ ),
11195
+ /* @__PURE__ */ jsxRuntime.jsxs(
11196
+ "button",
11197
+ {
11198
+ type: "button",
11199
+ disabled: totalSurveysCount === 0,
11200
+ onClick: () => setScope("all"),
11201
+ style: {
11202
+ padding: "9px 10px",
11203
+ borderRadius: 8,
11204
+ border: scope === "all" ? "2px solid #2563eb" : "1px solid #cbd5e1",
11205
+ background: scope === "all" ? "#eff6ff" : "#f8fafc",
11206
+ color: totalSurveysCount === 0 ? "#94a3b8" : scope === "all" ? "#1e3a8a" : "#334155",
11207
+ fontSize: 12,
11208
+ fontWeight: 700,
11209
+ cursor: totalSurveysCount === 0 ? "not-allowed" : "pointer",
11210
+ textAlign: "left"
11211
+ },
11212
+ children: [
11213
+ /* @__PURE__ */ jsxRuntime.jsx("div", { children: tr ? "Tüm Anketler (Toplu Paket)" : "All Surveys (Bundle)" }),
11214
+ /* @__PURE__ */ jsxRuntime.jsx("div", { style: { fontSize: 10.5, fontWeight: 500, color: "#64748b", marginTop: 2 }, children: tr ? `${totalSurveysCount} anket tek dosyada` : `${totalSurveysCount} surveys in one file` })
11215
+ ]
11216
+ }
11217
+ )
11218
+ ] })
11219
+ ] }),
11220
+ /* @__PURE__ */ jsxRuntime.jsxs("div", { children: [
11221
+ /* @__PURE__ */ jsxRuntime.jsx(
11222
+ "div",
11223
+ {
11224
+ style: {
11225
+ fontSize: 11.5,
11226
+ fontWeight: 700,
11227
+ color: "#334155",
11228
+ marginBottom: 6
11229
+ },
11230
+ children: allowAllSurveys ? tr ? "2. Paket İçeriği Seçin" : "2. Choose Package Mode" : tr ? "Paket İçeriği Seçin" : "Choose Package Mode"
11231
+ }
11232
+ ),
11233
+ /* @__PURE__ */ jsxRuntime.jsxs("div", { style: { display: "flex", flexDirection: "column", gap: 8 }, children: [
11234
+ /* @__PURE__ */ jsxRuntime.jsxs(
11235
+ "label",
11236
+ {
11237
+ onClick: () => setMode("structure"),
11238
+ style: {
11239
+ padding: 12,
11240
+ borderRadius: 9,
11241
+ border: mode === "structure" ? "2px solid #2563eb" : "1px solid #cbd5e1",
11242
+ background: mode === "structure" ? "#eff6ff" : "#ffffff",
11243
+ cursor: "pointer",
11244
+ display: "flex",
11245
+ alignItems: "flex-start",
11246
+ gap: 10
11247
+ },
11248
+ children: [
11249
+ /* @__PURE__ */ jsxRuntime.jsx(
11250
+ "input",
11251
+ {
11252
+ type: "radio",
11253
+ checked: mode === "structure",
11254
+ onChange: () => setMode("structure"),
11255
+ style: { marginTop: 3 }
11256
+ }
11257
+ ),
11258
+ /* @__PURE__ */ jsxRuntime.jsxs("div", { children: [
11259
+ /* @__PURE__ */ jsxRuntime.jsx("div", { style: { fontSize: 12.5, fontWeight: 700, color: "#0f172a" }, children: tr ? "Sadece Yapı (Şema, Kategoriler, Sorular & Kurallar)" : "Structure Only (Schema, Steps, Questions & Logic)" }),
11260
+ /* @__PURE__ */ jsxRuntime.jsx("div", { style: { fontSize: 11, color: "#475569", marginTop: 3, lineHeight: 1.45 }, children: tr ? "Tüm adımlar, çok dilli metinler, ölçek etiketleri ve koşullu mantık kurallarını dışa aktarır. Yanıt verisi içermez (0 yanıt). Şablon taşımak için idealdir." : "Exports all wizard steps, localized labels, scale labels, and skip-logic rules without participant responses (0 responses). Ideal for templates." })
11261
+ ] })
11262
+ ]
11263
+ }
11264
+ ),
11265
+ /* @__PURE__ */ jsxRuntime.jsxs(
11266
+ "label",
11267
+ {
11268
+ onClick: () => {
11269
+ if (!isUnsavedDraft) setMode("full");
11270
+ },
11271
+ style: {
11272
+ padding: 12,
11273
+ borderRadius: 9,
11274
+ border: mode === "full" ? "2px solid #059669" : "1px solid #cbd5e1",
11275
+ background: isUnsavedDraft ? "#f8fafc" : mode === "full" ? "#ecfdf5" : "#ffffff",
11276
+ opacity: isUnsavedDraft ? 0.6 : 1,
11277
+ cursor: isUnsavedDraft ? "not-allowed" : "pointer",
11278
+ display: "flex",
11279
+ alignItems: "flex-start",
11280
+ gap: 10
11281
+ },
11282
+ children: [
11283
+ /* @__PURE__ */ jsxRuntime.jsx(
11284
+ "input",
11285
+ {
11286
+ type: "radio",
11287
+ disabled: isUnsavedDraft,
11288
+ checked: mode === "full",
11289
+ onChange: () => setMode("full"),
11290
+ style: { marginTop: 3 }
11291
+ }
11292
+ ),
11293
+ /* @__PURE__ */ jsxRuntime.jsxs("div", { children: [
11294
+ /* @__PURE__ */ jsxRuntime.jsx("div", { style: { fontSize: 12.5, fontWeight: 700, color: "#0f172a" }, children: tr ? "Yapı + Yanıt Verileri (Tam Yedek & Rapor Canlandırma)" : "Structure + Response Data (Full Backup & Analytics Restore)" }),
11295
+ /* @__PURE__ */ jsxRuntime.jsx("div", { style: { fontSize: 11, color: "#475569", marginTop: 3, lineHeight: 1.45 }, children: isUnsavedDraft ? tr ? "Bu taslak henüz kaydedilmediği için sunucuda yanıt verisi bulunmuyor." : "Save this draft first to export server responses." : tr ? "Anket şemasıyla birlikte tüm katılımcı yanıtlarını, NPS skorlarını ve tarihçeyi dışa aktarır. İçe aktarıldığında tüm grafikler birebir canlanır." : "Includes complete survey structure plus all recorded responses, NPS metrics, and timestamps so charts and Excel exports revive 1:1." })
11296
+ ] })
11297
+ ]
11298
+ }
11299
+ )
11300
+ ] })
11301
+ ] }),
11302
+ /* @__PURE__ */ jsxRuntime.jsx(
11303
+ "div",
11304
+ {
11305
+ style: {
11306
+ padding: "8px 11px",
11307
+ borderRadius: 7,
11308
+ background: "#f8fafc",
11309
+ border: "1px solid #e2e8f0",
11310
+ fontSize: 11,
11311
+ color: "#64748b"
11312
+ },
11313
+ children: tr ? "Güvenlik notu: Gizli reCAPTCHA Secret Key ve özel SMTP parolaları dışa aktarılan JSON paketine dahil edilmez." : "Security note: Private reCAPTCHA secret keys and SMTP credentials are automatically stripped from exported packages."
11314
+ }
11315
+ ),
11316
+ errorMsg && /* @__PURE__ */ jsxRuntime.jsx(
11317
+ "div",
11318
+ {
11319
+ style: {
11320
+ padding: "8px 12px",
11321
+ borderRadius: 7,
11322
+ background: "#fee2e2",
11323
+ color: "#991b1b",
11324
+ fontSize: 11.5,
11325
+ fontWeight: 600
11326
+ },
11327
+ children: errorMsg
11328
+ }
11329
+ ),
11330
+ /* @__PURE__ */ jsxRuntime.jsxs("div", { style: { display: "flex", justifyContent: "flex-end", gap: 8 }, children: [
11331
+ /* @__PURE__ */ jsxRuntime.jsx(
11332
+ "button",
11333
+ {
11334
+ type: "button",
11335
+ onClick: onClose,
11336
+ style: {
11337
+ padding: "8px 14px",
11338
+ borderRadius: 7,
11339
+ border: "1px solid #cbd5e1",
11340
+ background: "#ffffff",
11341
+ color: "#334155",
11342
+ fontSize: 12,
11343
+ fontWeight: 600,
11344
+ cursor: "pointer"
11345
+ },
11346
+ children: tr ? "Vazgeç" : "Cancel"
11347
+ }
11348
+ ),
11349
+ /* @__PURE__ */ jsxRuntime.jsxs(
11350
+ "button",
11351
+ {
11352
+ type: "button",
11353
+ disabled: busy,
11354
+ onClick: handleExport,
11355
+ style: {
11356
+ padding: "8px 16px",
11357
+ borderRadius: 7,
11358
+ border: "none",
11359
+ background: mode === "full" ? "#059669" : "#2563eb",
11360
+ color: "#ffffff",
11361
+ fontSize: 12,
11362
+ fontWeight: 700,
11363
+ cursor: "pointer",
11364
+ display: "inline-flex",
11365
+ alignItems: "center",
11366
+ gap: 6
11367
+ },
11368
+ children: [
11369
+ /* @__PURE__ */ jsxRuntime.jsx(index.MaterialIcon, { name: "download", size: 16, color: "#fff" }),
11370
+ /* @__PURE__ */ jsxRuntime.jsx("span", { children: busy ? tr ? "Hazırlanıyor..." : "Preparing..." : tr ? "JSON Paketini İndir" : "Download JSON Package" })
11371
+ ]
11372
+ }
11373
+ )
11374
+ ] })
11375
+ ] })
11376
+ ]
11377
+ }
11378
+ )
11379
+ }
11380
+ ),
11381
+ document.body
11382
+ );
11383
+ };
11384
+ function inspectSurveyBundle(raw, existingSlugs) {
11385
+ let items = [];
11386
+ let mode = "structure";
11387
+ if (Array.isArray(raw)) {
11388
+ items = raw;
11389
+ } else if (raw && typeof raw === "object") {
11390
+ if (typeof raw.mode === "string") mode = raw.mode;
11391
+ if (Array.isArray(raw.surveys)) {
11392
+ items = raw.surveys;
11393
+ } else if (Array.isArray(raw.questions) || raw.title || raw.slug) {
11394
+ items = [raw];
11395
+ }
11396
+ }
11397
+ const valid = items.filter(
11398
+ (it) => it && typeof it === "object" && (Array.isArray(it.questions) || it.title)
11399
+ );
11400
+ if (valid.length === 0) return null;
11401
+ let totalQuestions = 0;
11402
+ let totalResponses = 0;
11403
+ let conflictCount = 0;
11404
+ const surveys = valid.map((it) => {
11405
+ const slug = String(it.slug || "").trim();
11406
+ const stepCount = Array.isArray(it.steps) ? it.steps.length : 0;
11407
+ const questionCount = Array.isArray(it.questions) ? it.questions.length : 0;
11408
+ const responseCount = Array.isArray(it.responses) ? it.responses.length : 0;
11409
+ const hasConflict = Boolean(slug && existingSlugs.has(slug));
11410
+ totalQuestions += questionCount;
11411
+ totalResponses += responseCount;
11412
+ if (hasConflict) conflictCount += 1;
11413
+ return {
11414
+ title: String(it.title || slug || "Survey"),
11415
+ slug: slug || "(auto)",
11416
+ displayMode: String(it.displayMode || "single_page"),
11417
+ stepCount,
11418
+ questionCount,
11419
+ responseCount,
11420
+ hasConflict
11421
+ };
11422
+ });
11423
+ if (totalResponses > 0) mode = "full";
11424
+ return {
11425
+ raw,
11426
+ mode,
11427
+ surveys,
11428
+ totalQuestions,
11429
+ totalResponses,
11430
+ conflictCount
11431
+ };
11432
+ }
11433
+ const SurveyImportModal = ({
11434
+ open,
11435
+ uiLocale = "en",
11436
+ existingSlugs = [],
11437
+ onClose,
11438
+ onImported
11439
+ }) => {
11440
+ const tr = uiLocale === "tr";
11441
+ const { post } = admin.useFetchClient();
11442
+ const fileInputRef = React.useRef(null);
11443
+ const [fileName, setFileName] = React.useState("");
11444
+ const [summary, setSummary] = React.useState(null);
11445
+ const [conflictStrategy, setConflictStrategy] = React.useState(
11446
+ "duplicate"
11447
+ );
11448
+ const [includeResponses, setIncludeResponses] = React.useState(true);
11449
+ const [dragOver, setDragOver] = React.useState(false);
11450
+ const [importing, setImporting] = React.useState(false);
11451
+ const [errorMsg, setErrorMsg] = React.useState("");
11452
+ React__default.default.useEffect(() => {
11453
+ if (open) {
11454
+ setFileName("");
11455
+ setSummary(null);
11456
+ setConflictStrategy("duplicate");
11457
+ setIncludeResponses(true);
11458
+ setErrorMsg("");
11459
+ }
11460
+ }, [open]);
11461
+ if (!open || typeof document === "undefined") return null;
11462
+ const slugSet = new Set(existingSlugs.map((s) => String(s || "").trim()).filter(Boolean));
11463
+ const parseFile = (file) => {
11464
+ setErrorMsg("");
11465
+ setFileName(file.name);
11466
+ const reader = new FileReader();
11467
+ reader.onload = () => {
11468
+ try {
11469
+ const parsed = JSON.parse(String(reader.result || ""));
11470
+ const inspected = inspectSurveyBundle(parsed, slugSet);
11471
+ if (!inspected) {
11472
+ setSummary(null);
11473
+ setErrorMsg(
11474
+ tr ? "Seçilen JSON dosyasında geçerli bir ContentInput anket tanımı bulunamadı." : "No valid ContentInput survey definition found in this JSON file."
11475
+ );
11476
+ return;
11477
+ }
11478
+ setSummary(inspected);
11479
+ setIncludeResponses(inspected.totalResponses > 0);
11480
+ } catch {
11481
+ setSummary(null);
11482
+ setErrorMsg(
11483
+ tr ? "Dosya geçerli bir JSON formatında değil." : "Invalid JSON file format."
11484
+ );
11485
+ }
11486
+ };
11487
+ reader.readAsText(file, "utf-8");
11488
+ };
11489
+ const handleImport = async () => {
11490
+ if (!summary) return;
11491
+ setImporting(true);
11492
+ setErrorMsg("");
11493
+ try {
11494
+ const res = await post("/content-input/survey-bundle/import", {
11495
+ bundle: summary.raw,
11496
+ conflictStrategy,
11497
+ includeResponses: summary.totalResponses > 0 ? includeResponses : false
11498
+ });
11499
+ const data = res?.data || {};
11500
+ onImported({
11501
+ importedCount: Number(data.importedCount || 0),
11502
+ importedResponsesCount: Number(data.importedResponsesCount || 0),
11503
+ importedSurveys: Array.isArray(data.importedSurveys) ? data.importedSurveys : []
11504
+ });
11505
+ onClose();
11506
+ } catch (err) {
11507
+ if (isRouteNotLoadedError(err)) {
11508
+ setErrorMsg(
11509
+ tr ? "Yeni sunucu rotalarının aktif olması için lütfen Strapi sunucusunu (npm run dev) bir kez yeniden başlatın." : "Please restart the Strapi server (npm run dev) once so the new backend routes take effect."
11510
+ );
11511
+ } else {
11512
+ setErrorMsg(
11513
+ err?.response?.data?.error?.message || err?.message || (tr ? "İçe aktarma başarısız oldu." : "Import failed.")
11514
+ );
11515
+ }
11516
+ } finally {
11517
+ setImporting(false);
11518
+ }
11519
+ };
11520
+ return ReactDOM.createPortal(
11521
+ /* @__PURE__ */ jsxRuntime.jsx(
11522
+ "div",
11523
+ {
11524
+ className: "ci-root",
11525
+ style: {
11526
+ position: "fixed",
11527
+ inset: 0,
11528
+ background: "rgba(15, 23, 42, 0.68)",
11529
+ zIndex: 310,
11530
+ display: "flex",
11531
+ alignItems: "center",
11532
+ justifyContent: "center",
11533
+ padding: 16
11534
+ },
11535
+ onClick: onClose,
11536
+ children: /* @__PURE__ */ jsxRuntime.jsxs(
11537
+ "div",
11538
+ {
11539
+ style: {
11540
+ width: "100%",
11541
+ maxWidth: 590,
11542
+ maxHeight: "90vh",
11543
+ background: "#ffffff",
11544
+ borderRadius: 12,
11545
+ boxShadow: "0 24px 54px rgba(15, 23, 42, 0.4)",
11546
+ display: "flex",
11547
+ flexDirection: "column",
11548
+ overflow: "hidden",
11549
+ fontFamily: "-apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Helvetica, Arial, sans-serif"
11550
+ },
11551
+ onClick: (e) => e.stopPropagation(),
11552
+ children: [
11553
+ /* @__PURE__ */ jsxRuntime.jsxs(
11554
+ "div",
11555
+ {
11556
+ style: {
11557
+ padding: "14px 18px",
11558
+ background: "#0f172a",
11559
+ color: "#ffffff",
11560
+ display: "flex",
11561
+ alignItems: "center",
11562
+ justifyContent: "space-between"
11563
+ },
11564
+ children: [
11565
+ /* @__PURE__ */ jsxRuntime.jsxs("div", { style: { display: "flex", alignItems: "center", gap: 8 }, children: [
11566
+ /* @__PURE__ */ jsxRuntime.jsx(index.MaterialIcon, { name: "upload_file", size: 20, color: "#38bdf8" }),
11567
+ /* @__PURE__ */ jsxRuntime.jsx("span", { style: { fontSize: 14, fontWeight: 700 }, children: tr ? "JSON Paketinden Anket Canlandır / İçe Aktar" : "Import & Revive Survey from JSON Package" })
11568
+ ] }),
11569
+ /* @__PURE__ */ jsxRuntime.jsx(
11570
+ "button",
11571
+ {
11572
+ type: "button",
11573
+ onClick: onClose,
11574
+ style: {
11575
+ border: "none",
11576
+ background: "transparent",
11577
+ color: "#cbd5e1",
11578
+ fontSize: 18,
11579
+ cursor: "pointer"
11580
+ },
11581
+ children: "×"
11582
+ }
11583
+ )
11584
+ ]
11585
+ }
11586
+ ),
11587
+ /* @__PURE__ */ jsxRuntime.jsxs(
11588
+ "div",
11589
+ {
11590
+ style: {
11591
+ padding: 18,
11592
+ overflowY: "auto",
11593
+ display: "flex",
11594
+ flexDirection: "column",
11595
+ gap: 14
11596
+ },
11597
+ children: [
11598
+ /* @__PURE__ */ jsxRuntime.jsxs(
11599
+ "div",
11600
+ {
11601
+ onClick: () => fileInputRef.current?.click(),
11602
+ onDragOver: (e) => {
11603
+ e.preventDefault();
11604
+ setDragOver(true);
11605
+ },
11606
+ onDragLeave: () => setDragOver(false),
11607
+ onDrop: (e) => {
11608
+ e.preventDefault();
11609
+ setDragOver(false);
11610
+ const f = e.dataTransfer.files?.[0];
11611
+ if (f) parseFile(f);
11612
+ },
11613
+ style: {
11614
+ padding: "20px 16px",
11615
+ borderRadius: 10,
11616
+ border: dragOver ? "2px dashed #2563eb" : "2px dashed #cbd5e1",
11617
+ background: dragOver ? "#eff6ff" : "#f8fafc",
11618
+ textAlign: "center",
11619
+ cursor: "pointer",
11620
+ transition: "all 0.14s ease"
11621
+ },
11622
+ children: [
11623
+ /* @__PURE__ */ jsxRuntime.jsx(
11624
+ "input",
11625
+ {
11626
+ ref: fileInputRef,
11627
+ type: "file",
11628
+ accept: ".json,application/json",
11629
+ style: { display: "none" },
11630
+ onChange: (e) => {
11631
+ const f = e.target.files?.[0];
11632
+ if (f) parseFile(f);
11633
+ e.target.value = "";
11634
+ }
11635
+ }
11636
+ ),
11637
+ /* @__PURE__ */ jsxRuntime.jsx(
11638
+ index.MaterialIcon,
11639
+ {
11640
+ name: "folder_open",
11641
+ size: 28,
11642
+ color: dragOver ? "#2563eb" : "#64748b"
11643
+ }
11644
+ ),
11645
+ /* @__PURE__ */ jsxRuntime.jsx("div", { style: { fontSize: 12.5, fontWeight: 700, color: "#0f172a", marginTop: 6 }, children: fileName ? `${tr ? "Seçilen Dosya:" : "Selected File:"} ${fileName}` : tr ? ".ci-survey.json dosyasını buraya sürükleyin veya seçmek için tıklayın" : "Drop a .ci-survey.json package here or click to browse" }),
11646
+ /* @__PURE__ */ jsxRuntime.jsx("div", { style: { fontSize: 11, color: "#64748b", marginTop: 3 }, children: tr ? "Tekil anket veya çoklu anket yedek paketlerini (Sadece Yapı / Yapı + Veri) destekler." : "Supports both single-survey and multi-survey bundles (Structure-only or Full Backup)." })
11647
+ ]
11648
+ }
11649
+ ),
11650
+ summary && /* @__PURE__ */ jsxRuntime.jsxs(jsxRuntime.Fragment, { children: [
11651
+ /* @__PURE__ */ jsxRuntime.jsxs(
11652
+ "div",
11653
+ {
11654
+ style: {
11655
+ padding: 12,
11656
+ borderRadius: 9,
11657
+ background: "#f8fafc",
11658
+ border: "1px solid #cbd5e1",
11659
+ display: "flex",
11660
+ flexDirection: "column",
11661
+ gap: 8
11662
+ },
11663
+ children: [
11664
+ /* @__PURE__ */ jsxRuntime.jsxs(
11665
+ "div",
11666
+ {
11667
+ style: {
11668
+ display: "flex",
11669
+ alignItems: "center",
11670
+ justifyContent: "space-between",
11671
+ flexWrap: "wrap",
11672
+ gap: 6
11673
+ },
11674
+ children: [
11675
+ /* @__PURE__ */ jsxRuntime.jsx("span", { style: { fontSize: 12, fontWeight: 800, color: "#0f172a" }, children: tr ? "Paket Ön İzlemesi" : "Package Summary" }),
11676
+ /* @__PURE__ */ jsxRuntime.jsx(
11677
+ "span",
11678
+ {
11679
+ style: {
11680
+ padding: "2px 8px",
11681
+ borderRadius: 10,
11682
+ fontSize: 10.5,
11683
+ fontWeight: 800,
11684
+ background: summary.totalResponses > 0 ? "#dcfce7" : "#dbeafe",
11685
+ color: summary.totalResponses > 0 ? "#166534" : "#1e40af"
11686
+ },
11687
+ children: summary.totalResponses > 0 ? tr ? `YAPI + ${summary.totalResponses} YANIT` : `STRUCTURE + ${summary.totalResponses} RESPONSES` : tr ? "SADECE YAPI (ŞEMA)" : "STRUCTURE ONLY"
11688
+ }
11689
+ )
11690
+ ]
11691
+ }
11692
+ ),
11693
+ /* @__PURE__ */ jsxRuntime.jsx(
11694
+ "div",
11695
+ {
11696
+ style: {
11697
+ display: "flex",
11698
+ flexDirection: "column",
11699
+ gap: 5,
11700
+ maxHeight: 150,
11701
+ overflowY: "auto"
11702
+ },
11703
+ children: summary.surveys.map((s, idx) => /* @__PURE__ */ jsxRuntime.jsxs(
11704
+ "div",
11705
+ {
11706
+ style: {
11707
+ padding: "7px 10px",
11708
+ borderRadius: 7,
11709
+ background: "#ffffff",
11710
+ border: "1px solid #e2e8f0",
11711
+ display: "flex",
11712
+ alignItems: "center",
11713
+ justifyContent: "space-between",
11714
+ gap: 8,
11715
+ fontSize: 11.5
11716
+ },
11717
+ children: [
11718
+ /* @__PURE__ */ jsxRuntime.jsxs("div", { style: { minWidth: 0 }, children: [
11719
+ /* @__PURE__ */ jsxRuntime.jsx("div", { style: { fontWeight: 700, color: "#0f172a" }, children: s.title }),
11720
+ /* @__PURE__ */ jsxRuntime.jsxs("div", { style: { fontSize: 10.5, color: "#64748b" }, children: [
11721
+ /* @__PURE__ */ jsxRuntime.jsx("code", { children: s.slug }),
11722
+ " • ",
11723
+ /* @__PURE__ */ jsxRuntime.jsx("code", { children: s.displayMode }),
11724
+ " •",
11725
+ " ",
11726
+ s.stepCount > 0 ? `${s.stepCount} ${tr ? "adım, " : "steps, "}` : "",
11727
+ s.questionCount,
11728
+ " ",
11729
+ tr ? "soru" : "Qs",
11730
+ " •",
11731
+ " ",
11732
+ /* @__PURE__ */ jsxRuntime.jsx("strong", { children: s.responseCount }),
11733
+ " ",
11734
+ tr ? "yanıt" : "resp"
11735
+ ] })
11736
+ ] }),
11737
+ /* @__PURE__ */ jsxRuntime.jsx(
11738
+ "span",
11739
+ {
11740
+ style: {
11741
+ flexShrink: 0,
11742
+ padding: "2px 7px",
11743
+ borderRadius: 8,
11744
+ fontSize: 10,
11745
+ fontWeight: 700,
11746
+ background: s.hasConflict ? "#fef3c7" : "#ecfdf5",
11747
+ color: s.hasConflict ? "#92400e" : "#047857"
11748
+ },
11749
+ children: s.hasConflict ? tr ? "Mevcut Slug" : "Slug Exists" : tr ? "Yeni Kayıt" : "New Slug"
11750
+ }
11751
+ )
11752
+ ]
11753
+ },
11754
+ `${s.slug}-${idx}`
11755
+ ))
11756
+ }
11757
+ )
11758
+ ]
11759
+ }
11760
+ ),
11761
+ /* @__PURE__ */ jsxRuntime.jsxs("div", { children: [
11762
+ /* @__PURE__ */ jsxRuntime.jsx(
11763
+ "div",
11764
+ {
11765
+ style: {
11766
+ fontSize: 11.5,
11767
+ fontWeight: 700,
11768
+ color: "#334155",
11769
+ marginBottom: 6
11770
+ },
11771
+ children: tr ? "Aynı Slug Mevcutsa Nasıl Davranılsın?" : "Conflict Strategy (When Slug Already Exists)"
11772
+ }
11773
+ ),
11774
+ /* @__PURE__ */ jsxRuntime.jsxs("div", { style: { display: "grid", gridTemplateColumns: "1fr 1fr", gap: 8 }, children: [
11775
+ /* @__PURE__ */ jsxRuntime.jsxs(
11776
+ "button",
11777
+ {
11778
+ type: "button",
11779
+ onClick: () => setConflictStrategy("duplicate"),
11780
+ style: {
11781
+ padding: "9px 10px",
11782
+ borderRadius: 8,
11783
+ border: conflictStrategy === "duplicate" ? "2px solid #2563eb" : "1px solid #cbd5e1",
11784
+ background: conflictStrategy === "duplicate" ? "#eff6ff" : "#ffffff",
11785
+ textAlign: "left",
11786
+ cursor: "pointer"
11787
+ },
11788
+ children: [
11789
+ /* @__PURE__ */ jsxRuntime.jsx("div", { style: { fontSize: 12, fontWeight: 700, color: "#0f172a" }, children: tr ? "Yeni Kopya Oluştur (_copy)" : "Create New Copy (_copy)" }),
11790
+ /* @__PURE__ */ jsxRuntime.jsx("div", { style: { fontSize: 10.5, color: "#64748b", marginTop: 2 }, children: tr ? "Mevcut ankete dokunmaz, ayrı bir kopya açar." : "Keeps existing survey untouched; creates unique slug." })
11791
+ ]
11792
+ }
11793
+ ),
11794
+ /* @__PURE__ */ jsxRuntime.jsxs(
11795
+ "button",
11796
+ {
11797
+ type: "button",
11798
+ onClick: () => setConflictStrategy("overwrite"),
11799
+ style: {
11800
+ padding: "9px 10px",
11801
+ borderRadius: 8,
11802
+ border: conflictStrategy === "overwrite" ? "2px solid #d97706" : "1px solid #cbd5e1",
11803
+ background: conflictStrategy === "overwrite" ? "#fffbeb" : "#ffffff",
11804
+ textAlign: "left",
11805
+ cursor: "pointer"
11806
+ },
11807
+ children: [
11808
+ /* @__PURE__ */ jsxRuntime.jsx("div", { style: { fontSize: 12, fontWeight: 700, color: "#0f172a" }, children: tr ? "Mevcut Anketin Üzerine Yaz" : "Overwrite Existing Survey" }),
11809
+ /* @__PURE__ */ jsxRuntime.jsx("div", { style: { fontSize: 10.5, color: "#64748b", marginTop: 2 }, children: tr ? "Aynı slug varsa yapıyı (ve seçiliyse yanıtları) günceller." : "Updates matching slug in place (and replaces responses if checked)." })
11810
+ ]
11811
+ }
11812
+ )
11813
+ ] })
11814
+ ] }),
11815
+ summary.totalResponses > 0 && /* @__PURE__ */ jsxRuntime.jsxs(
11816
+ "label",
11817
+ {
11818
+ style: {
11819
+ padding: "10px 12px",
11820
+ borderRadius: 8,
11821
+ background: includeResponses ? "#ecfdf5" : "#f8fafc",
11822
+ border: includeResponses ? "1px solid #10b981" : "1px solid #cbd5e1",
11823
+ display: "flex",
11824
+ alignItems: "center",
11825
+ gap: 9,
11826
+ cursor: "pointer"
11827
+ },
11828
+ children: [
11829
+ /* @__PURE__ */ jsxRuntime.jsx(
11830
+ "input",
11831
+ {
11832
+ type: "checkbox",
11833
+ checked: includeResponses,
11834
+ onChange: (e) => setIncludeResponses(e.target.checked)
11835
+ }
11836
+ ),
11837
+ /* @__PURE__ */ jsxRuntime.jsxs("div", { children: [
11838
+ /* @__PURE__ */ jsxRuntime.jsx("div", { style: { fontSize: 12, fontWeight: 700, color: "#0f172a" }, children: tr ? `Paketteki ${summary.totalResponses} Yanıt Verisini de İçe Aktar` : `Also Import ${summary.totalResponses} Recorded Responses` }),
11839
+ /* @__PURE__ */ jsxRuntime.jsx("div", { style: { fontSize: 10.5, color: "#475569" }, children: tr ? "İşareti kaldırırsanız bu tam yedek yalnızca temiz şema (0 yanıt) olarak kurulur." : "Uncheck to import only the clean survey schema with 0 responses." })
11840
+ ] })
11841
+ ]
11842
+ }
11843
+ )
11844
+ ] }),
11845
+ errorMsg && /* @__PURE__ */ jsxRuntime.jsx(
11846
+ "div",
11847
+ {
11848
+ style: {
11849
+ padding: "8px 12px",
11850
+ borderRadius: 7,
11851
+ background: "#fee2e2",
11852
+ color: "#991b1b",
11853
+ fontSize: 11.5,
11854
+ fontWeight: 600
11855
+ },
11856
+ children: errorMsg
11857
+ }
11858
+ ),
11859
+ /* @__PURE__ */ jsxRuntime.jsxs("div", { style: { display: "flex", justifyContent: "flex-end", gap: 8 }, children: [
11860
+ /* @__PURE__ */ jsxRuntime.jsx(
11861
+ "button",
11862
+ {
11863
+ type: "button",
11864
+ onClick: onClose,
11865
+ style: {
11866
+ padding: "8px 14px",
11867
+ borderRadius: 7,
11868
+ border: "1px solid #cbd5e1",
11869
+ background: "#ffffff",
11870
+ color: "#334155",
11871
+ fontSize: 12,
11872
+ fontWeight: 600,
11873
+ cursor: "pointer"
11874
+ },
11875
+ children: tr ? "Vazgeç" : "Cancel"
11876
+ }
11877
+ ),
11878
+ /* @__PURE__ */ jsxRuntime.jsxs(
11879
+ "button",
11880
+ {
11881
+ type: "button",
11882
+ disabled: !summary || importing,
11883
+ onClick: handleImport,
11884
+ style: {
11885
+ padding: "8px 16px",
11886
+ borderRadius: 7,
11887
+ border: "none",
11888
+ background: !summary ? "#94a3b8" : "#2563eb",
11889
+ color: "#ffffff",
11890
+ fontSize: 12,
11891
+ fontWeight: 700,
11892
+ cursor: !summary ? "not-allowed" : "pointer",
11893
+ display: "inline-flex",
11894
+ alignItems: "center",
11895
+ gap: 6
11896
+ },
11897
+ children: [
11898
+ /* @__PURE__ */ jsxRuntime.jsx(index.MaterialIcon, { name: "publish", size: 16, color: "#fff" }),
11899
+ /* @__PURE__ */ jsxRuntime.jsx("span", { children: importing ? tr ? "İçe Aktarılıyor..." : "Importing..." : tr ? "Anketi Canlandır / İçe Aktar" : "Import Survey Package" })
11900
+ ]
11901
+ }
11902
+ )
11903
+ ] })
11904
+ ]
11905
+ }
11906
+ )
11907
+ ]
11908
+ }
11909
+ )
11910
+ }
11911
+ ),
11912
+ document.body
11913
+ );
11914
+ };
11915
+ const SurveyCleanupConfirmModal = ({
11916
+ open,
11917
+ action,
11918
+ uiLocale = "en",
11919
+ targetSurvey,
11920
+ onClose,
11921
+ onCompleted
11922
+ }) => {
11923
+ const tr = uiLocale === "tr";
11924
+ const { post, del } = admin.useFetchClient();
11925
+ const [busy, setBusy] = React.useState(false);
11926
+ const [errorMsg, setErrorMsg] = React.useState("");
11927
+ React__default.default.useEffect(() => {
11928
+ if (open) {
11929
+ setErrorMsg("");
11930
+ }
11931
+ }, [open, action]);
11932
+ if (!open || !action || typeof document === "undefined") return null;
11933
+ const isPurgeDemo = action === "purge-demo";
11934
+ const isClearResp = action === "clear-responses";
11935
+ const respCount = targetSurvey?.responseCount ?? 0;
11936
+ const titleText = isPurgeDemo ? tr ? "Örnek (Dummy) Verileri Temizle" : "Purge Built-in Demo / Dummy Data" : isClearResp ? tr ? "Anket Yanıtlarını Sıfırla (Yapıyı Koru)" : "Clear Survey Responses (Keep Structure)" : tr ? "Anketi ve Yanıtlarını Kalıcı Olarak Sil" : "Delete Survey & All Responses";
11937
+ const bodyText = isPurgeDemo ? tr ? "Yalnızca eklentiyle gelen yerleşik vitrin verileri (showcase_dx_survey, showcase_roadmap_poll, showcase_visual_theme_poll + 525 örnek yanıt ve showcase_contact_form + 20 örnek form başvurusu) silinecektir. Sizin oluşturduğunuz özel anketlere ve formlara dokunulmaz. Ayrıca kalıcı koruma bayrağı işaretlendiği için sayfa yenilendiğinde veya sunucu yeniden başladığında dummy veriler kendiliğinden geri gelmez." : "Deletes ONLY the built-in showcase items (showcase_dx_survey, showcase_roadmap_poll, showcase_visual_theme_poll + sample responses and showcase_contact_form + sample submissions). Your custom surveys and forms remain untouched, and a persistent guard prevents demo data from auto-seeding again on reload or server restart." : isClearResp ? tr ? `"${targetSurvey?.title || ""}" (${targetSurvey?.slug || ""}) anketinin tüm adımları, soruları ve ayarları korunacak; yalnızca mevcut ${respCount} katılımcı yanıtı sıfırlanacaktır. Yayına çıkmadan önce test oylarını temizlemek için idealdir.` : `All steps, questions, and settings of "${targetSurvey?.title || ""}" (${targetSurvey?.slug || ""}) will be preserved, while its ${respCount} recorded response(s) will be permanently deleted.` : tr ? `"${targetSurvey?.title || ""}" (${targetSurvey?.slug || ""}) anketi ve bağlı ${respCount} katılımcı yanıtı kalıcı olarak silinecektir. İsterseniz silmeden önce Dışa Aktar ile .ci-survey.json yedeği alabilirsiniz.` : `"${targetSurvey?.title || ""}" (${targetSurvey?.slug || ""}) and all ${respCount} associated response(s) will be permanently deleted.`;
11938
+ const confirmLabel = isPurgeDemo ? tr ? "Evet, Dummy Verileri Temizle" : "Yes, Purge Demo Data" : isClearResp ? tr ? "Evet, Yanıtları Sıfırla (0 Yap)" : "Yes, Clear Responses" : tr ? "Evet, Anketi Kalıcı Sil" : "Yes, Delete Survey";
11939
+ const handleConfirm = async () => {
11940
+ setBusy(true);
11941
+ setErrorMsg("");
11942
+ try {
11943
+ if (isPurgeDemo) {
11944
+ const res2 = await post("/content-input/surveys/purge-demo", {});
11945
+ onCompleted("purge-demo", res2?.data);
11946
+ onClose();
11947
+ return;
11948
+ }
11949
+ const idOrSlug = String(
11950
+ targetSurvey?.slug || targetSurvey?.documentId || targetSurvey?.id || ""
11951
+ ).trim();
11952
+ if (!idOrSlug) {
11953
+ throw new Error(tr ? "Hedef anket bulunamadı." : "Target survey not found.");
11954
+ }
11955
+ if (isClearResp) {
11956
+ const res2 = await del(
11957
+ `/content-input/surveys/${encodeURIComponent(idOrSlug)}/responses`
11958
+ );
11959
+ onCompleted("clear-responses", res2?.data);
11960
+ onClose();
11961
+ return;
11962
+ }
11963
+ const res = await del(
11964
+ `/content-input/surveys/${encodeURIComponent(idOrSlug)}`
11965
+ );
11966
+ onCompleted("delete-survey", res?.data);
11967
+ onClose();
11968
+ } catch (err) {
11969
+ if (isRouteNotLoadedError(err)) {
11970
+ setErrorMsg(
11971
+ tr ? "Yeni sunucu rotalarının aktif olması için lütfen Strapi sunucusunu (npm run dev) bir kez yeniden başlatın." : "Please restart the Strapi server (npm run dev) once so the new backend routes take effect."
11972
+ );
11973
+ } else {
11974
+ setErrorMsg(
11975
+ err?.response?.data?.error?.message || err?.message || (tr ? "İşlem tamamlanamadı." : "Operation failed.")
11976
+ );
11977
+ }
11978
+ } finally {
11979
+ setBusy(false);
11980
+ }
11981
+ };
11982
+ return ReactDOM.createPortal(
11983
+ /* @__PURE__ */ jsxRuntime.jsx(
11984
+ "div",
11985
+ {
11986
+ className: "ci-root",
11987
+ style: {
11988
+ position: "fixed",
11989
+ inset: 0,
11990
+ background: "rgba(15, 23, 42, 0.68)",
11991
+ zIndex: 320,
11992
+ display: "flex",
11993
+ alignItems: "center",
11994
+ justifyContent: "center",
11995
+ padding: 16
11996
+ },
11997
+ onClick: onClose,
11998
+ children: /* @__PURE__ */ jsxRuntime.jsxs(
11999
+ "div",
12000
+ {
12001
+ style: {
12002
+ width: "100%",
12003
+ maxWidth: 490,
12004
+ background: "#ffffff",
12005
+ borderRadius: 12,
12006
+ boxShadow: "0 24px 54px rgba(15, 23, 42, 0.4)",
12007
+ overflow: "hidden",
12008
+ fontFamily: "-apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Helvetica, Arial, sans-serif"
12009
+ },
12010
+ onClick: (e) => e.stopPropagation(),
12011
+ children: [
12012
+ /* @__PURE__ */ jsxRuntime.jsxs(
12013
+ "div",
12014
+ {
12015
+ style: {
12016
+ padding: "14px 18px",
12017
+ background: isClearResp ? "#92400e" : "#991b1b",
12018
+ color: "#ffffff",
12019
+ display: "flex",
12020
+ alignItems: "center",
12021
+ justifyContent: "space-between"
12022
+ },
12023
+ children: [
12024
+ /* @__PURE__ */ jsxRuntime.jsxs("div", { style: { display: "flex", alignItems: "center", gap: 8 }, children: [
12025
+ /* @__PURE__ */ jsxRuntime.jsx(
12026
+ index.MaterialIcon,
12027
+ {
12028
+ name: isClearResp ? "restart_alt" : "delete_sweep",
12029
+ size: 20,
12030
+ color: "#fde68a"
12031
+ }
12032
+ ),
12033
+ /* @__PURE__ */ jsxRuntime.jsx("span", { style: { fontSize: 14, fontWeight: 700 }, children: titleText })
12034
+ ] }),
12035
+ /* @__PURE__ */ jsxRuntime.jsx(
12036
+ "button",
12037
+ {
12038
+ type: "button",
12039
+ onClick: onClose,
12040
+ style: {
12041
+ border: "none",
12042
+ background: "transparent",
12043
+ color: "#fecaca",
12044
+ fontSize: 18,
12045
+ cursor: "pointer"
12046
+ },
12047
+ children: "×"
12048
+ }
12049
+ )
12050
+ ]
12051
+ }
12052
+ ),
12053
+ /* @__PURE__ */ jsxRuntime.jsxs("div", { style: { padding: 18, display: "flex", flexDirection: "column", gap: 14 }, children: [
12054
+ /* @__PURE__ */ jsxRuntime.jsx("div", { style: { fontSize: 12.5, color: "#334155", lineHeight: 1.55 }, children: bodyText }),
12055
+ errorMsg && /* @__PURE__ */ jsxRuntime.jsx(
12056
+ "div",
12057
+ {
12058
+ style: {
12059
+ padding: "8px 12px",
12060
+ borderRadius: 7,
12061
+ background: "#fee2e2",
12062
+ color: "#991b1b",
12063
+ fontSize: 11.5,
12064
+ fontWeight: 600
12065
+ },
12066
+ children: errorMsg
12067
+ }
12068
+ ),
12069
+ /* @__PURE__ */ jsxRuntime.jsxs("div", { style: { display: "flex", justifyContent: "flex-end", gap: 8 }, children: [
12070
+ /* @__PURE__ */ jsxRuntime.jsx(
12071
+ "button",
12072
+ {
12073
+ type: "button",
12074
+ onClick: onClose,
12075
+ style: {
12076
+ padding: "8px 14px",
12077
+ borderRadius: 7,
12078
+ border: "1px solid #cbd5e1",
12079
+ background: "#ffffff",
12080
+ color: "#334155",
12081
+ fontSize: 12,
12082
+ fontWeight: 600,
12083
+ cursor: "pointer"
12084
+ },
12085
+ children: tr ? "Vazgeç" : "Cancel"
12086
+ }
12087
+ ),
12088
+ /* @__PURE__ */ jsxRuntime.jsx(
12089
+ "button",
12090
+ {
12091
+ type: "button",
12092
+ disabled: busy,
12093
+ onClick: handleConfirm,
12094
+ style: {
12095
+ padding: "8px 16px",
12096
+ borderRadius: 7,
12097
+ border: "none",
12098
+ background: isClearResp ? "#d97706" : "#dc2626",
12099
+ color: "#ffffff",
12100
+ fontSize: 12,
12101
+ fontWeight: 700,
12102
+ cursor: "pointer"
12103
+ },
12104
+ children: busy ? "..." : confirmLabel
12105
+ }
12106
+ )
12107
+ ] })
12108
+ ] })
12109
+ ]
12110
+ }
12111
+ )
12112
+ }
12113
+ ),
12114
+ document.body
12115
+ );
12116
+ };
12117
+ function normalizeMultiStepDraft(draft) {
12118
+ const rawSteps = Array.isArray(draft.steps) && draft.steps.length > 0 ? draft.steps : [
12119
+ {
12120
+ id: "step_1",
12121
+ title: { tr: "1. Adım", en: "Step 1" }
12122
+ }
12123
+ ];
12124
+ const buckets = /* @__PURE__ */ new Map();
12125
+ for (const st of rawSteps) {
12126
+ buckets.set(st.id, []);
12127
+ }
12128
+ const fallbackStepId = rawSteps[0].id;
12129
+ for (const q of draft.questions || []) {
12130
+ if (!q) continue;
12131
+ const validStepId = q.stepId && buckets.has(q.stepId) ? q.stepId : fallbackStepId;
12132
+ buckets.get(validStepId).push({
12133
+ ...q,
12134
+ stepId: validStepId
12135
+ });
12136
+ }
12137
+ const orderedQuestions = rawSteps.flatMap((st) => buckets.get(st.id) || []);
12138
+ return {
12139
+ ...draft,
12140
+ steps: rawSteps,
12141
+ questions: orderedQuestions
12142
+ };
12143
+ }
12144
+ function groupQuestionsByStep(questions, steps) {
12145
+ const map = /* @__PURE__ */ new Map();
12146
+ for (const st of steps) {
12147
+ map.set(st.id, []);
12148
+ }
12149
+ if (steps.length === 0) return map;
12150
+ const fallbackId = steps[0].id;
12151
+ questions.forEach((q, gIdx) => {
12152
+ const targetId = q.stepId && map.has(q.stepId) ? q.stepId : fallbackId;
12153
+ const list = map.get(targetId);
12154
+ list.push({
12155
+ question: q,
12156
+ globalIndex: gIdx,
12157
+ localIndex: list.length
12158
+ });
12159
+ });
12160
+ return map;
12161
+ }
12162
+ function reorderStepsInDraft(draft, sourceStepId, targetStepId, position = "before") {
12163
+ const normalized = normalizeMultiStepDraft(draft);
12164
+ const steps = normalized.steps || [];
12165
+ if (!sourceStepId || !targetStepId || sourceStepId === targetStepId) {
12166
+ return normalized;
12167
+ }
12168
+ const moving = steps.find((s) => s.id === sourceStepId);
12169
+ const target = steps.find((s) => s.id === targetStepId);
12170
+ if (!moving || !target) return normalized;
12171
+ const remaining = steps.filter((s) => s.id !== sourceStepId);
12172
+ const targetIdx = remaining.findIndex((s) => s.id === targetStepId);
12173
+ const insertAt = position === "after" ? targetIdx + 1 : targetIdx;
12174
+ remaining.splice(Math.max(0, insertAt), 0, moving);
12175
+ return normalizeMultiStepDraft({
12176
+ ...normalized,
12177
+ steps: remaining
12178
+ });
12179
+ }
12180
+ function shiftStepByOffset(draft, stepId, delta) {
12181
+ const normalized = normalizeMultiStepDraft(draft);
12182
+ const steps = [...normalized.steps || []];
12183
+ const idx = steps.findIndex((s) => s.id === stepId);
12184
+ if (idx < 0) return normalized;
12185
+ const nextIdx = idx + delta;
12186
+ if (nextIdx < 0 || nextIdx >= steps.length) return normalized;
12187
+ const [moved] = steps.splice(idx, 1);
12188
+ steps.splice(nextIdx, 0, moved);
12189
+ return normalizeMultiStepDraft({
12190
+ ...normalized,
12191
+ steps
12192
+ });
12193
+ }
12194
+ function moveQuestionInMultiStepDraft(draft, sourceQuestionKey, target) {
12195
+ const normalized = normalizeMultiStepDraft(draft);
12196
+ const steps = normalized.steps || [];
12197
+ if (steps.length === 0) return normalized;
12198
+ if (target.targetQuestionKey && target.targetQuestionKey === sourceQuestionKey && target.position !== "end") {
12199
+ return normalized;
12200
+ }
12201
+ const buckets = /* @__PURE__ */ new Map();
12202
+ for (const st of steps) {
12203
+ buckets.set(st.id, []);
12204
+ }
12205
+ let movingQuestion = null;
12206
+ for (const q of normalized.questions || []) {
12207
+ if (q.key === sourceQuestionKey && !movingQuestion) {
12208
+ movingQuestion = q;
12209
+ continue;
12210
+ }
12211
+ const sid = q.stepId && buckets.has(q.stepId) ? q.stepId : steps[0].id;
12212
+ buckets.get(sid).push(q);
12213
+ }
12214
+ if (!movingQuestion) return normalized;
12215
+ const destStepId = buckets.has(target.stepId) ? target.stepId : steps[0].id;
12216
+ const updatedQuestion = {
12217
+ ...movingQuestion,
12218
+ stepId: destStepId
12219
+ };
12220
+ const destBucket = buckets.get(destStepId);
12221
+ if (!target.targetQuestionKey || target.position === "end") {
12222
+ destBucket.push(updatedQuestion);
12223
+ } else {
12224
+ const tIdx = destBucket.findIndex((q) => q.key === target.targetQuestionKey);
12225
+ if (tIdx < 0) {
12226
+ destBucket.push(updatedQuestion);
12227
+ } else {
12228
+ const insertIdx = target.position === "after" ? tIdx + 1 : tIdx;
12229
+ destBucket.splice(insertIdx, 0, updatedQuestion);
12230
+ }
12231
+ }
12232
+ return {
12233
+ ...normalized,
12234
+ questions: steps.flatMap((st) => buckets.get(st.id) || [])
12235
+ };
12236
+ }
12237
+ function insertQuestionInMultiStepDraft(draft, newQuestion, target) {
12238
+ const normalized = normalizeMultiStepDraft(draft);
12239
+ const steps = normalized.steps || [];
12240
+ const destStepId = steps.some((s) => s.id === target.stepId) ? target.stepId : steps[0].id;
12241
+ const buckets = /* @__PURE__ */ new Map();
12242
+ for (const st of steps) {
12243
+ buckets.set(st.id, []);
12244
+ }
12245
+ for (const q of normalized.questions || []) {
12246
+ const sid = q.stepId && buckets.has(q.stepId) ? q.stepId : steps[0].id;
12247
+ buckets.get(sid).push(q);
12248
+ }
12249
+ const prepared = {
12250
+ ...newQuestion,
12251
+ stepId: destStepId
12252
+ };
12253
+ const destBucket = buckets.get(destStepId);
12254
+ if (!target.targetQuestionKey || target.position === "end") {
12255
+ destBucket.push(prepared);
12256
+ } else {
12257
+ const tIdx = destBucket.findIndex((q) => q.key === target.targetQuestionKey);
12258
+ if (tIdx < 0) {
12259
+ destBucket.push(prepared);
12260
+ } else {
12261
+ const insertIdx = target.position === "after" ? tIdx + 1 : tIdx;
12262
+ destBucket.splice(insertIdx, 0, prepared);
12263
+ }
12264
+ }
12265
+ const nextQuestions = steps.flatMap((st) => buckets.get(st.id) || []);
12266
+ const insertedIndex = Math.max(
12267
+ 0,
12268
+ nextQuestions.findIndex((q) => q.key === prepared.key)
12269
+ );
12270
+ return {
12271
+ draft: {
12272
+ ...normalized,
12273
+ questions: nextQuestions
12274
+ },
12275
+ insertedIndex
12276
+ };
12277
+ }
12278
+ function reorderFlatQuestions(questions, sourceKey, targetKey, position = "before") {
12279
+ if (!sourceKey || !targetKey || sourceKey === targetKey) return questions;
12280
+ const moving = questions.find((q) => q.key === sourceKey);
12281
+ if (!moving) return questions;
12282
+ const remaining = questions.filter((q) => q.key !== sourceKey);
12283
+ const tIdx = remaining.findIndex((q) => q.key === targetKey);
12284
+ if (tIdx < 0) return questions;
12285
+ const insertIdx = position === "after" ? tIdx + 1 : tIdx;
12286
+ remaining.splice(insertIdx, 0, moving);
12287
+ return remaining;
12288
+ }
12289
+ function deleteStepWithQuestionReassignment(draft, stepIdToDelete) {
12290
+ const normalized = normalizeMultiStepDraft(draft);
12291
+ const steps = normalized.steps || [];
12292
+ if (steps.length <= 1) {
12293
+ return {
12294
+ draft: normalized,
12295
+ fallbackStepId: steps[0]?.id || "step_1",
12296
+ movedQuestionCount: 0
12297
+ };
12298
+ }
12299
+ const delIdx = steps.findIndex((s) => s.id === stepIdToDelete);
12300
+ if (delIdx < 0) {
12301
+ return {
12302
+ draft: normalized,
12303
+ fallbackStepId: steps[0].id,
12304
+ movedQuestionCount: 0
12305
+ };
12306
+ }
12307
+ const fallbackStep = delIdx > 0 ? steps[delIdx - 1] : steps[1];
12308
+ let movedQuestionCount = 0;
12309
+ const updatedQuestions = (normalized.questions || []).map((q) => {
12310
+ if (q.stepId === stepIdToDelete) {
12311
+ movedQuestionCount += 1;
12312
+ return { ...q, stepId: fallbackStep.id };
12313
+ }
12314
+ return q;
12315
+ });
12316
+ const remainingSteps = steps.filter((s) => s.id !== stepIdToDelete);
12317
+ const nextDraft = normalizeMultiStepDraft({
12318
+ ...normalized,
12319
+ steps: remainingSteps,
12320
+ questions: updatedQuestions
12321
+ });
12322
+ return {
12323
+ draft: nextDraft,
12324
+ fallbackStepId: fallbackStep.id,
12325
+ movedQuestionCount
12326
+ };
12327
+ }
10893
12328
  const inputStyle = {
10894
12329
  width: "100%",
10895
12330
  padding: "6px 9px",
@@ -10906,22 +12341,25 @@ const labelStyle = {
10906
12341
  color: "#475569",
10907
12342
  marginBottom: 4
10908
12343
  };
12344
+ const TURKISH_CHAR_MAP = {
12345
+ ç: "c",
12346
+ Ç: "c",
12347
+ ğ: "g",
12348
+ Ğ: "g",
12349
+ ı: "i",
12350
+ İ: "i",
12351
+ ö: "o",
12352
+ Ö: "o",
12353
+ ş: "s",
12354
+ Ş: "s",
12355
+ ü: "u",
12356
+ Ü: "u"
12357
+ };
12358
+ function sanitizeSlugInput(input) {
12359
+ return String(input || "").replace(/[çÇğĞıİöÖşŞüÜ]/g, (ch) => TURKISH_CHAR_MAP[ch] || ch).toLowerCase().replace(/\s+/g, "-").replace(/[^a-z0-9_-]/g, "");
12360
+ }
10909
12361
  function slugifyKey(input) {
10910
- const map = {
10911
- ç: "c",
10912
- Ç: "c",
10913
- ğ: "g",
10914
- Ğ: "g",
10915
- ı: "i",
10916
- İ: "i",
10917
- ö: "o",
10918
- Ö: "o",
10919
- ş: "s",
10920
- Ş: "s",
10921
- ü: "u",
10922
- Ü: "u"
10923
- };
10924
- return String(input || "").replace(/[çÇğĞıİöÖşŞüÜ]/g, (ch) => map[ch] || ch).toLowerCase().replace(/[^a-z0-9_]+/g, "_").replace(/^_+|_+$/g, "");
12362
+ return String(input || "").replace(/[çÇğĞıİöÖşŞüÜ]/g, (ch) => TURKISH_CHAR_MAP[ch] || ch).toLowerCase().replace(/[^a-z0-9_-]+/g, "-").replace(/-{2,}/g, "-").replace(/_{2,}/g, "_").replace(/^[-_]+|[-_]+$/g, "");
10925
12363
  }
10926
12364
  const LIKERT_SCALE_PRESETS = [
10927
12365
  {
@@ -11027,13 +12465,14 @@ const QUESTION_TYPES_CATALOG = [
11027
12465
  function createBlankSurveyDraft(locale = "en") {
11028
12466
  const tr = locale === "tr";
11029
12467
  const ts = Date.now().toString(36).slice(-4);
12468
+ const initialTitle = tr ? "Yeni Müşteri Geri Bildirim Anketi" : "New Customer Feedback Survey";
11030
12469
  return {
11031
- title: tr ? "Yeni Müşteri Geri Bildirim Anketi" : "New Customer Feedback Survey",
12470
+ title: initialTitle,
11032
12471
  titleI18n: {
11033
12472
  en: "New Customer Feedback Survey",
11034
12473
  tr: "Yeni Müşteri Geri Bildirim Anketi"
11035
12474
  },
11036
- slug: `survey_${ts}`,
12475
+ slug: `${slugifyKey(initialTitle)}-${ts}`,
11037
12476
  description: {
11038
12477
  tr: "Görüşleriniz hizmet kalitemizi geliştirmemize yardımcı olur.",
11039
12478
  en: "Your feedback helps us improve our service quality."
@@ -11156,27 +12595,65 @@ const SurveyStudioModal = ({
11156
12595
  const { post } = admin.useFetchClient();
11157
12596
  const { locales: strapiLocales } = useStrapiLocales();
11158
12597
  const [tab, setTab] = React.useState(initialTab);
11159
- const [draft, setDraft] = React.useState(
11160
- () => JSON.parse(JSON.stringify(initialSurvey))
11161
- );
12598
+ const [draft, setDraft] = React.useState(() => {
12599
+ const cloned = JSON.parse(JSON.stringify(initialSurvey));
12600
+ return cloned.displayMode === "multi_step" ? normalizeMultiStepDraft(cloned) : cloned;
12601
+ });
11162
12602
  const [selectedQuestionIdx, setSelectedQuestionIdx] = React.useState(0);
12603
+ const [collapsedStepIds, setCollapsedStepIds] = React.useState({});
12604
+ const [openStepDescIds, setOpenStepDescIds] = React.useState({});
12605
+ const [activeStepId, setActiveStepId] = React.useState(
12606
+ () => initialSurvey.steps?.[0]?.id || "step_1"
12607
+ );
12608
+ const [stepDragReadyId, setStepDragReadyId] = React.useState(null);
12609
+ const [dropIndicator, setDropIndicator] = React.useState(null);
11163
12610
  const [saving, setSaving] = React.useState(false);
11164
12611
  const [statusMsg, setStatusMsg] = React.useState("");
12612
+ const [slugAutoSync, setSlugAutoSync] = React.useState(
12613
+ () => !initialSurvey.id && !initialSurvey.documentId && !initialSurvey._id
12614
+ );
11165
12615
  const [optDragReadyIdx, setOptDragReadyIdx] = React.useState(null);
12616
+ const [studioExportOpen, setStudioExportOpen] = React.useState(false);
12617
+ const [studioImportOpen, setStudioImportOpen] = React.useState(false);
12618
+ const [studioCleanupAction, setStudioCleanupAction] = React.useState(null);
12619
+ const [studioAnalyticsKey, setStudioAnalyticsKey] = React.useState(0);
11166
12620
  const dragRef = React.useRef(null);
12621
+ const hoverExpandTimerRef = React.useRef(null);
12622
+ const clearHoverExpandTimer = () => {
12623
+ if (hoverExpandTimerRef.current) {
12624
+ clearTimeout(hoverExpandTimerRef.current.timer);
12625
+ hoverExpandTimerRef.current = null;
12626
+ }
12627
+ };
11167
12628
  React.useEffect(() => {
11168
12629
  if (open) {
11169
- setDraft(JSON.parse(JSON.stringify(initialSurvey)));
12630
+ const cloned = JSON.parse(JSON.stringify(initialSurvey));
12631
+ const nextDraft = cloned.displayMode === "multi_step" ? normalizeMultiStepDraft(cloned) : cloned;
12632
+ setDraft(nextDraft);
12633
+ setSlugAutoSync(!cloned.id && !cloned.documentId && !cloned._id);
11170
12634
  setSelectedQuestionIdx(0);
12635
+ setCollapsedStepIds({});
12636
+ setOpenStepDescIds({});
12637
+ setActiveStepId(nextDraft.steps?.[0]?.id || "step_1");
12638
+ setDropIndicator(null);
12639
+ setStepDragReadyId(null);
11171
12640
  setTab(initialTab);
11172
12641
  setStatusMsg("");
11173
12642
  }
12643
+ return () => clearHoverExpandTimer();
11174
12644
  }, [open, initialSurvey, initialTab]);
11175
12645
  if (!open || typeof document === "undefined") return null;
11176
12646
  const questions = Array.isArray(draft.questions) ? draft.questions : [];
11177
12647
  const activeQ = questions[selectedQuestionIdx] || questions[0] || null;
11178
12648
  const steps = Array.isArray(draft.steps) ? draft.steps : [];
11179
12649
  const localeGridCols = `repeat(${Math.min(Math.max(strapiLocales.length, 1), 3)}, 1fr)`;
12650
+ const selectQuestionByKey = (nextQuestions, key) => {
12651
+ if (!key) return;
12652
+ const foundIdx = nextQuestions.findIndex((q) => q.key === key);
12653
+ if (foundIdx >= 0) {
12654
+ setSelectedQuestionIdx(foundIdx);
12655
+ }
12656
+ };
11180
12657
  const updateActiveQuestion = (patch) => {
11181
12658
  if (!activeQ) return;
11182
12659
  setDraft((prev) => ({
@@ -11186,11 +12663,27 @@ const SurveyStudioModal = ({
11186
12663
  )
11187
12664
  }));
11188
12665
  };
11189
- const addQuestionOfType = (qType, insertAt) => {
11190
- const defaultStepId = draft.displayMode === "multi_step" && steps[0]?.id ? steps[0].id : void 0;
12666
+ const addQuestionOfType = (qType, insertAt, explicitStepId) => {
12667
+ if (draft.displayMode === "multi_step") {
12668
+ const targetStepId = explicitStepId || (activeStepId && steps.some((s) => s.id === activeStepId) ? activeStepId : void 0) || (activeQ?.stepId && steps.some((s) => s.id === activeQ.stepId) ? activeQ.stepId : void 0) || steps[0]?.id || "step_1";
12669
+ const newQ2 = buildQuestionFromType(
12670
+ qType,
12671
+ targetStepId,
12672
+ questions.map((q) => q.key)
12673
+ );
12674
+ const { draft: nextDraft, insertedIndex } = insertQuestionInMultiStepDraft(draft, newQ2, {
12675
+ stepId: targetStepId,
12676
+ position: "end"
12677
+ });
12678
+ setDraft(nextDraft);
12679
+ setSelectedQuestionIdx(insertedIndex);
12680
+ setActiveStepId(targetStepId);
12681
+ setCollapsedStepIds((prev) => ({ ...prev, [targetStepId]: false }));
12682
+ return;
12683
+ }
11191
12684
  const newQ = buildQuestionFromType(
11192
12685
  qType,
11193
- activeQ?.stepId || defaultStepId,
12686
+ void 0,
11194
12687
  questions.map((q) => q.key)
11195
12688
  );
11196
12689
  const nextList = [...questions];
@@ -11209,14 +12702,17 @@ const SurveyStudioModal = ({
11209
12702
  setSaving(true);
11210
12703
  setStatusMsg("");
11211
12704
  try {
12705
+ const cleanFinalSlug = slugifyKey(draft.slug) || slugifyKey(draft.title) || `survey-${Date.now().toString(36).slice(-4)}`;
11212
12706
  const payload = {
11213
12707
  ...draft,
12708
+ slug: cleanFinalSlug,
11214
12709
  id: draft.documentId || draft._id || draft.id
11215
12710
  };
11216
12711
  const res = await post("/content-input/surveys", payload);
11217
12712
  const saved = res?.data;
11218
12713
  if (saved) {
11219
12714
  setDraft(JSON.parse(JSON.stringify(saved)));
12715
+ setSlugAutoSync(false);
11220
12716
  setStatusMsg(tr ? "Anket kaydedildi!" : "Survey saved!");
11221
12717
  if (typeof window !== "undefined") {
11222
12718
  window.dispatchEvent(new CustomEvent("ci-survey-updated", { detail: saved }));
@@ -11297,27 +12793,35 @@ const SurveyStudioModal = ({
11297
12793
  children: [
11298
12794
  /* @__PURE__ */ jsxRuntime.jsxs("div", { style: { display: "flex", alignItems: "center", gap: 10 }, children: [
11299
12795
  /* @__PURE__ */ jsxRuntime.jsx(index.MaterialIcon, { name: "poll", size: 22, color: "#38bdf8" }),
11300
- /* @__PURE__ */ jsxRuntime.jsxs("div", { children: [
11301
- /* @__PURE__ */ jsxRuntime.jsxs("div", { style: { fontSize: 15, fontWeight: 700 }, children: [
11302
- tr ? "Kurumsal Anket & Oylama Stüdyosu" : "Enterprise Survey & Poll Studio",
11303
- " —",
11304
- " ",
11305
- /* @__PURE__ */ jsxRuntime.jsx("span", { style: { color: "#93c5fd" }, children: draft.title })
11306
- ] }),
11307
- /* @__PURE__ */ jsxRuntime.jsxs("div", { style: { fontSize: 11, color: "#94a3b8" }, children: [
11308
- "Slug: ",
11309
- /* @__PURE__ */ jsxRuntime.jsx("code", { children: draft.slug }),
11310
- " • Mode: ",
11311
- /* @__PURE__ */ jsxRuntime.jsx("code", { children: draft.displayMode }),
11312
- " • Submit:",
11313
- " ",
11314
- /* @__PURE__ */ jsxRuntime.jsxs("code", { children: [
11315
- "/api/content-input/surveys/",
11316
- draft.slug,
11317
- "/submit"
11318
- ] })
11319
- ] })
11320
- ] })
12796
+ /* @__PURE__ */ jsxRuntime.jsxs(
12797
+ "div",
12798
+ {
12799
+ onClick: () => setTab("settings"),
12800
+ title: tr ? "Yönetim başlığını ve Survey Slug alanını düzenlemek için tıklayın" : "Click to edit Internal Title & Survey Slug",
12801
+ style: { cursor: "pointer" },
12802
+ children: [
12803
+ /* @__PURE__ */ jsxRuntime.jsxs("div", { style: { fontSize: 15, fontWeight: 700 }, children: [
12804
+ tr ? "Kurumsal Anket & Oylama Stüdyosu" : "Enterprise Survey & Poll Studio",
12805
+ " —",
12806
+ " ",
12807
+ /* @__PURE__ */ jsxRuntime.jsx("span", { style: { color: "#93c5fd", textDecoration: "underline dotted" }, children: draft.title })
12808
+ ] }),
12809
+ /* @__PURE__ */ jsxRuntime.jsxs("div", { style: { fontSize: 11, color: "#94a3b8" }, children: [
12810
+ "Slug: ",
12811
+ /* @__PURE__ */ jsxRuntime.jsx("code", { children: draft.slug }),
12812
+ " • Mode: ",
12813
+ /* @__PURE__ */ jsxRuntime.jsx("code", { children: draft.displayMode }),
12814
+ " • Submit:",
12815
+ " ",
12816
+ /* @__PURE__ */ jsxRuntime.jsxs("code", { children: [
12817
+ "/api/content-input/surveys/",
12818
+ draft.slug,
12819
+ "/submit"
12820
+ ] })
12821
+ ] })
12822
+ ]
12823
+ }
12824
+ )
11321
12825
  ] }),
11322
12826
  /* @__PURE__ */ jsxRuntime.jsxs("div", { style: { display: "flex", alignItems: "center", gap: 8 }, children: [
11323
12827
  statusMsg && /* @__PURE__ */ jsxRuntime.jsx(
@@ -11334,6 +12838,81 @@ const SurveyStudioModal = ({
11334
12838
  children: statusMsg
11335
12839
  }
11336
12840
  ),
12841
+ /* @__PURE__ */ jsxRuntime.jsxs(
12842
+ "button",
12843
+ {
12844
+ type: "button",
12845
+ onClick: () => setStudioImportOpen(true),
12846
+ title: tr ? ".ci-survey.json paketinden anket içe aktar" : "Import survey from .ci-survey.json bundle",
12847
+ style: {
12848
+ padding: "7px 11px",
12849
+ borderRadius: 6,
12850
+ border: "1px solid rgba(56, 189, 248, 0.45)",
12851
+ background: "rgba(14, 165, 233, 0.16)",
12852
+ color: "#e0f2fe",
12853
+ fontSize: 11.5,
12854
+ fontWeight: 700,
12855
+ cursor: "pointer",
12856
+ display: "inline-flex",
12857
+ alignItems: "center",
12858
+ gap: 5
12859
+ },
12860
+ children: [
12861
+ /* @__PURE__ */ jsxRuntime.jsx(index.MaterialIcon, { name: "upload_file", size: 15, color: "#7dd3fc" }),
12862
+ /* @__PURE__ */ jsxRuntime.jsx("span", { children: tr ? "İçe Aktar" : "Import" })
12863
+ ]
12864
+ }
12865
+ ),
12866
+ /* @__PURE__ */ jsxRuntime.jsxs(
12867
+ "button",
12868
+ {
12869
+ type: "button",
12870
+ onClick: () => setStudioExportOpen(true),
12871
+ title: tr ? "Bu anketi Sadece Yapı veya Yapı + Veri olarak .ci-survey.json indir" : "Export this survey as Structure or Full Backup (.ci-survey.json)",
12872
+ style: {
12873
+ padding: "7px 11px",
12874
+ borderRadius: 6,
12875
+ border: "1px solid rgba(52, 211, 153, 0.45)",
12876
+ background: "rgba(16, 185, 129, 0.16)",
12877
+ color: "#d1fae5",
12878
+ fontSize: 11.5,
12879
+ fontWeight: 700,
12880
+ cursor: "pointer",
12881
+ display: "inline-flex",
12882
+ alignItems: "center",
12883
+ gap: 5
12884
+ },
12885
+ children: [
12886
+ /* @__PURE__ */ jsxRuntime.jsx(index.MaterialIcon, { name: "download", size: 15, color: "#6ee7b7" }),
12887
+ /* @__PURE__ */ jsxRuntime.jsx("span", { children: tr ? "Dışa Aktar" : "Export" })
12888
+ ]
12889
+ }
12890
+ ),
12891
+ Boolean(draft.id || draft.documentId || draft._id) && /* @__PURE__ */ jsxRuntime.jsxs(
12892
+ "button",
12893
+ {
12894
+ type: "button",
12895
+ onClick: () => setStudioCleanupAction("clear-responses"),
12896
+ title: tr ? "Anket yapısını koruyarak mevcut yanıtları sıfırlar (0 yapar)" : "Clear all recorded responses while keeping survey structure",
12897
+ style: {
12898
+ padding: "7px 10px",
12899
+ borderRadius: 6,
12900
+ border: "1px solid rgba(251, 191, 36, 0.45)",
12901
+ background: "rgba(217, 119, 6, 0.18)",
12902
+ color: "#fef3c7",
12903
+ fontSize: 11.5,
12904
+ fontWeight: 700,
12905
+ cursor: "pointer",
12906
+ display: "inline-flex",
12907
+ alignItems: "center",
12908
+ gap: 5
12909
+ },
12910
+ children: [
12911
+ /* @__PURE__ */ jsxRuntime.jsx(index.MaterialIcon, { name: "restart_alt", size: 15, color: "#fcd34d" }),
12912
+ /* @__PURE__ */ jsxRuntime.jsx("span", { children: tr ? "Yanıt 0'la" : "Reset Resp" })
12913
+ ]
12914
+ }
12915
+ ),
11337
12916
  /* @__PURE__ */ jsxRuntime.jsxs(
11338
12917
  "button",
11339
12918
  {
@@ -11544,16 +13123,22 @@ const SurveyStudioModal = ({
11544
13123
  "button",
11545
13124
  {
11546
13125
  type: "button",
11547
- onClick: () => setDraft((prev) => ({
11548
- ...prev,
11549
- displayMode: m.id,
11550
- steps: m.id === "multi_step" && (!prev.steps || prev.steps.length === 0) ? [
11551
- {
11552
- id: "step_1",
11553
- title: { tr: "1. Adım", en: "Step 1" }
13126
+ onClick: () => {
13127
+ setDraft((prev) => {
13128
+ const nextRaw = {
13129
+ ...prev,
13130
+ displayMode: m.id
13131
+ };
13132
+ if (m.id === "multi_step") {
13133
+ const norm = normalizeMultiStepDraft(nextRaw);
13134
+ if (norm.steps?.[0]?.id) {
13135
+ setActiveStepId(norm.steps[0].id);
13136
+ }
13137
+ return norm;
11554
13138
  }
11555
- ] : prev.steps
11556
- })),
13139
+ return nextRaw;
13140
+ });
13141
+ },
11557
13142
  style: {
11558
13143
  padding: "7px 8px",
11559
13144
  borderRadius: 6,
@@ -11572,7 +13157,7 @@ const SurveyStudioModal = ({
11572
13157
  ]
11573
13158
  }
11574
13159
  ),
11575
- draft.displayMode === "multi_step" && /* @__PURE__ */ jsxRuntime.jsxs(
13160
+ /* @__PURE__ */ jsxRuntime.jsxs(
11576
13161
  "div",
11577
13162
  {
11578
13163
  style: {
@@ -11589,138 +13174,36 @@ const SurveyStudioModal = ({
11589
13174
  display: "flex",
11590
13175
  alignItems: "center",
11591
13176
  justifyContent: "space-between",
11592
- marginBottom: 8
13177
+ gap: 6,
13178
+ marginBottom: 6
11593
13179
  },
11594
13180
  children: [
11595
- /* @__PURE__ */ jsxRuntime.jsx("span", { style: { fontSize: 11, fontWeight: 700, color: "#1e3a8a" }, children: tr ? "Sihirbaz Adımları (Steps)" : "Wizard Steps" }),
11596
- /* @__PURE__ */ jsxRuntime.jsx(
11597
- "button",
13181
+ /* @__PURE__ */ jsxRuntime.jsx("span", { style: { fontSize: 11, fontWeight: 700, color: "#334155" }, children: tr ? "Soru Tipleri Paleti (Tıklayın veya Kategoriye Sürükleyin):" : "Question Types Palette (Click or Drag into a Step):" }),
13182
+ draft.displayMode === "multi_step" && steps.length > 0 && /* @__PURE__ */ jsxRuntime.jsxs(
13183
+ "span",
11598
13184
  {
11599
- type: "button",
11600
- onClick: () => {
11601
- const nextIdx = steps.length + 1;
11602
- setDraft((prev) => ({
11603
- ...prev,
11604
- steps: [
11605
- ...prev.steps || [],
11606
- {
11607
- id: `step_${uid("s")}`,
11608
- title: { tr: `${nextIdx}. Adım`, en: `Step ${nextIdx}` }
11609
- }
11610
- ]
11611
- }));
11612
- },
11613
13185
  style: {
11614
- padding: "3px 8px",
11615
13186
  fontSize: 10,
11616
13187
  fontWeight: 700,
11617
- borderRadius: 4,
11618
- border: "1px solid #93c5fd",
13188
+ padding: "2px 7px",
13189
+ borderRadius: 10,
11619
13190
  background: "#eff6ff",
11620
- color: "#1d4ed8",
11621
- cursor: "pointer"
13191
+ color: "#1d4ed8"
11622
13192
  },
11623
- children: tr ? "+ Adım Ekle" : "+ Add Step"
13193
+ children: [
13194
+ tr ? "Hedef:" : "Target:",
13195
+ " ",
13196
+ pickTextForLocale(
13197
+ steps.find((s) => s.id === activeStepId)?.title || steps[0].title,
13198
+ uiLocale,
13199
+ activeStepId
13200
+ )
13201
+ ]
11624
13202
  }
11625
13203
  )
11626
13204
  ]
11627
13205
  }
11628
13206
  ),
11629
- /* @__PURE__ */ jsxRuntime.jsx("div", { style: { display: "flex", flexDirection: "column", gap: 6 }, children: steps.map((st, sIdx) => {
11630
- const stTitleObj = normalizeLocalizedRecord(st.title, strapiLocales);
11631
- return /* @__PURE__ */ jsxRuntime.jsxs(
11632
- "div",
11633
- {
11634
- draggable: true,
11635
- onDragStart: () => {
11636
- dragRef.current = { kind: "step", index: sIdx };
11637
- },
11638
- onDragOver: (e) => {
11639
- if (dragRef.current?.kind === "step") e.preventDefault();
11640
- },
11641
- onDrop: (e) => {
11642
- e.preventDefault();
11643
- if (dragRef.current?.kind !== "step") return;
11644
- const from = dragRef.current.index;
11645
- dragRef.current = null;
11646
- if (from === sIdx) return;
11647
- const copy = [...steps];
11648
- const [moved] = copy.splice(from, 1);
11649
- copy.splice(sIdx, 0, moved);
11650
- setDraft((prev) => ({ ...prev, steps: copy }));
11651
- },
11652
- style: {
11653
- display: "grid",
11654
- gridTemplateColumns: `20px repeat(${strapiLocales.length}, 1fr) 22px`,
11655
- gap: 5,
11656
- alignItems: "center",
11657
- padding: "4px 6px",
11658
- borderRadius: 5,
11659
- background: "#f8fafc",
11660
- border: "1px solid #e2e8f0"
11661
- },
11662
- children: [
11663
- /* @__PURE__ */ jsxRuntime.jsx(index.MaterialIcon, { name: "drag_indicator", size: 14, color: "#64748b" }),
11664
- strapiLocales.map((loc) => /* @__PURE__ */ jsxRuntime.jsx(
11665
- "input",
11666
- {
11667
- type: "text",
11668
- value: stTitleObj[loc.code] || "",
11669
- onChange: (e) => {
11670
- const nextSteps = steps.map(
11671
- (item, i) => i === sIdx ? {
11672
- ...item,
11673
- title: {
11674
- ...stTitleObj,
11675
- [loc.code]: e.target.value
11676
- }
11677
- } : item
11678
- );
11679
- setDraft((prev) => ({ ...prev, steps: nextSteps }));
11680
- },
11681
- placeholder: `${loc.code.toUpperCase()} Step`,
11682
- style: { ...inputStyle, padding: "4px 6px", fontSize: 11 }
11683
- },
11684
- `st-${st.id}-${loc.code}`
11685
- )),
11686
- /* @__PURE__ */ jsxRuntime.jsx(
11687
- "button",
11688
- {
11689
- type: "button",
11690
- disabled: steps.length <= 1,
11691
- onClick: () => setDraft((prev) => ({
11692
- ...prev,
11693
- steps: (prev.steps || []).filter((_, i) => i !== sIdx)
11694
- })),
11695
- style: {
11696
- border: "none",
11697
- background: "transparent",
11698
- color: steps.length <= 1 ? "#cbd5e1" : "#dc2626",
11699
- cursor: "pointer",
11700
- fontSize: 13
11701
- },
11702
- children: "×"
11703
- }
11704
- )
11705
- ]
11706
- },
11707
- st.id
11708
- );
11709
- }) })
11710
- ]
11711
- }
11712
- ),
11713
- /* @__PURE__ */ jsxRuntime.jsxs(
11714
- "div",
11715
- {
11716
- style: {
11717
- padding: 10,
11718
- borderRadius: 8,
11719
- background: "#ffffff",
11720
- border: "1px solid #cbd5e1"
11721
- },
11722
- children: [
11723
- /* @__PURE__ */ jsxRuntime.jsx("div", { style: { fontSize: 11, fontWeight: 700, color: "#334155", marginBottom: 6 }, children: tr ? "Soru Tipleri Paleti (Tıklayın veya Aşağıya Sürükleyin):" : "Question Types Palette (Click or Drag Below):" }),
11724
13207
  /* @__PURE__ */ jsxRuntime.jsx("div", { style: { display: "flex", flexWrap: "wrap", gap: 5 }, children: QUESTION_TYPES_CATALOG.map((qt) => /* @__PURE__ */ jsxRuntime.jsxs(
11725
13208
  "button",
11726
13209
  {
@@ -11728,8 +13211,14 @@ const SurveyStudioModal = ({
11728
13211
  draggable: true,
11729
13212
  onDragStart: (e) => {
11730
13213
  dragRef.current = { kind: "new-type", qType: qt.type };
13214
+ e.dataTransfer.effectAllowed = "copyMove";
11731
13215
  e.dataTransfer.setData("text/plain", qt.type);
11732
13216
  },
13217
+ onDragEnd: () => {
13218
+ dragRef.current = null;
13219
+ setDropIndicator(null);
13220
+ clearHoverExpandTimer();
13221
+ },
11733
13222
  onClick: () => addQuestionOfType(qt.type),
11734
13223
  style: {
11735
13224
  padding: "4px 8px",
@@ -11746,182 +13235,1259 @@ const SurveyStudioModal = ({
11746
13235
  tr ? qt.labelTr : qt.labelEn
11747
13236
  ]
11748
13237
  },
11749
- qt.type
11750
- )) })
11751
- ]
11752
- }
11753
- ),
11754
- /* @__PURE__ */ jsxRuntime.jsx(
11755
- "div",
11756
- {
11757
- onDragOver: (e) => {
11758
- if (dragRef.current?.kind === "question" || dragRef.current?.kind === "new-type") {
11759
- e.preventDefault();
11760
- }
11761
- },
11762
- onDrop: (e) => {
11763
- e.preventDefault();
11764
- if (dragRef.current?.kind === "new-type") {
11765
- const t = dragRef.current.qType;
11766
- dragRef.current = null;
11767
- addQuestionOfType(t);
13238
+ qt.type
13239
+ )) })
13240
+ ]
13241
+ }
13242
+ ),
13243
+ draft.displayMode === "multi_step" ? (() => {
13244
+ const groupedMap = groupQuestionsByStep(questions, steps);
13245
+ const allCollapsed = steps.length > 0 && steps.every((s) => Boolean(collapsedStepIds[s.id]));
13246
+ const addNewStepCategory = () => {
13247
+ const nextIdx = steps.length + 1;
13248
+ const newStepId = `step_${uid("s")}`;
13249
+ const dynamicStepTitles = {};
13250
+ for (const loc of strapiLocales) {
13251
+ dynamicStepTitles[loc.code] = loc.code.toLowerCase().startsWith("tr") ? `${nextIdx}. Adım` : `Step ${nextIdx}`;
13252
+ }
13253
+ if (!dynamicStepTitles.tr) dynamicStepTitles.tr = `${nextIdx}. Adım`;
13254
+ if (!dynamicStepTitles.en) dynamicStepTitles.en = `Step ${nextIdx}`;
13255
+ setDraft(
13256
+ (prev) => normalizeMultiStepDraft({
13257
+ ...prev,
13258
+ steps: [
13259
+ ...prev.steps || [],
13260
+ {
13261
+ id: newStepId,
13262
+ title: dynamicStepTitles
13263
+ }
13264
+ ]
13265
+ })
13266
+ );
13267
+ setActiveStepId(newStepId);
13268
+ setCollapsedStepIds((prev) => ({ ...prev, [newStepId]: false }));
13269
+ };
13270
+ return /* @__PURE__ */ jsxRuntime.jsxs("div", { style: { display: "flex", flexDirection: "column", gap: 9 }, children: [
13271
+ /* @__PURE__ */ jsxRuntime.jsxs(
13272
+ "div",
13273
+ {
13274
+ style: {
13275
+ display: "flex",
13276
+ alignItems: "center",
13277
+ justifyContent: "space-between",
13278
+ flexWrap: "wrap",
13279
+ gap: 6,
13280
+ padding: "6px 10px",
13281
+ borderRadius: 8,
13282
+ background: "#eef2ff",
13283
+ border: "1px solid #c7d2fe"
13284
+ },
13285
+ children: [
13286
+ /* @__PURE__ */ jsxRuntime.jsxs("div", { style: { display: "flex", alignItems: "center", gap: 6 }, children: [
13287
+ /* @__PURE__ */ jsxRuntime.jsx(index.MaterialIcon, { name: "layers", size: 15, color: "#3730a3" }),
13288
+ /* @__PURE__ */ jsxRuntime.jsx("span", { style: { fontSize: 11.5, fontWeight: 800, color: "#1e1b4b" }, children: tr ? `Sihirbaz Kategorileri (${steps.length} Adım • ${questions.length} Soru)` : `Wizard Step Categories (${steps.length} Steps • ${questions.length} Qs)` })
13289
+ ] }),
13290
+ /* @__PURE__ */ jsxRuntime.jsxs("div", { style: { display: "flex", alignItems: "center", gap: 5 }, children: [
13291
+ /* @__PURE__ */ jsxRuntime.jsx(
13292
+ "button",
13293
+ {
13294
+ type: "button",
13295
+ onClick: () => {
13296
+ const nextState = {};
13297
+ for (const s of steps) {
13298
+ nextState[s.id] = !allCollapsed;
13299
+ }
13300
+ setCollapsedStepIds(nextState);
13301
+ },
13302
+ style: {
13303
+ padding: "4px 8px",
13304
+ fontSize: 10.5,
13305
+ fontWeight: 700,
13306
+ borderRadius: 5,
13307
+ border: "1px solid #cbd5e1",
13308
+ background: "#ffffff",
13309
+ color: "#334155",
13310
+ cursor: "pointer"
13311
+ },
13312
+ children: allCollapsed ? tr ? "▾ Tümünü Aç" : "▾ Expand All" : tr ? "▸ Tümünü Daralt" : "▸ Collapse All"
13313
+ }
13314
+ ),
13315
+ /* @__PURE__ */ jsxRuntime.jsx(
13316
+ "button",
13317
+ {
13318
+ type: "button",
13319
+ onClick: addNewStepCategory,
13320
+ style: {
13321
+ padding: "4px 10px",
13322
+ fontSize: 10.5,
13323
+ fontWeight: 700,
13324
+ borderRadius: 5,
13325
+ border: "none",
13326
+ background: "#2563eb",
13327
+ color: "#ffffff",
13328
+ cursor: "pointer"
13329
+ },
13330
+ children: tr ? "+ Yeni Adım Ekle" : "+ Add Step"
13331
+ }
13332
+ )
13333
+ ] })
13334
+ ]
11768
13335
  }
11769
- },
11770
- style: { display: "flex", flexDirection: "column", gap: 7 },
11771
- children: questions.map((q, qIdx) => {
11772
- const selected = qIdx === selectedQuestionIdx;
11773
- const qTitle = pickTextForLocale(q.title, uiLocale, q.key);
11774
- const hasCond = q.conditions && Array.isArray(q.conditions.rules) && q.conditions.rules.length > 0;
13336
+ ),
13337
+ steps.map((st, sIdx) => {
13338
+ const stTitleObj = normalizeLocalizedRecord(st.title, strapiLocales);
13339
+ const stepEntries = groupedMap.get(st.id) || [];
13340
+ const isCollapsed = Boolean(collapsedStepIds[st.id]);
13341
+ const isFocusedStep = activeStepId === st.id;
13342
+ const containsSelectedQ = stepEntries.some(
13343
+ (ent) => ent.globalIndex === selectedQuestionIdx
13344
+ );
13345
+ const stepIndicatorBefore = dropIndicator?.kind === "step" && dropIndicator.targetId === st.id && dropIndicator.position === "before";
13346
+ const stepIndicatorAfter = dropIndicator?.kind === "step" && dropIndicator.targetId === st.id && dropIndicator.position === "after";
13347
+ const isQuestionZoneHovered = dropIndicator?.kind === "step-zone" && dropIndicator.targetId === st.id;
13348
+ const handleDropIntoStepEnd = (item) => {
13349
+ const prevSelectedKey = activeQ?.key;
13350
+ if (item.kind === "question") {
13351
+ const nextDraft = moveQuestionInMultiStepDraft(
13352
+ draft,
13353
+ item.questionKey,
13354
+ {
13355
+ stepId: st.id,
13356
+ position: "end"
13357
+ }
13358
+ );
13359
+ setDraft(nextDraft);
13360
+ selectQuestionByKey(nextDraft.questions, item.questionKey || prevSelectedKey);
13361
+ setActiveStepId(st.id);
13362
+ setCollapsedStepIds((prev) => ({ ...prev, [st.id]: false }));
13363
+ } else if (item.kind === "new-type") {
13364
+ const newQ = buildQuestionFromType(
13365
+ item.qType,
13366
+ st.id,
13367
+ questions.map((q) => q.key)
13368
+ );
13369
+ const { draft: nextDraft, insertedIndex } = insertQuestionInMultiStepDraft(draft, newQ, {
13370
+ stepId: st.id,
13371
+ position: "end"
13372
+ });
13373
+ setDraft(nextDraft);
13374
+ setSelectedQuestionIdx(insertedIndex);
13375
+ setActiveStepId(st.id);
13376
+ setCollapsedStepIds((prev) => ({ ...prev, [st.id]: false }));
13377
+ }
13378
+ };
11775
13379
  return /* @__PURE__ */ jsxRuntime.jsxs(
11776
13380
  "div",
11777
13381
  {
11778
- draggable: true,
11779
- onDragStart: (e) => {
11780
- dragRef.current = { kind: "question", index: qIdx };
11781
- e.dataTransfer.setData("text/plain", q.key);
11782
- },
11783
- onDragOver: (e) => {
11784
- if (dragRef.current?.kind === "question" || dragRef.current?.kind === "new-type") {
11785
- e.preventDefault();
11786
- e.stopPropagation();
11787
- }
11788
- },
11789
- onDrop: (e) => {
11790
- e.preventDefault();
11791
- e.stopPropagation();
11792
- const item = dragRef.current;
11793
- dragRef.current = null;
11794
- if (!item) return;
11795
- if (item.kind === "new-type") {
11796
- addQuestionOfType(item.qType, qIdx);
11797
- return;
11798
- }
11799
- if (item.kind === "question" && item.index !== qIdx) {
11800
- const next = [...questions];
11801
- const [moved] = next.splice(item.index, 1);
11802
- next.splice(qIdx, 0, moved);
11803
- setDraft((prev) => ({ ...prev, questions: next }));
11804
- setSelectedQuestionIdx(qIdx);
11805
- }
11806
- },
11807
- onClick: () => setSelectedQuestionIdx(qIdx),
11808
13382
  style: {
11809
- padding: "9px 10px",
11810
- borderRadius: 8,
11811
- border: selected ? "2px solid #2563eb" : "1px solid #cbd5e1",
11812
- background: selected ? "#eff6ff" : "#ffffff",
11813
- cursor: "grab",
11814
- display: "flex",
11815
- alignItems: "center",
11816
- justifyContent: "space-between",
11817
- gap: 8
13383
+ position: "relative",
13384
+ borderRadius: 10,
13385
+ border: isQuestionZoneHovered ? "2px dashed #2563eb" : isFocusedStep || containsSelectedQ ? "1.5px solid #60a5fa" : "1px solid #cbd5e1",
13386
+ background: "#ffffff",
13387
+ boxShadow: isFocusedStep || containsSelectedQ ? "0 2px 10px rgba(37, 99, 235, 0.08)" : "none",
13388
+ transition: "border-color 0.14s ease, box-shadow 0.14s ease"
11818
13389
  },
11819
13390
  children: [
13391
+ stepIndicatorBefore && /* @__PURE__ */ jsxRuntime.jsx(
13392
+ "div",
13393
+ {
13394
+ style: {
13395
+ position: "absolute",
13396
+ top: -5,
13397
+ left: 6,
13398
+ right: 6,
13399
+ height: 3,
13400
+ borderRadius: 3,
13401
+ background: "#2563eb",
13402
+ zIndex: 5
13403
+ }
13404
+ }
13405
+ ),
11820
13406
  /* @__PURE__ */ jsxRuntime.jsxs(
11821
13407
  "div",
11822
13408
  {
13409
+ draggable: stepDragReadyId === st.id,
13410
+ onClick: () => setActiveStepId(st.id),
13411
+ onDragStart: (e) => {
13412
+ if (stepDragReadyId !== st.id) {
13413
+ e.preventDefault();
13414
+ return;
13415
+ }
13416
+ dragRef.current = {
13417
+ kind: "step",
13418
+ index: sIdx,
13419
+ stepId: st.id
13420
+ };
13421
+ e.dataTransfer.effectAllowed = "move";
13422
+ e.dataTransfer.setData("text/plain", st.id);
13423
+ },
13424
+ onDragEnd: () => {
13425
+ dragRef.current = null;
13426
+ setStepDragReadyId(null);
13427
+ setDropIndicator(null);
13428
+ clearHoverExpandTimer();
13429
+ },
13430
+ onDragOver: (e) => {
13431
+ const item = dragRef.current;
13432
+ if (!item) return;
13433
+ if (item.kind === "step") {
13434
+ if (item.stepId === st.id) return;
13435
+ e.preventDefault();
13436
+ e.stopPropagation();
13437
+ const rect = e.currentTarget.getBoundingClientRect();
13438
+ const pos = e.clientY - rect.top < rect.height / 2 ? "before" : "after";
13439
+ setDropIndicator({ kind: "step", targetId: st.id, position: pos });
13440
+ } else if (item.kind === "question" || item.kind === "new-type") {
13441
+ e.preventDefault();
13442
+ e.stopPropagation();
13443
+ setDropIndicator({ kind: "step-zone", targetId: st.id });
13444
+ if (isCollapsed && hoverExpandTimerRef.current?.stepId !== st.id) {
13445
+ clearHoverExpandTimer();
13446
+ hoverExpandTimerRef.current = {
13447
+ stepId: st.id,
13448
+ timer: setTimeout(() => {
13449
+ setCollapsedStepIds((prev) => ({
13450
+ ...prev,
13451
+ [st.id]: false
13452
+ }));
13453
+ hoverExpandTimerRef.current = null;
13454
+ }, 380)
13455
+ };
13456
+ }
13457
+ }
13458
+ },
13459
+ onDragLeave: () => {
13460
+ clearHoverExpandTimer();
13461
+ },
13462
+ onDrop: (e) => {
13463
+ e.preventDefault();
13464
+ e.stopPropagation();
13465
+ clearHoverExpandTimer();
13466
+ const item = dragRef.current;
13467
+ const curInd = dropIndicator;
13468
+ dragRef.current = null;
13469
+ setStepDragReadyId(null);
13470
+ setDropIndicator(null);
13471
+ if (!item) return;
13472
+ if (item.kind === "step" && item.stepId !== st.id) {
13473
+ const prevSelectedKey = activeQ?.key;
13474
+ const pos = curInd?.kind === "step" && curInd.targetId === st.id ? curInd.position : "before";
13475
+ const nextDraft = reorderStepsInDraft(
13476
+ draft,
13477
+ item.stepId,
13478
+ st.id,
13479
+ pos
13480
+ );
13481
+ setDraft(nextDraft);
13482
+ selectQuestionByKey(nextDraft.questions, prevSelectedKey);
13483
+ return;
13484
+ }
13485
+ if (item.kind === "question" || item.kind === "new-type") {
13486
+ handleDropIntoStepEnd(item);
13487
+ }
13488
+ },
11823
13489
  style: {
13490
+ padding: "8px 10px",
13491
+ borderTopLeftRadius: 9,
13492
+ borderTopRightRadius: 9,
13493
+ borderBottomLeftRadius: isCollapsed ? 9 : 0,
13494
+ borderBottomRightRadius: isCollapsed ? 9 : 0,
13495
+ borderBottom: isCollapsed ? "none" : "1px solid #e2e8f0",
13496
+ background: isQuestionZoneHovered ? "#dbeafe" : isFocusedStep || containsSelectedQ ? "#eff6ff" : "#f8fafc",
11824
13497
  display: "flex",
11825
- alignItems: "center",
11826
- gap: 7,
11827
- overflow: "hidden"
13498
+ flexDirection: "column",
13499
+ gap: 6
11828
13500
  },
11829
13501
  children: [
11830
- /* @__PURE__ */ jsxRuntime.jsx(
11831
- index.MaterialIcon,
13502
+ /* @__PURE__ */ jsxRuntime.jsxs(
13503
+ "div",
11832
13504
  {
11833
- name: "drag_indicator",
11834
- size: 16,
11835
- color: selected ? "#2563eb" : "#94a3b8"
13505
+ style: {
13506
+ display: "flex",
13507
+ alignItems: "center",
13508
+ justifyContent: "space-between",
13509
+ gap: 6
13510
+ },
13511
+ children: [
13512
+ /* @__PURE__ */ jsxRuntime.jsxs(
13513
+ "div",
13514
+ {
13515
+ style: {
13516
+ display: "flex",
13517
+ alignItems: "center",
13518
+ gap: 6,
13519
+ minWidth: 0
13520
+ },
13521
+ children: [
13522
+ /* @__PURE__ */ jsxRuntime.jsx(
13523
+ "span",
13524
+ {
13525
+ onMouseDown: () => setStepDragReadyId(st.id),
13526
+ onMouseUp: () => setStepDragReadyId(null),
13527
+ title: tr ? "Adımı sürükleyerek sıralayın" : "Drag to reorder step category",
13528
+ style: {
13529
+ display: "inline-flex",
13530
+ alignItems: "center",
13531
+ padding: "2px 3px",
13532
+ borderRadius: 4,
13533
+ cursor: "grab",
13534
+ background: "#e2e8f0"
13535
+ },
13536
+ children: /* @__PURE__ */ jsxRuntime.jsx(
13537
+ index.MaterialIcon,
13538
+ {
13539
+ name: "drag_indicator",
13540
+ size: 15,
13541
+ color: "#334155"
13542
+ }
13543
+ )
13544
+ }
13545
+ ),
13546
+ /* @__PURE__ */ jsxRuntime.jsxs(
13547
+ "button",
13548
+ {
13549
+ type: "button",
13550
+ onClick: (e) => {
13551
+ e.stopPropagation();
13552
+ setCollapsedStepIds((prev) => ({
13553
+ ...prev,
13554
+ [st.id]: !prev[st.id]
13555
+ }));
13556
+ setActiveStepId(st.id);
13557
+ },
13558
+ style: {
13559
+ border: "none",
13560
+ background: "transparent",
13561
+ padding: "2px 4px",
13562
+ cursor: "pointer",
13563
+ fontSize: 12,
13564
+ fontWeight: 800,
13565
+ color: "#1e3a8a",
13566
+ display: "inline-flex",
13567
+ alignItems: "center",
13568
+ gap: 5
13569
+ },
13570
+ children: [
13571
+ /* @__PURE__ */ jsxRuntime.jsx("span", { children: isCollapsed ? "▸" : "▾" }),
13572
+ /* @__PURE__ */ jsxRuntime.jsx(
13573
+ "span",
13574
+ {
13575
+ style: {
13576
+ padding: "2px 7px",
13577
+ borderRadius: 6,
13578
+ background: "#1e3a8a",
13579
+ color: "#ffffff",
13580
+ fontSize: 10.5,
13581
+ fontWeight: 800
13582
+ },
13583
+ children: tr ? `Adım ${sIdx + 1}` : `Step ${sIdx + 1}`
13584
+ }
13585
+ ),
13586
+ /* @__PURE__ */ jsxRuntime.jsx(
13587
+ "span",
13588
+ {
13589
+ style: {
13590
+ fontSize: 12,
13591
+ fontWeight: 700,
13592
+ color: "#0f172a"
13593
+ },
13594
+ children: pickTextForLocale(st.title, uiLocale, st.id)
13595
+ }
13596
+ )
13597
+ ]
13598
+ }
13599
+ )
13600
+ ]
13601
+ }
13602
+ ),
13603
+ /* @__PURE__ */ jsxRuntime.jsxs("div", { style: { display: "flex", alignItems: "center", gap: 4 }, children: [
13604
+ /* @__PURE__ */ jsxRuntime.jsxs(
13605
+ "span",
13606
+ {
13607
+ style: {
13608
+ fontSize: 10.5,
13609
+ fontWeight: 700,
13610
+ padding: "2px 8px",
13611
+ borderRadius: 10,
13612
+ background: stepEntries.length > 0 ? "#dbeafe" : "#f1f5f9",
13613
+ color: stepEntries.length > 0 ? "#1e40af" : "#64748b"
13614
+ },
13615
+ children: [
13616
+ stepEntries.length,
13617
+ " ",
13618
+ tr ? "soru" : "Qs"
13619
+ ]
13620
+ }
13621
+ ),
13622
+ /* @__PURE__ */ jsxRuntime.jsx(
13623
+ "button",
13624
+ {
13625
+ type: "button",
13626
+ disabled: sIdx === 0,
13627
+ onClick: (e) => {
13628
+ e.stopPropagation();
13629
+ const prevKey = activeQ?.key;
13630
+ const nextDraft = shiftStepByOffset(draft, st.id, -1);
13631
+ setDraft(nextDraft);
13632
+ selectQuestionByKey(nextDraft.questions, prevKey);
13633
+ },
13634
+ title: tr ? "Kategoriyi yukarı taşı" : "Move step up",
13635
+ style: {
13636
+ border: "1px solid #cbd5e1",
13637
+ background: "#ffffff",
13638
+ color: sIdx === 0 ? "#cbd5e1" : "#334155",
13639
+ borderRadius: 4,
13640
+ padding: "1px 5px",
13641
+ fontSize: 11,
13642
+ cursor: sIdx === 0 ? "default" : "pointer"
13643
+ },
13644
+ children: "↑"
13645
+ }
13646
+ ),
13647
+ /* @__PURE__ */ jsxRuntime.jsx(
13648
+ "button",
13649
+ {
13650
+ type: "button",
13651
+ disabled: sIdx === steps.length - 1,
13652
+ onClick: (e) => {
13653
+ e.stopPropagation();
13654
+ const prevKey = activeQ?.key;
13655
+ const nextDraft = shiftStepByOffset(draft, st.id, 1);
13656
+ setDraft(nextDraft);
13657
+ selectQuestionByKey(nextDraft.questions, prevKey);
13658
+ },
13659
+ title: tr ? "Kategoriyi aşağı taşı" : "Move step down",
13660
+ style: {
13661
+ border: "1px solid #cbd5e1",
13662
+ background: "#ffffff",
13663
+ color: sIdx === steps.length - 1 ? "#cbd5e1" : "#334155",
13664
+ borderRadius: 4,
13665
+ padding: "1px 5px",
13666
+ fontSize: 11,
13667
+ cursor: sIdx === steps.length - 1 ? "default" : "pointer"
13668
+ },
13669
+ children: "↓"
13670
+ }
13671
+ ),
13672
+ /* @__PURE__ */ jsxRuntime.jsx(
13673
+ "button",
13674
+ {
13675
+ type: "button",
13676
+ disabled: steps.length <= 1,
13677
+ onClick: (e) => {
13678
+ e.stopPropagation();
13679
+ const prevKey = activeQ?.key;
13680
+ const res = deleteStepWithQuestionReassignment(
13681
+ draft,
13682
+ st.id
13683
+ );
13684
+ setDraft(res.draft);
13685
+ setActiveStepId(res.fallbackStepId);
13686
+ setCollapsedStepIds((prev) => ({
13687
+ ...prev,
13688
+ [res.fallbackStepId]: false
13689
+ }));
13690
+ selectQuestionByKey(res.draft.questions, prevKey);
13691
+ if (res.movedQuestionCount > 0) {
13692
+ setStatusMsg(
13693
+ tr ? `${res.movedQuestionCount} soru komşu adıma aktarıldı.` : `${res.movedQuestionCount} question(s) moved to adjacent step.`
13694
+ );
13695
+ }
13696
+ },
13697
+ title: tr ? "Adımı sil (içindeki sorular komşu adıma aktarılır)" : "Delete step (reassigns questions safely)",
13698
+ style: {
13699
+ border: "none",
13700
+ background: "transparent",
13701
+ color: steps.length <= 1 ? "#cbd5e1" : "#dc2626",
13702
+ cursor: steps.length <= 1 ? "default" : "pointer",
13703
+ fontSize: 14,
13704
+ fontWeight: 700,
13705
+ padding: "0 4px"
13706
+ },
13707
+ children: "×"
13708
+ }
13709
+ )
13710
+ ] })
13711
+ ]
11836
13712
  }
11837
13713
  ),
11838
- /* @__PURE__ */ jsxRuntime.jsxs("div", { style: { overflow: "hidden" }, children: [
11839
- /* @__PURE__ */ jsxRuntime.jsxs(
13714
+ !isCollapsed && (() => {
13715
+ const stDescObj = normalizeLocalizedRecord(
13716
+ st.description,
13717
+ strapiLocales
13718
+ );
13719
+ const hasFilledDesc = Object.values(stDescObj).some(
13720
+ (val) => String(val || "").trim().length > 0
13721
+ );
13722
+ const showStepDesc = openStepDescIds[st.id] !== void 0 ? openStepDescIds[st.id] : hasFilledDesc;
13723
+ const stepLocaleCols = `repeat(${Math.min(
13724
+ Math.max(strapiLocales.length, 1),
13725
+ 2
13726
+ )}, minmax(0, 1fr))`;
13727
+ return /* @__PURE__ */ jsxRuntime.jsxs(
11840
13728
  "div",
11841
13729
  {
13730
+ onMouseDown: (e) => {
13731
+ e.stopPropagation();
13732
+ setStepDragReadyId(null);
13733
+ },
13734
+ onClick: (e) => e.stopPropagation(),
11842
13735
  style: {
11843
- fontSize: 12,
11844
- fontWeight: 700,
11845
- color: "#0f172a",
11846
- whiteSpace: "nowrap",
11847
- overflow: "hidden",
11848
- textOverflow: "ellipsis"
13736
+ display: "flex",
13737
+ flexDirection: "column",
13738
+ gap: 6
11849
13739
  },
11850
13740
  children: [
11851
- qIdx + 1,
11852
- ". ",
11853
- qTitle,
11854
- " ",
11855
- q.required && /* @__PURE__ */ jsxRuntime.jsx("span", { style: { color: "#dc2626" }, children: "*" })
13741
+ /* @__PURE__ */ jsxRuntime.jsx(
13742
+ "div",
13743
+ {
13744
+ style: {
13745
+ display: "grid",
13746
+ gridTemplateColumns: stepLocaleCols,
13747
+ gap: 5
13748
+ },
13749
+ children: strapiLocales.map((loc) => /* @__PURE__ */ jsxRuntime.jsxs(
13750
+ "div",
13751
+ {
13752
+ style: {
13753
+ display: "flex",
13754
+ alignItems: "stretch",
13755
+ borderRadius: 6,
13756
+ border: "1px solid #cbd5e1",
13757
+ background: "#ffffff",
13758
+ overflow: "hidden"
13759
+ },
13760
+ children: [
13761
+ /* @__PURE__ */ jsxRuntime.jsx(
13762
+ "span",
13763
+ {
13764
+ title: loc.name || loc.code,
13765
+ style: {
13766
+ padding: "0 7px",
13767
+ background: loc.isDefault ? "#dbeafe" : "#f1f5f9",
13768
+ color: loc.isDefault ? "#1e40af" : "#334155",
13769
+ fontSize: 10,
13770
+ fontWeight: 800,
13771
+ borderRight: "1px solid #cbd5e1",
13772
+ display: "inline-flex",
13773
+ alignItems: "center",
13774
+ flexShrink: 0
13775
+ },
13776
+ children: loc.code.toUpperCase()
13777
+ }
13778
+ ),
13779
+ /* @__PURE__ */ jsxRuntime.jsx(
13780
+ "input",
13781
+ {
13782
+ type: "text",
13783
+ value: stTitleObj[loc.code] || "",
13784
+ onChange: (e) => {
13785
+ const nextSteps = steps.map(
13786
+ (item, i) => i === sIdx ? {
13787
+ ...item,
13788
+ title: {
13789
+ ...stTitleObj,
13790
+ [loc.code]: e.target.value
13791
+ }
13792
+ } : item
13793
+ );
13794
+ setDraft((prev) => ({
13795
+ ...prev,
13796
+ steps: nextSteps
13797
+ }));
13798
+ },
13799
+ placeholder: tr ? "Kategori Başlığı" : "Step Title",
13800
+ style: {
13801
+ flex: 1,
13802
+ minWidth: 0,
13803
+ border: "none",
13804
+ outline: "none",
13805
+ padding: "4px 7px",
13806
+ fontSize: 11,
13807
+ color: "#0f172a",
13808
+ background: "transparent"
13809
+ }
13810
+ }
13811
+ )
13812
+ ]
13813
+ },
13814
+ `st-${st.id}-${loc.code}`
13815
+ ))
13816
+ }
13817
+ ),
13818
+ /* @__PURE__ */ jsxRuntime.jsx("div", { style: { display: "flex", alignItems: "center" }, children: /* @__PURE__ */ jsxRuntime.jsxs(
13819
+ "button",
13820
+ {
13821
+ type: "button",
13822
+ onClick: () => setOpenStepDescIds((prev) => ({
13823
+ ...prev,
13824
+ [st.id]: !showStepDesc
13825
+ })),
13826
+ style: {
13827
+ border: "none",
13828
+ background: "transparent",
13829
+ padding: "1px 2px",
13830
+ fontSize: 10.5,
13831
+ fontWeight: 700,
13832
+ color: showStepDesc ? "#1d4ed8" : "#64748b",
13833
+ cursor: "pointer",
13834
+ display: "inline-flex",
13835
+ alignItems: "center",
13836
+ gap: 4
13837
+ },
13838
+ children: [
13839
+ /* @__PURE__ */ jsxRuntime.jsx("span", { children: showStepDesc ? "▾" : "+" }),
13840
+ /* @__PURE__ */ jsxRuntime.jsx("span", { children: tr ? "Kategori Alt Açıklaması (Opsiyonel)" : "Step Subtitle / Description (Optional)" })
13841
+ ]
13842
+ }
13843
+ ) }),
13844
+ showStepDesc && /* @__PURE__ */ jsxRuntime.jsx(
13845
+ "div",
13846
+ {
13847
+ style: {
13848
+ display: "grid",
13849
+ gridTemplateColumns: stepLocaleCols,
13850
+ gap: 5
13851
+ },
13852
+ children: strapiLocales.map((loc) => /* @__PURE__ */ jsxRuntime.jsxs(
13853
+ "div",
13854
+ {
13855
+ style: {
13856
+ display: "flex",
13857
+ alignItems: "stretch",
13858
+ borderRadius: 6,
13859
+ border: "1px dashed #cbd5e1",
13860
+ background: "#f8fafc",
13861
+ overflow: "hidden"
13862
+ },
13863
+ children: [
13864
+ /* @__PURE__ */ jsxRuntime.jsx(
13865
+ "span",
13866
+ {
13867
+ style: {
13868
+ padding: "0 6px",
13869
+ background: "#e2e8f0",
13870
+ color: "#475569",
13871
+ fontSize: 9.5,
13872
+ fontWeight: 800,
13873
+ borderRight: "1px solid #cbd5e1",
13874
+ display: "inline-flex",
13875
+ alignItems: "center",
13876
+ flexShrink: 0
13877
+ },
13878
+ children: loc.code.toUpperCase()
13879
+ }
13880
+ ),
13881
+ /* @__PURE__ */ jsxRuntime.jsx(
13882
+ "input",
13883
+ {
13884
+ type: "text",
13885
+ value: stDescObj[loc.code] || "",
13886
+ onChange: (e) => {
13887
+ const nextSteps = steps.map(
13888
+ (item, i) => i === sIdx ? {
13889
+ ...item,
13890
+ description: {
13891
+ ...stDescObj,
13892
+ [loc.code]: e.target.value
13893
+ }
13894
+ } : item
13895
+ );
13896
+ setDraft((prev) => ({
13897
+ ...prev,
13898
+ steps: nextSteps
13899
+ }));
13900
+ },
13901
+ placeholder: tr ? "Opsiyonel alt açıklama..." : "Optional step description...",
13902
+ style: {
13903
+ flex: 1,
13904
+ minWidth: 0,
13905
+ border: "none",
13906
+ outline: "none",
13907
+ padding: "4px 7px",
13908
+ fontSize: 10.5,
13909
+ color: "#334155",
13910
+ background: "transparent"
13911
+ }
13912
+ }
13913
+ )
13914
+ ]
13915
+ },
13916
+ `stdesc-${st.id}-${loc.code}`
13917
+ ))
13918
+ }
13919
+ )
11856
13920
  ]
11857
13921
  }
11858
- ),
11859
- /* @__PURE__ */ jsxRuntime.jsxs(
13922
+ );
13923
+ })()
13924
+ ]
13925
+ }
13926
+ ),
13927
+ !isCollapsed && /* @__PURE__ */ jsxRuntime.jsxs(
13928
+ "div",
13929
+ {
13930
+ onDragOver: (e) => {
13931
+ const item = dragRef.current;
13932
+ if (item?.kind === "question" || item?.kind === "new-type") {
13933
+ e.preventDefault();
13934
+ setDropIndicator({ kind: "step-zone", targetId: st.id });
13935
+ }
13936
+ },
13937
+ onDrop: (e) => {
13938
+ const item = dragRef.current;
13939
+ if (item?.kind === "question" || item?.kind === "new-type") {
13940
+ e.preventDefault();
13941
+ e.stopPropagation();
13942
+ dragRef.current = null;
13943
+ setDropIndicator(null);
13944
+ handleDropIntoStepEnd(item);
13945
+ }
13946
+ },
13947
+ style: {
13948
+ padding: 9,
13949
+ display: "flex",
13950
+ flexDirection: "column",
13951
+ gap: 6,
13952
+ background: isQuestionZoneHovered ? "#f0f9ff" : "#ffffff",
13953
+ borderBottomLeftRadius: 9,
13954
+ borderBottomRightRadius: 9
13955
+ },
13956
+ children: [
13957
+ stepEntries.length === 0 ? /* @__PURE__ */ jsxRuntime.jsx(
13958
+ "div",
13959
+ {
13960
+ style: {
13961
+ padding: "14px 10px",
13962
+ borderRadius: 7,
13963
+ border: "1.5 dashed #cbd5e1",
13964
+ borderStyle: "dashed",
13965
+ background: "#f8fafc",
13966
+ textAlign: "center",
13967
+ fontSize: 11,
13968
+ color: "#64748b"
13969
+ },
13970
+ children: tr ? "Bu adımda henüz soru yok — Yukarıdan soru tipi sürükleyin veya başka bir adımdan soru taşıyın." : "No questions in this step yet — Drag a question here from another step or from the palette above."
13971
+ }
13972
+ ) : stepEntries.map(({ question: q, globalIndex: qIdx, localIndex }) => {
13973
+ const selected = qIdx === selectedQuestionIdx;
13974
+ const qTitle = pickTextForLocale(q.title, uiLocale, q.key);
13975
+ const hasCond = q.conditions && Array.isArray(q.conditions.rules) && q.conditions.rules.length > 0;
13976
+ const qIndBefore = dropIndicator?.kind === "question" && dropIndicator.targetId === q.key && dropIndicator.position === "before";
13977
+ const qIndAfter = dropIndicator?.kind === "question" && dropIndicator.targetId === q.key && dropIndicator.position === "after";
13978
+ return /* @__PURE__ */ jsxRuntime.jsxs(
11860
13979
  "div",
11861
13980
  {
13981
+ draggable: true,
13982
+ onDragStart: (e) => {
13983
+ e.stopPropagation();
13984
+ dragRef.current = {
13985
+ kind: "question",
13986
+ index: qIdx,
13987
+ questionKey: q.key,
13988
+ fromStepId: st.id
13989
+ };
13990
+ e.dataTransfer.effectAllowed = "move";
13991
+ e.dataTransfer.setData("text/plain", q.key);
13992
+ },
13993
+ onDragEnd: () => {
13994
+ dragRef.current = null;
13995
+ setDropIndicator(null);
13996
+ clearHoverExpandTimer();
13997
+ },
13998
+ onDragOver: (e) => {
13999
+ const item = dragRef.current;
14000
+ if (item?.kind === "question" || item?.kind === "new-type") {
14001
+ e.preventDefault();
14002
+ e.stopPropagation();
14003
+ const rect = e.currentTarget.getBoundingClientRect();
14004
+ const pos = e.clientY - rect.top < rect.height / 2 ? "before" : "after";
14005
+ setDropIndicator({
14006
+ kind: "question",
14007
+ targetId: q.key,
14008
+ position: pos
14009
+ });
14010
+ }
14011
+ },
14012
+ onDrop: (e) => {
14013
+ e.preventDefault();
14014
+ e.stopPropagation();
14015
+ const item = dragRef.current;
14016
+ const curInd = dropIndicator;
14017
+ dragRef.current = null;
14018
+ setDropIndicator(null);
14019
+ if (!item) return;
14020
+ const pos = curInd?.kind === "question" && curInd.targetId === q.key ? curInd.position : "before";
14021
+ if (item.kind === "new-type") {
14022
+ const newQ = buildQuestionFromType(
14023
+ item.qType,
14024
+ st.id,
14025
+ questions.map((x) => x.key)
14026
+ );
14027
+ const { draft: nextDraft, insertedIndex } = insertQuestionInMultiStepDraft(draft, newQ, {
14028
+ stepId: st.id,
14029
+ targetQuestionKey: q.key,
14030
+ position: pos
14031
+ });
14032
+ setDraft(nextDraft);
14033
+ setSelectedQuestionIdx(insertedIndex);
14034
+ setActiveStepId(st.id);
14035
+ return;
14036
+ }
14037
+ if (item.kind === "question") {
14038
+ const nextDraft = moveQuestionInMultiStepDraft(
14039
+ draft,
14040
+ item.questionKey,
14041
+ {
14042
+ stepId: st.id,
14043
+ targetQuestionKey: q.key,
14044
+ position: pos
14045
+ }
14046
+ );
14047
+ setDraft(nextDraft);
14048
+ selectQuestionByKey(
14049
+ nextDraft.questions,
14050
+ item.questionKey
14051
+ );
14052
+ setActiveStepId(st.id);
14053
+ }
14054
+ },
14055
+ onClick: (e) => {
14056
+ e.stopPropagation();
14057
+ setSelectedQuestionIdx(qIdx);
14058
+ setActiveStepId(st.id);
14059
+ },
11862
14060
  style: {
14061
+ position: "relative",
14062
+ padding: "8px 10px",
14063
+ borderRadius: 7,
14064
+ border: selected ? "2px solid #2563eb" : "1px solid #cbd5e1",
14065
+ background: selected ? "#eff6ff" : "#f8fafc",
14066
+ cursor: "grab",
11863
14067
  display: "flex",
11864
14068
  alignItems: "center",
11865
- gap: 6,
11866
- fontSize: 10,
11867
- color: "#64748b",
11868
- marginTop: 2
14069
+ justifyContent: "space-between",
14070
+ gap: 8
11869
14071
  },
11870
14072
  children: [
11871
- /* @__PURE__ */ jsxRuntime.jsx("code", { children: q.key }),
11872
- /* @__PURE__ */ jsxRuntime.jsxs("span", { children: [
11873
- "• ",
11874
- q.type
11875
- ] }),
11876
- draft.displayMode === "multi_step" && q.stepId && /* @__PURE__ */ jsxRuntime.jsxs("span", { style: { color: "#1d4ed8", fontWeight: 600 }, children: [
11877
- "• ",
11878
- q.stepId
11879
- ] }),
11880
- hasCond && /* @__PURE__ */ jsxRuntime.jsx(
11881
- "span",
14073
+ qIndBefore && /* @__PURE__ */ jsxRuntime.jsx(
14074
+ "div",
14075
+ {
14076
+ style: {
14077
+ position: "absolute",
14078
+ top: -4,
14079
+ left: 4,
14080
+ right: 4,
14081
+ height: 2.5,
14082
+ borderRadius: 2,
14083
+ background: "#2563eb",
14084
+ zIndex: 4
14085
+ }
14086
+ }
14087
+ ),
14088
+ /* @__PURE__ */ jsxRuntime.jsxs(
14089
+ "div",
14090
+ {
14091
+ style: {
14092
+ display: "flex",
14093
+ alignItems: "center",
14094
+ gap: 7,
14095
+ overflow: "hidden"
14096
+ },
14097
+ children: [
14098
+ /* @__PURE__ */ jsxRuntime.jsx(
14099
+ index.MaterialIcon,
14100
+ {
14101
+ name: "drag_indicator",
14102
+ size: 15,
14103
+ color: selected ? "#2563eb" : "#94a3b8"
14104
+ }
14105
+ ),
14106
+ /* @__PURE__ */ jsxRuntime.jsxs("div", { style: { overflow: "hidden" }, children: [
14107
+ /* @__PURE__ */ jsxRuntime.jsxs(
14108
+ "div",
14109
+ {
14110
+ style: {
14111
+ fontSize: 12,
14112
+ fontWeight: 700,
14113
+ color: "#0f172a",
14114
+ whiteSpace: "nowrap",
14115
+ overflow: "hidden",
14116
+ textOverflow: "ellipsis"
14117
+ },
14118
+ children: [
14119
+ /* @__PURE__ */ jsxRuntime.jsxs(
14120
+ "span",
14121
+ {
14122
+ style: {
14123
+ color: "#2563eb",
14124
+ marginRight: 4,
14125
+ fontSize: 11
14126
+ },
14127
+ children: [
14128
+ sIdx + 1,
14129
+ ".",
14130
+ localIndex + 1
14131
+ ]
14132
+ }
14133
+ ),
14134
+ qTitle,
14135
+ " ",
14136
+ q.required && /* @__PURE__ */ jsxRuntime.jsx("span", { style: { color: "#dc2626" }, children: "*" })
14137
+ ]
14138
+ }
14139
+ ),
14140
+ /* @__PURE__ */ jsxRuntime.jsxs(
14141
+ "div",
14142
+ {
14143
+ style: {
14144
+ display: "flex",
14145
+ alignItems: "center",
14146
+ gap: 6,
14147
+ fontSize: 10,
14148
+ color: "#64748b",
14149
+ marginTop: 2
14150
+ },
14151
+ children: [
14152
+ /* @__PURE__ */ jsxRuntime.jsx("code", { children: q.key }),
14153
+ /* @__PURE__ */ jsxRuntime.jsxs("span", { children: [
14154
+ "• ",
14155
+ q.type
14156
+ ] }),
14157
+ hasCond && /* @__PURE__ */ jsxRuntime.jsx(
14158
+ "span",
14159
+ {
14160
+ style: {
14161
+ padding: "1px 5px",
14162
+ borderRadius: 4,
14163
+ background: "#fef3c7",
14164
+ color: "#92400e",
14165
+ fontWeight: 700
14166
+ },
14167
+ children: tr ? "Koşullu" : "Skip Logic"
14168
+ }
14169
+ )
14170
+ ]
14171
+ }
14172
+ )
14173
+ ] })
14174
+ ]
14175
+ }
14176
+ ),
14177
+ /* @__PURE__ */ jsxRuntime.jsx(
14178
+ "button",
11882
14179
  {
14180
+ type: "button",
14181
+ onClick: (e) => {
14182
+ e.stopPropagation();
14183
+ removeQuestion(qIdx);
14184
+ },
11883
14185
  style: {
11884
- padding: "1px 5px",
11885
- borderRadius: 4,
11886
- background: "#fef3c7",
11887
- color: "#92400e",
11888
- fontWeight: 700
14186
+ border: "none",
14187
+ background: "transparent",
14188
+ color: "#dc2626",
14189
+ cursor: "pointer",
14190
+ fontSize: 15
11889
14191
  },
11890
- children: tr ? "Koşullu" : "Skip Logic"
14192
+ title: tr ? "Soruyu sil" : "Delete question",
14193
+ children: "×"
14194
+ }
14195
+ ),
14196
+ qIndAfter && /* @__PURE__ */ jsxRuntime.jsx(
14197
+ "div",
14198
+ {
14199
+ style: {
14200
+ position: "absolute",
14201
+ bottom: -4,
14202
+ left: 4,
14203
+ right: 4,
14204
+ height: 2.5,
14205
+ borderRadius: 2,
14206
+ background: "#2563eb",
14207
+ zIndex: 4
14208
+ }
11891
14209
  }
11892
14210
  )
11893
14211
  ]
11894
- }
11895
- )
11896
- ] })
14212
+ },
14213
+ q.key || qIdx
14214
+ );
14215
+ }),
14216
+ /* @__PURE__ */ jsxRuntime.jsxs(
14217
+ "button",
14218
+ {
14219
+ type: "button",
14220
+ onClick: (e) => {
14221
+ e.stopPropagation();
14222
+ addQuestionOfType("single_choice", void 0, st.id);
14223
+ },
14224
+ style: {
14225
+ marginTop: 2,
14226
+ padding: "5px 8px",
14227
+ borderRadius: 6,
14228
+ border: "1px dashed #93c5fd",
14229
+ background: "#f8fafc",
14230
+ color: "#1d4ed8",
14231
+ fontSize: 10.5,
14232
+ fontWeight: 700,
14233
+ cursor: "pointer"
14234
+ },
14235
+ children: [
14236
+ "+ ",
14237
+ tr ? "Bu Adıma Soru Ekle" : "Add Question to This Step"
14238
+ ]
14239
+ }
14240
+ )
11897
14241
  ]
11898
14242
  }
11899
14243
  ),
11900
- /* @__PURE__ */ jsxRuntime.jsx(
11901
- "button",
14244
+ stepIndicatorAfter && /* @__PURE__ */ jsxRuntime.jsx(
14245
+ "div",
11902
14246
  {
11903
- type: "button",
11904
- onClick: (e) => {
11905
- e.stopPropagation();
11906
- removeQuestion(qIdx);
11907
- },
11908
14247
  style: {
11909
- border: "none",
11910
- background: "transparent",
11911
- color: "#dc2626",
11912
- cursor: "pointer",
11913
- fontSize: 15
11914
- },
11915
- title: tr ? "Soruyu sil" : "Delete question",
11916
- children: "×"
14248
+ position: "absolute",
14249
+ bottom: -5,
14250
+ left: 6,
14251
+ right: 6,
14252
+ height: 3,
14253
+ borderRadius: 3,
14254
+ background: "#2563eb",
14255
+ zIndex: 5
14256
+ }
11917
14257
  }
11918
14258
  )
11919
14259
  ]
11920
14260
  },
11921
- q.key || qIdx
14261
+ st.id
11922
14262
  );
11923
14263
  })
11924
- }
14264
+ ] });
14265
+ })() : (
14266
+ /* SINGLE-PAGE / QUICK-POLL FLAT DRAGGABLE QUESTIONS LIST */
14267
+ /* @__PURE__ */ jsxRuntime.jsx(
14268
+ "div",
14269
+ {
14270
+ onDragOver: (e) => {
14271
+ if (dragRef.current?.kind === "question" || dragRef.current?.kind === "new-type") {
14272
+ e.preventDefault();
14273
+ }
14274
+ },
14275
+ onDrop: (e) => {
14276
+ e.preventDefault();
14277
+ if (dragRef.current?.kind === "new-type") {
14278
+ const t = dragRef.current.qType;
14279
+ dragRef.current = null;
14280
+ setDropIndicator(null);
14281
+ addQuestionOfType(t);
14282
+ }
14283
+ },
14284
+ style: { display: "flex", flexDirection: "column", gap: 7 },
14285
+ children: questions.map((q, qIdx) => {
14286
+ const selected = qIdx === selectedQuestionIdx;
14287
+ const qTitle = pickTextForLocale(q.title, uiLocale, q.key);
14288
+ const hasCond = q.conditions && Array.isArray(q.conditions.rules) && q.conditions.rules.length > 0;
14289
+ const qIndBefore = dropIndicator?.kind === "question" && dropIndicator.targetId === q.key && dropIndicator.position === "before";
14290
+ const qIndAfter = dropIndicator?.kind === "question" && dropIndicator.targetId === q.key && dropIndicator.position === "after";
14291
+ return /* @__PURE__ */ jsxRuntime.jsxs(
14292
+ "div",
14293
+ {
14294
+ draggable: true,
14295
+ onDragStart: (e) => {
14296
+ dragRef.current = {
14297
+ kind: "question",
14298
+ index: qIdx,
14299
+ questionKey: q.key
14300
+ };
14301
+ e.dataTransfer.setData("text/plain", q.key);
14302
+ },
14303
+ onDragEnd: () => {
14304
+ dragRef.current = null;
14305
+ setDropIndicator(null);
14306
+ },
14307
+ onDragOver: (e) => {
14308
+ if (dragRef.current?.kind === "question" || dragRef.current?.kind === "new-type") {
14309
+ e.preventDefault();
14310
+ e.stopPropagation();
14311
+ const rect = e.currentTarget.getBoundingClientRect();
14312
+ const pos = e.clientY - rect.top < rect.height / 2 ? "before" : "after";
14313
+ setDropIndicator({
14314
+ kind: "question",
14315
+ targetId: q.key,
14316
+ position: pos
14317
+ });
14318
+ }
14319
+ },
14320
+ onDrop: (e) => {
14321
+ e.preventDefault();
14322
+ e.stopPropagation();
14323
+ const item = dragRef.current;
14324
+ const curInd = dropIndicator;
14325
+ dragRef.current = null;
14326
+ setDropIndicator(null);
14327
+ if (!item) return;
14328
+ const pos = curInd?.kind === "question" && curInd.targetId === q.key ? curInd.position : "before";
14329
+ if (item.kind === "new-type") {
14330
+ const insIdx = pos === "after" ? qIdx + 1 : qIdx;
14331
+ addQuestionOfType(item.qType, insIdx);
14332
+ return;
14333
+ }
14334
+ if (item.kind === "question" && item.questionKey !== q.key) {
14335
+ const next = reorderFlatQuestions(
14336
+ questions,
14337
+ item.questionKey,
14338
+ q.key,
14339
+ pos
14340
+ );
14341
+ setDraft((prev) => ({ ...prev, questions: next }));
14342
+ selectQuestionByKey(next, item.questionKey);
14343
+ }
14344
+ },
14345
+ onClick: () => setSelectedQuestionIdx(qIdx),
14346
+ style: {
14347
+ position: "relative",
14348
+ padding: "9px 10px",
14349
+ borderRadius: 8,
14350
+ border: selected ? "2px solid #2563eb" : "1px solid #cbd5e1",
14351
+ background: selected ? "#eff6ff" : "#ffffff",
14352
+ cursor: "grab",
14353
+ display: "flex",
14354
+ alignItems: "center",
14355
+ justifyContent: "space-between",
14356
+ gap: 8
14357
+ },
14358
+ children: [
14359
+ qIndBefore && /* @__PURE__ */ jsxRuntime.jsx(
14360
+ "div",
14361
+ {
14362
+ style: {
14363
+ position: "absolute",
14364
+ top: -4,
14365
+ left: 4,
14366
+ right: 4,
14367
+ height: 2.5,
14368
+ borderRadius: 2,
14369
+ background: "#2563eb",
14370
+ zIndex: 4
14371
+ }
14372
+ }
14373
+ ),
14374
+ /* @__PURE__ */ jsxRuntime.jsxs(
14375
+ "div",
14376
+ {
14377
+ style: {
14378
+ display: "flex",
14379
+ alignItems: "center",
14380
+ gap: 7,
14381
+ overflow: "hidden"
14382
+ },
14383
+ children: [
14384
+ /* @__PURE__ */ jsxRuntime.jsx(
14385
+ index.MaterialIcon,
14386
+ {
14387
+ name: "drag_indicator",
14388
+ size: 16,
14389
+ color: selected ? "#2563eb" : "#94a3b8"
14390
+ }
14391
+ ),
14392
+ /* @__PURE__ */ jsxRuntime.jsxs("div", { style: { overflow: "hidden" }, children: [
14393
+ /* @__PURE__ */ jsxRuntime.jsxs(
14394
+ "div",
14395
+ {
14396
+ style: {
14397
+ fontSize: 12,
14398
+ fontWeight: 700,
14399
+ color: "#0f172a",
14400
+ whiteSpace: "nowrap",
14401
+ overflow: "hidden",
14402
+ textOverflow: "ellipsis"
14403
+ },
14404
+ children: [
14405
+ qIdx + 1,
14406
+ ". ",
14407
+ qTitle,
14408
+ " ",
14409
+ q.required && /* @__PURE__ */ jsxRuntime.jsx("span", { style: { color: "#dc2626" }, children: "*" })
14410
+ ]
14411
+ }
14412
+ ),
14413
+ /* @__PURE__ */ jsxRuntime.jsxs(
14414
+ "div",
14415
+ {
14416
+ style: {
14417
+ display: "flex",
14418
+ alignItems: "center",
14419
+ gap: 6,
14420
+ fontSize: 10,
14421
+ color: "#64748b",
14422
+ marginTop: 2
14423
+ },
14424
+ children: [
14425
+ /* @__PURE__ */ jsxRuntime.jsx("code", { children: q.key }),
14426
+ /* @__PURE__ */ jsxRuntime.jsxs("span", { children: [
14427
+ "• ",
14428
+ q.type
14429
+ ] }),
14430
+ hasCond && /* @__PURE__ */ jsxRuntime.jsx(
14431
+ "span",
14432
+ {
14433
+ style: {
14434
+ padding: "1px 5px",
14435
+ borderRadius: 4,
14436
+ background: "#fef3c7",
14437
+ color: "#92400e",
14438
+ fontWeight: 700
14439
+ },
14440
+ children: tr ? "Koşullu" : "Skip Logic"
14441
+ }
14442
+ )
14443
+ ]
14444
+ }
14445
+ )
14446
+ ] })
14447
+ ]
14448
+ }
14449
+ ),
14450
+ /* @__PURE__ */ jsxRuntime.jsx(
14451
+ "button",
14452
+ {
14453
+ type: "button",
14454
+ onClick: (e) => {
14455
+ e.stopPropagation();
14456
+ removeQuestion(qIdx);
14457
+ },
14458
+ style: {
14459
+ border: "none",
14460
+ background: "transparent",
14461
+ color: "#dc2626",
14462
+ cursor: "pointer",
14463
+ fontSize: 15
14464
+ },
14465
+ title: tr ? "Soruyu sil" : "Delete question",
14466
+ children: "×"
14467
+ }
14468
+ ),
14469
+ qIndAfter && /* @__PURE__ */ jsxRuntime.jsx(
14470
+ "div",
14471
+ {
14472
+ style: {
14473
+ position: "absolute",
14474
+ bottom: -4,
14475
+ left: 4,
14476
+ right: 4,
14477
+ height: 2.5,
14478
+ borderRadius: 2,
14479
+ background: "#2563eb",
14480
+ zIndex: 4
14481
+ }
14482
+ }
14483
+ )
14484
+ ]
14485
+ },
14486
+ q.key || qIdx
14487
+ );
14488
+ })
14489
+ }
14490
+ )
11925
14491
  )
11926
14492
  ]
11927
14493
  }
@@ -11989,7 +14555,10 @@ const SurveyStudioModal = ({
11989
14555
  type: "text",
11990
14556
  value: activeQ.key,
11991
14557
  onChange: (e) => updateActiveQuestion({
11992
- key: slugifyKey(e.target.value) || activeQ.key
14558
+ key: sanitizeSlugInput(e.target.value)
14559
+ }),
14560
+ onBlur: (e) => updateActiveQuestion({
14561
+ key: slugifyKey(e.target.value) || `q_${activeQ.type}_${selectedQuestionIdx + 1}`
11993
14562
  }),
11994
14563
  style: { ...inputStyle, fontFamily: "monospace" }
11995
14564
  }
@@ -12013,7 +14582,17 @@ const SurveyStudioModal = ({
12013
14582
  "select",
12014
14583
  {
12015
14584
  value: activeQ.stepId || steps[0]?.id || "",
12016
- onChange: (e) => updateActiveQuestion({ stepId: e.target.value }),
14585
+ onChange: (e) => {
14586
+ const nextStepId = e.target.value;
14587
+ const nextDraft = moveQuestionInMultiStepDraft(draft, activeQ.key, {
14588
+ stepId: nextStepId,
14589
+ position: "end"
14590
+ });
14591
+ setDraft(nextDraft);
14592
+ selectQuestionByKey(nextDraft.questions, activeQ.key);
14593
+ setActiveStepId(nextStepId);
14594
+ setCollapsedStepIds((prev) => ({ ...prev, [nextStepId]: false }));
14595
+ },
12017
14596
  style: inputStyle,
12018
14597
  children: steps.map((st) => /* @__PURE__ */ jsxRuntime.jsx("option", { value: st.id, children: pickTextForLocale(st.title, uiLocale, st.id) }, st.id))
12019
14598
  }
@@ -12279,7 +14858,16 @@ const SurveyStudioModal = ({
12279
14858
  value: opt.id,
12280
14859
  onChange: (e) => {
12281
14860
  const next = opts.map(
12282
- (x, i) => i === oIdx ? { ...x, id: slugifyKey(e.target.value) || x.id } : x
14861
+ (x, i) => i === oIdx ? { ...x, id: sanitizeSlugInput(e.target.value) } : x
14862
+ );
14863
+ saveOpts(next);
14864
+ },
14865
+ onBlur: (e) => {
14866
+ const next = opts.map(
14867
+ (x, i) => i === oIdx ? {
14868
+ ...x,
14869
+ id: slugifyKey(e.target.value) || `opt_${oIdx + 1}`
14870
+ } : x
12283
14871
  );
12284
14872
  saveOpts(next);
12285
14873
  },
@@ -12347,7 +14935,7 @@ const SurveyStudioModal = ({
12347
14935
  ) })
12348
14936
  ]
12349
14937
  },
12350
- `${opt.id}-${oIdx}`
14938
+ oIdx
12351
14939
  );
12352
14940
  }),
12353
14941
  /* @__PURE__ */ jsxRuntime.jsx(
@@ -12851,7 +15439,16 @@ const SurveyStudioModal = ({
12851
15439
  value: r.id,
12852
15440
  onChange: (e) => {
12853
15441
  const next = mRows.map(
12854
- (x, i) => i === rIdx ? { ...x, id: slugifyKey(e.target.value) } : x
15442
+ (x, i) => i === rIdx ? { ...x, id: sanitizeSlugInput(e.target.value) } : x
15443
+ );
15444
+ updateActiveQuestion({ matrixRows: next });
15445
+ },
15446
+ onBlur: (e) => {
15447
+ const next = mRows.map(
15448
+ (x, i) => i === rIdx ? {
15449
+ ...x,
15450
+ id: slugifyKey(e.target.value) || `row_${rIdx + 1}`
15451
+ } : x
12855
15452
  );
12856
15453
  updateActiveQuestion({ matrixRows: next });
12857
15454
  },
@@ -12894,7 +15491,7 @@ const SurveyStudioModal = ({
12894
15491
  )
12895
15492
  ]
12896
15493
  },
12897
- r.id
15494
+ rIdx
12898
15495
  );
12899
15496
  })
12900
15497
  ] }),
@@ -12962,7 +15559,16 @@ const SurveyStudioModal = ({
12962
15559
  value: c.id,
12963
15560
  onChange: (e) => {
12964
15561
  const next = mCols.map(
12965
- (x, i) => i === cIdx ? { ...x, id: slugifyKey(e.target.value) } : x
15562
+ (x, i) => i === cIdx ? { ...x, id: sanitizeSlugInput(e.target.value) } : x
15563
+ );
15564
+ updateActiveQuestion({ matrixColumns: next });
15565
+ },
15566
+ onBlur: (e) => {
15567
+ const next = mCols.map(
15568
+ (x, i) => i === cIdx ? {
15569
+ ...x,
15570
+ id: slugifyKey(e.target.value) || `col_${cIdx + 1}`
15571
+ } : x
12966
15572
  );
12967
15573
  updateActiveQuestion({ matrixColumns: next });
12968
15574
  },
@@ -13005,7 +15611,7 @@ const SurveyStudioModal = ({
13005
15611
  )
13006
15612
  ]
13007
15613
  },
13008
- c.id
15614
+ cIdx
13009
15615
  );
13010
15616
  })
13011
15617
  ] })
@@ -13229,25 +15835,102 @@ const SurveyStudioModal = ({
13229
15835
  /* @__PURE__ */ jsxRuntime.jsx("div", { style: { fontSize: 13, fontWeight: 700, color: "#0f172a" }, children: tr ? "Anket Kimliği & Çok Dilli Başlıklar" : "Survey Identity & Localized Titles" }),
13230
15836
  /* @__PURE__ */ jsxRuntime.jsxs("div", { style: { display: "grid", gridTemplateColumns: "1fr 1fr", gap: 10 }, children: [
13231
15837
  /* @__PURE__ */ jsxRuntime.jsxs("div", { children: [
13232
- /* @__PURE__ */ jsxRuntime.jsx("label", { style: labelStyle, children: tr ? "Yönetim Başlığı" : "Internal Title" }),
15838
+ /* @__PURE__ */ jsxRuntime.jsx("label", { style: labelStyle, children: tr ? "Yönetim Başlığı (Internal Title)" : "Survey Internal Title" }),
13233
15839
  /* @__PURE__ */ jsxRuntime.jsx(
13234
15840
  "input",
13235
15841
  {
13236
15842
  type: "text",
13237
15843
  value: draft.title,
13238
- onChange: (e) => setDraft({ ...draft, title: e.target.value }),
15844
+ onChange: (e) => {
15845
+ const nextTitle = e.target.value;
15846
+ setDraft((prev) => ({
15847
+ ...prev,
15848
+ title: nextTitle,
15849
+ ...slugAutoSync ? { slug: slugifyKey(nextTitle) } : {}
15850
+ }));
15851
+ },
15852
+ placeholder: tr ? "Örn: 2026 Müşteri Nabzı Anketi" : "e.g. 2026 Customer Pulse Survey",
13239
15853
  style: inputStyle
13240
15854
  }
13241
15855
  )
13242
15856
  ] }),
13243
15857
  /* @__PURE__ */ jsxRuntime.jsxs("div", { children: [
13244
- /* @__PURE__ */ jsxRuntime.jsx("label", { style: labelStyle, children: "Survey Slug" }),
15858
+ /* @__PURE__ */ jsxRuntime.jsxs(
15859
+ "div",
15860
+ {
15861
+ style: {
15862
+ display: "flex",
15863
+ alignItems: "center",
15864
+ justifyContent: "space-between",
15865
+ gap: 6,
15866
+ marginBottom: 4
15867
+ },
15868
+ children: [
15869
+ /* @__PURE__ */ jsxRuntime.jsxs("label", { style: { ...labelStyle, marginBottom: 0 }, children: [
15870
+ "Survey Slug",
15871
+ " ",
15872
+ /* @__PURE__ */ jsxRuntime.jsx(
15873
+ "span",
15874
+ {
15875
+ style: {
15876
+ fontSize: 9.5,
15877
+ fontWeight: 700,
15878
+ padding: "1px 6px",
15879
+ borderRadius: 8,
15880
+ marginLeft: 4,
15881
+ background: slugAutoSync ? "#dbeafe" : "#f1f5f9",
15882
+ color: slugAutoSync ? "#1e40af" : "#475569"
15883
+ },
15884
+ children: slugAutoSync ? tr ? "Otomatik" : "Auto" : tr ? "Özel" : "Custom"
15885
+ }
15886
+ )
15887
+ ] }),
15888
+ /* @__PURE__ */ jsxRuntime.jsx(
15889
+ "button",
15890
+ {
15891
+ type: "button",
15892
+ onClick: () => {
15893
+ const generated = slugifyKey(draft.title);
15894
+ setDraft((prev) => ({
15895
+ ...prev,
15896
+ slug: generated || prev.slug
15897
+ }));
15898
+ setSlugAutoSync(true);
15899
+ },
15900
+ title: tr ? "Yönetim Başlığından (Internal Title) otomatik slug üret ve senkronla" : "Generate slug from Internal Title and keep synced",
15901
+ style: {
15902
+ padding: "1px 7px",
15903
+ borderRadius: 5,
15904
+ border: "1px solid #93c5fd",
15905
+ background: "#eff6ff",
15906
+ color: "#1d4ed8",
15907
+ fontSize: 10,
15908
+ fontWeight: 700,
15909
+ cursor: "pointer"
15910
+ },
15911
+ children: tr ? "↻ Başlıktan Üret" : "↻ From Title"
15912
+ }
15913
+ )
15914
+ ]
15915
+ }
15916
+ ),
13245
15917
  /* @__PURE__ */ jsxRuntime.jsx(
13246
15918
  "input",
13247
15919
  {
13248
15920
  type: "text",
13249
15921
  value: draft.slug,
13250
- onChange: (e) => setDraft({ ...draft, slug: slugifyKey(e.target.value) }),
15922
+ onChange: (e) => {
15923
+ setSlugAutoSync(false);
15924
+ setDraft((prev) => ({
15925
+ ...prev,
15926
+ slug: sanitizeSlugInput(e.target.value)
15927
+ }));
15928
+ },
15929
+ onBlur: (e) => {
15930
+ const cleaned = slugifyKey(e.target.value) || slugifyKey(draft.title) || `survey-${Date.now().toString(36).slice(-4)}`;
15931
+ setDraft((prev) => ({ ...prev, slug: cleaned }));
15932
+ },
15933
+ placeholder: "ornek-anket_2026",
13251
15934
  style: { ...inputStyle, fontFamily: "monospace" }
13252
15935
  }
13253
15936
  )
@@ -13544,7 +16227,72 @@ const SurveyStudioModal = ({
13544
16227
  strapiLocales
13545
16228
  }
13546
16229
  ),
13547
- tab === "analytics" && /* @__PURE__ */ jsxRuntime.jsx("div", { style: { flex: 1, padding: 20, overflowY: "auto", background: "#f8fafc" }, children: /* @__PURE__ */ jsxRuntime.jsx(SurveyAnalyticsView, { surveySlugOrId: draft.slug, uiLocale }) })
16230
+ tab === "analytics" && /* @__PURE__ */ jsxRuntime.jsx("div", { style: { flex: 1, padding: 20, overflowY: "auto", background: "#f8fafc" }, children: /* @__PURE__ */ jsxRuntime.jsx(
16231
+ SurveyAnalyticsView,
16232
+ {
16233
+ surveySlugOrId: draft.slug,
16234
+ uiLocale
16235
+ },
16236
+ `${draft.slug}-${studioAnalyticsKey}`
16237
+ ) }),
16238
+ /* @__PURE__ */ jsxRuntime.jsx(
16239
+ SurveyExportModal,
16240
+ {
16241
+ open: studioExportOpen,
16242
+ uiLocale,
16243
+ targetSurvey: draft,
16244
+ allowAllSurveys: false,
16245
+ isUnsavedDraft: !draft.id && !draft.documentId && !draft._id,
16246
+ onClose: () => setStudioExportOpen(false)
16247
+ }
16248
+ ),
16249
+ /* @__PURE__ */ jsxRuntime.jsx(
16250
+ SurveyImportModal,
16251
+ {
16252
+ open: studioImportOpen,
16253
+ uiLocale,
16254
+ existingSlugs: draft.slug ? [draft.slug] : [],
16255
+ onClose: () => setStudioImportOpen(false),
16256
+ onImported: (res) => {
16257
+ const first = res.importedSurveys?.[0];
16258
+ if (first) {
16259
+ const nextDraft = first.displayMode === "multi_step" ? normalizeMultiStepDraft(JSON.parse(JSON.stringify(first))) : JSON.parse(JSON.stringify(first));
16260
+ setDraft(nextDraft);
16261
+ setSelectedQuestionIdx(0);
16262
+ setActiveStepId(nextDraft.steps?.[0]?.id || "step_1");
16263
+ setStudioAnalyticsKey((k) => k + 1);
16264
+ setStatusMsg(
16265
+ tr ? `İçe aktarıldı (${res.importedResponsesCount} yanıt)!` : `Imported (${res.importedResponsesCount} responses)!`
16266
+ );
16267
+ if (typeof window !== "undefined") {
16268
+ window.dispatchEvent(new CustomEvent("ci-survey-updated", { detail: first }));
16269
+ }
16270
+ onSaved?.(first);
16271
+ }
16272
+ }
16273
+ }
16274
+ ),
16275
+ /* @__PURE__ */ jsxRuntime.jsx(
16276
+ SurveyCleanupConfirmModal,
16277
+ {
16278
+ open: Boolean(studioCleanupAction),
16279
+ action: studioCleanupAction,
16280
+ uiLocale,
16281
+ targetSurvey: draft,
16282
+ onClose: () => setStudioCleanupAction(null),
16283
+ onCompleted: (act, payload) => {
16284
+ if (act === "clear-responses") {
16285
+ const updatedDraft = { ...draft, responseCount: 0, npsScore: null };
16286
+ setDraft(updatedDraft);
16287
+ setStudioAnalyticsKey((k) => k + 1);
16288
+ setStatusMsg(
16289
+ tr ? `${payload?.deletedCount || 0} yanıt sıfırlandı.` : `Cleared ${payload?.deletedCount || 0} response(s).`
16290
+ );
16291
+ onSaved?.(updatedDraft);
16292
+ }
16293
+ }
16294
+ }
16295
+ )
13548
16296
  ]
13549
16297
  }
13550
16298
  )
@@ -13605,13 +16353,13 @@ const SurveyWidgetEditor = ({ widget, onChange }) => {
13605
16353
  /* @__PURE__ */ jsxRuntime.jsx(
13606
16354
  "select",
13607
16355
  {
13608
- value: matchedSurvey?.slug || selectedRef,
16356
+ value: matchedSurvey?.slug || (surveysList.length > 0 ? selectedRef : ""),
13609
16357
  onChange: (e) => {
13610
16358
  const chosen = surveysList.find((s) => s.slug === e.target.value);
13611
16359
  if (chosen) bindSurveyToWidget(chosen);
13612
16360
  },
13613
16361
  style: inputStyle,
13614
- children: surveysList.map((s) => /* @__PURE__ */ jsxRuntime.jsxs("option", { value: s.slug, children: [
16362
+ children: surveysList.length === 0 ? /* @__PURE__ */ jsxRuntime.jsx("option", { value: "", children: tr ? "Henüz kayıtlı anket yok — Yeni yaratın veya JSON yükleyin" : "No surveys yet — Create new or Import JSON" }) : surveysList.map((s) => /* @__PURE__ */ jsxRuntime.jsxs("option", { value: s.slug, children: [
13615
16363
  pickTextForLocale(s.titleI18n, locale, s.title),
13616
16364
  " (",
13617
16365
  s.responseCount ?? 0,
@@ -13817,6 +16565,9 @@ exports.EditorProvider = EditorProvider;
13817
16565
  exports.ROW_PRESETS = ROW_PRESETS;
13818
16566
  exports.StrapiMediaPicker = StrapiMediaPicker;
13819
16567
  exports.SurveyAnalyticsView = SurveyAnalyticsView;
16568
+ exports.SurveyCleanupConfirmModal = SurveyCleanupConfirmModal;
16569
+ exports.SurveyExportModal = SurveyExportModal;
16570
+ exports.SurveyImportModal = SurveyImportModal;
13820
16571
  exports.SurveyStudioModal = SurveyStudioModal;
13821
16572
  exports.SurveyWidgetEditor = SurveyWidgetEditor;
13822
16573
  exports.WIDGET_CATEGORIES = WIDGET_CATEGORIES;