import {
  ExperimentsTable
} from "/build/_shared/chunk-EWUZNH5A.js";
import {
  RSHTheme,
  prism_async_default
} from "/build/_shared/chunk-VUTUXWPD.js";
import {
  PrettyJson
} from "/build/_shared/chunk-2LVPY4YG.js";
import "/build/_shared/chunk-5DGBJUUY.js";
import {
  flexRender,
  getCoreRowModel,
  getFilteredRowModel,
  getPaginationRowModel,
  getSortedRowModel,
  useReactTable
} from "/build/_shared/chunk-BE5T5FJF.js";
import {
  Pagination
} from "/build/_shared/chunk-66K6NTQO.js";
import {
  PageDocLink
} from "/build/_shared/chunk-T75MUU5G.js";
import {
  Dialog,
  DialogClose,
  DialogContent,
  DialogFooter,
  DialogHeader,
  DialogTitle,
  DialogTrigger
} from "/build/_shared/chunk-WUQHNDXA.js";
import "/build/_shared/chunk-SC7ILUKJ.js";
import {
  DropdownMenu,
  DropdownMenuContent,
  DropdownMenuItem,
  DropdownMenuTrigger
} from "/build/_shared/chunk-BWG25Z4X.js";
import "/build/_shared/chunk-JZ6W5YHO.js";
import {
  require_lodash
} from "/build/_shared/chunk-O67VWZBP.js";
import {
  Label
} from "/build/_shared/chunk-Z3FLWRAR.js";
import {
  Button
} from "/build/_shared/chunk-UWBTKPLD.js";
import "/build/_shared/chunk-SMFRBP2T.js";
import {
  Select,
  SelectContent,
  SelectItem,
  SelectTrigger,
  SelectValue
} from "/build/_shared/chunk-KORRUOSI.js";
import "/build/_shared/chunk-5HIGY2MY.js";
import "/build/_shared/chunk-7FHGZRTC.js";
import {
  Badge,
  idShortener
} from "/build/_shared/chunk-634BMO4L.js";
import {
  require_dayjs_min
} from "/build/_shared/chunk-HUUSILLY.js";
import {
  PageSubtitle
} from "/build/_shared/chunk-VV3RU6RL.js";
import "/build/_shared/chunk-VO5VXZGS.js";
import "/build/_shared/chunk-4R7ODGQQ.js";
import "/build/_shared/chunk-A4I3UNHM.js";
import "/build/_shared/chunk-ERWYPUCA.js";
import {
  Table,
  TableBody,
  TableCell,
  TableHead,
  TableHeader,
  TableRow
} from "/build/_shared/chunk-P3C75TI5.js";
import {
  PageLayout
} from "/build/_shared/chunk-BXT5AGPN.js";
import "/build/_shared/chunk-5YPGPC4O.js";
import "/build/_shared/chunk-7K73PJIB.js";
import {
  CircleDotDashed,
  Clipboard,
  ClipboardCheck,
  Database,
  Download,
  FlaskConical,
  SlidersHorizontal,
  Trash
} from "/build/_shared/chunk-EJE2TVVM.js";
import {
  DotsHorizontalIcon
} from "/build/_shared/chunk-LGQ4GCFK.js";
import {
  useCopyToClipboard
} from "/build/_shared/chunk-B7TG3BDD.js";
import "/build/_shared/chunk-7NMI3PDC.js";
import "/build/_shared/chunk-AI5FD5Y6.js";
import {
  withAuth
} from "/build/_shared/chunk-NHF4CNMF.js";
import {
  require_dist
} from "/build/_shared/chunk-KQKP3VNY.js";
import {
  init_esm2 as init_esm,
  useFetcher,
  useLoaderData,
  useMatches,
  useNavigate,
  useParams
} from "/build/_shared/chunk-ZC2TL3GZ.js";
import {
  require_jsx_dev_runtime
} from "/build/_shared/chunk-ED7KKCRB.js";
import "/build/_shared/chunk-RYE6BCZB.js";
import {
  require_react
} from "/build/_shared/chunk-PECDPABK.js";
import {
  require_node
} from "/build/_shared/chunk-G7CHZRZX.js";
import "/build/_shared/chunk-TLLKLDIT.js";
import {
  Routes
} from "/build/_shared/chunk-N27UEDHN.js";
import {
  createHotContext,
  init_remix_hmr
} from "/build/_shared/chunk-G7KTOMTD.js";
import "/build/_shared/chunk-ZIPKILLR.js";
import {
  __toESM
} from "/build/_shared/chunk-PNG5AS42.js";

// app/routes/app+/project+/$projectId+/env+/$envId+/datasets+/$datasetId+/index.tsx
init_remix_hmr();
var import_node = __toESM(require_node(), 1);
init_esm();
var import_dayjs2 = __toESM(require_dayjs_min(), 1);

// app/pages/datasets/dataset/DatasetIdPage.tsx
init_remix_hmr();
init_esm();

