1import{d as G,H as J,o as Q,f as t,c as n,b as g,w as X,e,B as Y,D as Z,ao as B,C as tt,F as b,t as d,g as T,m as V,j as w,r as l,v as et,_ as ot,a as r,p as st}from"./BJ-fXIum.js";import{_ as at}from"./DWVO9tK9.js";import{_ as nt}from"./CqOw22xb.js";import{_ as rt}from"./B19hcrjh.js";import{_ as it}from"./CKns6ltv.js";import{u as lt}from"./B6avjkXk.js";import{a as dt}from"./C-c2tz7K.js";import{u as ct}from"./DaGf2Aai.js";import{u as mt}from"./D2nMFcDl.js";import{u as ut}from"./DyOszaq-.js";import"./D3dKKD4A.js";const pt={key:0},ft={class:"flex flex-wrap items-center justify-between gap-3 mb-6"},_t={class:"min-w-0"},xt={class:"flex items-center gap-2"},yt={class:"flex items-center gap-2 mt-1"},gt={class:"font-mono text-xs text-gray-500 bg-gray-50 border border-gray-200 px-2 py-0.5 rounded truncate"},vt={class:"flex items-center gap-3"},bt={class:"text-sm text-gray-700"},ht={class:"bg-white rounded-lg border border-gray-200 overflow-hidden"},wt={class:"px-4 py-3 border-b border-gray-200 flex items-center justify-between"},kt={class:"text-sm font-semibold text-gray-900"},Ct={key:0,class:"font-normal text-gray-400"},Ft={key:0,class:"p-6 text-gray-500 text-sm"},jt={key:1,class:"p-8 text-center"},Nt={key:2,class:"overflow-x-auto"},Et={class:"w-full text-sm"},Dt={class:"border-b border-gray-100"},Lt={class:"divide-y divide-gray-50"},St=["title"],Bt={class:"block truncate"},Tt={class:"px-4 py-2.5 text-gray-400 font-mono text-xs whitespace-nowrap"},Vt={key:3,class:"px-4 py-3 border-t border-gray-100 text-center"},$t=["disabled"],It={key:1,class:"text-gray-500 font-mono text-sm"},Pt=50,Qt=G({__name:"[widgetId]",setup(zt){const k=J(),c=k.params.id,u=k.params.widgetId,{fetchForm:$,updateForm:C,fetchFormSubmissions:I}=lt(),{show:v}=dt(),{trackFormViewed:P}=ct(),a=l(null),m=l([]),p=l(0),_=l(!1),F=l(1),x=l(!1),y=l(""),j=l(null),N=()=>{y.value=a.value?.name||"",x.value=!0,et(()=>j.value?.focus())},z=()=>{x.value=!1},E=async()=>{const s=y.value.trim();if(!s||s===a.value?.name){x.value=!1;return}try{await C(c,u,{name:s}),a.value.name=s,x.value=!1}catch{v("Failed to rename form","error")}},D=st(()=>{if(!a.value)return[];if(a.value.schema_def?.fields){const o=a.value.schema_def.fields;return Array.isArray(o)?o.map(f=>f.name):Object.keys(o)}const s=new Set;for(const o of m.value)if(o.data)for(const f of Object.keys(o.data))f.startsWith("_")||s.add(f);return Array.from(s)}),{fetchProject:M}=mt(),{formatDate:A}=ut(),L=l(null),U=s=>A(s,L.value?.timezone),H=async s=>{const o=a.value.enabled;a.value.enabled=s;try{await C(c,u,{enabled:s})}catch{a.value.enabled=o,v("Failed to update form","error")}};Q(async()=>{P(u);try{const s=await $(c,u);a.value={...s}}catch{v("Failed to load form","error")}S();try{L.value=await M(c)}catch{}});const S=async()=>{_.value=!0;try{const s=await I(c,u,{page:F.value,per_page:Pt});m.value.push(...s.items),p.value=s.total}catch{v("Failed to load submissions","error")}finally{_.value=!1}},K=()=>{F.value++,S()};return(s,o)=>{const f=ot,O=at,R=nt,W=rt,q=it;return t(a)?(r(),n("div",pt,[g(f,{to:`/projects/${t(c)}/forms`,class:"text-xs text-gray-400 hover:text-gray-600 mb-4 inline-block font-mono"},{default:X(()=>[...o[2]||(o[2]=[T("â forms",-1)])]),_:1},8,["to"]),e("div",ft,[e("div",_t,[e("div",xt,[t(x)?Y((r(),n("input",{key:0,ref_key:"nameInputEl",ref:j,"onUpdate:modelValue":o[0]||(o[0]=i=>tt(y)?y.value=i:null),type:"text",class:"font-mono text-xl font-semibold text-gray-900 bg-white border border-gray-300 rounded px-2 py-0.5 focus:outline-none focus:ring-2 focus:ring-green-500/20 focus:border-green-500",onKeydown:[B(E,["enter"]),B(z,["escape"])],onBlur:E},null,544)),[[Z,t(y)]]):(r(),n(b,{key:1},[e("h1",{class:"font-mono text-xl font-semibold text-gray-900 cursor-pointer hover:text-green-600 transition-colors",title:"Click to edit name",onClick:N},d(t(a).name||"Untitled Form"),1),e("button",{class:"text-gray-400 hover:text-gray-600 transition-colors",title:"Edit name",onClick:N},[...o[3]||(o[3]=[e("svg",{xmlns:"http://www.w3.org/2000/svg",class:"w-4 h-4",fill:"none",viewBox:"0 0 24 24",stroke:"currentColor","stroke-width":"2"},[e("path",{"stroke-linecap":"round","stroke-linejoin":"round",d:"M15.232 5.232l3.536 3.536m-2.036-5.036a2.5 2.5 0 113.536 3.536L6.5 21.036H3v-3.572L16.732 3.732z"})],-1)])])],64))]),e("div",yt,[e("code",gt,d(t(a).form_key),1),g(O,{text:t(a).form_key,size:"sm"},null,8,["text"])])]),e("div",vt,[g(R,{"model-value":t(a).enabled,"onUpdate:modelValue":o[1]||(o[1]=i=>H(i))},null,8,["model-value"]),e("span",bt,d(t(a).enabled?"Enabled":"Disabled"),1)])]),e("div",ht,[e("div",wt,[e("h3",kt,[o[4]||(o[4]=T(" Submissions ",-1)),t(p)?(r(),n("span",Ct,"("+d(t(p))+")",1)):V("",!0)]),g(W,{endpoint:`/v1/projects/${t(c)}/forms/${t(u)}
1/submissions/export`,disabled:t(p)===0},null,8,["endpoint","disabled"])]),t(_)&&t(m).length===0?(r(),n("div",Ft," Loading... ")):t(m).length===0?(r(),n("div",jt,[g(q,{title:"No submissions yet",description:"Submissions will appear here when people fill out this form."})])):(r(),n("div",Nt,[e("table",Et,[e("thead",null,[e("tr",Dt,[(r(!0),n(b,null,w(t(D),i=>(r(),n("th",{key:i,class:"px-4 py-2.5 text-left text-xs font-medium text-gray-500 uppercase tracking-wider whitespace-nowrap"},d(i),1))),128)),o[5]||(o[5]=e("th",{class:"px-4 py-2.5 text-left text-xs font-medium text-gray-500 uppercase tracking-wider whitespace-nowrap"}," Submitted ",-1))])]),e("tbody",Lt,[(r(!0),n(b,null,w(t(m),i=>(r(),n("tr",{key:i.id,class:"hover:bg-gray-50/50"},[(r(!0),n(b,null,w(t(D),h=>(r(),n("td",{key:h,class:"px-4 py-2.5 text-gray-700 font-mono text-xs max-w-[300px]",title:String(i.data[h]||"")},[e("span",Bt,d(i.data[h]||"â"),1)],8,St))),128)),e("td",Tt,d(U(i.created_at)),1)]))),128))])])])),t(m).length<t(p)?(r(),n("div",Vt,[e("button",{disabled:t(_),class:"text-sm font-mono text-green-600 hover:text-green-700 disabled:opacity-50",onClick:K},d(t(_)?"Loading...":`Load more (${t(m).length} of ${t(p)})`),9,$t)])):V("",!0)])])):(r(),n("div",It,"Loading..."))}}});export{Qt as default};
Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.