"use strict";

Object.defineProperty(exports, "__esModule", {
  value: true
});
exports.default = void 0;
var _react = _interopRequireWildcard(require("react"));
var _reactNative = require("react-native");
var _GViewWebView = _interopRequireDefault(require("./GViewWebView"));
var _jsxRuntime = require("react/jsx-runtime");
function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
function _interopRequireWildcard(e, t) { if ("function" == typeof WeakMap) var r = new WeakMap(), n = new WeakMap(); return (_interopRequireWildcard = function (e, t) { if (!t && e && e.__esModule) return e; var o, i, f = { __proto__: null, default: e }; if (null === e || "object" != typeof e && "function" != typeof e) return f; if (o = t ? n : r) { if (o.has(e)) return o.get(e); o.set(e, f); } for (const t in e) "default" !== t && {}.hasOwnProperty.call(e, t) && ((i = (o = Object.defineProperty) && Object.getOwnPropertyDescriptor(e, t)) && (i.get || i.set) ? o(f, t, i) : f[t] = e[t]); return f; })(e, t); }
/**
 * Inline preview for office documents (DOC / DOCX / XLS / XLSX / PPT /
 * PPTX / TXT / RTF / CSV) and other non-PDF formats supported by
 * Google's free gview rendering service.
 *
 *
 * Limitations (documented for the integrator):
 *   - Requires public URL — won't work for auth-gated downloads.
 *   - First load can take 2-5s on slow networks.
 *   - Read-only — no editing, no print/share buttons.
 *
 */
const DocumentViewer = ({
  url,
  fileName
}) => {
  const [errored, setErrored] = (0, _react.useState)(false);
  if (errored) {
    return /*#__PURE__*/(0, _jsxRuntime.jsxs)(_reactNative.View, {
      style: styles.center,
      children: [/*#__PURE__*/(0, _jsxRuntime.jsx)(_reactNative.Text, {
        style: styles.errorTitle,
        children: fileName || 'Document'
      }), /*#__PURE__*/(0, _jsxRuntime.jsx)(_reactNative.Text, {
        style: styles.errorBody,
        children: "Couldn't render an inline preview. Tap the save icon above to download the file."
      })]
    });
  }
  return /*#__PURE__*/(0, _jsxRuntime.jsx)(_GViewWebView.default, {
    url: url,
    onError: () => setErrored(true)
  });
};
var _default = exports.default = DocumentViewer;
const styles = _reactNative.StyleSheet.create({
  center: {
    flex: 1,
    alignItems: 'center',
    justifyContent: 'center',
    padding: 24,
    gap: 8
  },
  errorTitle: {
    fontSize: 16,
    fontWeight: '600'
  },
  errorBody: {
    color: '#666',
    textAlign: 'center'
  }
});
//# sourceMappingURL=DocumentViewer.js.map