// app/pages/datasets/dataset/DatapointsTable.tsx
init_remix_hmr();
init_esm();
var import_lodash = __toESM(require_lodash(), 1);
var import_jsx_dev_runtime = __toESM(require_jsx_dev_runtime(), 1);
if (!window.$RefreshReg$ || !window.$RefreshSig$ || !window.$RefreshRuntime$) {
  console.warn("remix:hmr: React Fast Refresh only works when the Remix compiler is running in development mode.");
} else {
  prevRefreshReg = window.$RefreshReg$;
  prevRefreshSig = window.$RefreshSig$;
  window.$RefreshReg$ = (type, id) => {
    window.$RefreshRuntime$.register(type, '"app/pages/datasets/dataset/DatapointsTable.tsx"' + id);
  };
  window.$RefreshSig$ = window.$RefreshRuntime$.createSignatureFunctionForTransform;
}
var prevRefreshReg;
var prevRefreshSig;
var _s = $RefreshSig$();
var _s2 = $RefreshSig$();
if (import.meta) {
  import.meta.hot = createHotContext(
    //@ts-expect-error
    "app/pages/datasets/dataset/DatapointsTable.tsx"
  );
  import.meta.hot.lastModified = "1713199469912.8271";
}
var columns = [{
  accessorKey: "id",
  header: "ID",
  cell: ({
    row
  }) => {
    const id = row.getValue("id");
    const {
      short,
      variant
    } = idShortener(id);
    return /* @__PURE__ */ (0, import_jsx_dev_runtime.jsxDEV)("div", { className: "max-w-8", children: /* @__PURE__ */ (0, import_jsx_dev_runtime.jsxDEV)(Badge, { variant, children: short }, void 0, false, {
      fileName: "app/pages/datasets/dataset/DatapointsTable.tsx",
      lineNumber: 50,
      columnNumber: 11
    }, this) }, void 0, false, {
      fileName: "app/pages/datasets/dataset/DatapointsTable.tsx",
      lineNumber: 49,
      columnNumber: 12
    }, this);
  }
}, {
  accessorKey: "input",
  header: "Input",
  cell: ({
    row
  }) => {
    const val = row.getValue("input");
    return /* @__PURE__ */ (0, import_jsx_dev_runtime.jsxDEV)(PrettyJson, { data: val }, void 0, false, {
      fileName: "app/pages/datasets/dataset/DatapointsTable.tsx",
      lineNumber: 60,
      columnNumber: 12
    }, this);
  }
}, {
  accessorKey: "expectedOutput",
  header: "Expected Output",
  cell: ({
    row
  }) => {
    const val = row.getValue("expectedOutput");
    return /* @__PURE__ */ (0, import_jsx_dev_runtime.jsxDEV)(PrettyJson, { data: val }, void 0, false, {
      fileName: "app/pages/datasets/dataset/DatapointsTable.tsx",
      lineNumber: 69,
      columnNumber: 12
    }, this);
  }
}, {
  accessorKey: "split",
  header: "Split",
  cell: ({
    row
  }) => {
    const val = row.getValue("split");
    return /* @__PURE__ */ (0, import_jsx_dev_runtime.jsxDEV)("p", { children: val ? import_lodash.default.capitalize(val) : "\u2014" }, void 0, false, {
      fileName: "app/pages/datasets/dataset/DatapointsTable.tsx",
      lineNumber: 78,
      columnNumber: 12
    }, this);
  }
}, {
  id: "actions",
  cell: _s(({
    row
  }) => {
    _s();
    const params = useParams();
    const fetcher = useFetcher();
    const {
      id: datapointId
    } = row.original;
    const handleDeleteDatapoint = () => {
      fetcher.submit(null, {
        method: "DELETE",
        action: Routes.actions.datapoints.delete({
          projectId: params.projectId,
          datapointId
        })
      });
    };
    return /* @__PURE__ */ (0, import_jsx_dev_runtime.jsxDEV)(DropdownMenu, { children: [
      /* @__PURE__ */ (0, import_jsx_dev_runtime.jsxDEV)(DropdownMenuTrigger, { asChild: true, children: /* @__PURE__ */ (0, import_jsx_dev_runtime.jsxDEV)(Button, { variant: "ghost", className: "h-8 w-8 p-0", children: [
        /* @__PURE__ */ (0, import_jsx_dev_runtime.jsxDEV)("span", { className: "sr-only", children: "Open menu" }, void 0, false, {
          fileName: "app/pages/datasets/dataset/DatapointsTable.tsx",
          lineNumber: 103,
          columnNumber: 15
        }, this),
        /* @__PURE__ */ (0, import_jsx_dev_runtime.jsxDEV)(DotsHorizontalIcon, { className: "h-4 w-4" }, void 0, false, {
          fileName: "app/pages/datasets/dataset/DatapointsTable.tsx",
          lineNumber: 104,
          columnNumber: 15
        }, this)
      ] }, void 0, true, {
        fileName: "app/pages/datasets/dataset/DatapointsTable.tsx",
        lineNumber: 102,
        columnNumber: 13
      }, this) }, void 0, false, {
        fileName: "app/pages/datasets/dataset/DatapointsTable.tsx",
        lineNumber: 101,
        columnNumber: 11
      }, this),
      /* @__PURE__ */ (0, import_jsx_dev_runtime.jsxDEV)(DropdownMenuContent, { align: "end", children: /* @__PURE__ */ (0, import_jsx_dev_runtime.jsxDEV)(DropdownMenuItem, { className: "text-destructive gap-2", onClick: handleDeleteDatapoint, children: [
        /* @__PURE__ */ (0, import_jsx_dev_runtime.jsxDEV)(Trash, { size: 16 }, void 0, false, {
          fileName: "app/pages/datasets/dataset/DatapointsTable.tsx",
          lineNumber: 109,
          columnNumber: 15
        }, this),
        " Delete"
      ] }, void 0, true, {
        fileName: "app/pages/datasets/dataset/DatapointsTable.tsx",
        lineNumber: 108,
        columnNumber: 13
      }, this) }, void 0, false, {
        fileName: "app/pages/datasets/dataset/DatapointsTable.tsx",
        lineNumber: 107,
        columnNumber: 11
      }, this)
    ] }, void 0, true, {
      fileName: "app/pages/datasets/dataset/DatapointsTable.tsx",
      lineNumber: 100,
      columnNumber: 12
    }, this);
  }, "RvKeqhn+XOGsSHwDFTx5Hb6Xjts=", false, function() {
    return [useParams, useFetcher];
  })
}];
var DatapointsTable = ({
  datapoints,
  currentPage,
  totalPages,
  totalCount
}) => {
  _s2();
  const table = useReactTable({
    data: datapoints,
    columns,
    manualPagination: true,
    getCoreRowModel: getCoreRowModel(),
    getPaginationRowModel: getPaginationRowModel(),
    getSortedRowModel: getSortedRowModel(),
    getFilteredRowModel: getFilteredRowModel()
  });
  return /* @__PURE__ */ (0, import_jsx_dev_runtime.jsxDEV)("div", { className: "w-full", children: [
    /* @__PURE__ */ (0, import_jsx_dev_runtime.jsxDEV)("p", { className: "flex items-center gap-2 text-xl font-semibold", children: [
      /* @__PURE__ */ (0, import_jsx_dev_runtime.jsxDEV)(CircleDotDashed, { size: 20 }, void 0, false, {
        fileName: "app/pages/datasets/dataset/DatapointsTable.tsx",
        lineNumber: 135,
        columnNumber: 9
      }, this),
      "Datapoints"
    ] }, void 0, true, {
      fileName: "app/pages/datasets/dataset/DatapointsTable.tsx",
      lineNumber: 134,
      columnNumber: 7
    }, this),
    /* @__PURE__ */ (0, import_jsx_dev_runtime.jsxDEV)("p", { className: "text-muted-foreground", children: [
      "Each datapoint is a single input and expected output pair.",
      " ",
      /* @__PURE__ */ (0, import_jsx_dev_runtime.jsxDEV)(PageDocLink, { to: Routes.external.docs.datapoints, children: "Datapoints Docs." }, void 0, false, {
        fileName: "app/pages/datasets/dataset/DatapointsTable.tsx",
        lineNumber: 140,
        columnNumber: 9
      }, this)
    ] }, void 0, true, {
      fileName: "app/pages/datasets/dataset/DatapointsTable.tsx",
      lineNumber: 138,
      columnNumber: 7
    }, this),
    /* @__PURE__ */ (0, import_jsx_dev_runtime.jsxDEV)("p", { className: "text-muted-foreground mb-4", children: [
      totalCount,
      " datapoints."
    ] }, void 0, true, {
      fileName: "app/pages/datasets/dataset/DatapointsTable.tsx",
      lineNumber: 142,
      columnNumber: 7
    }, this),
    /* @__PURE__ */ (0, import_jsx_dev_runtime.jsxDEV)("div", { className: "mb-2 rounded-md border", children: /* @__PURE__ */ (0, import_jsx_dev_runtime.jsxDEV)(Table, { children: [
      /* @__PURE__ */ (0, import_jsx_dev_runtime.jsxDEV)(TableHeader, { children: table.getHeaderGroups().map((headerGroup) => /* @__PURE__ */ (0, import_jsx_dev_runtime.jsxDEV)(TableRow, { children: headerGroup.headers.map((header) => {
        return /* @__PURE__ */ (0, import_jsx_dev_runtime.jsxDEV)(TableHead, { children: header.isPlaceholder ? null : flexRender(header.column.columnDef.header, header.getContext()) }, header.id, false, {
          fileName: "app/pages/datasets/dataset/DatapointsTable.tsx",
          lineNumber: 149,
          columnNumber: 22
        }, this);
      }) }, headerGroup.id, false, {
        fileName: "app/pages/datasets/dataset/DatapointsTable.tsx",
        lineNumber: 147,
        columnNumber: 57
      }, this)) }, void 0, false, {
        fileName: "app/pages/datasets/dataset/DatapointsTable.tsx",
        lineNumber: 146,
        columnNumber: 11
      }, this),
      /* @__PURE__ */ (0, import_jsx_dev_runtime.jsxDEV)(TableBody, { children: table.getRowModel().rows?.length ? table.getRowModel().rows.map((row) => /* @__PURE__ */ (0, import_jsx_dev_runtime.jsxDEV)(TableRow, { "data-state": row.getIsSelected() && "selected", children: row.getVisibleCells().map((cell) => /* @__PURE__ */ (0, import_jsx_dev_runtime.jsxDEV)(TableCell, { children: flexRender(cell.column.columnDef.cell, cell.getContext()) }, cell.id, false, {
        fileName: "app/pages/datasets/dataset/DatapointsTable.tsx",
        lineNumber: 157,
        columnNumber: 54
      }, this)) }, row.id, false, {
        fileName: "app/pages/datasets/dataset/DatapointsTable.tsx",
        lineNumber: 156,
        columnNumber: 85
      }, this)) : /* @__PURE__ */ (0, import_jsx_dev_runtime.jsxDEV)(TableRow, { children: /* @__PURE__ */ (0, import_jsx_dev_runtime.jsxDEV)(TableCell, { colSpan: columns.length, className: "h-24 text-center", children: "No data points." }, void 0, false, {
        fileName: "app/pages/datasets/dataset/DatapointsTable.tsx",
        lineNumber: 159,
        columnNumber: 17
      }, this) }, void 0, false, {
        fileName: "app/pages/datasets/dataset/DatapointsTable.tsx",
        lineNumber: 158,
        columnNumber: 32
      }, this) }, void 0, false, {
        fileName: "app/pages/datasets/dataset/DatapointsTable.tsx",
        lineNumber: 155,
        columnNumber: 11
      }, this)
    ] }, void 0, true, {
      fileName: "app/pages/datasets/dataset/DatapointsTable.tsx",
      lineNumber: 145,
      columnNumber: 9
    }, this) }, void 0, false, {
      fileName: "app/pages/datasets/dataset/DatapointsTable.tsx",
      lineNumber: 144,
      columnNumber: 7
    }, this),
    /* @__PURE__ */ (0, import_jsx_dev_runtime.jsxDEV)("div", { className: "mb-2 flex items-center justify-end", children: /* @__PURE__ */ (0, import_jsx_dev_runtime.jsxDEV)("div", { className: "space-x-2", children: /* @__PURE__ */ (0, import_jsx_dev_runtime.jsxDEV)(Pagination, { currentPage, totalPages }, void 0, false, {
      fileName: "app/pages/datasets/dataset/DatapointsTable.tsx",
      lineNumber: 169,
      columnNumber: 11
    }, this) }, void 0, false, {
      fileName: "app/pages/datasets/dataset/DatapointsTable.tsx",
      lineNumber: 168,
      columnNumber: 9
    }, this) }, void 0, false, {
      fileName: "app/pages/datasets/dataset/DatapointsTable.tsx",
      lineNumber: 167,
      columnNumber: 7
    }, this)
  ] }, void 0, true, {
    fileName: "app/pages/datasets/dataset/DatapointsTable.tsx",
    lineNumber: 133,
    columnNumber: 10
  }, this);
};
_s2(DatapointsTable, "+qfJc9U8evODZQ8bBg9G2KVouAc=", false, function() {
  return [useReactTable];
});
_c = DatapointsTable;
var _c;
$RefreshReg$(_c, "DatapointsTable");
window.$RefreshReg$ = prevRefreshReg;
window.$RefreshSig$ = prevRefreshSig;

