var __gh = require("react").createElement, __gf = require("react").Fragment; var __defProp=Object.defineProperty;var __getOwnPropDesc=Object.getOwnPropertyDescriptor;var __getOwnPropNames=Object.getOwnPropertyNames;var __hasOwnProp=Object.prototype.hasOwnProperty;var __export=(target,all)=>{for(var name in all)__defProp(target,name,{get:all[name],enumerable:!0})},__copyProps=(to,from,except,desc)=>{if(from&&typeof from=="object"||typeof from=="function")for(let key of __getOwnPropNames(from))!__hasOwnProp.call(to,key)&&key!==except&&__defProp(to,key,{get:()=>from[key],enumerable:!(desc=__getOwnPropDesc(from,key))||desc.enumerable});return to};var __toCommonJS=mod=>__copyProps(__defProp({},"__esModule",{value:!0}),mod);var stdin_exports={};__export(stdin_exports,{default:()=>stdin_default,featureConfig:()=>featureConfig});module.exports=__toCommonJS(stdin_exports);var dataSources=[{key:"sin_datos",table:"portal__sin_datos",access:"public:read"}];var import_react=require("react"),EMPRESA_DE_LOS_ENLACES_VIEJOS="640",STRINGS={es:{iframeTitle:"Documento",errorTitle:"Documento no disponible",errorBody:"El enlace no es v\xE1lido o el documento ya no est\xE1 accesible. Solicita un nuevo enlace a quien te lo envi\xF3.",kindLabels:{factura:"Factura",presupuesto:"Presupuesto"}},en:{iframeTitle:"Document",errorTitle:"Document not available",errorBody:"The link is invalid or the document is no longer accessible. Ask the sender for a new link.",kindLabels:{factura:"Invoice",presupuesto:"Quote"}}};function PortalDeDocumentos({id,gufi}){let[phase,setPhase]=(0,import_react.useState)("loading"),[html,setHtml]=(0,import_react.useState)(""),[lang,setLang]=(0,import_react.useState)(null);(0,import_react.useEffect)(()=>{let params=new URLSearchParams(window.location.search),kind=params.get("kind"),token=params.get("token"),empresa=params.get("empresa")||EMPRESA_DE_LOS_ENLACES_VIEJOS;if(!kind||!token||!/^\d+$/.test(empresa)){setPhase("error");return}let url=window.location.origin+"/api/public/"+empresa+"/doc?kind="+encodeURIComponent(kind)+"&token="+encodeURIComponent(token);fetch(url).then(r=>r.json()).then(json=>{let doc=json&&json.result,docLang=doc&&doc.lang==="en"?"en":"es";if(doc&&doc.lang&&setLang(docLang),json&&json.success&&doc&&doc.html){let t2=STRINGS[docLang],kindLabel=t2.kindLabels[kind]||t2.iframeTitle;document.title=doc.numero?kindLabel+" "+doc.numero:kindLabel,setHtml(doc.html),setPhase("ready")}else doc&&doc.lang&&(document.title=STRINGS[docLang].errorTitle),setPhase("error")}).catch(()=>setPhase("error"))},[]);let t=lang?STRINGS[lang]:null;return phase==="ready"?__gh("iframe",{title:t?t.iframeTitle:"Documento",srcDoc:html,style:{position:"fixed",inset:0,width:"100%",height:"100dvh",border:0,background:"#ffffff"},"data-gufi-src":"page.tsx:80"}):__gh("div",{style:{position:"fixed",inset:0,height:"100dvh",display:"flex",flexDirection:"column",alignItems:"center",justifyContent:"center",gap:16,background:"#0a0a12",color:"#e5e5ef",fontFamily:"-apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif"},"data-gufi-src":"page.tsx:96"},__gh("style",{"data-gufi-src":"page.tsx:112"},"@keyframes portal-spin { to { transform: rotate(360deg); } }"),phase==="loading"?__gh(__gf,null,__gh("div",{style:{width:36,height:36,borderRadius:"50%",border:"3px solid rgba(107,78,255,0.25)",borderTopColor:"#6B4EFF",animation:"portal-spin 0.8s linear infinite"},"data-gufi-src":"page.tsx:115"}),__gh("p",{style:{fontSize:14,color:"#9b9bb0",margin:0},"data-gufi-src":"page.tsx:125"},"Cargando documento\u2026 / Loading document\u2026")):__gh(__gf,null,__gh("div",{style:{width:56,height:56,borderRadius:16,display:"flex",alignItems:"center",justifyContent:"center",background:"rgba(107,78,255,0.12)",fontSize:26},"data-gufi-src":"page.tsx:131"},__gh("svg",{width:"26",height:"26",viewBox:"0 0 24 24",fill:"none",stroke:"#6B4EFF",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round","data-gufi-src":"page.tsx:143"},__gh("path",{d:"M14 2H6a2 2 0 0 0-2 2v16a2 2 0 0 0 2 2h12a2 2 0 0 0 2-2V8z","data-gufi-src":"page.tsx:153"}),__gh("polyline",{points:"14 2 14 8 20 8","data-gufi-src":"page.tsx:154"}),__gh("line",{x1:"9",y1:"13",x2:"15",y2:"13","data-gufi-src":"page.tsx:155"}))),__gh("h1",{style:{fontSize:18,fontWeight:600,margin:0,maxWidth:320,textAlign:"center"},"data-gufi-src":"page.tsx:158"},t?t.errorTitle:"Documento no disponible / Document not available"),__gh("p",{style:{fontSize:14,color:"#9b9bb0",margin:0,maxWidth:320,textAlign:"center",lineHeight:1.5},"data-gufi-src":"page.tsx:169"},t?t.errorBody:STRINGS.es.errorBody),!t&&__gh("p",{style:{fontSize:14,color:"#9b9bb0",margin:0,maxWidth:320,textAlign:"center",lineHeight:1.5},"data-gufi-src":"page.tsx:182"},STRINGS.en.errorBody)))}var featureConfig={dataSources,meta:{name:"Portal de Documentos",version:"1.0.0"}};var stdin_default=PortalDeDocumentos;