"use strict";
Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
const jsxDevRuntime = require("react/jsx-dev-runtime");
const reactBinding = require("@contember/react-binding");
const getAudioFileDataExtractor = ({
  durationField
}) => ({
  staticRender: () => !!durationField && /* @__PURE__ */ jsxDevRuntime.jsxDEV(reactBinding.SugaredField, { field: durationField }, void 0, false, {
    fileName: "/__w/interface/interface/packages/admin/src/components/bindingFacade/upload/fileDataExtractors/getAudioFileDataExtractor.tsx",
    lineNumber: 12,
    columnNumber: 41
  }, void 0),
  extractFileData: ({ objectUrl }) => {
    if (!durationField) {
      return null;
    }
    return new Promise((resolve, reject) => {
      const audio = document.createElement("audio");
      audio.addEventListener("canplay", () => {
        resolve(audio);
      });
      audio.addEventListener("error", () => {
        reject();
      });
      audio.src = objectUrl;
    });
  },
  populateFields: ({ entity, extractedData }) => {
    !!durationField && entity.getField(durationField).updateValue(extractedData.duration);
  }
});
exports.getAudioFileDataExtractor = getAudioFileDataExtractor;
//# sourceMappingURL=getAudioFileDataExtractor.cjs.map