// app/pages/datasets/dataset/DatasetSchemaDialog.tsx
init_remix_hmr();
var import_jsx_dev_runtime2 = __toESM(require_jsx_dev_runtime(), 1);
if (!window.$RefreshReg$ || !window.$RefreshSig$ || !window.$RefreshRuntime$) {
  console.warn("remix:hmr: React Fast Refresh only works when the Remix compiler is running in development mode.");
} else {
  prevRefreshReg = window.$RefreshReg$;
  prevRefreshSig = window.$RefreshSig$;
  window.$RefreshReg$ = (type, id) => {
    window.$RefreshRuntime$.register(type, '"app/pages/datasets/dataset/DatasetSchemaDialog.tsx"' + id);
  };
  window.$RefreshSig$ = window.$RefreshRuntime$.createSignatureFunctionForTransform;
}
var prevRefreshReg;
var prevRefreshSig;
var _s3 = $RefreshSig$();
if (import.meta) {
  import.meta.hot = createHotContext(
    //@ts-expect-error
    "app/pages/datasets/dataset/DatasetSchemaDialog.tsx"
  );
  import.meta.hot.lastModified = "1713199469913.1165";
}
var DatasetSchemaDialog = ({
  isPrimary,
  slug,
  inputSchema,
  outputSchema
}) => {
  _s3();
  const [copied, copyToClipboard] = useCopyToClipboard();
  const generateTypeDefinition = (obj, varName) => {
    const entries = Object.entries(obj);
    const typeProperties = entries.map(([key, value]) => {
      let tsType;
      switch (value) {
        case "string":
          tsType = "string";
          break;
        case "number":
          tsType = "number";
          break;
        case "boolean":
          tsType = "boolean";
          break;
        case "object":
          tsType = "Record<string, any>";
          break;
        case "array":
          tsType = "any[]";
          break;
        default:
          tsType = "any";
      }
      return `${key}: ${tsType};`;
    });
    return `export type ${varName} = {
  ${typeProperties.join("\n  ")}
};`;
  };
  const sampleCode = `
const localDataset: Array<{ input: DatasetInput; expectedOutput: DatasetOutput }> = [...];  

for (const { input, expectedOutput } of localDataset) {
  await montelo.datapoints.create({
    dataset: "${slug}",
    input,
    expectedOutput,
  });
}

await montelo.experiments.createAndRun({
  name: "Experiment Name",
  description: "Experiment Description",
  dataset: "${slug}",
  runner: (input: DatasetInput) => DatasetOutput,
});
  `;
  const inputTypeDefinition = generateTypeDefinition(inputSchema, "DatesetInput");
  const outputTypeDefinition = generateTypeDefinition(outputSchema, "DatesetOutput");
  const combinedTypeDefinition = `${inputTypeDefinition}

${outputTypeDefinition}

${sampleCode}`;
  const isCopied = copied.value === combinedTypeDefinition;
  const Icon = isCopied ? ClipboardCheck : Clipboard;
  return /* @__PURE__ */ (0, import_jsx_dev_runtime2.jsxDEV)(Dialog, { children: [
    /* @__PURE__ */ (0, import_jsx_dev_runtime2.jsxDEV)(DialogTrigger, { asChild: true, children: /* @__PURE__ */ (0, import_jsx_dev_runtime2.jsxDEV)(Button, { variant: isPrimary ? "default" : "secondary", children: "View Code" }, void 0, false, {
      fileName: "app/pages/datasets/dataset/DatasetSchemaDialog.tsx",
      lineNumber: 88,
      columnNumber: 9
    }, this) }, void 0, false, {
      fileName: "app/pages/datasets/dataset/DatasetSchemaDialog.tsx",
      lineNumber: 87,
      columnNumber: 7
    }, this),
    /* @__PURE__ */ (0, import_jsx_dev_runtime2.jsxDEV)(DialogContent, { className: "max-h-[750px] max-w-[56rem] overflow-y-scroll", children: [
      /* @__PURE__ */ (0, import_jsx_dev_runtime2.jsxDEV)(DialogHeader, { children: /* @__PURE__ */ (0, import_jsx_dev_runtime2.jsxDEV)(DialogTitle, { children: "Dataset Schemas" }, void 0, false, {
        fileName: "app/pages/datasets/dataset/DatasetSchemaDialog.tsx",
        lineNumber: 92,
        columnNumber: 11
      }, this) }, void 0, false, {
        fileName: "app/pages/datasets/dataset/DatasetSchemaDialog.tsx",
        lineNumber: 91,
        columnNumber: 9
      }, this),
      /* @__PURE__ */ (0, import_jsx_dev_runtime2.jsxDEV)("div", { className: "flex flex-col gap-8", children: /* @__PURE__ */ (0, import_jsx_dev_runtime2.jsxDEV)("div", { className: "flex flex-col gap-2", children: [
        /* @__PURE__ */ (0, import_jsx_dev_runtime2.jsxDEV)("p", { className: "text-lg font-medium", children: "TypeScript Code" }, void 0, false, {
          fileName: "app/pages/datasets/dataset/DatasetSchemaDialog.tsx",
          lineNumber: 106,
          columnNumber: 13
        }, this),
        /* @__PURE__ */ (0, import_jsx_dev_runtime2.jsxDEV)("p", { children: "Copy the following TypeScript code to upload datapoints and run experiments against this dataset." }, void 0, false, {
          fileName: "app/pages/datasets/dataset/DatasetSchemaDialog.tsx",
          lineNumber: 107,
          columnNumber: 13
        }, this),
        /* @__PURE__ */ (0, import_jsx_dev_runtime2.jsxDEV)(prism_async_default, { style: RSHTheme, language: "typescript", children: combinedTypeDefinition }, void 0, false, {
          fileName: "app/pages/datasets/dataset/DatasetSchemaDialog.tsx",
          lineNumber: 108,
          columnNumber: 13
        }, this),
        /* @__PURE__ */ (0, import_jsx_dev_runtime2.jsxDEV)(Icon, { className: "text-muted-foreground hover:text-foreground fixed right-1 mr-7 mt-20 cursor-pointer", onClick: () => {
          copyToClipboard(combinedTypeDefinition);
        } }, void 0, false, {
          fileName: "app/pages/datasets/dataset/DatasetSchemaDialog.tsx",
          lineNumber: 111,
          columnNumber: 13
        }, this)
      ] }, void 0, true, {
        fileName: "app/pages/datasets/dataset/DatasetSchemaDialog.tsx",
        lineNumber: 105,
        columnNumber: 11
      }, this) }, void 0, false, {
        fileName: "app/pages/datasets/dataset/DatasetSchemaDialog.tsx",
        lineNumber: 94,
        columnNumber: 9
      }, this)
    ] }, void 0, true, {
      fileName: "app/pages/datasets/dataset/DatasetSchemaDialog.tsx",
      lineNumber: 90,
      columnNumber: 7
    }, this)
  ] }, void 0, true, {
    fileName: "app/pages/datasets/dataset/DatasetSchemaDialog.tsx",
    lineNumber: 86,
    columnNumber: 10
  }, this);
};
_s3(DatasetSchemaDialog, "xe37LXpC6NbqLMDO4XOsBHzFJ3s=", false, function() {
  return [useCopyToClipboard];
});
_c2 = DatasetSchemaDialog;
var _c2;
$RefreshReg$(_c2, "DatasetSchemaDialog");
window.$RefreshReg$ = prevRefreshReg;
window.$RefreshSig$ = prevRefreshSig;

// app/pages/datasets/dataset/FineTuneDialog.tsx
init_remix_hmr();
var import_browser_client = __toESM(require_dist(), 1);
init_esm();
var import_react3 = __toESM(require_react(), 1);
var import_jsx_dev_runtime3 = __toESM(require_jsx_dev_runtime(), 1);
if (!window.$RefreshReg$ || !window.$RefreshSig$ || !window.$RefreshRuntime$) {
  console.warn("remix:hmr: React Fast Refresh only works when the Remix compiler is running in development mode.");
} else {
  prevRefreshReg = window.$RefreshReg$;
  prevRefreshSig = window.$RefreshSig$;
  window.$RefreshReg$ = (type, id) => {
    window.$RefreshRuntime$.register(type, '"app/pages/datasets/dataset/FineTuneDialog.tsx"' + id);
  };
  window.$RefreshSig$ = window.$RefreshRuntime$.createSignatureFunctionForTransform;
}
var prevRefreshReg;
var prevRefreshSig;
var _s4 = $RefreshSig$();
if (import.meta) {
  import.meta.hot = createHotContext(
    //@ts-expect-error
    "app/pages/datasets/dataset/FineTuneDialog.tsx"
  );
  import.meta.hot.lastModified = "1713199469913.193";
}
var FineTuneDialog = ({
  isDialogDisabled
}) => {
  _s4();
  const matches = useMatches();
  const params = useParams();
  const fetcher = useFetcher();
  const navigate = useNavigate();
  const [selectedModel, setSelectedModel] = (0, import_react3.useState)(null);
  const [isDialogOpen, setIsDialogOpen] = (0, import_react3.useState)(false);
  const projectOpenAIKey = matches.find((match) => match.id === "routes/app+/project+/$projectId+/env+/$envId+/_layout").data.project.openaiApiKey;
  const noApiKey = !projectOpenAIKey.length;
  const isNotIdle = fetcher.state !== "idle";
  const isCancelDisabled = isNotIdle;
  const isStartDisabled = isNotIdle || noApiKey || !selectedModel;
  const handleStartFineTune = () => {
    if (!selectedModel || isNotIdle) {
      return;
    }
    fetcher.submit({
      model: selectedModel
    }, {
      method: "POST",
      action: Routes.actions.finetuning.create({
        projectId: params.projectId,
        datasetId: params.datasetId
      }),
      encType: "application/json"
    });
  };
  const handleSelect = (value) => {
    setSelectedModel(value);
  };
  (0, import_react3.useEffect)(() => {
    if (fetcher.data?.finetune.id) {
      setIsDialogOpen(false);
      void navigate(Routes.app.project.env.finetuning({
        projectId: params.projectId,
        envId: params.envId
      }));
    }
  }, [fetcher.data]);
  return /* @__PURE__ */ (0, import_jsx_dev_runtime3.jsxDEV)(Dialog, { open: isDialogOpen, onOpenChange: setIsDialogOpen, children: [
    /* @__PURE__ */ (0, import_jsx_dev_runtime3.jsxDEV)(DialogTrigger, { asChild: true, children: /* @__PURE__ */ (0, import_jsx_dev_runtime3.jsxDEV)(Button, { disabled: isDialogDisabled, children: [
      /* @__PURE__ */ (0, import_jsx_dev_runtime3.jsxDEV)(SlidersHorizontal, { className: "mr-2 h-4 w-4" }, void 0, false, {
        fileName: "app/pages/datasets/dataset/FineTuneDialog.tsx",
        lineNumber: 76,
        columnNumber: 11
      }, this),
      " Fine-Tune"
    ] }, void 0, true, {
      fileName: "app/pages/datasets/dataset/FineTuneDialog.tsx",
      lineNumber: 75,
      columnNumber: 9
    }, this) }, void 0, false, {
      fileName: "app/pages/datasets/dataset/FineTuneDialog.tsx",
      lineNumber: 74,
      columnNumber: 7
    }, this),
    /* @__PURE__ */ (0, import_jsx_dev_runtime3.jsxDEV)(DialogContent, { className: "max-h-[500px] overflow-y-scroll", children: [
      /* @__PURE__ */ (0, import_jsx_dev_runtime3.jsxDEV)(DialogHeader, { children: /* @__PURE__ */ (0, import_jsx_dev_runtime3.jsxDEV)(DialogTitle, { children: "Create a Fine-Tuned Model" }, void 0, false, {
        fileName: "app/pages/datasets/dataset/FineTuneDialog.tsx",
        lineNumber: 81,
        columnNumber: 11
      }, this) }, void 0, false, {
        fileName: "app/pages/datasets/dataset/FineTuneDialog.tsx",
        lineNumber: 80,
        columnNumber: 9
      }, this),
      /* @__PURE__ */ (0, import_jsx_dev_runtime3.jsxDEV)("div", { className: "flex flex-col gap-8", children: [
        noApiKey && /* @__PURE__ */ (0, import_jsx_dev_runtime3.jsxDEV)("p", { className: "text-destructive", children: "Please set an OpenAI API Key to fine-tune models." }, void 0, false, {
          fileName: "app/pages/datasets/dataset/FineTuneDialog.tsx",
          lineNumber: 84,
          columnNumber: 24
        }, this),
        /* @__PURE__ */ (0, import_jsx_dev_runtime3.jsxDEV)("div", { className: "flex flex-col gap-2", children: [
          /* @__PURE__ */ (0, import_jsx_dev_runtime3.jsxDEV)(Label, { children: "Base Model" }, void 0, false, {
            fileName: "app/pages/datasets/dataset/FineTuneDialog.tsx",
            lineNumber: 86,
            columnNumber: 13
          }, this),
          /* @__PURE__ */ (0, import_jsx_dev_runtime3.jsxDEV)(Select, { onValueChange: handleSelect, children: [
            /* @__PURE__ */ (0, import_jsx_dev_runtime3.jsxDEV)(SelectTrigger, { className: "w-1/2", children: /* @__PURE__ */ (0, import_jsx_dev_runtime3.jsxDEV)(SelectValue, { placeholder: "Select..." }, void 0, false, {
              fileName: "app/pages/datasets/dataset/FineTuneDialog.tsx",
              lineNumber: 89,
              columnNumber: 17
            }, this) }, void 0, false, {
              fileName: "app/pages/datasets/dataset/FineTuneDialog.tsx",
              lineNumber: 88,
              columnNumber: 15
            }, this),
            /* @__PURE__ */ (0, import_jsx_dev_runtime3.jsxDEV)(SelectContent, { children: Object.values(import_browser_client.FineTuneOpenaiInputModelEnum).map((model) => /* @__PURE__ */ (0, import_jsx_dev_runtime3.jsxDEV)(SelectItem, { value: model, children: model }, model, false, {
              fileName: "app/pages/datasets/dataset/FineTuneDialog.tsx",
              lineNumber: 92,
              columnNumber: 75
            }, this)) }, void 0, false, {
              fileName: "app/pages/datasets/dataset/FineTuneDialog.tsx",
              lineNumber: 91,
              columnNumber: 15
            }, this)
          ] }, void 0, true, {
            fileName: "app/pages/datasets/dataset/FineTuneDialog.tsx",
            lineNumber: 87,
            columnNumber: 13
          }, this)
        ] }, void 0, true, {
          fileName: "app/pages/datasets/dataset/FineTuneDialog.tsx",
          lineNumber: 85,
          columnNumber: 11
        }, this)
      ] }, void 0, true, {
        fileName: "app/pages/datasets/dataset/FineTuneDialog.tsx",
        lineNumber: 83,
        columnNumber: 9
      }, this),
      /* @__PURE__ */ (0, import_jsx_dev_runtime3.jsxDEV)(DialogFooter, { children: [
        /* @__PURE__ */ (0, import_jsx_dev_runtime3.jsxDEV)(DialogClose, { asChild: true, children: /* @__PURE__ */ (0, import_jsx_dev_runtime3.jsxDEV)(Button, { variant: "secondary", disabled: isCancelDisabled, children: "Cancel" }, void 0, false, {
          fileName: "app/pages/datasets/dataset/FineTuneDialog.tsx",
          lineNumber: 101,
          columnNumber: 13
        }, this) }, void 0, false, {
          fileName: "app/pages/datasets/dataset/FineTuneDialog.tsx",
          lineNumber: 100,
          columnNumber: 11
        }, this),
        /* @__PURE__ */ (0, import_jsx_dev_runtime3.jsxDEV)(Button, { onClick: handleStartFineTune, disabled: isStartDisabled, children: "Start Fine-Tune" }, void 0, false, {
          fileName: "app/pages/datasets/dataset/FineTuneDialog.tsx",
          lineNumber: 105,
          columnNumber: 11
        }, this)
      ] }, void 0, true, {
        fileName: "app/pages/datasets/dataset/FineTuneDialog.tsx",
        lineNumber: 99,
        columnNumber: 9
      }, this)
    ] }, void 0, true, {
      fileName: "app/pages/datasets/dataset/FineTuneDialog.tsx",
      lineNumber: 79,
      columnNumber: 7
    }, this)
  ] }, void 0, true, {
    fileName: "app/pages/datasets/dataset/FineTuneDialog.tsx",
    lineNumber: 73,
    columnNumber: 10
  }, this);
};
_s4(FineTuneDialog, "jYGr6+y7gnHSnUVV+pY4z77KAGo=", false, function() {
  return [useMatches, useParams, useFetcher, useNavigate];
});
_c3 = FineTuneDialog;
var _c3;
$RefreshReg$(_c3, "FineTuneDialog");
window.$RefreshReg$ = prevRefreshReg;
window.$RefreshSig$ = prevRefreshSig;

// app/pages/datasets/dataset/RecentExperimentsTable.tsx
init_remix_hmr();
var import_dayjs = __toESM(require_dayjs_min(), 1);
var import_jsx_dev_runtime4 = __toESM(require_jsx_dev_runtime(), 1);
if (!window.$RefreshReg$ || !window.$RefreshSig$ || !window.$RefreshRuntime$) {
  console.warn("remix:hmr: React Fast Refresh only works when the Remix compiler is running in development mode.");
} else {
  prevRefreshReg = window.$RefreshReg$;
  prevRefreshSig = window.$RefreshSig$;
  window.$RefreshReg$ = (type, id) => {
    window.$RefreshRuntime$.register(type, '"app/pages/datasets/dataset/RecentExperimentsTable.tsx"' + id);
  };
  window.$RefreshSig$ = window.$RefreshRuntime$.createSignatureFunctionForTransform;
}
var prevRefreshReg;
var prevRefreshSig;
if (import.meta) {
  import.meta.hot = createHotContext(
    //@ts-expect-error
    "app/pages/datasets/dataset/RecentExperimentsTable.tsx"
  );
  import.meta.hot.lastModified = "1711327267023.1663";
}
var RecentExperimentsTable = ({
  experiments
}) => {
  return /* @__PURE__ */ (0, import_jsx_dev_runtime4.jsxDEV)("div", { className: "w-full", children: [
    /* @__PURE__ */ (0, import_jsx_dev_runtime4.jsxDEV)("p", { className: "flex items-center gap-2 text-xl font-semibold", children: [
      /* @__PURE__ */ (0, import_jsx_dev_runtime4.jsxDEV)(FlaskConical, { size: 20 }, void 0, false, {
        fileName: "app/pages/datasets/dataset/RecentExperimentsTable.tsx",
        lineNumber: 75,
        columnNumber: 9
      }, this),
      "Experiments"
    ] }, void 0, true, {
      fileName: "app/pages/datasets/dataset/RecentExperimentsTable.tsx",
      lineNumber: 74,
      columnNumber: 7
    }, this),
    /* @__PURE__ */ (0, import_jsx_dev_runtime4.jsxDEV)("p", { className: "text-muted-foreground mb-4", children: [
      "Recent experiments ran against this dataset.",
      " ",
      /* @__PURE__ */ (0, import_jsx_dev_runtime4.jsxDEV)(PageDocLink, { to: Routes.external.docs.experiments, children: "Experiments Docs." }, void 0, false, {
        fileName: "app/pages/datasets/dataset/RecentExperimentsTable.tsx",
        lineNumber: 80,
        columnNumber: 9
      }, this)
    ] }, void 0, true, {
      fileName: "app/pages/datasets/dataset/RecentExperimentsTable.tsx",
      lineNumber: 78,
      columnNumber: 7
    }, this),
    /* @__PURE__ */ (0, import_jsx_dev_runtime4.jsxDEV)("div", { className: "rounded-md border", children: /* @__PURE__ */ (0, import_jsx_dev_runtime4.jsxDEV)(ExperimentsTable, { experiments }, void 0, false, {
      fileName: "app/pages/datasets/dataset/RecentExperimentsTable.tsx",
      lineNumber: 83,
      columnNumber: 9
    }, this) }, void 0, false, {
      fileName: "app/pages/datasets/dataset/RecentExperimentsTable.tsx",
      lineNumber: 82,
      columnNumber: 7
    }, this)
  ] }, void 0, true, {
    fileName: "app/pages/datasets/dataset/RecentExperimentsTable.tsx",
    lineNumber: 73,
    columnNumber: 10
  }, this);
};
_c4 = RecentExperimentsTable;
var _c4;
$RefreshReg$(_c4, "RecentExperimentsTable");
window.$RefreshReg$ = prevRefreshReg;
window.$RefreshSig$ = prevRefreshSig;

// app/pages/datasets/dataset/DatasetIdPage.tsx
var import_jsx_dev_runtime5 = __toESM(require_jsx_dev_runtime(), 1);
if (!window.$RefreshReg$ || !window.$RefreshSig$ || !window.$RefreshRuntime$) {
  console.warn("remix:hmr: React Fast Refresh only works when the Remix compiler is running in development mode.");
} else {
  prevRefreshReg = window.$RefreshReg$;
  prevRefreshSig = window.$RefreshSig$;
  window.$RefreshReg$ = (type, id) => {
    window.$RefreshRuntime$.register(type, '"app/pages/datasets/dataset/DatasetIdPage.tsx"' + id);
  };
  window.$RefreshSig$ = window.$RefreshRuntime$.createSignatureFunctionForTransform;
}
var prevRefreshReg;
var prevRefreshSig;
var _s5 = $RefreshSig$();
if (import.meta) {
  import.meta.hot = createHotContext(
    //@ts-expect-error
    "app/pages/datasets/dataset/DatasetIdPage.tsx"
  );
  import.meta.hot.lastModified = "1713199469912.9858";
}
var DatasetIdPage = ({
  dataset,
  currentPage,
  totalPages,
  experiments,
  totalCount
}) => {
  _s5();
  const params = useParams();
  const isFineTuning = dataset.isFineTuning;
  const breadcrumbs = [{
    label: "Datasets",
    to: Routes.app.project.env.datasets({
      projectId: params.projectId,
      envId: dataset.envId
    })
  }, {
    label: dataset.name
  }];
  const subtitle = () => {
    return /* @__PURE__ */ (0, import_jsx_dev_runtime5.jsxDEV)(PageSubtitle, { children: [
      "Datasets consist of datapoints that adhere to an input/expected output schema.",
      " ",
      /* @__PURE__ */ (0, import_jsx_dev_runtime5.jsxDEV)(PageDocLink, { to: Routes.external.docs.datasets, children: "Datasets Docs." }, void 0, false, {
        fileName: "app/pages/datasets/dataset/DatasetIdPage.tsx",
        lineNumber: 55,
        columnNumber: 9
      }, this)
    ] }, void 0, true, {
      fileName: "app/pages/datasets/dataset/DatasetIdPage.tsx",
      lineNumber: 53,
      columnNumber: 12
    }, this);
  };
  const action = () => {
    const isSchemaPrimary = !isFineTuning;
    return /* @__PURE__ */ (0, import_jsx_dev_runtime5.jsxDEV)("div", { className: "flex gap-2", children: [
      /* @__PURE__ */ (0, import_jsx_dev_runtime5.jsxDEV)(Button, { variant: "ghost", disabled: true, children: /* @__PURE__ */ (0, import_jsx_dev_runtime5.jsxDEV)(Download, { size: 20 }, void 0, false, {
        fileName: "app/pages/datasets/dataset/DatasetIdPage.tsx",
        lineNumber: 62,
        columnNumber: 11
      }, this) }, void 0, false, {
        fileName: "app/pages/datasets/dataset/DatasetIdPage.tsx",
        lineNumber: 61,
        columnNumber: 9
      }, this),
      /* @__PURE__ */ (0, import_jsx_dev_runtime5.jsxDEV)(DatasetSchemaDialog, { isPrimary: isSchemaPrimary, slug: dataset.slug, inputSchema: dataset.inputSchema, outputSchema: dataset.outputSchema }, void 0, false, {
        fileName: "app/pages/datasets/dataset/DatasetIdPage.tsx",
        lineNumber: 64,
        columnNumber: 9
      }, this),
      isFineTuning && /* @__PURE__ */ (0, import_jsx_dev_runtime5.jsxDEV)(FineTuneDialog, { isDialogDisabled: totalCount === 0 }, void 0, false, {
        fileName: "app/pages/datasets/dataset/DatasetIdPage.tsx",
        lineNumber: 65,
        columnNumber: 26
      }, this)
    ] }, void 0, true, {
      fileName: "app/pages/datasets/dataset/DatasetIdPage.tsx",
      lineNumber: 60,
      columnNumber: 12
    }, this);
  };
  return /* @__PURE__ */ (0, import_jsx_dev_runtime5.jsxDEV)(PageLayout, { breadcrumbs, subtitle, action, children: /* @__PURE__ */ (0, import_jsx_dev_runtime5.jsxDEV)("div", { className: "flex flex-col gap-8", children: [
    /* @__PURE__ */ (0, import_jsx_dev_runtime5.jsxDEV)("div", { className: "flex flex-col", children: [
      /* @__PURE__ */ (0, import_jsx_dev_runtime5.jsxDEV)("p", { className: "flex items-center gap-2 text-xl font-semibold", children: [
        /* @__PURE__ */ (0, import_jsx_dev_runtime5.jsxDEV)(Database, { size: 20 }, void 0, false, {
          fileName: "app/pages/datasets/dataset/DatasetIdPage.tsx",
          lineNumber: 72,
          columnNumber: 13
        }, this),
        "Dataset ",
        isFineTuning ? "(Fine-Tuning)" : ""
      ] }, void 0, true, {
        fileName: "app/pages/datasets/dataset/DatasetIdPage.tsx",
        lineNumber: 71,
        columnNumber: 11
      }, this),
      /* @__PURE__ */ (0, import_jsx_dev_runtime5.jsxDEV)("p", { className: "text-muted-foreground", children: dataset.description }, void 0, false, {
        fileName: "app/pages/datasets/dataset/DatasetIdPage.tsx",
        lineNumber: 75,
        columnNumber: 11
      }, this),
      /* @__PURE__ */ (0, import_jsx_dev_runtime5.jsxDEV)("p", { className: "text-muted-foreground", children: [
        "Slug \u27AF ",
        dataset.slug
      ] }, void 0, true, {
        fileName: "app/pages/datasets/dataset/DatasetIdPage.tsx",
        lineNumber: 76,
        columnNumber: 11
      }, this)
    ] }, void 0, true, {
      fileName: "app/pages/datasets/dataset/DatasetIdPage.tsx",
      lineNumber: 70,
      columnNumber: 9
    }, this),
    /* @__PURE__ */ (0, import_jsx_dev_runtime5.jsxDEV)(DatapointsTable, { datapoints: dataset.datapoints, currentPage, totalPages, totalCount }, void 0, false, {
      fileName: "app/pages/datasets/dataset/DatasetIdPage.tsx",
      lineNumber: 79,
      columnNumber: 9
    }, this),
    /* @__PURE__ */ (0, import_jsx_dev_runtime5.jsxDEV)(RecentExperimentsTable, { experiments }, void 0, false, {
      fileName: "app/pages/datasets/dataset/DatasetIdPage.tsx",
      lineNumber: 80,
      columnNumber: 9
    }, this)
  ] }, void 0, true, {
    fileName: "app/pages/datasets/dataset/DatasetIdPage.tsx",
    lineNumber: 69,
    columnNumber: 7
  }, this) }, void 0, false, {
    fileName: "app/pages/datasets/dataset/DatasetIdPage.tsx",
    lineNumber: 68,
    columnNumber: 10
  }, this);
};
_s5(DatasetIdPage, "+jVsTcECDRo3yq2d7EQxlN9Ixog=", false, function() {
  return [useParams];
});
_c5 = DatasetIdPage;
var _c5;
$RefreshReg$(_c5, "DatasetIdPage");
window.$RefreshReg$ = prevRefreshReg;
window.$RefreshSig$ = prevRefreshSig;

// app/routes/app+/project+/$projectId+/env+/$envId+/datasets+/$datasetId+/index.tsx
var import_jsx_dev_runtime6 = __toESM(require_jsx_dev_runtime(), 1);
if (!window.$RefreshReg$ || !window.$RefreshSig$ || !window.$RefreshRuntime$) {
  console.warn("remix:hmr: React Fast Refresh only works when the Remix compiler is running in development mode.");
} else {
  prevRefreshReg = window.$RefreshReg$;
  prevRefreshSig = window.$RefreshSig$;
  window.$RefreshReg$ = (type, id) => {
    window.$RefreshRuntime$.register(type, '"app/routes/app+/project+/$projectId+/env+/$envId+/datasets+/$datasetId+/index.tsx"' + id);
  };
  window.$RefreshSig$ = window.$RefreshRuntime$.createSignatureFunctionForTransform;
}
var prevRefreshReg;
var prevRefreshSig;
var _s6 = $RefreshSig$();
if (import.meta) {
  import.meta.hot = createHotContext(
    //@ts-expect-error
    "app/routes/app+/project+/$projectId+/env+/$envId+/datasets+/$datasetId+/index.tsx"
  );
  import.meta.hot.lastModified = "1711487143845.0212";
}
var loader = withAuth(async ({
  api,
  params,
  request
}) => {
  const datasetId = params.datasetId;
  const {
    searchParams
  } = new URL(request.url);
  const page = parseInt(searchParams.get("page") || "1");
  const pageSize = 5;
  const skipAmount = (page - 1) * pageSize;
  const datasetPromise = api.dataset.datasetControllerGetDatasetWithDatapoints({
    datasetId,
    take: pageSize.toString(),
    skip: skipAmount.toString()
  });
  const experimentsPromise = api.dataset.datasetControllerGetDatasetRecentExperiments({
    datasetId
  });
  const [datasetRes, experiments] = await Promise.all([datasetPromise, experimentsPromise]);
  const {
    dataset,
    totalCount
  } = datasetRes;
  return (0, import_node.json)({
    dataset,
    currentPage: page,
    totalPages: totalCount ? Math.ceil(totalCount / pageSize) : 0,
    experiments,
    totalCount
  });
});
function DatasetIdRoute() {
  _s6();
  const {
    dataset,
    currentPage,
    totalPages,
    experiments,
    totalCount
  } = useLoaderData();
  const formattedExperiments = experiments.map((experiment) => ({
    ...experiment,
    createdAt: (0, import_dayjs2.default)(experiment.createdAt).format("MMM D YY / h:mm:ss a")
  }));
  return /* @__PURE__ */ (0, import_jsx_dev_runtime6.jsxDEV)(DatasetIdPage, { dataset, currentPage, totalPages, experiments: formattedExperiments, totalCount }, void 0, false, {
    fileName: "app/routes/app+/project+/$projectId+/env+/$envId+/datasets+/$datasetId+/index.tsx",
    lineNumber: 73,
    columnNumber: 10
  }, this);
}
_s6(DatasetIdRoute, "uI5onGPEJmNonjDcqYgbYQSJuuo=", false, function() {
  return [useLoaderData];
});
_c6 = DatasetIdRoute;
var _c6;
$RefreshReg$(_c6, "DatasetIdRoute");
window.$RefreshReg$ = prevRefreshReg;
window.$RefreshSig$ = prevRefreshSig;
export {
  DatasetIdRoute as default
};
//# sourceMappingURL=/build/routes/app+/project+/$projectId+/env+/$envId+/datasets+/$datasetId+/index-I2LD3ZHX.js.map
