@objectstack/console 12.0.0 → 12.1.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (75) hide show
  1. package/dist/.objectui-sha +1 -1
  2. package/dist/assets/{AdapterProvider-BIB-F0Qa.js → AdapterProvider-BcaDLM8t.js} +1 -1
  3. package/dist/assets/{AiPendingActionsPage-CMVG4Uuj.js → AiPendingActionsPage-kXdn272E.js} +1 -1
  4. package/dist/assets/{ApiConsolePage-BpBKlVk6.js → ApiConsolePage-BUAZ2Y01.js} +1 -1
  5. package/dist/assets/{AppDocsIndex-35urFMpk.js → AppDocsIndex-BfFCj_wz.js} +1 -1
  6. package/dist/assets/{AppManagementPage-Q8hLq3cQ.js → AppManagementPage-lZl1h0_x.js} +1 -1
  7. package/dist/assets/{ApprovalsInboxPage-Cjd1esAG.js → ApprovalsInboxPage-BllA35Q9.js} +1 -1
  8. package/dist/assets/{AuditLogPage-C2lQmF3X.js → AuditLogPage-Du_n63Ua.js} +1 -1
  9. package/dist/assets/{ComponentNavView-BuEXrmXR.js → ComponentNavView-BNkTx_gd.js} +1 -1
  10. package/dist/assets/{ConsoleFloatingChatbot-XMVIlmjf.js → ConsoleFloatingChatbot-BTKK_vEs.js} +1 -1
  11. package/dist/assets/{DashboardView-cKnnhVZW.js → DashboardView-DwORDYTI.js} +1 -1
  12. package/dist/assets/{DashboardWidgetInspector-DQzulo-e.js → DashboardWidgetInspector-DnxXy8MD.js} +1 -1
  13. package/dist/assets/{DeveloperHubPage-DO4z3Sj9.js → DeveloperHubPage-BJDkM5bW.js} +1 -1
  14. package/dist/assets/{ExpressionProvider-BI-jCA0B.js → ExpressionProvider-CD5Qq5aY.js} +1 -1
  15. package/dist/assets/{FlowRunsPage-DVvg_WMt.js → FlowRunsPage-C8usAiCs.js} +1 -1
  16. package/dist/assets/{IntegrationsPage-kF55v0ix.js → IntegrationsPage-DHi5SpvX.js} +1 -1
  17. package/dist/assets/{InterfaceListPage-CH9wtpOt.js → InterfaceListPage-BqCFOLqM.js} +1 -1
  18. package/dist/assets/{ManagedByBadge-DtZfR2w_.js → ManagedByBadge-CQOEWdSz.js} +1 -1
  19. package/dist/assets/{MarketplaceAccessDenied-JR0ElPYV.js → MarketplaceAccessDenied-BUAjFq6w.js} +1 -1
  20. package/dist/assets/{MarketplaceInstalledPage-c1qqM0m9.js → MarketplaceInstalledPage-CK-HsgOu.js} +1 -1
  21. package/dist/assets/{MarketplacePackagePage-CT5bU1QW.js → MarketplacePackagePage-DHsi6uiN.js} +1 -1
  22. package/dist/assets/{MarketplacePage-BkOByUub.js → MarketplacePage-DIFzpvbl.js} +1 -1
  23. package/dist/assets/{MetadataInspector-FQJn-0mY.js → MetadataInspector-Bayj0F4e.js} +1 -1
  24. package/dist/assets/{MetadataProvider-DlGQbrYS.js → MetadataProvider-DboJnyDA.js} +1 -1
  25. package/dist/assets/{PageView-BR-dytGp.js → PageView-BfC2HLWA.js} +1 -1
  26. package/dist/assets/{ProfilePage-BfNhQTic.js → ProfilePage-YhSTeHYm.js} +1 -1
  27. package/dist/assets/{PublicFormsPage-D5HXZ9gs.js → PublicFormsPage-B3Wg58sq.js} +1 -1
  28. package/dist/assets/{RecordDetailView-BUBX12o3.js → RecordDetailView-BXq0yKAC.js} +1 -1
  29. package/dist/assets/{RecordFormPage-dOx4tkq3.js → RecordFormPage-BqNRd1-N.js} +1 -1
  30. package/dist/assets/ReportDefaultInspector-BpiqbNpa.js +11 -0
  31. package/dist/assets/{ReportView-BoYtuwGU.js → ReportView-C44qsTBA.js} +1 -1
  32. package/dist/assets/{SearchResultsPage-Dn6Lg7cm.js → SearchResultsPage-CcZIaPuL.js} +1 -1
  33. package/dist/assets/{SettingsHub-BIUh_NaE.js → SettingsHub-B8_T5GH3.js} +1 -1
  34. package/dist/assets/{SettingsView-iFSFGurq.js → SettingsView-DU5GHJoJ.js} +1 -1
  35. package/dist/assets/{SystemHubPage-BbYZjpSv.js → SystemHubPage-CgvK6Oyz.js} +1 -1
  36. package/dist/assets/appRoute-CbCiASix.js +1 -0
  37. package/dist/assets/{data-adapter-BJMUjXWO.js → data-adapter-B0hWGLbx.js} +1 -1
  38. package/dist/assets/{framework-Bn8ShCi0.js → framework-CUm99d5f.js} +10 -10
  39. package/dist/assets/{highlighted-body-OFNGDK62-CLYrkLJN.js → highlighted-body-OFNGDK62-DRL1o2sE.js} +1 -1
  40. package/dist/assets/index-BT5Kcjbb.css +2 -0
  41. package/dist/assets/{index-BecTd5hZ.js → index-gh_wl34E.js} +1 -1
  42. package/dist/assets/mermaid-GHXKKRXX-CnhpyTzH.js +1 -0
  43. package/dist/assets/metadata-admin-B0y5-vc3.js +22 -0
  44. package/dist/assets/{plugin-calendar-DJ1vxgSA.js → plugin-calendar-jq5LS38z.js} +1 -1
  45. package/dist/assets/{plugin-charts-vp7sTLa2.js → plugin-charts-CN_USFkK.js} +1 -1
  46. package/dist/assets/{plugin-chatbot-DCC-44Dt.js → plugin-chatbot-BTDg_ecv.js} +3 -3
  47. package/dist/assets/{plugin-dashboard-z2hSPvkm.js → plugin-dashboard-DVmEJF7R.js} +1 -1
  48. package/dist/assets/{plugin-form-BUDPowXG.js → plugin-form-G3dyuFOt.js} +1 -1
  49. package/dist/assets/{plugin-gantt-BJIjCj1A.js → plugin-gantt-D51p6Rw0.js} +1 -1
  50. package/dist/assets/{plugin-grid-ieKf1CBn.js → plugin-grid-Dk1ZUbuk.js} +1 -1
  51. package/dist/assets/{plugin-kanban-DhARoJCa.js → plugin-kanban-D2Et0gJr.js} +1 -1
  52. package/dist/assets/{plugin-map-C2xGbkMv.js → plugin-map-C_5T2eDy.js} +1 -1
  53. package/dist/assets/{plugin-markdown-DXEq1goV.js → plugin-markdown-BAdYqOQi.js} +1 -1
  54. package/dist/assets/{plugin-report-Cho-TzT3.js → plugin-report-6nU1jd3t.js} +1 -1
  55. package/dist/assets/{plugin-timeline-6gVRcvzs.js → plugin-timeline-DFNoZxR2.js} +1 -1
  56. package/dist/assets/{plugin-tree-_9p0xC9K.js → plugin-tree-B5L8YkYP.js} +1 -1
  57. package/dist/assets/{plugin-view-vYQlhE3F.js → plugin-view-BSG5MvLZ.js} +1 -1
  58. package/dist/assets/{plugins-views-ycDq-ZXC.js → plugins-views-Cxvy9qpT.js} +1 -1
  59. package/dist/assets/{skeletons-C2aQsjPE.js → skeletons-9VTXs8YD.js} +1 -1
  60. package/dist/assets/{src-B4OzWw0f.js → src-4pltlsqa.js} +1 -1
  61. package/dist/assets/src-DdEhFXgM.js +15 -0
  62. package/dist/assets/{types-B0Soeu38.js → types-B9qOi1b_.js} +1 -1
  63. package/dist/assets/{ui-components-DlauVk27.js → ui-components-DvVVxGRS.js} +1 -1
  64. package/dist/assets/{ui-layout-DnHby9xU.js → ui-layout-DmrJIZR6.js} +1 -1
  65. package/dist/assets/{useOpenRecordList-DWDU_kYn.js → useOpenRecordList-WXseLM45.js} +1 -1
  66. package/dist/assets/{useReconcileOnError-B9komLeJ.js → useReconcileOnError-DzkPdzFt.js} +1 -1
  67. package/dist/assets/{useRecordApprovals-B_jxSZvZ.js → useRecordApprovals-PhUYX_dd.js} +1 -1
  68. package/dist/index.html +4 -4
  69. package/package.json +1 -1
  70. package/dist/assets/ReportDefaultInspector-DQlvnczB.js +0 -11
  71. package/dist/assets/appRoute-D5vwtoc_.js +0 -1
  72. package/dist/assets/index-Ci5dbUDe.css +0 -2
  73. package/dist/assets/mermaid-GHXKKRXX-B7A4_dsH.js +0 -1
  74. package/dist/assets/metadata-admin-CwGCDJE1.js +0 -22
  75. package/dist/assets/src-CbqgiuxM.js +0 -15
@@ -1 +1 @@
1
- import{o as e,r as t}from"./rolldown-runtime-DAXXjFlN.js";import{_ as n,f as r,l as i,p as a,t as o,u as s}from"./vendor-react-slxo-5GC.js";import{d as c,f as l,m as u,n as d}from"./infrastructure-BySW-NB0.js";import{G as f,N as p,P as m,R as h,a as g,g as _}from"./framework-Bn8ShCi0.js";import{B as v,G as y,Ic as b,Io as x,J as S,Sr as C,W as w,_r as T,br as E,gr as D,hr as O,pr as k,ra as A,vr as j,yr as M}from"./ui-components-DlauVk27.js";import{r as N}from"./vendor-ui-utils-C1OpMExs.js";import"./MetadataProvider-DlGQbrYS.js";import{r as P}from"./ExpressionProvider-BI-jCA0B.js";import{c as ee,i as te,l as ne,r as re,u as ie}from"./RecordDetailView-BUBX12o3.js";import{n as F,r as I,t as L}from"./MetadataInspector-FQJn-0mY.js";import{t as R}from"./InterfaceListPage-CH9wtpOt.js";var z=e(n(),1),B=o();function V(e,t){if(/^https?:\/\//i.test(e)||e.startsWith(`mailto:`))return{href:e,external:!e.startsWith(`mailto:`)};let n=(t||``).replace(/\/+$/,``);return{href:`${n}${e}`,external:!!n}}function H({cta:e,apiBase:t,primary:n,onNavigate:r}){let{href:i,external:a}=V(e.url,t);return(0,B.jsx)(C,{asChild:!0,variant:n?`default`:`outline`,size:`sm`,children:(0,B.jsx)(`a`,{href:i,onClick:r,...a?{target:`_blank`,rel:`noopener noreferrer`}:{},"data-testid":`entitlement-cta-${n?`primary`:`secondary`}`,children:e.label})})}function ae({state:e,apiBase:t,onOpenChange:n}){let r=e.spec;return(0,B.jsx)(k,{open:e.open,onOpenChange:e=>{e||n(!1)},children:(0,B.jsxs)(D,{"data-testid":`environment-entitlement-dialog`,children:[(0,B.jsxs)(M,{children:[(0,B.jsx)(E,{children:r?.title}),(0,B.jsx)(T,{children:r?.message})]}),(0,B.jsxs)(j,{children:[(0,B.jsx)(O,{children:`Close`}),r?.secondaryCta&&(0,B.jsx)(H,{cta:r.secondaryCta,apiBase:t,primary:!1,onNavigate:()=>n(!1)}),r?.cta&&(0,B.jsx)(H,{cta:r.cta,apiBase:t,primary:!0,onNavigate:()=>n(!1)})]})]})})}var U=new Set([`DEV_ENV_PLAN_LOCKED`,`DEV_ENV_LIMIT`,`PRODUCTION_ENV_LIMIT`]);function W(e){return typeof e==`string`&&U.has(e)}var G=`/settings/billing`;function oe(e){let t=e?.code;if(!W(t))return null;let n=typeof e?.error==`string`&&e.error?e.error:typeof e?.message==`string`?e.message:``,r=typeof e?.upgrade_url==`string`&&e.upgrade_url?e.upgrade_url:G,i=typeof e?.contact_url==`string`&&e.contact_url?e.contact_url:``;return t===`PRODUCTION_ENV_LIMIT`?{code:t,title:`You already have your production environment`,message:n||`Each organization includes exactly one production environment. Create a separate organization for another, or contact us about an Enterprise arrangement.`,cta:i?{label:`Contact sales`,url:i}:void 0}:{code:t,title:t===`DEV_ENV_PLAN_LOCKED`?`Development environments are a paid feature`:`Development environment limit reached`,message:n||(t===`DEV_ENV_PLAN_LOCKED`?`Your free plan includes one production environment. Upgrade to add development environments — build in dev, then publish to production.`:`Capacity scales with AI seats. Add an AI seat, or archive an unused development environment to free one up.`),cta:{label:`Upgrade plan`,url:r}}}function K(e){return e.hasProductionEnv?e.canCreateDevelopmentEnv===!1?`upgrade_for_development`:`add_development`:`setup_production`}function q(e){return{code:`DEV_ENV_PLAN_LOCKED`,title:`Development environments are a paid feature`,message:`${e.plan&&e.plan!==`free`?`your ${e.plan} plan`:`your free plan`} includes one production environment. Upgrade to add development environments — build in dev, then publish to production.`,cta:{label:`Upgrade plan`,url:e.upgradeUrl||`/settings/billing`}}}var J=/^\s*\{\{\s*page\.([A-Za-z_$][\w$]*(?:\.[A-Za-z_$][\w$]*)*)\s*\}\}\s*$/;function Y(e,t){let n=t;for(let t of e.split(`.`)){if(n==null)return;n=n[t]}return n}function se(e,t){if(!e.includes(`{{`))return e;let n=e.match(J);if(n){let e=Y(n[1],t);return e===void 0?``:e}return e.replace(/\{\{\s*page\.([A-Za-z_$][\w$]*(?:\.[A-Za-z_$][\w$]*)*)\s*\}\}/g,(e,n)=>{let r=Y(n,t);return r==null?``:String(r)})}function X(e,t){if(typeof e==`string`)return se(e,t);if(Array.isArray(e))return e.map(e=>X(e,t));if(e&&typeof e==`object`){let n={};for(let[r,i]of Object.entries(e))n[r]=X(i,t);return n}return e}function Z(e,t){return t?X(e,t):e}var ce={id:`current-user`,name:`Demo User`,isPlatformAdmin:!1};function Q(e){let t=e.locations;return Array.isArray(t)?t.some(e=>e===`list_item`||e===`record_header`||e===`record_more`||e===`record_section`):!1}function $(e){let{dataSource:t,objects:n,objectName:r,onRefresh:i}=e,a=s(),{user:o,activeOrganization:c}=l(),{systemPermissions:f}=d(),{fieldLabel:p,fieldOptionLabel:m,actionParamText:h,actionParamOptionLabel:g,actionDescription:v}=b(),y=(0,z.useMemo)(()=>r?n?.find(e=>e.name===r):void 0,[n,r]),x=r||y?.name,S=(0,z.useCallback)(()=>{i?.()},[i]),C=_({dataSource:t,onUndo:()=>{S(),N.success(`Change undone`)}}),[w,T]=(0,z.useState)({open:!1,message:``}),[E,D]=(0,z.useState)({open:!1,params:[]}),[O,k]=(0,z.useState)({open:!1}),[A,j]=(0,z.useState)(null),[M,P]=(0,z.useState)({open:!1}),F=(0,z.useRef)(new Set),I=(0,z.useCallback)((e,t)=>new Promise(n=>{k({open:!0,spec:e,data:t,resolve:n})}),[]),L=(0,z.useCallback)((e,t)=>new Promise(n=>{T({open:!0,message:e,options:t,resolve:n})}),[]),R=(0,z.useCallback)((e,t)=>new Promise(i=>{let a=t?.params&&!Array.isArray(t.params)?t.params._rowRecord:void 0,o=re(e,{objectName:r||y?.name||``,objects:n||[],fieldLabel:p,fieldOptionLabel:m,row:a}),s=r||y?.name;D({open:!0,params:o.map(e=>({...e,label:h(s,t?.name,e.name,`label`,e.label)??e.label,placeholder:h(s,t?.name,e.name,`placeholder`,e.placeholder)??e.placeholder,helpText:h(s,t?.name,e.name,`helpText`,e.helpText)??e.helpText,options:Array.isArray(e.options)?e.options.map(n=>({...n,label:g(s,t?.name,e.name,n.value,n.label)})):e.options})),title:t?.label||t?.title,description:v(s,t?.name,t?.description),resolve:i})}),[r,y,n,p,m,h,g]),V=o?{id:o.id,name:o.name,avatar:o.image,isPlatformAdmin:o?.isPlatformAdmin??!1,systemPermissions:f??[]}:{...ce,systemPermissions:f??[]},H=(0,z.useCallback)((e,t)=>{if(t?.type===`error`){N.error(e);return}if(t?.undo){N.success(e,{duration:t.duration,action:{label:t.undo.label||`Undo`,onClick:()=>{C.undo()}}});return}N.success(e,{duration:t?.duration})},[C]),U=(0,z.useCallback)((e,t)=>{t?.external||t?.newTab?window.open(e,`_blank`,`noopener,noreferrer`):a(e)},[a]),W=(0,z.useMemo)(()=>u(),[]),G=(0,z.useCallback)(e=>{P({open:!0,spec:e})},[]),K=(0,z.useCallback)(async(e,n)=>{try{let r=e.target||e.name,i=e.params||{},a=typeof r==`string`?r:``;if(a.startsWith(`/`)||/^https?:\/\//i.test(a)){let t={...i},r=t._rowRecord;delete t._rowRecord;let o=n?.pageVariables??void 0,s=Z(t,o),l=a;r&&/\{[a-z_][a-z0-9_]*\}/i.test(l)&&(l=l.replace(/\{([a-z_][a-z0-9_]*)\}/gi,(e,t)=>{let n=r[t];return n==null?``:encodeURIComponent(String(n))}));let u=l.startsWith(`http`)?l:`${l}`,d=e.bodyShape&&typeof e.bodyShape==`object`&&e.bodyShape.wrap?e.bodyShape.wrap:void 0,f=d?{[d]:s}:{...s};if(r&&e.recordIdParam){let t=r[e.recordIdField||`id`];t!=null&&(f[e.recordIdParam]=t)}/\/api\/v1\/auth\//.test(l)&&!f.organizationId&&c?.id&&(f.organizationId=c.id),e.bodyExtra&&typeof e.bodyExtra==`object`&&Object.assign(f,Z(e.bodyExtra,o));let p=(e.method||`POST`).toUpperCase(),m={method:p,headers:{"Content-Type":`application/json`},credentials:`include`};p!==`GET`&&p!==`DELETE`&&(m.body=JSON.stringify(f));let h=await W(u,m);if(!h.ok){let e=null;try{e=await h.json()}catch{}let t=oe(e);return t?(G(t),{success:!1}):{success:!1,error:e?.error||e?.message||`HTTP ${h.status}`}}let g=await h.json().catch(()=>({}));return e.refreshAfter!==!1&&S(),{success:!0,data:g,reload:e.refreshAfter!==!1}}let o=e.objectName||x,s=i._rowRecord,l={...i};delete l._rowRecord;let u=l.recordId??s?.[e.recordIdField||`id`];delete l.recordId,e.bodyExtra&&typeof e.bodyExtra==`object`&&Object.assign(l,e.bodyExtra),o&&typeof t?.execute==`function`?await t.execute(o,r,l):o&&u&&Object.keys(l).length>0&&typeof t?.update==`function`&&await t.update(o,u,l);let d;if(e.undoable&&o&&u&&s&&Object.keys(l).length>0&&typeof t?.update==`function`){let t={};for(let e of Object.keys(l))t[e]=s[e]??null;d={id:`undo-${o}-${u}-${Date.now()}`,type:`update`,objectName:o,recordId:String(u),timestamp:Date.now(),description:e.label||`Undo ${o}`,undoData:t,redoData:{...l}}}let f=e.refreshAfter!==!1;return f&&S(),{success:!0,reload:f,undo:d}}catch(e){return{success:!1,error:e.message}}},[t,x,W,c,S,G]),q=(0,z.useCallback)(async(e,t)=>{let n=e.target||e.name;if(!n)return{success:!1,error:`No flow target provided for flow action`};try{let r={...e.params||{}},i=r._rowRecord;delete r._rowRecord;let a=r.recordId??i?.id;if(a==null){let n=Array.isArray(t?.selectedRecords)?t.selectedRecords:[];if(n.length===1)a=n[0]?.id;else if(n.length>1)return{success:!1,error:`This flow runs on a single record — select exactly one row.`};else if(Q(e))return{success:!1,error:`This flow runs on a single record — select a row first.`}}a!=null&&r.recordId==null&&(r.recordId=a);let o=await W(`/api/v1/automation/${encodeURIComponent(n)}/trigger`,{method:`POST`,headers:{"Content-Type":`application/json`},body:JSON.stringify({recordId:a,objectName:e.objectName||x,params:r})}),s=await o.json().catch(()=>null);if(!o.ok||s&&s.success===!1)return{success:!1,error:s?.error||`Flow "${n}" failed (HTTP ${o.status})`};let c=s?.data??{};if(c.status===`paused`&&c.screen)return j({flowName:n,runId:c.runId,screen:c.screen}),{success:!0,silent:!0};let l=e.refreshAfter!==!1;return l&&S(),{success:!0,data:s?.data,reload:l}}catch(e){return{success:!1,error:e.message}}},[W,x,S]),J=(0,z.useCallback)(async(e,t)=>{let n=e.target||e.name;if(!n)return{success:!1,error:`No action target provided`};let r=e.params&&!Array.isArray(e.params)?{...e.params}:{},i=r._rowRecord;delete r._rowRecord;let a=e.recordIdField||`id`,o=r.recordId??i?.[a];if(o==null){let n=Array.isArray(t?.selectedRecords)?t.selectedRecords:[];if(n.length===1)o=n[0]?.[a];else if(n.length>1)return{success:!1,error:`This action runs on a single record — select exactly one row.`};else if(Q(e))return{success:!1,error:`This action runs on a single record — select a row first.`}}let s=`${n}:${o??``}`;if(F.current.has(s))return{success:!1,error:`Action already in progress`};F.current.add(s);let c=null;if(e.opensInNewTab)try{c=window.open(`about:blank`,`_blank`),c&&(c.document.write(`<!doctype html><meta charset="utf-8"><title>正在打开… Opening…</title><body style="margin:0;font-family:system-ui,sans-serif;display:flex;flex-direction:column;align-items:center;justify-content:center;height:100vh;gap:16px;color:#4b5563"><div style="width:28px;height:28px;border:3px solid #e5e7eb;border-top-color:#6366f1;border-radius:50%;animation:s .8s linear infinite"></div><div>正在为你打开环境…</div><style>@keyframes s{to{transform:rotate(360deg)}}</style></body>`),c.document.close())}catch{c=null}try{let t=typeof e.newTabUrl==`string`?e.newTabUrl:``;if(e.opensInNewTab&&t){if(o==null){if(c)try{c.close()}catch{}return{success:!1,error:`This action runs on a single record — no record id available.`}}let n=`${window.location.origin}${t.replace(`{recordId}`,encodeURIComponent(String(o)))}`;if(c)try{c.location.href=n}catch{try{c.close()}catch{}window.location.href=n}else{let e=null;try{e=window.open(n,`_blank`)}catch{e=null}e||N(`浏览器拦截了弹窗 / Popup blocked`,{description:`点击在新标签页打开环境`,action:{label:`打开环境`,onClick:()=>{try{window.open(n,`_blank`)}catch{window.location.href=n}}},duration:1e4})}return e.refreshAfter===!0&&S(),{success:!0}}let i=e.objectName||x||`global`,a=await W(`/api/v1/actions/${encodeURIComponent(i)}/${encodeURIComponent(n)}`,{method:`POST`,headers:{"Content-Type":`application/json`},body:JSON.stringify({recordId:o,params:r})}),s=await a.json().catch(()=>null);if(!a.ok||s&&s.success===!1){let e=s?.error||`Action "${n}" failed (HTTP ${a.status})`;if(c)try{c.close()}catch{}return{success:!1,error:e}}let l=e.refreshAfter!==!1;l&&S();let u=s?.data,d=u&&typeof u==`object`&&typeof u.redirectUrl==`string`?u.redirectUrl:null;if(d)if(c)try{c.location.href=d}catch{try{c.close()}catch{}window.location.href=d}else{let e=null;try{e=window.open(d,`_blank`)}catch{e=null}e||N(`浏览器拦截了弹窗 / Popup blocked`,{description:`点击在新标签页打开环境`,action:{label:`打开环境`,onClick:()=>{try{window.open(d,`_blank`)}catch{window.location.href=d}}},duration:1e4})}else if(c)try{c.close()}catch{}return{success:!0,data:u,reload:l}}catch(e){if(c)try{c.close()}catch{}return{success:!1,error:e.message}}finally{F.current.delete(s)}},[W,x,S]);return{confirmHandler:L,toastHandler:H,navigateHandler:U,paramCollectionHandler:R,resultDialogHandler:I,apiHandler:K,flowHandler:q,serverActionHandler:J,authFetch:W,openEntitlementDialog:G,actionProviderProps:(0,z.useMemo)(()=>({context:{...r?{objectName:r}:{},user:V,apiBase:``,activeOrganization:c?{id:c.id,slug:c.slug,name:c.name}:null},onConfirm:L,onToast:H,onNavigate:U,onParamCollection:R,onResultDialog:I,handlers:{api:K,flow:q,script:J,modal:J}}),[r,V,c,L,H,U,R,I,K,q,J]),dialogs:(0,B.jsxs)(B.Fragment,{children:[(0,B.jsx)(ie,{state:w,onOpenChange:e=>{e||T({open:!1,message:``})}}),(0,B.jsx)(ne,{state:E,onOpenChange:e=>{e||D({open:!1,params:[]})}}),(0,B.jsx)(ee,{state:O,onAcknowledge:()=>{O.resolve?.(),k({open:!1})}}),(0,B.jsx)(te,{state:A,authFetch:W,baseUrl:``,dataSource:t,objects:n,onClose:()=>j(null),onComplete:()=>{j(null),S()}}),(0,B.jsx)(ae,{state:M,apiBase:``,onOpenChange:e=>{e||P({open:!1})}})]})}}function le({children:e,...t}){let n=$(t);return(0,B.jsxs)(h,{...n.actionProviderProps,children:[e,n.dialogs]})}var ue=t({PageView:()=>de});function de(){let{t:e}=g(),{pageName:t}=r(),[n]=a(),{showDebug:o}=F(),l=s(),u=i(),d=c(),{pages:h,objects:_,getTypeStatus:b}=m(),{app:C}=P(),T=p(),[E,D]=(0,z.useState)(0),O=I(h,t,C?._packageId);if(!O){let n=b?.(`page`);return n===`idle`||n===`loading`?(0,B.jsx)(`div`,{className:`h-full flex items-center justify-center p-8`,"data-testid":`page-loading`,children:(0,B.jsx)(v,{className:`h-5 w-5 text-muted-foreground`})}):(0,B.jsx)(`div`,{className:`h-full flex items-center justify-center p-8`,children:(0,B.jsxs)(w,{children:[(0,B.jsx)(`div`,{className:`mx-auto mb-4 flex h-12 w-12 items-center justify-center rounded-full bg-muted`,children:(0,B.jsx)(x,{className:`h-6 w-6 text-muted-foreground`})}),(0,B.jsx)(S,{children:e(`empty.pageNotFound`)}),(0,B.jsx)(y,{children:e(`empty.pageNotFoundDescription`,{name:t})})]})})}let k=Object.fromEntries(n.entries()),j=u.pathname.match(/\/apps\/([^/]+)/)?.[1],M=d&&!!j&&!!t;return(0,B.jsx)(le,{dataSource:T,objects:_,onRefresh:()=>D(e=>e+1),children:(0,B.jsxs)(`div`,{className:`flex flex-row h-full w-full overflow-hidden relative`,children:[(0,B.jsxs)(`div`,{className:`flex-1 overflow-auto h-full relative`,children:[M&&(0,B.jsx)(`button`,{type:`button`,onClick:()=>{M&&l(`/apps/${j}/metadata/page/${encodeURIComponent(t)}`)},className:`absolute right-3 top-3 z-30 inline-flex h-7 w-7 items-center justify-center rounded-md border border-input bg-background/90 text-muted-foreground shadow-sm backdrop-blur hover:bg-accent hover:text-accent-foreground`,"data-testid":`page-edit-in-studio-button`,title:e(`common.editInStudio`,{defaultValue:`Edit in studio`}),"aria-label":e(`common.editInStudio`,{defaultValue:`Edit in studio`}),children:(0,B.jsx)(A,{className:`h-3.5 w-3.5`})}),O.interfaceConfig?.source?(0,B.jsx)(R,{page:O,reserveEditAffordance:M},E):(0,B.jsx)(f,{schema:{...O,type:O.type||`page`,context:{...O.context,params:k,refreshKey:E}}},E)]}),(0,B.jsx)(L,{open:o,sections:[{title:`Page Configuration`,data:O}]})]})})}export{q as a,K as i,$ as n,G as r,ue as t};
1
+ import{o as e,r as t}from"./rolldown-runtime-DAXXjFlN.js";import{_ as n,f as r,l as i,p as a,t as o,u as s}from"./vendor-react-slxo-5GC.js";import{d as c,f as l,m as u,n as d}from"./infrastructure-BySW-NB0.js";import{G as f,N as p,P as m,R as h,a as g,g as _}from"./framework-CUm99d5f.js";import{B as v,G as y,Ic as b,Io as x,J as S,Sr as C,W as w,_r as T,br as E,gr as D,hr as O,pr as k,ra as A,vr as j,yr as M}from"./ui-components-DvVVxGRS.js";import{r as N}from"./vendor-ui-utils-C1OpMExs.js";import"./MetadataProvider-DboJnyDA.js";import{r as P}from"./ExpressionProvider-CD5Qq5aY.js";import{c as ee,i as te,l as ne,r as re,u as ie}from"./RecordDetailView-BXq0yKAC.js";import{n as F,r as I,t as L}from"./MetadataInspector-Bayj0F4e.js";import{t as R}from"./InterfaceListPage-BqCFOLqM.js";var z=e(n(),1),B=o();function V(e,t){if(/^https?:\/\//i.test(e)||e.startsWith(`mailto:`))return{href:e,external:!e.startsWith(`mailto:`)};let n=(t||``).replace(/\/+$/,``);return{href:`${n}${e}`,external:!!n}}function H({cta:e,apiBase:t,primary:n,onNavigate:r}){let{href:i,external:a}=V(e.url,t);return(0,B.jsx)(C,{asChild:!0,variant:n?`default`:`outline`,size:`sm`,children:(0,B.jsx)(`a`,{href:i,onClick:r,...a?{target:`_blank`,rel:`noopener noreferrer`}:{},"data-testid":`entitlement-cta-${n?`primary`:`secondary`}`,children:e.label})})}function ae({state:e,apiBase:t,onOpenChange:n}){let r=e.spec;return(0,B.jsx)(k,{open:e.open,onOpenChange:e=>{e||n(!1)},children:(0,B.jsxs)(D,{"data-testid":`environment-entitlement-dialog`,children:[(0,B.jsxs)(M,{children:[(0,B.jsx)(E,{children:r?.title}),(0,B.jsx)(T,{children:r?.message})]}),(0,B.jsxs)(j,{children:[(0,B.jsx)(O,{children:`Close`}),r?.secondaryCta&&(0,B.jsx)(H,{cta:r.secondaryCta,apiBase:t,primary:!1,onNavigate:()=>n(!1)}),r?.cta&&(0,B.jsx)(H,{cta:r.cta,apiBase:t,primary:!0,onNavigate:()=>n(!1)})]})]})})}var U=new Set([`DEV_ENV_PLAN_LOCKED`,`DEV_ENV_LIMIT`,`PRODUCTION_ENV_LIMIT`]);function W(e){return typeof e==`string`&&U.has(e)}var G=`/settings/billing`;function oe(e){let t=e?.code;if(!W(t))return null;let n=typeof e?.error==`string`&&e.error?e.error:typeof e?.message==`string`?e.message:``,r=typeof e?.upgrade_url==`string`&&e.upgrade_url?e.upgrade_url:G,i=typeof e?.contact_url==`string`&&e.contact_url?e.contact_url:``;return t===`PRODUCTION_ENV_LIMIT`?{code:t,title:`You already have your production environment`,message:n||`Each organization includes exactly one production environment. Create a separate organization for another, or contact us about an Enterprise arrangement.`,cta:i?{label:`Contact sales`,url:i}:void 0}:{code:t,title:t===`DEV_ENV_PLAN_LOCKED`?`Development environments are a paid feature`:`Development environment limit reached`,message:n||(t===`DEV_ENV_PLAN_LOCKED`?`Your free plan includes one production environment. Upgrade to add development environments — build in dev, then publish to production.`:`Capacity scales with AI seats. Add an AI seat, or archive an unused development environment to free one up.`),cta:{label:`Upgrade plan`,url:r}}}function K(e){return e.hasProductionEnv?e.canCreateDevelopmentEnv===!1?`upgrade_for_development`:`add_development`:`setup_production`}function q(e){return{code:`DEV_ENV_PLAN_LOCKED`,title:`Development environments are a paid feature`,message:`${e.plan&&e.plan!==`free`?`your ${e.plan} plan`:`your free plan`} includes one production environment. Upgrade to add development environments — build in dev, then publish to production.`,cta:{label:`Upgrade plan`,url:e.upgradeUrl||`/settings/billing`}}}var J=/^\s*\{\{\s*page\.([A-Za-z_$][\w$]*(?:\.[A-Za-z_$][\w$]*)*)\s*\}\}\s*$/;function Y(e,t){let n=t;for(let t of e.split(`.`)){if(n==null)return;n=n[t]}return n}function se(e,t){if(!e.includes(`{{`))return e;let n=e.match(J);if(n){let e=Y(n[1],t);return e===void 0?``:e}return e.replace(/\{\{\s*page\.([A-Za-z_$][\w$]*(?:\.[A-Za-z_$][\w$]*)*)\s*\}\}/g,(e,n)=>{let r=Y(n,t);return r==null?``:String(r)})}function X(e,t){if(typeof e==`string`)return se(e,t);if(Array.isArray(e))return e.map(e=>X(e,t));if(e&&typeof e==`object`){let n={};for(let[r,i]of Object.entries(e))n[r]=X(i,t);return n}return e}function Z(e,t){return t?X(e,t):e}var ce={id:`current-user`,name:`Demo User`,isPlatformAdmin:!1};function Q(e){let t=e.locations;return Array.isArray(t)?t.some(e=>e===`list_item`||e===`record_header`||e===`record_more`||e===`record_section`):!1}function $(e){let{dataSource:t,objects:n,objectName:r,onRefresh:i}=e,a=s(),{user:o,activeOrganization:c}=l(),{systemPermissions:f}=d(),{fieldLabel:p,fieldOptionLabel:m,actionParamText:h,actionParamOptionLabel:g,actionDescription:v}=b(),y=(0,z.useMemo)(()=>r?n?.find(e=>e.name===r):void 0,[n,r]),x=r||y?.name,S=(0,z.useCallback)(()=>{i?.()},[i]),C=_({dataSource:t,onUndo:()=>{S(),N.success(`Change undone`)}}),[w,T]=(0,z.useState)({open:!1,message:``}),[E,D]=(0,z.useState)({open:!1,params:[]}),[O,k]=(0,z.useState)({open:!1}),[A,j]=(0,z.useState)(null),[M,P]=(0,z.useState)({open:!1}),F=(0,z.useRef)(new Set),I=(0,z.useCallback)((e,t)=>new Promise(n=>{k({open:!0,spec:e,data:t,resolve:n})}),[]),L=(0,z.useCallback)((e,t)=>new Promise(n=>{T({open:!0,message:e,options:t,resolve:n})}),[]),R=(0,z.useCallback)((e,t)=>new Promise(i=>{let a=t?.params&&!Array.isArray(t.params)?t.params._rowRecord:void 0,o=re(e,{objectName:r||y?.name||``,objects:n||[],fieldLabel:p,fieldOptionLabel:m,row:a}),s=r||y?.name;D({open:!0,params:o.map(e=>({...e,label:h(s,t?.name,e.name,`label`,e.label)??e.label,placeholder:h(s,t?.name,e.name,`placeholder`,e.placeholder)??e.placeholder,helpText:h(s,t?.name,e.name,`helpText`,e.helpText)??e.helpText,options:Array.isArray(e.options)?e.options.map(n=>({...n,label:g(s,t?.name,e.name,n.value,n.label)})):e.options})),title:t?.label||t?.title,description:v(s,t?.name,t?.description),resolve:i})}),[r,y,n,p,m,h,g]),V=o?{id:o.id,name:o.name,avatar:o.image,isPlatformAdmin:o?.isPlatformAdmin??!1,systemPermissions:f??[]}:{...ce,systemPermissions:f??[]},H=(0,z.useCallback)((e,t)=>{if(t?.type===`error`){N.error(e);return}if(t?.undo){N.success(e,{duration:t.duration,action:{label:t.undo.label||`Undo`,onClick:()=>{C.undo()}}});return}N.success(e,{duration:t?.duration})},[C]),U=(0,z.useCallback)((e,t)=>{t?.external||t?.newTab?window.open(e,`_blank`,`noopener,noreferrer`):a(e)},[a]),W=(0,z.useMemo)(()=>u(),[]),G=(0,z.useCallback)(e=>{P({open:!0,spec:e})},[]),K=(0,z.useCallback)(async(e,n)=>{try{let r=e.target||e.name,i=e.params||{},a=typeof r==`string`?r:``;if(a.startsWith(`/`)||/^https?:\/\//i.test(a)){let t={...i},r=t._rowRecord;delete t._rowRecord;let o=n?.pageVariables??void 0,s=Z(t,o),l=a;r&&/\{[a-z_][a-z0-9_]*\}/i.test(l)&&(l=l.replace(/\{([a-z_][a-z0-9_]*)\}/gi,(e,t)=>{let n=r[t];return n==null?``:encodeURIComponent(String(n))}));let u=l.startsWith(`http`)?l:`${l}`,d=e.bodyShape&&typeof e.bodyShape==`object`&&e.bodyShape.wrap?e.bodyShape.wrap:void 0,f=d?{[d]:s}:{...s};if(r&&e.recordIdParam){let t=r[e.recordIdField||`id`];t!=null&&(f[e.recordIdParam]=t)}/\/api\/v1\/auth\//.test(l)&&!f.organizationId&&c?.id&&(f.organizationId=c.id),e.bodyExtra&&typeof e.bodyExtra==`object`&&Object.assign(f,Z(e.bodyExtra,o));let p=(e.method||`POST`).toUpperCase(),m={method:p,headers:{"Content-Type":`application/json`},credentials:`include`};p!==`GET`&&p!==`DELETE`&&(m.body=JSON.stringify(f));let h=await W(u,m);if(!h.ok){let e=null;try{e=await h.json()}catch{}let t=oe(e);return t?(G(t),{success:!1}):{success:!1,error:e?.error||e?.message||`HTTP ${h.status}`}}let g=await h.json().catch(()=>({}));return e.refreshAfter!==!1&&S(),{success:!0,data:g,reload:e.refreshAfter!==!1}}let o=e.objectName||x,s=i._rowRecord,l={...i};delete l._rowRecord;let u=l.recordId??s?.[e.recordIdField||`id`];delete l.recordId,e.bodyExtra&&typeof e.bodyExtra==`object`&&Object.assign(l,e.bodyExtra),o&&typeof t?.execute==`function`?await t.execute(o,r,l):o&&u&&Object.keys(l).length>0&&typeof t?.update==`function`&&await t.update(o,u,l);let d;if(e.undoable&&o&&u&&s&&Object.keys(l).length>0&&typeof t?.update==`function`){let t={};for(let e of Object.keys(l))t[e]=s[e]??null;d={id:`undo-${o}-${u}-${Date.now()}`,type:`update`,objectName:o,recordId:String(u),timestamp:Date.now(),description:e.label||`Undo ${o}`,undoData:t,redoData:{...l}}}let f=e.refreshAfter!==!1;return f&&S(),{success:!0,reload:f,undo:d}}catch(e){return{success:!1,error:e.message}}},[t,x,W,c,S,G]),q=(0,z.useCallback)(async(e,t)=>{let n=e.target||e.name;if(!n)return{success:!1,error:`No flow target provided for flow action`};try{let r={...e.params||{}},i=r._rowRecord;delete r._rowRecord;let a=r.recordId??i?.id;if(a==null){let n=Array.isArray(t?.selectedRecords)?t.selectedRecords:[];if(n.length===1)a=n[0]?.id;else if(n.length>1)return{success:!1,error:`This flow runs on a single record — select exactly one row.`};else if(Q(e))return{success:!1,error:`This flow runs on a single record — select a row first.`}}a!=null&&r.recordId==null&&(r.recordId=a);let o=await W(`/api/v1/automation/${encodeURIComponent(n)}/trigger`,{method:`POST`,headers:{"Content-Type":`application/json`},body:JSON.stringify({recordId:a,objectName:e.objectName||x,params:r})}),s=await o.json().catch(()=>null);if(!o.ok||s&&s.success===!1)return{success:!1,error:s?.error||`Flow "${n}" failed (HTTP ${o.status})`};let c=s?.data??{};if(c.status===`paused`&&c.screen)return j({flowName:n,runId:c.runId,screen:c.screen}),{success:!0,silent:!0};let l=e.refreshAfter!==!1;return l&&S(),{success:!0,data:s?.data,reload:l}}catch(e){return{success:!1,error:e.message}}},[W,x,S]),J=(0,z.useCallback)(async(e,t)=>{let n=e.target||e.name;if(!n)return{success:!1,error:`No action target provided`};let r=e.params&&!Array.isArray(e.params)?{...e.params}:{},i=r._rowRecord;delete r._rowRecord;let a=e.recordIdField||`id`,o=r.recordId??i?.[a];if(o==null){let n=Array.isArray(t?.selectedRecords)?t.selectedRecords:[];if(n.length===1)o=n[0]?.[a];else if(n.length>1)return{success:!1,error:`This action runs on a single record — select exactly one row.`};else if(Q(e))return{success:!1,error:`This action runs on a single record — select a row first.`}}let s=`${n}:${o??``}`;if(F.current.has(s))return{success:!1,error:`Action already in progress`};F.current.add(s);let c=null;if(e.opensInNewTab)try{c=window.open(`about:blank`,`_blank`),c&&(c.document.write(`<!doctype html><meta charset="utf-8"><title>正在打开… Opening…</title><body style="margin:0;font-family:system-ui,sans-serif;display:flex;flex-direction:column;align-items:center;justify-content:center;height:100vh;gap:16px;color:#4b5563"><div style="width:28px;height:28px;border:3px solid #e5e7eb;border-top-color:#6366f1;border-radius:50%;animation:s .8s linear infinite"></div><div>正在为你打开环境…</div><style>@keyframes s{to{transform:rotate(360deg)}}</style></body>`),c.document.close())}catch{c=null}try{let t=typeof e.newTabUrl==`string`?e.newTabUrl:``;if(e.opensInNewTab&&t){if(o==null){if(c)try{c.close()}catch{}return{success:!1,error:`This action runs on a single record — no record id available.`}}let n=`${window.location.origin}${t.replace(`{recordId}`,encodeURIComponent(String(o)))}`;if(c)try{c.location.href=n}catch{try{c.close()}catch{}window.location.href=n}else{let e=null;try{e=window.open(n,`_blank`)}catch{e=null}e||N(`浏览器拦截了弹窗 / Popup blocked`,{description:`点击在新标签页打开环境`,action:{label:`打开环境`,onClick:()=>{try{window.open(n,`_blank`)}catch{window.location.href=n}}},duration:1e4})}return e.refreshAfter===!0&&S(),{success:!0}}let i=e.objectName||x||`global`,a=await W(`/api/v1/actions/${encodeURIComponent(i)}/${encodeURIComponent(n)}`,{method:`POST`,headers:{"Content-Type":`application/json`},body:JSON.stringify({recordId:o,params:r})}),s=await a.json().catch(()=>null);if(!a.ok||s&&s.success===!1){let e=s?.error||`Action "${n}" failed (HTTP ${a.status})`;if(c)try{c.close()}catch{}return{success:!1,error:e}}let l=e.refreshAfter!==!1;l&&S();let u=s?.data,d=u&&typeof u==`object`&&typeof u.redirectUrl==`string`?u.redirectUrl:null;if(d)if(c)try{c.location.href=d}catch{try{c.close()}catch{}window.location.href=d}else{let e=null;try{e=window.open(d,`_blank`)}catch{e=null}e||N(`浏览器拦截了弹窗 / Popup blocked`,{description:`点击在新标签页打开环境`,action:{label:`打开环境`,onClick:()=>{try{window.open(d,`_blank`)}catch{window.location.href=d}}},duration:1e4})}else if(c)try{c.close()}catch{}return{success:!0,data:u,reload:l}}catch(e){if(c)try{c.close()}catch{}return{success:!1,error:e.message}}finally{F.current.delete(s)}},[W,x,S]);return{confirmHandler:L,toastHandler:H,navigateHandler:U,paramCollectionHandler:R,resultDialogHandler:I,apiHandler:K,flowHandler:q,serverActionHandler:J,authFetch:W,openEntitlementDialog:G,actionProviderProps:(0,z.useMemo)(()=>({context:{...r?{objectName:r}:{},user:V,apiBase:``,activeOrganization:c?{id:c.id,slug:c.slug,name:c.name}:null},onConfirm:L,onToast:H,onNavigate:U,onParamCollection:R,onResultDialog:I,handlers:{api:K,flow:q,script:J,modal:J}}),[r,V,c,L,H,U,R,I,K,q,J]),dialogs:(0,B.jsxs)(B.Fragment,{children:[(0,B.jsx)(ie,{state:w,onOpenChange:e=>{e||T({open:!1,message:``})}}),(0,B.jsx)(ne,{state:E,onOpenChange:e=>{e||D({open:!1,params:[]})}}),(0,B.jsx)(ee,{state:O,onAcknowledge:()=>{O.resolve?.(),k({open:!1})}}),(0,B.jsx)(te,{state:A,authFetch:W,baseUrl:``,dataSource:t,objects:n,onClose:()=>j(null),onComplete:()=>{j(null),S()}}),(0,B.jsx)(ae,{state:M,apiBase:``,onOpenChange:e=>{e||P({open:!1})}})]})}}function le({children:e,...t}){let n=$(t);return(0,B.jsxs)(h,{...n.actionProviderProps,children:[e,n.dialogs]})}var ue=t({PageView:()=>de});function de(){let{t:e}=g(),{pageName:t}=r(),[n]=a(),{showDebug:o}=F(),l=s(),u=i(),d=c(),{pages:h,objects:_,getTypeStatus:b}=m(),{app:C}=P(),T=p(),[E,D]=(0,z.useState)(0),O=I(h,t,C?._packageId);if(!O){let n=b?.(`page`);return n===`idle`||n===`loading`?(0,B.jsx)(`div`,{className:`h-full flex items-center justify-center p-8`,"data-testid":`page-loading`,children:(0,B.jsx)(v,{className:`h-5 w-5 text-muted-foreground`})}):(0,B.jsx)(`div`,{className:`h-full flex items-center justify-center p-8`,children:(0,B.jsxs)(w,{children:[(0,B.jsx)(`div`,{className:`mx-auto mb-4 flex h-12 w-12 items-center justify-center rounded-full bg-muted`,children:(0,B.jsx)(x,{className:`h-6 w-6 text-muted-foreground`})}),(0,B.jsx)(S,{children:e(`empty.pageNotFound`)}),(0,B.jsx)(y,{children:e(`empty.pageNotFoundDescription`,{name:t})})]})})}let k=Object.fromEntries(n.entries()),j=u.pathname.match(/\/apps\/([^/]+)/)?.[1],M=d&&!!j&&!!t;return(0,B.jsx)(le,{dataSource:T,objects:_,onRefresh:()=>D(e=>e+1),children:(0,B.jsxs)(`div`,{className:`flex flex-row h-full w-full overflow-hidden relative`,children:[(0,B.jsxs)(`div`,{className:`flex-1 overflow-auto h-full relative`,children:[M&&(0,B.jsx)(`button`,{type:`button`,onClick:()=>{M&&l(`/apps/${j}/metadata/page/${encodeURIComponent(t)}`)},className:`absolute right-3 top-3 z-30 inline-flex h-7 w-7 items-center justify-center rounded-md border border-input bg-background/90 text-muted-foreground shadow-sm backdrop-blur hover:bg-accent hover:text-accent-foreground`,"data-testid":`page-edit-in-studio-button`,title:e(`common.editInStudio`,{defaultValue:`Edit in studio`}),"aria-label":e(`common.editInStudio`,{defaultValue:`Edit in studio`}),children:(0,B.jsx)(A,{className:`h-3.5 w-3.5`})}),O.interfaceConfig?.source?(0,B.jsx)(R,{page:O,reserveEditAffordance:M},E):(0,B.jsx)(f,{schema:{...O,type:O.type||`page`,context:{...O.context,params:k,refreshKey:E}}},E)]}),(0,B.jsx)(L,{open:o,sections:[{title:`Page Configuration`,data:O}]})]})})}export{q as a,K as i,$ as n,G as r,ue as t};
@@ -1 +1 @@
1
- import{o as e}from"./rolldown-runtime-DAXXjFlN.js";import{_ as t,t as n}from"./vendor-react-slxo-5GC.js";import{f as r,o as i}from"./infrastructure-BySW-NB0.js";import{Ba as a,Fs as o,Ms as s,Rr as c,Sr as l,Vr as u,cn as d,cr as f,dr as p,er as m,fn as h,ir as g,kr as _,lr as v,nr as y,or as b,rr as x,sr as S,tr as C,ur as w,w as T,za as E}from"./ui-components-DlauVk27.js";var D=e(t(),1),O=n();function k(){let{user:e,updateUser:t,isLoading:n,changePassword:E,setInitialPassword:k,hasLocalPassword:j}=r(),{upload:M}=T(),[N,P]=(0,D.useState)(e?.name??``),[F,I]=(0,D.useState)(!1),[L,R]=(0,D.useState)(null),z=(0,D.useRef)(null),[B,V]=(0,D.useState)(!1),[H,U]=(0,D.useState)(null);return(0,D.useEffect)(()=>{P(e?.name??``)},[e?.name]),e?(0,O.jsxs)(`div`,{className:`flex flex-col gap-4 sm:gap-6 p-4 sm:p-6 max-w-2xl`,children:[(0,O.jsxs)(`div`,{className:`min-w-0`,children:[(0,O.jsx)(`h1`,{className:`text-xl sm:text-2xl font-bold tracking-tight`,children:`Profile`}),(0,O.jsx)(`p`,{className:`text-sm text-muted-foreground mt-1`,children:`Manage your account settings`})]}),(0,O.jsx)(m,{children:(0,O.jsxs)(C,{className:`pt-6`,children:[(0,O.jsxs)(`div`,{className:`flex items-center gap-4`,children:[(0,O.jsxs)(S,{className:`h-16 w-16`,children:[(0,O.jsx)(v,{src:e.image??void 0,alt:e.name??`User`}),(0,O.jsx)(f,{className:`text-lg bg-primary text-primary-foreground`,children:i(e)})]}),(0,O.jsxs)(`div`,{className:`min-w-0 flex-1`,children:[(0,O.jsx)(`p`,{className:`text-lg font-semibold truncate`,children:e.name??`User`}),(0,O.jsx)(`p`,{className:`text-sm text-muted-foreground truncate`,children:e.email}),(0,O.jsx)(b,{variant:`secondary`,className:`mt-1`,children:e.role??`member`})]}),(0,O.jsxs)(`div`,{className:`flex flex-col gap-2 shrink-0`,children:[(0,O.jsx)(`input`,{ref:z,type:`file`,accept:`image/*`,className:`hidden`,onChange:async e=>{let n=e.target.files?.[0];if(z.current&&(z.current.value=``),n){V(!0),U(null);try{await t({image:(await M(n)).url})}catch(e){U(e instanceof Error?e.message:String(e))}finally{V(!1)}}},"data-testid":`profile-avatar-file`}),(0,O.jsxs)(l,{type:`button`,variant:`outline`,size:`sm`,disabled:B,onClick:()=>z.current?.click(),"data-testid":`profile-avatar-upload-btn`,children:[B?(0,O.jsx)(a,{className:`mr-2 h-4 w-4 animate-spin`}):(0,O.jsx)(u,{className:`mr-2 h-4 w-4`}),e.image?`Replace`:`Upload`]}),e.image&&(0,O.jsxs)(l,{type:`button`,variant:`ghost`,size:`sm`,disabled:B,onClick:async()=>{V(!0),U(null);try{await t({image:null})}catch(e){U(e instanceof Error?e.message:String(e))}finally{V(!1)}},"data-testid":`profile-avatar-remove-btn`,children:[(0,O.jsx)(_,{className:`mr-2 h-4 w-4`}),`Remove`]})]})]}),H&&(0,O.jsxs)(w,{variant:`destructive`,className:`mt-4`,children:[(0,O.jsx)(o,{className:`h-4 w-4`}),(0,O.jsx)(p,{children:H})]})]})}),(0,O.jsxs)(m,{children:[(0,O.jsxs)(x,{children:[(0,O.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,O.jsx)(c,{className:`h-4 w-4 text-muted-foreground`}),(0,O.jsx)(g,{className:`text-base sm:text-lg`,children:`Personal Information`})]}),(0,O.jsx)(y,{children:`Update your name and view account details`})]}),(0,O.jsx)(C,{children:(0,O.jsxs)(`form`,{onSubmit:async e=>{e.preventDefault(),R(null),I(!1);try{await t({name:N}),I(!0)}catch(e){R(e instanceof Error?e.message:String(e))}},className:`space-y-4`,children:[L&&(0,O.jsxs)(w,{variant:`destructive`,children:[(0,O.jsx)(o,{className:`h-4 w-4`}),(0,O.jsx)(p,{children:L})]}),F&&(0,O.jsxs)(w,{children:[(0,O.jsx)(s,{className:`h-4 w-4 text-green-600`}),(0,O.jsx)(p,{className:`text-green-800 dark:text-green-400`,children:`Profile updated successfully.`})]}),(0,O.jsxs)(`div`,{className:`space-y-2`,children:[(0,O.jsx)(h,{htmlFor:`profile-name`,children:`Name`}),(0,O.jsx)(d,{id:`profile-name`,type:`text`,value:N,onChange:e=>P(e.target.value),required:!0,"aria-required":`true`,disabled:n})]}),(0,O.jsxs)(`div`,{className:`space-y-2`,children:[(0,O.jsx)(h,{htmlFor:`profile-email`,children:`Email`}),(0,O.jsx)(d,{id:`profile-email`,type:`email`,value:e.email,disabled:!0,className:`bg-muted text-muted-foreground`}),(0,O.jsx)(`p`,{className:`text-xs text-muted-foreground`,children:`Email cannot be changed.`})]}),(0,O.jsxs)(`div`,{className:`space-y-2`,children:[(0,O.jsx)(h,{children:`Role`}),(0,O.jsx)(d,{type:`text`,value:e.role??`member`,disabled:!0,className:`bg-muted text-muted-foreground`})]}),(0,O.jsx)(l,{type:`submit`,disabled:n,className:`w-full sm:w-auto`,children:n?`Saving…`:`Save Changes`})]})})]}),(0,O.jsx)(A,{changePassword:E,setInitialPassword:k,hasLocalPassword:j})]}):null}function A({changePassword:e,setInitialPassword:t,hasLocalPassword:n,highlight:r,onPasswordSet:i}){let[a,c]=(0,D.useState)(null),[u,f]=(0,D.useState)(``),[_,v]=(0,D.useState)(``),[b,S]=(0,D.useState)(``),[T,k]=(0,D.useState)(!1),[A,j]=(0,D.useState)(null),[M,N]=(0,D.useState)(null);(0,D.useEffect)(()=>{let e=!1;return n().then(t=>{e||c(t)}).catch(()=>{e||c(!1)}),()=>{e=!0}},[n]);let P=()=>{f(``),v(``),S(``)},F=async n=>{if(n.preventDefault(),j(null),N(null),_.length<8){j(`Password must be at least 8 characters`);return}if(_!==b){j(`Passwords do not match`);return}k(!0);try{if(a){if(!u){j(`Enter your current password`),k(!1);return}await e(u,_),N(`Password changed.`)}else await t(_),N(`Local password set. You can now sign in with email and password on this environment.`),c(!0),i?.();P()}catch(e){j(e instanceof Error?e.message:String(e))}finally{k(!1)}},I=a===null;return(0,O.jsxs)(m,{className:r?`ring-2 ring-amber-300 dark:ring-amber-700`:void 0,children:[(0,O.jsxs)(x,{children:[(0,O.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,O.jsx)(E,{className:`h-4 w-4 text-muted-foreground`}),(0,O.jsx)(g,{className:`text-base sm:text-lg`,children:a?`Change Password`:`Set Local Password`})]}),(0,O.jsx)(y,{children:a?`Update the password you use to sign in to this environment.`:`You signed in via single sign-on. Set a local password to also sign in with email and password on this environment.`})]}),(0,O.jsx)(C,{children:(0,O.jsxs)(`form`,{onSubmit:F,className:`space-y-4 max-w-md`,children:[a&&(0,O.jsxs)(`div`,{className:`space-y-2`,children:[(0,O.jsx)(h,{htmlFor:`current-password`,children:`Current password`}),(0,O.jsx)(d,{id:`current-password`,type:`password`,autoComplete:`current-password`,value:u,onChange:e=>f(e.target.value),disabled:T||I,required:!0})]}),(0,O.jsxs)(`div`,{className:`space-y-2`,children:[(0,O.jsx)(h,{htmlFor:`new-password`,children:a?`New password`:`Password`}),(0,O.jsx)(d,{id:`new-password`,type:`password`,autoComplete:`new-password`,value:_,onChange:e=>v(e.target.value),disabled:T||I,minLength:8,required:!0})]}),(0,O.jsxs)(`div`,{className:`space-y-2`,children:[(0,O.jsx)(h,{htmlFor:`confirm-password`,children:`Confirm password`}),(0,O.jsx)(d,{id:`confirm-password`,type:`password`,autoComplete:`new-password`,value:b,onChange:e=>S(e.target.value),disabled:T||I,minLength:8,required:!0})]}),A&&(0,O.jsxs)(w,{variant:`destructive`,children:[(0,O.jsx)(o,{className:`h-4 w-4`}),(0,O.jsx)(p,{children:A})]}),M&&(0,O.jsxs)(w,{children:[(0,O.jsx)(s,{className:`h-4 w-4`}),(0,O.jsx)(p,{children:M})]}),(0,O.jsx)(l,{type:`submit`,disabled:T||I,className:`w-full sm:w-auto`,children:T?`Saving…`:a?`Change password`:`Set password`})]})})]})}export{k as ProfilePage};
1
+ import{o as e}from"./rolldown-runtime-DAXXjFlN.js";import{_ as t,t as n}from"./vendor-react-slxo-5GC.js";import{f as r,o as i}from"./infrastructure-BySW-NB0.js";import{Ba as a,Fs as o,Ms as s,Rr as c,Sr as l,Vr as u,cn as d,cr as f,dr as p,er as m,fn as h,ir as g,kr as _,lr as v,nr as y,or as b,rr as x,sr as S,tr as C,ur as w,w as T,za as E}from"./ui-components-DvVVxGRS.js";var D=e(t(),1),O=n();function k(){let{user:e,updateUser:t,isLoading:n,changePassword:E,setInitialPassword:k,hasLocalPassword:j}=r(),{upload:M}=T(),[N,P]=(0,D.useState)(e?.name??``),[F,I]=(0,D.useState)(!1),[L,R]=(0,D.useState)(null),z=(0,D.useRef)(null),[B,V]=(0,D.useState)(!1),[H,U]=(0,D.useState)(null);return(0,D.useEffect)(()=>{P(e?.name??``)},[e?.name]),e?(0,O.jsxs)(`div`,{className:`flex flex-col gap-4 sm:gap-6 p-4 sm:p-6 max-w-2xl`,children:[(0,O.jsxs)(`div`,{className:`min-w-0`,children:[(0,O.jsx)(`h1`,{className:`text-xl sm:text-2xl font-bold tracking-tight`,children:`Profile`}),(0,O.jsx)(`p`,{className:`text-sm text-muted-foreground mt-1`,children:`Manage your account settings`})]}),(0,O.jsx)(m,{children:(0,O.jsxs)(C,{className:`pt-6`,children:[(0,O.jsxs)(`div`,{className:`flex items-center gap-4`,children:[(0,O.jsxs)(S,{className:`h-16 w-16`,children:[(0,O.jsx)(v,{src:e.image??void 0,alt:e.name??`User`}),(0,O.jsx)(f,{className:`text-lg bg-primary text-primary-foreground`,children:i(e)})]}),(0,O.jsxs)(`div`,{className:`min-w-0 flex-1`,children:[(0,O.jsx)(`p`,{className:`text-lg font-semibold truncate`,children:e.name??`User`}),(0,O.jsx)(`p`,{className:`text-sm text-muted-foreground truncate`,children:e.email}),(0,O.jsx)(b,{variant:`secondary`,className:`mt-1`,children:e.role??`member`})]}),(0,O.jsxs)(`div`,{className:`flex flex-col gap-2 shrink-0`,children:[(0,O.jsx)(`input`,{ref:z,type:`file`,accept:`image/*`,className:`hidden`,onChange:async e=>{let n=e.target.files?.[0];if(z.current&&(z.current.value=``),n){V(!0),U(null);try{await t({image:(await M(n)).url})}catch(e){U(e instanceof Error?e.message:String(e))}finally{V(!1)}}},"data-testid":`profile-avatar-file`}),(0,O.jsxs)(l,{type:`button`,variant:`outline`,size:`sm`,disabled:B,onClick:()=>z.current?.click(),"data-testid":`profile-avatar-upload-btn`,children:[B?(0,O.jsx)(a,{className:`mr-2 h-4 w-4 animate-spin`}):(0,O.jsx)(u,{className:`mr-2 h-4 w-4`}),e.image?`Replace`:`Upload`]}),e.image&&(0,O.jsxs)(l,{type:`button`,variant:`ghost`,size:`sm`,disabled:B,onClick:async()=>{V(!0),U(null);try{await t({image:null})}catch(e){U(e instanceof Error?e.message:String(e))}finally{V(!1)}},"data-testid":`profile-avatar-remove-btn`,children:[(0,O.jsx)(_,{className:`mr-2 h-4 w-4`}),`Remove`]})]})]}),H&&(0,O.jsxs)(w,{variant:`destructive`,className:`mt-4`,children:[(0,O.jsx)(o,{className:`h-4 w-4`}),(0,O.jsx)(p,{children:H})]})]})}),(0,O.jsxs)(m,{children:[(0,O.jsxs)(x,{children:[(0,O.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,O.jsx)(c,{className:`h-4 w-4 text-muted-foreground`}),(0,O.jsx)(g,{className:`text-base sm:text-lg`,children:`Personal Information`})]}),(0,O.jsx)(y,{children:`Update your name and view account details`})]}),(0,O.jsx)(C,{children:(0,O.jsxs)(`form`,{onSubmit:async e=>{e.preventDefault(),R(null),I(!1);try{await t({name:N}),I(!0)}catch(e){R(e instanceof Error?e.message:String(e))}},className:`space-y-4`,children:[L&&(0,O.jsxs)(w,{variant:`destructive`,children:[(0,O.jsx)(o,{className:`h-4 w-4`}),(0,O.jsx)(p,{children:L})]}),F&&(0,O.jsxs)(w,{children:[(0,O.jsx)(s,{className:`h-4 w-4 text-green-600`}),(0,O.jsx)(p,{className:`text-green-800 dark:text-green-400`,children:`Profile updated successfully.`})]}),(0,O.jsxs)(`div`,{className:`space-y-2`,children:[(0,O.jsx)(h,{htmlFor:`profile-name`,children:`Name`}),(0,O.jsx)(d,{id:`profile-name`,type:`text`,value:N,onChange:e=>P(e.target.value),required:!0,"aria-required":`true`,disabled:n})]}),(0,O.jsxs)(`div`,{className:`space-y-2`,children:[(0,O.jsx)(h,{htmlFor:`profile-email`,children:`Email`}),(0,O.jsx)(d,{id:`profile-email`,type:`email`,value:e.email,disabled:!0,className:`bg-muted text-muted-foreground`}),(0,O.jsx)(`p`,{className:`text-xs text-muted-foreground`,children:`Email cannot be changed.`})]}),(0,O.jsxs)(`div`,{className:`space-y-2`,children:[(0,O.jsx)(h,{children:`Role`}),(0,O.jsx)(d,{type:`text`,value:e.role??`member`,disabled:!0,className:`bg-muted text-muted-foreground`})]}),(0,O.jsx)(l,{type:`submit`,disabled:n,className:`w-full sm:w-auto`,children:n?`Saving…`:`Save Changes`})]})})]}),(0,O.jsx)(A,{changePassword:E,setInitialPassword:k,hasLocalPassword:j})]}):null}function A({changePassword:e,setInitialPassword:t,hasLocalPassword:n,highlight:r,onPasswordSet:i}){let[a,c]=(0,D.useState)(null),[u,f]=(0,D.useState)(``),[_,v]=(0,D.useState)(``),[b,S]=(0,D.useState)(``),[T,k]=(0,D.useState)(!1),[A,j]=(0,D.useState)(null),[M,N]=(0,D.useState)(null);(0,D.useEffect)(()=>{let e=!1;return n().then(t=>{e||c(t)}).catch(()=>{e||c(!1)}),()=>{e=!0}},[n]);let P=()=>{f(``),v(``),S(``)},F=async n=>{if(n.preventDefault(),j(null),N(null),_.length<8){j(`Password must be at least 8 characters`);return}if(_!==b){j(`Passwords do not match`);return}k(!0);try{if(a){if(!u){j(`Enter your current password`),k(!1);return}await e(u,_),N(`Password changed.`)}else await t(_),N(`Local password set. You can now sign in with email and password on this environment.`),c(!0),i?.();P()}catch(e){j(e instanceof Error?e.message:String(e))}finally{k(!1)}},I=a===null;return(0,O.jsxs)(m,{className:r?`ring-2 ring-amber-300 dark:ring-amber-700`:void 0,children:[(0,O.jsxs)(x,{children:[(0,O.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,O.jsx)(E,{className:`h-4 w-4 text-muted-foreground`}),(0,O.jsx)(g,{className:`text-base sm:text-lg`,children:a?`Change Password`:`Set Local Password`})]}),(0,O.jsx)(y,{children:a?`Update the password you use to sign in to this environment.`:`You signed in via single sign-on. Set a local password to also sign in with email and password on this environment.`})]}),(0,O.jsx)(C,{children:(0,O.jsxs)(`form`,{onSubmit:F,className:`space-y-4 max-w-md`,children:[a&&(0,O.jsxs)(`div`,{className:`space-y-2`,children:[(0,O.jsx)(h,{htmlFor:`current-password`,children:`Current password`}),(0,O.jsx)(d,{id:`current-password`,type:`password`,autoComplete:`current-password`,value:u,onChange:e=>f(e.target.value),disabled:T||I,required:!0})]}),(0,O.jsxs)(`div`,{className:`space-y-2`,children:[(0,O.jsx)(h,{htmlFor:`new-password`,children:a?`New password`:`Password`}),(0,O.jsx)(d,{id:`new-password`,type:`password`,autoComplete:`new-password`,value:_,onChange:e=>v(e.target.value),disabled:T||I,minLength:8,required:!0})]}),(0,O.jsxs)(`div`,{className:`space-y-2`,children:[(0,O.jsx)(h,{htmlFor:`confirm-password`,children:`Confirm password`}),(0,O.jsx)(d,{id:`confirm-password`,type:`password`,autoComplete:`new-password`,value:b,onChange:e=>S(e.target.value),disabled:T||I,minLength:8,required:!0})]}),A&&(0,O.jsxs)(w,{variant:`destructive`,children:[(0,O.jsx)(o,{className:`h-4 w-4`}),(0,O.jsx)(p,{children:A})]}),M&&(0,O.jsxs)(w,{children:[(0,O.jsx)(s,{className:`h-4 w-4`}),(0,O.jsx)(p,{children:M})]}),(0,O.jsx)(l,{type:`submit`,disabled:T||I,className:`w-full sm:w-auto`,children:T?`Saving…`:a?`Change password`:`Set password`})]})})]})}export{k as ProfilePage};
@@ -1 +1 @@
1
- import{o as e}from"./rolldown-runtime-DAXXjFlN.js";import{_ as t,t as n}from"./vendor-react-slxo-5GC.js";import{N as r}from"./framework-Bn8ShCi0.js";import{Di as i,Gi as a,Gn as o,Hi as ee,Jn as s,Kn as c,Sr as l,Wn as u,Xi as d,Yn as f,Yo as te,_t as p,cn as m,er as ne,fn as h,fs as re,ft as ie,gt as ae,ht as g,ir as oe,ls as se,mt as _,nr as ce,or as le,pt as ue,qa as de,qn as v,rr as fe,tr as pe}from"./ui-components-DlauVk27.js";import{r as y}from"./vendor-ui-utils-C1OpMExs.js";import"./src-CbqgiuxM.js";var b=e(t(),1),x=n();function me(e){return e?e.replace(/^\/+/,``).match(/^forms\/([^/?#]+)/i)?.[1]??null:null}function S(e){return e.trim().toLowerCase().replace(/[^a-z0-9-_]+/g,`-`).replace(/^-+|-+$/g,``)}function C(){let e=r()?.getClient?.(),[t,n]=(0,b.useState)([]),[C,he]=(0,b.useState)([]),[w,T]=(0,b.useState)(!0),[E,D]=(0,b.useState)(null),[ge,O]=(0,b.useState)(!1),[k,A]=(0,b.useState)(``),[j,M]=(0,b.useState)(``),[N,P]=(0,b.useState)(!1),[_e,F]=(0,b.useState)(!1),[I,L]=(0,b.useState)(null),[R,z]=(0,b.useState)(``),[B,V]=(0,b.useState)(`thank-you`),[H,U]=(0,b.useState)(``),[W,G]=(0,b.useState)(``),[K,q]=(0,b.useState)(``),[J,Y]=(0,b.useState)(!1),X=async()=>{if(!e?.meta?.getItems){D(`meta.getItems is not available on this client`),T(!1);return}T(!0),D(null);try{let t=await e.meta.getItems(`view`),r=Array.isArray(t)?t:Array.isArray(t?.items)?t.items:Array.isArray(t?.value)?t.value:[],i=[],a=[];for(let e of r){let t=e?.spec??e;if(!(t?.sections||t?.groups||t?.form||t?.type===`simple`||t?.type===`tabbed`||t?.type===`wizard`||t?.viewType===`form`))continue;let n=t?.sharing,r=n?.publicLink,o=me(r);n?.allowAnonymous&&o&&r?i.push({name:t?.name??e?.name,label:t?.label,object:t?.object,slug:o,publicLink:r,updatedAt:e?.updatedAt??e?.updated_at,spec:t}):a.push({name:t?.name??e?.name,label:t?.label,object:t?.object,spec:t})}n(i),he(a)}catch(e){D(e?.message??String(e))}finally{T(!1)}};(0,b.useEffect)(()=>{X()},[]);let ve=typeof window<`u`?window.location.origin:``,Z=e=>`${ve}/console/f/${e}`,ye=e=>`<iframe src="${Z(e)}" width="100%" height="640" frameborder="0" style="border:0;"></iframe>`,be=e=>`<iframe\n src={\`${Z(e)}\`}\n title="Public form"\n style={{ width: '100%', height: 640, border: 0 }}\n/>`,Q=async(e,t)=>{try{await navigator.clipboard.writeText(t),y.success(`Copied ${e}`)}catch{y.error(`Clipboard unavailable`)}},xe=async()=>{if(!k||!j)return;let t=C.find(e=>e.name===k);if(!t)return;let n=S(j);if(!n){y.error(`Invalid slug`);return}let r={...t.spec,sharing:{...t.spec.sharing??{},enabled:!0,allowAnonymous:!0,publicLink:`/forms/${n}`}};P(!0);try{await e.meta.saveItem(`view`,t.name,r),y.success(`Published ${t.name}`),O(!1),A(``),M(``),await X()}catch(e){y.error(`Publish failed: ${e?.message??e}`)}finally{P(!1)}},Se=e=>{L(e),z(e.slug);let t=e.spec?.submitBehavior;V(t?.kind??`thank-you`),U(t?.title??``),G(t?.message??``),q(t?.url??``),F(!0)},Ce=async()=>{if(!I)return;let t=S(R);if(!t){y.error(`Invalid slug`);return}let n;switch(B){case`thank-you`:n={kind:`thank-you`},H&&(n.title=H),W&&(n.message=W);break;case`redirect`:if(!K){y.error(`Redirect URL is required`);return}n={kind:`redirect`,url:K};break;case`continue`:case`next-record`:n={kind:B};break}let r={...I.spec,sharing:{...I.spec.sharing??{},enabled:!0,allowAnonymous:!0,publicLink:`/forms/${t}`},submitBehavior:n};Y(!0);try{await e.meta.saveItem(`view`,I.name,r),y.success(`Saved ${I.name}`),F(!1),L(null),await X()}catch(e){y.error(`Save failed: ${e?.message??e}`)}finally{Y(!1)}},$=t.length>0;return(0,x.jsxs)(`div`,{className:`flex flex-1 flex-col gap-4 p-4 md:p-6 overflow-auto`,children:[(0,x.jsxs)(ne,{children:[(0,x.jsxs)(fe,{className:`flex flex-row items-start justify-between gap-4 space-y-0`,children:[(0,x.jsxs)(`div`,{children:[(0,x.jsxs)(oe,{className:`flex items-center gap-2`,children:[(0,x.jsx)(a,{className:`h-4 w-4`}),`Public Forms`]}),(0,x.jsx)(ce,{children:`Forms anyone can fill out — no login required. Publish a form to get a shareable link; submissions land directly in the bound object.`})]}),(0,x.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,x.jsxs)(l,{variant:`default`,size:`sm`,onClick:()=>O(!0),disabled:C.length===0,title:C.length===0?`No non-public FormViews available`:`Publish a FormView`,children:[(0,x.jsx)(d,{className:`h-3.5 w-3.5`}),(0,x.jsx)(`span`,{className:`ml-1.5`,children:`Publish form…`})]}),(0,x.jsxs)(l,{variant:`outline`,size:`sm`,onClick:X,disabled:w,children:[(0,x.jsx)(ee,{className:`h-3.5 w-3.5 ${w?`animate-spin`:``}`}),(0,x.jsx)(`span`,{className:`ml-1.5`,children:`Refresh`})]})]})]}),(0,x.jsxs)(pe,{children:[E&&(0,x.jsx)(`div`,{className:`mb-3 rounded-md border border-destructive/40 bg-destructive/10 p-3 text-sm text-destructive`,children:E}),!w&&!$&&(0,x.jsxs)(`div`,{className:`rounded-md border border-dashed p-6 text-center text-sm text-muted-foreground`,children:[(0,x.jsx)(`p`,{className:`font-medium text-foreground`,children:`No public forms yet`}),(0,x.jsxs)(`p`,{className:`mt-1`,children:[`Click `,(0,x.jsx)(`strong`,{children:`Publish form…`}),` above to share an existing form, or build a new one in Views & Apps and mark it public.`]})]}),$&&(0,x.jsxs)(ie,{children:[(0,x.jsx)(ae,{children:(0,x.jsxs)(p,{children:[(0,x.jsx)(g,{children:`Name`}),(0,x.jsx)(g,{children:`Object`}),(0,x.jsx)(g,{children:`Slug`}),(0,x.jsx)(g,{children:`Public URL`}),(0,x.jsx)(g,{className:`text-right`,children:`Actions`})]})}),(0,x.jsx)(ue,{children:t.map(e=>{let t=Z(e.slug);return(0,x.jsxs)(p,{children:[(0,x.jsx)(_,{children:(0,x.jsxs)(`div`,{className:`flex flex-col`,children:[(0,x.jsx)(`span`,{className:`font-medium`,children:e.label??e.name}),(0,x.jsx)(`code`,{className:`text-xs text-muted-foreground`,children:e.name})]})}),(0,x.jsx)(_,{children:e.object?(0,x.jsx)(le,{variant:`secondary`,children:e.object}):(0,x.jsx)(`span`,{className:`text-muted-foreground`,children:`—`})}),(0,x.jsx)(_,{children:(0,x.jsx)(`code`,{className:`text-xs`,children:e.slug})}),(0,x.jsx)(_,{children:(0,x.jsxs)(`a`,{href:t,target:`_blank`,rel:`noreferrer`,className:`inline-flex items-center gap-1 text-xs text-primary underline-offset-2 hover:underline`,children:[t,(0,x.jsx)(te,{className:`h-3 w-3`})]})}),(0,x.jsx)(_,{className:`text-right`,children:(0,x.jsxs)(`div`,{className:`inline-flex gap-1`,children:[(0,x.jsx)(l,{variant:`ghost`,size:`sm`,title:`Copy URL`,onClick:()=>Q(`URL`,t),children:(0,x.jsx)(de,{className:`h-3.5 w-3.5`})}),(0,x.jsx)(l,{variant:`ghost`,size:`sm`,title:`Copy <iframe> embed`,onClick:()=>Q(`iframe snippet`,ye(e.slug)),children:(0,x.jsx)(re,{className:`h-3.5 w-3.5`})}),(0,x.jsx)(l,{variant:`ghost`,size:`sm`,title:`Copy React snippet`,onClick:()=>Q(`React snippet`,be(e.slug)),children:(0,x.jsx)(se,{className:`h-3.5 w-3.5`})}),(0,x.jsx)(l,{variant:`ghost`,size:`sm`,title:`Edit sharing & post-submit behavior`,onClick:()=>Se(e),children:(0,x.jsx)(i,{className:`h-3.5 w-3.5`})})]})})]},e.name)})})]})]})]}),(0,x.jsx)(u,{open:ge,onOpenChange:O,children:(0,x.jsxs)(o,{className:`sm:max-w-md`,children:[(0,x.jsxs)(s,{children:[(0,x.jsx)(f,{children:`Publish a FormView`}),(0,x.jsxs)(c,{children:[`Pick an existing FormView and turn it into a public form by enabling `,(0,x.jsx)(`code`,{className:`text-xs`,children:`sharing.allowAnonymous`}),` `,`and setting `,(0,x.jsx)(`code`,{className:`text-xs`,children:`publicLink`}),`.`]})]}),(0,x.jsxs)(`div`,{className:`space-y-3`,children:[(0,x.jsxs)(`div`,{className:`space-y-1.5`,children:[(0,x.jsx)(h,{htmlFor:`publish-view`,children:`FormView`}),(0,x.jsxs)(`select`,{id:`publish-view`,className:`flex h-9 w-full rounded-md border border-input bg-transparent px-3 py-1 text-sm shadow-sm`,value:k,onChange:e=>A(e.target.value),children:[(0,x.jsx)(`option`,{value:``,children:`— Select a FormView —`}),C.map(e=>(0,x.jsxs)(`option`,{value:e.name,children:[e.label??e.name,` (`,e.name,`) `,e.object?`· ${e.object}`:``]},e.name))]})]}),(0,x.jsxs)(`div`,{className:`space-y-1.5`,children:[(0,x.jsx)(h,{htmlFor:`publish-slug`,children:`URL slug`}),(0,x.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,x.jsx)(`span`,{className:`text-xs text-muted-foreground whitespace-nowrap`,children:`/console/f/`}),(0,x.jsx)(m,{id:`publish-slug`,placeholder:`contact-us`,value:j,onChange:e=>M(e.target.value)})]}),(0,x.jsx)(`p`,{className:`text-xs text-muted-foreground`,children:`Lowercase letters, digits, dashes and underscores only.`})]})]}),(0,x.jsxs)(v,{children:[(0,x.jsx)(l,{variant:`ghost`,onClick:()=>O(!1),disabled:N,children:`Cancel`}),(0,x.jsx)(l,{onClick:xe,disabled:N||!k||!j,children:N?`Publishing…`:`Publish`})]})]})}),(0,x.jsx)(u,{open:_e,onOpenChange:F,children:(0,x.jsxs)(o,{className:`sm:max-w-lg`,children:[(0,x.jsxs)(s,{children:[(0,x.jsx)(f,{children:I?`Edit ${I.label??I.name}`:`Edit form`}),(0,x.jsx)(c,{children:`Configure the public URL and what happens after submit.`})]}),(0,x.jsxs)(`div`,{className:`space-y-3`,children:[(0,x.jsxs)(`div`,{className:`space-y-1.5`,children:[(0,x.jsx)(h,{htmlFor:`edit-slug`,children:`URL slug`}),(0,x.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,x.jsx)(`span`,{className:`text-xs text-muted-foreground whitespace-nowrap`,children:`/console/f/`}),(0,x.jsx)(m,{id:`edit-slug`,value:R,onChange:e=>z(e.target.value)})]})]}),(0,x.jsxs)(`div`,{className:`space-y-1.5`,children:[(0,x.jsx)(h,{htmlFor:`edit-behavior`,children:`After submit`}),(0,x.jsxs)(`select`,{id:`edit-behavior`,className:`flex h-9 w-full rounded-md border border-input bg-transparent px-3 py-1 text-sm shadow-sm`,value:B,onChange:e=>V(e.target.value),children:[(0,x.jsx)(`option`,{value:`thank-you`,children:`Show a thank-you panel`}),(0,x.jsx)(`option`,{value:`redirect`,children:`Redirect to a URL`}),(0,x.jsx)(`option`,{value:`continue`,children:`Reset for another response`}),(0,x.jsx)(`option`,{value:`next-record`,children:`Advance to next record (internal queues)`})]})]}),B===`thank-you`&&(0,x.jsxs)(x.Fragment,{children:[(0,x.jsxs)(`div`,{className:`space-y-1.5`,children:[(0,x.jsx)(h,{htmlFor:`edit-tytitle`,children:`Title`}),(0,x.jsx)(m,{id:`edit-tytitle`,placeholder:`Thanks!`,value:H,onChange:e=>U(e.target.value)})]}),(0,x.jsxs)(`div`,{className:`space-y-1.5`,children:[(0,x.jsx)(h,{htmlFor:`edit-tymsg`,children:`Message`}),(0,x.jsx)(m,{id:`edit-tymsg`,placeholder:`Your submission has been received.`,value:W,onChange:e=>G(e.target.value)})]})]}),B===`redirect`&&(0,x.jsxs)(`div`,{className:`space-y-1.5`,children:[(0,x.jsx)(h,{htmlFor:`edit-url`,children:`Redirect URL`}),(0,x.jsx)(m,{id:`edit-url`,type:`url`,placeholder:`https://example.com/thanks`,value:K,onChange:e=>q(e.target.value)})]})]}),(0,x.jsxs)(v,{children:[(0,x.jsx)(l,{variant:`ghost`,onClick:()=>F(!1),disabled:J,children:`Cancel`}),(0,x.jsx)(l,{onClick:Ce,disabled:J||!R,children:J?`Saving…`:`Save`})]})]})})]})}export{C as PublicFormsPage};
1
+ import{o as e}from"./rolldown-runtime-DAXXjFlN.js";import{_ as t,t as n}from"./vendor-react-slxo-5GC.js";import{N as r}from"./framework-CUm99d5f.js";import{Di as i,Gi as a,Gn as o,Hi as ee,Jn as s,Kn as c,Sr as l,Wn as u,Xi as d,Yn as f,Yo as te,_t as p,cn as m,er as ne,fn as h,fs as re,ft as ie,gt as ae,ht as g,ir as oe,ls as se,mt as _,nr as ce,or as le,pt as ue,qa as de,qn as v,rr as fe,tr as pe}from"./ui-components-DvVVxGRS.js";import{r as y}from"./vendor-ui-utils-C1OpMExs.js";import"./src-DdEhFXgM.js";var b=e(t(),1),x=n();function me(e){return e?e.replace(/^\/+/,``).match(/^forms\/([^/?#]+)/i)?.[1]??null:null}function S(e){return e.trim().toLowerCase().replace(/[^a-z0-9-_]+/g,`-`).replace(/^-+|-+$/g,``)}function C(){let e=r()?.getClient?.(),[t,n]=(0,b.useState)([]),[C,he]=(0,b.useState)([]),[w,T]=(0,b.useState)(!0),[E,D]=(0,b.useState)(null),[ge,O]=(0,b.useState)(!1),[k,A]=(0,b.useState)(``),[j,M]=(0,b.useState)(``),[N,P]=(0,b.useState)(!1),[_e,F]=(0,b.useState)(!1),[I,L]=(0,b.useState)(null),[R,z]=(0,b.useState)(``),[B,V]=(0,b.useState)(`thank-you`),[H,U]=(0,b.useState)(``),[W,G]=(0,b.useState)(``),[K,q]=(0,b.useState)(``),[J,Y]=(0,b.useState)(!1),X=async()=>{if(!e?.meta?.getItems){D(`meta.getItems is not available on this client`),T(!1);return}T(!0),D(null);try{let t=await e.meta.getItems(`view`),r=Array.isArray(t)?t:Array.isArray(t?.items)?t.items:Array.isArray(t?.value)?t.value:[],i=[],a=[];for(let e of r){let t=e?.spec??e;if(!(t?.sections||t?.groups||t?.form||t?.type===`simple`||t?.type===`tabbed`||t?.type===`wizard`||t?.viewType===`form`))continue;let n=t?.sharing,r=n?.publicLink,o=me(r);n?.allowAnonymous&&o&&r?i.push({name:t?.name??e?.name,label:t?.label,object:t?.object,slug:o,publicLink:r,updatedAt:e?.updatedAt??e?.updated_at,spec:t}):a.push({name:t?.name??e?.name,label:t?.label,object:t?.object,spec:t})}n(i),he(a)}catch(e){D(e?.message??String(e))}finally{T(!1)}};(0,b.useEffect)(()=>{X()},[]);let ve=typeof window<`u`?window.location.origin:``,Z=e=>`${ve}/console/f/${e}`,ye=e=>`<iframe src="${Z(e)}" width="100%" height="640" frameborder="0" style="border:0;"></iframe>`,be=e=>`<iframe\n src={\`${Z(e)}\`}\n title="Public form"\n style={{ width: '100%', height: 640, border: 0 }}\n/>`,Q=async(e,t)=>{try{await navigator.clipboard.writeText(t),y.success(`Copied ${e}`)}catch{y.error(`Clipboard unavailable`)}},xe=async()=>{if(!k||!j)return;let t=C.find(e=>e.name===k);if(!t)return;let n=S(j);if(!n){y.error(`Invalid slug`);return}let r={...t.spec,sharing:{...t.spec.sharing??{},enabled:!0,allowAnonymous:!0,publicLink:`/forms/${n}`}};P(!0);try{await e.meta.saveItem(`view`,t.name,r),y.success(`Published ${t.name}`),O(!1),A(``),M(``),await X()}catch(e){y.error(`Publish failed: ${e?.message??e}`)}finally{P(!1)}},Se=e=>{L(e),z(e.slug);let t=e.spec?.submitBehavior;V(t?.kind??`thank-you`),U(t?.title??``),G(t?.message??``),q(t?.url??``),F(!0)},Ce=async()=>{if(!I)return;let t=S(R);if(!t){y.error(`Invalid slug`);return}let n;switch(B){case`thank-you`:n={kind:`thank-you`},H&&(n.title=H),W&&(n.message=W);break;case`redirect`:if(!K){y.error(`Redirect URL is required`);return}n={kind:`redirect`,url:K};break;case`continue`:case`next-record`:n={kind:B};break}let r={...I.spec,sharing:{...I.spec.sharing??{},enabled:!0,allowAnonymous:!0,publicLink:`/forms/${t}`},submitBehavior:n};Y(!0);try{await e.meta.saveItem(`view`,I.name,r),y.success(`Saved ${I.name}`),F(!1),L(null),await X()}catch(e){y.error(`Save failed: ${e?.message??e}`)}finally{Y(!1)}},$=t.length>0;return(0,x.jsxs)(`div`,{className:`flex flex-1 flex-col gap-4 p-4 md:p-6 overflow-auto`,children:[(0,x.jsxs)(ne,{children:[(0,x.jsxs)(fe,{className:`flex flex-row items-start justify-between gap-4 space-y-0`,children:[(0,x.jsxs)(`div`,{children:[(0,x.jsxs)(oe,{className:`flex items-center gap-2`,children:[(0,x.jsx)(a,{className:`h-4 w-4`}),`Public Forms`]}),(0,x.jsx)(ce,{children:`Forms anyone can fill out — no login required. Publish a form to get a shareable link; submissions land directly in the bound object.`})]}),(0,x.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,x.jsxs)(l,{variant:`default`,size:`sm`,onClick:()=>O(!0),disabled:C.length===0,title:C.length===0?`No non-public FormViews available`:`Publish a FormView`,children:[(0,x.jsx)(d,{className:`h-3.5 w-3.5`}),(0,x.jsx)(`span`,{className:`ml-1.5`,children:`Publish form…`})]}),(0,x.jsxs)(l,{variant:`outline`,size:`sm`,onClick:X,disabled:w,children:[(0,x.jsx)(ee,{className:`h-3.5 w-3.5 ${w?`animate-spin`:``}`}),(0,x.jsx)(`span`,{className:`ml-1.5`,children:`Refresh`})]})]})]}),(0,x.jsxs)(pe,{children:[E&&(0,x.jsx)(`div`,{className:`mb-3 rounded-md border border-destructive/40 bg-destructive/10 p-3 text-sm text-destructive`,children:E}),!w&&!$&&(0,x.jsxs)(`div`,{className:`rounded-md border border-dashed p-6 text-center text-sm text-muted-foreground`,children:[(0,x.jsx)(`p`,{className:`font-medium text-foreground`,children:`No public forms yet`}),(0,x.jsxs)(`p`,{className:`mt-1`,children:[`Click `,(0,x.jsx)(`strong`,{children:`Publish form…`}),` above to share an existing form, or build a new one in Views & Apps and mark it public.`]})]}),$&&(0,x.jsxs)(ie,{children:[(0,x.jsx)(ae,{children:(0,x.jsxs)(p,{children:[(0,x.jsx)(g,{children:`Name`}),(0,x.jsx)(g,{children:`Object`}),(0,x.jsx)(g,{children:`Slug`}),(0,x.jsx)(g,{children:`Public URL`}),(0,x.jsx)(g,{className:`text-right`,children:`Actions`})]})}),(0,x.jsx)(ue,{children:t.map(e=>{let t=Z(e.slug);return(0,x.jsxs)(p,{children:[(0,x.jsx)(_,{children:(0,x.jsxs)(`div`,{className:`flex flex-col`,children:[(0,x.jsx)(`span`,{className:`font-medium`,children:e.label??e.name}),(0,x.jsx)(`code`,{className:`text-xs text-muted-foreground`,children:e.name})]})}),(0,x.jsx)(_,{children:e.object?(0,x.jsx)(le,{variant:`secondary`,children:e.object}):(0,x.jsx)(`span`,{className:`text-muted-foreground`,children:`—`})}),(0,x.jsx)(_,{children:(0,x.jsx)(`code`,{className:`text-xs`,children:e.slug})}),(0,x.jsx)(_,{children:(0,x.jsxs)(`a`,{href:t,target:`_blank`,rel:`noreferrer`,className:`inline-flex items-center gap-1 text-xs text-primary underline-offset-2 hover:underline`,children:[t,(0,x.jsx)(te,{className:`h-3 w-3`})]})}),(0,x.jsx)(_,{className:`text-right`,children:(0,x.jsxs)(`div`,{className:`inline-flex gap-1`,children:[(0,x.jsx)(l,{variant:`ghost`,size:`sm`,title:`Copy URL`,onClick:()=>Q(`URL`,t),children:(0,x.jsx)(de,{className:`h-3.5 w-3.5`})}),(0,x.jsx)(l,{variant:`ghost`,size:`sm`,title:`Copy <iframe> embed`,onClick:()=>Q(`iframe snippet`,ye(e.slug)),children:(0,x.jsx)(re,{className:`h-3.5 w-3.5`})}),(0,x.jsx)(l,{variant:`ghost`,size:`sm`,title:`Copy React snippet`,onClick:()=>Q(`React snippet`,be(e.slug)),children:(0,x.jsx)(se,{className:`h-3.5 w-3.5`})}),(0,x.jsx)(l,{variant:`ghost`,size:`sm`,title:`Edit sharing & post-submit behavior`,onClick:()=>Se(e),children:(0,x.jsx)(i,{className:`h-3.5 w-3.5`})})]})})]},e.name)})})]})]})]}),(0,x.jsx)(u,{open:ge,onOpenChange:O,children:(0,x.jsxs)(o,{className:`sm:max-w-md`,children:[(0,x.jsxs)(s,{children:[(0,x.jsx)(f,{children:`Publish a FormView`}),(0,x.jsxs)(c,{children:[`Pick an existing FormView and turn it into a public form by enabling `,(0,x.jsx)(`code`,{className:`text-xs`,children:`sharing.allowAnonymous`}),` `,`and setting `,(0,x.jsx)(`code`,{className:`text-xs`,children:`publicLink`}),`.`]})]}),(0,x.jsxs)(`div`,{className:`space-y-3`,children:[(0,x.jsxs)(`div`,{className:`space-y-1.5`,children:[(0,x.jsx)(h,{htmlFor:`publish-view`,children:`FormView`}),(0,x.jsxs)(`select`,{id:`publish-view`,className:`flex h-9 w-full rounded-md border border-input bg-transparent px-3 py-1 text-sm shadow-sm`,value:k,onChange:e=>A(e.target.value),children:[(0,x.jsx)(`option`,{value:``,children:`— Select a FormView —`}),C.map(e=>(0,x.jsxs)(`option`,{value:e.name,children:[e.label??e.name,` (`,e.name,`) `,e.object?`· ${e.object}`:``]},e.name))]})]}),(0,x.jsxs)(`div`,{className:`space-y-1.5`,children:[(0,x.jsx)(h,{htmlFor:`publish-slug`,children:`URL slug`}),(0,x.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,x.jsx)(`span`,{className:`text-xs text-muted-foreground whitespace-nowrap`,children:`/console/f/`}),(0,x.jsx)(m,{id:`publish-slug`,placeholder:`contact-us`,value:j,onChange:e=>M(e.target.value)})]}),(0,x.jsx)(`p`,{className:`text-xs text-muted-foreground`,children:`Lowercase letters, digits, dashes and underscores only.`})]})]}),(0,x.jsxs)(v,{children:[(0,x.jsx)(l,{variant:`ghost`,onClick:()=>O(!1),disabled:N,children:`Cancel`}),(0,x.jsx)(l,{onClick:xe,disabled:N||!k||!j,children:N?`Publishing…`:`Publish`})]})]})}),(0,x.jsx)(u,{open:_e,onOpenChange:F,children:(0,x.jsxs)(o,{className:`sm:max-w-lg`,children:[(0,x.jsxs)(s,{children:[(0,x.jsx)(f,{children:I?`Edit ${I.label??I.name}`:`Edit form`}),(0,x.jsx)(c,{children:`Configure the public URL and what happens after submit.`})]}),(0,x.jsxs)(`div`,{className:`space-y-3`,children:[(0,x.jsxs)(`div`,{className:`space-y-1.5`,children:[(0,x.jsx)(h,{htmlFor:`edit-slug`,children:`URL slug`}),(0,x.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,x.jsx)(`span`,{className:`text-xs text-muted-foreground whitespace-nowrap`,children:`/console/f/`}),(0,x.jsx)(m,{id:`edit-slug`,value:R,onChange:e=>z(e.target.value)})]})]}),(0,x.jsxs)(`div`,{className:`space-y-1.5`,children:[(0,x.jsx)(h,{htmlFor:`edit-behavior`,children:`After submit`}),(0,x.jsxs)(`select`,{id:`edit-behavior`,className:`flex h-9 w-full rounded-md border border-input bg-transparent px-3 py-1 text-sm shadow-sm`,value:B,onChange:e=>V(e.target.value),children:[(0,x.jsx)(`option`,{value:`thank-you`,children:`Show a thank-you panel`}),(0,x.jsx)(`option`,{value:`redirect`,children:`Redirect to a URL`}),(0,x.jsx)(`option`,{value:`continue`,children:`Reset for another response`}),(0,x.jsx)(`option`,{value:`next-record`,children:`Advance to next record (internal queues)`})]})]}),B===`thank-you`&&(0,x.jsxs)(x.Fragment,{children:[(0,x.jsxs)(`div`,{className:`space-y-1.5`,children:[(0,x.jsx)(h,{htmlFor:`edit-tytitle`,children:`Title`}),(0,x.jsx)(m,{id:`edit-tytitle`,placeholder:`Thanks!`,value:H,onChange:e=>U(e.target.value)})]}),(0,x.jsxs)(`div`,{className:`space-y-1.5`,children:[(0,x.jsx)(h,{htmlFor:`edit-tymsg`,children:`Message`}),(0,x.jsx)(m,{id:`edit-tymsg`,placeholder:`Your submission has been received.`,value:W,onChange:e=>G(e.target.value)})]})]}),B===`redirect`&&(0,x.jsxs)(`div`,{className:`space-y-1.5`,children:[(0,x.jsx)(h,{htmlFor:`edit-url`,children:`Redirect URL`}),(0,x.jsx)(m,{id:`edit-url`,type:`url`,placeholder:`https://example.com/thanks`,value:K,onChange:e=>q(e.target.value)})]})]}),(0,x.jsxs)(v,{children:[(0,x.jsx)(l,{variant:`ghost`,onClick:()=>F(!1),disabled:J,children:`Cancel`}),(0,x.jsx)(l,{onClick:Ce,disabled:J||!R,children:J?`Saving…`:`Save`})]})]})})]})}export{C as PublicFormsPage};
@@ -1,4 +1,4 @@
1
- import{o as e,r as t,t as n}from"./rolldown-runtime-DAXXjFlN.js";import{_ as r,f as i,l as a,r as o,t as s,u as c}from"./vendor-react-slxo-5GC.js";import{f as l,m as u}from"./infrastructure-BySW-NB0.js";import{D as d,E as f,Ft as p,G as m,R as h,a as g,b as _,g as v,it as y,m as b,w as x,z as S}from"./framework-Bn8ShCi0.js";import{$n as C,Ac as w,Fc as T,G as ee,Gn as te,Hs as ne,Ic as re,J as ie,Jn as E,Jo as D,Jt as O,Kn as k,Kt as ae,Sr as A,T as oe,W as se,Wn as ce,Ws as le,Xt as ue,Yn as j,Yt as de,_r as fe,br as pe,cn as me,fn as he,gr as ge,hr as _e,ls as ve,mr as ye,pr as be,qn as M,qo as N,qt as P,rs as xe,st as Se,vr as Ce,yr as F}from"./ui-components-DlauVk27.js";import{r as I}from"./vendor-ui-utils-C1OpMExs.js";import{t as we}from"./plugin-form-BUDPowXG.js";import{i as Te,o as Ee,r as De,t as Oe}from"./useRecordApprovals-B_jxSZvZ.js";import{n as ke}from"./utils-Bixzg6Bz.js";import{n as Ae,t as je}from"./MetadataInspector-FQJn-0mY.js";import{c as Me,i as Ne,n as Pe,r as Fe,s as Ie}from"./plugins-views-ycDq-ZXC.js";import{t as Le}from"./ManagedByBadge-DtZfR2w_.js";import{t as Re}from"./skeletons-C2aQsjPE.js";var L=e(r(),1),R=s(),z=(0,L.createContext)(void 0);function ze({children:e}){let[t,n]=(0,L.useState)(`home`),[r,i]=(0,L.useState)(),[a,o]=(0,L.useState)(),s=(0,L.useMemo)(()=>({context:t,setContext:n,currentAppName:r,setCurrentAppName:i,recordTitle:a,setRecordTitle:o}),[t,r,a]);return(0,R.jsx)(z.Provider,{value:s,children:e})}function Be(){return(0,L.useContext)(z)||{context:`app`,setContext:()=>{},currentAppName:void 0,setCurrentAppName:()=>{},recordTitle:void 0,setRecordTitle:()=>{}}}function Ve(e){let{setRecordTitle:t}=Be();(0,L.useEffect)(()=>(t(e),()=>t(void 0)),[e,t])}var He=n(((e,t)=>{t.exports=function(){return typeof Promise==`function`&&Promise.prototype&&Promise.prototype.then}})),B=n((e=>{var t,n=[0,26,44,70,100,134,172,196,242,292,346,404,466,532,581,655,733,815,901,991,1085,1156,1258,1364,1474,1588,1706,1828,1921,2051,2185,2323,2465,2611,2761,2876,3034,3196,3362,3532,3706];e.getSymbolSize=function(e){if(!e)throw Error(`"version" cannot be null or undefined`);if(e<1||e>40)throw Error(`"version" should be in range from 1 to 40`);return e*4+17},e.getSymbolTotalCodewords=function(e){return n[e]},e.getBCHDigit=function(e){let t=0;for(;e!==0;)t++,e>>>=1;return t},e.setToSJISFunction=function(e){if(typeof e!=`function`)throw Error(`"toSJISFunc" is not a valid function.`);t=e},e.isKanjiModeEnabled=function(){return t!==void 0},e.toSJIS=function(e){return t(e)}})),Ue=n((e=>{e.L={bit:1},e.M={bit:0},e.Q={bit:3},e.H={bit:2};function t(t){if(typeof t!=`string`)throw Error(`Param is not a string`);switch(t.toLowerCase()){case`l`:case`low`:return e.L;case`m`:case`medium`:return e.M;case`q`:case`quartile`:return e.Q;case`h`:case`high`:return e.H;default:throw Error(`Unknown EC Level: `+t)}}e.isValid=function(e){return e&&e.bit!==void 0&&e.bit>=0&&e.bit<4},e.from=function(n,r){if(e.isValid(n))return n;try{return t(n)}catch{return r}}})),We=n(((e,t)=>{function n(){this.buffer=[],this.length=0}n.prototype={get:function(e){let t=Math.floor(e/8);return(this.buffer[t]>>>7-e%8&1)==1},put:function(e,t){for(let n=0;n<t;n++)this.putBit((e>>>t-n-1&1)==1)},getLengthInBits:function(){return this.length},putBit:function(e){let t=Math.floor(this.length/8);this.buffer.length<=t&&this.buffer.push(0),e&&(this.buffer[t]|=128>>>this.length%8),this.length++}},t.exports=n})),V=n(((e,t)=>{function n(e){if(!e||e<1)throw Error(`BitMatrix size must be defined and greater than 0`);this.size=e,this.data=new Uint8Array(e*e),this.reservedBit=new Uint8Array(e*e)}n.prototype.set=function(e,t,n,r){let i=e*this.size+t;this.data[i]=n,r&&(this.reservedBit[i]=!0)},n.prototype.get=function(e,t){return this.data[e*this.size+t]},n.prototype.xor=function(e,t,n){this.data[e*this.size+t]^=n},n.prototype.isReserved=function(e,t){return this.reservedBit[e*this.size+t]},t.exports=n})),Ge=n((e=>{var t=B().getSymbolSize;e.getRowColCoords=function(e){if(e===1)return[];let n=Math.floor(e/7)+2,r=t(e),i=r===145?26:Math.ceil((r-13)/(2*n-2))*2,a=[r-7];for(let e=1;e<n-1;e++)a[e]=a[e-1]-i;return a.push(6),a.reverse()},e.getPositions=function(t){let n=[],r=e.getRowColCoords(t),i=r.length;for(let e=0;e<i;e++)for(let t=0;t<i;t++)e===0&&t===0||e===0&&t===i-1||e===i-1&&t===0||n.push([r[e],r[t]]);return n}})),H=n((e=>{var t=B().getSymbolSize,n=7;e.getPositions=function(e){let r=t(e);return[[0,0],[r-n,0],[0,r-n]]}})),U=n((e=>{e.Patterns={PATTERN000:0,PATTERN001:1,PATTERN010:2,PATTERN011:3,PATTERN100:4,PATTERN101:5,PATTERN110:6,PATTERN111:7};var t={N1:3,N2:3,N3:40,N4:10};e.isValid=function(e){return e!=null&&e!==``&&!isNaN(e)&&e>=0&&e<=7},e.from=function(t){return e.isValid(t)?parseInt(t,10):void 0},e.getPenaltyN1=function(e){let n=e.size,r=0,i=0,a=0,o=null,s=null;for(let c=0;c<n;c++){i=a=0,o=s=null;for(let l=0;l<n;l++){let n=e.get(c,l);n===o?i++:(i>=5&&(r+=t.N1+(i-5)),o=n,i=1),n=e.get(l,c),n===s?a++:(a>=5&&(r+=t.N1+(a-5)),s=n,a=1)}i>=5&&(r+=t.N1+(i-5)),a>=5&&(r+=t.N1+(a-5))}return r},e.getPenaltyN2=function(e){let n=e.size,r=0;for(let t=0;t<n-1;t++)for(let i=0;i<n-1;i++){let n=e.get(t,i)+e.get(t,i+1)+e.get(t+1,i)+e.get(t+1,i+1);(n===4||n===0)&&r++}return r*t.N2},e.getPenaltyN3=function(e){let n=e.size,r=0,i=0,a=0;for(let t=0;t<n;t++){i=a=0;for(let o=0;o<n;o++)i=i<<1&2047|e.get(t,o),o>=10&&(i===1488||i===93)&&r++,a=a<<1&2047|e.get(o,t),o>=10&&(a===1488||a===93)&&r++}return r*t.N3},e.getPenaltyN4=function(e){let n=0,r=e.data.length;for(let t=0;t<r;t++)n+=e.data[t];return Math.abs(Math.ceil(n*100/r/5)-10)*t.N4};function n(t,n,r){switch(t){case e.Patterns.PATTERN000:return(n+r)%2==0;case e.Patterns.PATTERN001:return n%2==0;case e.Patterns.PATTERN010:return r%3==0;case e.Patterns.PATTERN011:return(n+r)%3==0;case e.Patterns.PATTERN100:return(Math.floor(n/2)+Math.floor(r/3))%2==0;case e.Patterns.PATTERN101:return n*r%2+n*r%3==0;case e.Patterns.PATTERN110:return(n*r%2+n*r%3)%2==0;case e.Patterns.PATTERN111:return(n*r%3+(n+r)%2)%2==0;default:throw Error(`bad maskPattern:`+t)}}e.applyMask=function(e,t){let r=t.size;for(let i=0;i<r;i++)for(let a=0;a<r;a++)t.isReserved(a,i)||t.xor(a,i,n(e,a,i))},e.getBestMask=function(t,n){let r=Object.keys(e.Patterns).length,i=0,a=1/0;for(let o=0;o<r;o++){n(o),e.applyMask(o,t);let r=e.getPenaltyN1(t)+e.getPenaltyN2(t)+e.getPenaltyN3(t)+e.getPenaltyN4(t);e.applyMask(o,t),r<a&&(a=r,i=o)}return i}})),W=n((e=>{var t=Ue(),n=[1,1,1,1,1,1,1,1,1,1,2,2,1,2,2,4,1,2,4,4,2,4,4,4,2,4,6,5,2,4,6,6,2,5,8,8,4,5,8,8,4,5,8,11,4,8,10,11,4,9,12,16,4,9,16,16,6,10,12,18,6,10,17,16,6,11,16,19,6,13,18,21,7,14,21,25,8,16,20,25,8,17,23,25,9,17,23,34,9,18,25,30,10,20,27,32,12,21,29,35,12,23,34,37,12,25,34,40,13,26,35,42,14,28,38,45,15,29,40,48,16,31,43,51,17,33,45,54,18,35,48,57,19,37,51,60,19,38,53,63,20,40,56,66,21,43,59,70,22,45,62,74,24,47,65,77,25,49,68,81],r=[7,10,13,17,10,16,22,28,15,26,36,44,20,36,52,64,26,48,72,88,36,64,96,112,40,72,108,130,48,88,132,156,60,110,160,192,72,130,192,224,80,150,224,264,96,176,260,308,104,198,288,352,120,216,320,384,132,240,360,432,144,280,408,480,168,308,448,532,180,338,504,588,196,364,546,650,224,416,600,700,224,442,644,750,252,476,690,816,270,504,750,900,300,560,810,960,312,588,870,1050,336,644,952,1110,360,700,1020,1200,390,728,1050,1260,420,784,1140,1350,450,812,1200,1440,480,868,1290,1530,510,924,1350,1620,540,980,1440,1710,570,1036,1530,1800,570,1064,1590,1890,600,1120,1680,1980,630,1204,1770,2100,660,1260,1860,2220,720,1316,1950,2310,750,1372,2040,2430];e.getBlocksCount=function(e,r){switch(r){case t.L:return n[(e-1)*4+0];case t.M:return n[(e-1)*4+1];case t.Q:return n[(e-1)*4+2];case t.H:return n[(e-1)*4+3];default:return}},e.getTotalCodewordsCount=function(e,n){switch(n){case t.L:return r[(e-1)*4+0];case t.M:return r[(e-1)*4+1];case t.Q:return r[(e-1)*4+2];case t.H:return r[(e-1)*4+3];default:return}}})),G=n((e=>{var t=new Uint8Array(512),n=new Uint8Array(256);(function(){let e=1;for(let r=0;r<255;r++)t[r]=e,n[e]=r,e<<=1,e&256&&(e^=285);for(let e=255;e<512;e++)t[e]=t[e-255]})(),e.log=function(e){if(e<1)throw Error(`log(`+e+`)`);return n[e]},e.exp=function(e){return t[e]},e.mul=function(e,r){return e===0||r===0?0:t[n[e]+n[r]]}})),Ke=n((e=>{var t=G();e.mul=function(e,n){let r=new Uint8Array(e.length+n.length-1);for(let i=0;i<e.length;i++)for(let a=0;a<n.length;a++)r[i+a]^=t.mul(e[i],n[a]);return r},e.mod=function(e,n){let r=new Uint8Array(e);for(;r.length-n.length>=0;){let e=r[0];for(let i=0;i<n.length;i++)r[i]^=t.mul(n[i],e);let i=0;for(;i<r.length&&r[i]===0;)i++;r=r.slice(i)}return r},e.generateECPolynomial=function(n){let r=new Uint8Array([1]);for(let i=0;i<n;i++)r=e.mul(r,new Uint8Array([1,t.exp(i)]));return r}})),qe=n(((e,t)=>{var n=Ke();function r(e){this.genPoly=void 0,this.degree=e,this.degree&&this.initialize(this.degree)}r.prototype.initialize=function(e){this.degree=e,this.genPoly=n.generateECPolynomial(this.degree)},r.prototype.encode=function(e){if(!this.genPoly)throw Error(`Encoder not initialized`);let t=new Uint8Array(e.length+this.degree);t.set(e);let r=n.mod(t,this.genPoly),i=this.degree-r.length;if(i>0){let e=new Uint8Array(this.degree);return e.set(r,i),e}return r},t.exports=r})),Je=n((e=>{e.isValid=function(e){return!isNaN(e)&&e>=1&&e<=40}})),K=n((e=>{var t=`[0-9]+`,n=`[A-Z $%*+\\-./:]+`,r=`(?:[u3000-u303F]|[u3040-u309F]|[u30A0-u30FF]|[uFF00-uFFEF]|[u4E00-u9FAF]|[u2605-u2606]|[u2190-u2195]|u203B|[u2010u2015u2018u2019u2025u2026u201Cu201Du2225u2260]|[u0391-u0451]|[u00A7u00A8u00B1u00B4u00D7u00F7])+`;r=r.replace(/u/g,`\\u`);var i=`(?:(?![A-Z0-9 $%*+\\-./:]|`+r+`)(?:.|[\r
1
+ import{o as e,r as t,t as n}from"./rolldown-runtime-DAXXjFlN.js";import{_ as r,f as i,l as a,r as o,t as s,u as c}from"./vendor-react-slxo-5GC.js";import{f as l,m as u}from"./infrastructure-BySW-NB0.js";import{D as d,E as f,Ft as p,G as m,R as h,a as g,b as _,g as v,it as y,m as b,w as x,z as S}from"./framework-CUm99d5f.js";import{$n as C,Ac as w,Fc as T,G as ee,Gn as te,Hs as ne,Ic as re,J as ie,Jn as E,Jo as D,Jt as O,Kn as k,Kt as ae,Sr as A,T as oe,W as se,Wn as ce,Ws as le,Xt as ue,Yn as j,Yt as de,_r as fe,br as pe,cn as me,fn as he,gr as ge,hr as _e,ls as ve,mr as ye,pr as be,qn as M,qo as N,qt as P,rs as xe,st as Se,vr as Ce,yr as F}from"./ui-components-DvVVxGRS.js";import{r as I}from"./vendor-ui-utils-C1OpMExs.js";import{t as we}from"./plugin-form-G3dyuFOt.js";import{i as Te,o as Ee,r as De,t as Oe}from"./useRecordApprovals-PhUYX_dd.js";import{n as ke}from"./utils-Bixzg6Bz.js";import{n as Ae,t as je}from"./MetadataInspector-Bayj0F4e.js";import{c as Me,i as Ne,n as Pe,r as Fe,s as Ie}from"./plugins-views-Cxvy9qpT.js";import{t as Le}from"./ManagedByBadge-CQOEWdSz.js";import{t as Re}from"./skeletons-9VTXs8YD.js";var L=e(r(),1),R=s(),z=(0,L.createContext)(void 0);function ze({children:e}){let[t,n]=(0,L.useState)(`home`),[r,i]=(0,L.useState)(),[a,o]=(0,L.useState)(),s=(0,L.useMemo)(()=>({context:t,setContext:n,currentAppName:r,setCurrentAppName:i,recordTitle:a,setRecordTitle:o}),[t,r,a]);return(0,R.jsx)(z.Provider,{value:s,children:e})}function Be(){return(0,L.useContext)(z)||{context:`app`,setContext:()=>{},currentAppName:void 0,setCurrentAppName:()=>{},recordTitle:void 0,setRecordTitle:()=>{}}}function Ve(e){let{setRecordTitle:t}=Be();(0,L.useEffect)(()=>(t(e),()=>t(void 0)),[e,t])}var He=n(((e,t)=>{t.exports=function(){return typeof Promise==`function`&&Promise.prototype&&Promise.prototype.then}})),B=n((e=>{var t,n=[0,26,44,70,100,134,172,196,242,292,346,404,466,532,581,655,733,815,901,991,1085,1156,1258,1364,1474,1588,1706,1828,1921,2051,2185,2323,2465,2611,2761,2876,3034,3196,3362,3532,3706];e.getSymbolSize=function(e){if(!e)throw Error(`"version" cannot be null or undefined`);if(e<1||e>40)throw Error(`"version" should be in range from 1 to 40`);return e*4+17},e.getSymbolTotalCodewords=function(e){return n[e]},e.getBCHDigit=function(e){let t=0;for(;e!==0;)t++,e>>>=1;return t},e.setToSJISFunction=function(e){if(typeof e!=`function`)throw Error(`"toSJISFunc" is not a valid function.`);t=e},e.isKanjiModeEnabled=function(){return t!==void 0},e.toSJIS=function(e){return t(e)}})),Ue=n((e=>{e.L={bit:1},e.M={bit:0},e.Q={bit:3},e.H={bit:2};function t(t){if(typeof t!=`string`)throw Error(`Param is not a string`);switch(t.toLowerCase()){case`l`:case`low`:return e.L;case`m`:case`medium`:return e.M;case`q`:case`quartile`:return e.Q;case`h`:case`high`:return e.H;default:throw Error(`Unknown EC Level: `+t)}}e.isValid=function(e){return e&&e.bit!==void 0&&e.bit>=0&&e.bit<4},e.from=function(n,r){if(e.isValid(n))return n;try{return t(n)}catch{return r}}})),We=n(((e,t)=>{function n(){this.buffer=[],this.length=0}n.prototype={get:function(e){let t=Math.floor(e/8);return(this.buffer[t]>>>7-e%8&1)==1},put:function(e,t){for(let n=0;n<t;n++)this.putBit((e>>>t-n-1&1)==1)},getLengthInBits:function(){return this.length},putBit:function(e){let t=Math.floor(this.length/8);this.buffer.length<=t&&this.buffer.push(0),e&&(this.buffer[t]|=128>>>this.length%8),this.length++}},t.exports=n})),V=n(((e,t)=>{function n(e){if(!e||e<1)throw Error(`BitMatrix size must be defined and greater than 0`);this.size=e,this.data=new Uint8Array(e*e),this.reservedBit=new Uint8Array(e*e)}n.prototype.set=function(e,t,n,r){let i=e*this.size+t;this.data[i]=n,r&&(this.reservedBit[i]=!0)},n.prototype.get=function(e,t){return this.data[e*this.size+t]},n.prototype.xor=function(e,t,n){this.data[e*this.size+t]^=n},n.prototype.isReserved=function(e,t){return this.reservedBit[e*this.size+t]},t.exports=n})),Ge=n((e=>{var t=B().getSymbolSize;e.getRowColCoords=function(e){if(e===1)return[];let n=Math.floor(e/7)+2,r=t(e),i=r===145?26:Math.ceil((r-13)/(2*n-2))*2,a=[r-7];for(let e=1;e<n-1;e++)a[e]=a[e-1]-i;return a.push(6),a.reverse()},e.getPositions=function(t){let n=[],r=e.getRowColCoords(t),i=r.length;for(let e=0;e<i;e++)for(let t=0;t<i;t++)e===0&&t===0||e===0&&t===i-1||e===i-1&&t===0||n.push([r[e],r[t]]);return n}})),H=n((e=>{var t=B().getSymbolSize,n=7;e.getPositions=function(e){let r=t(e);return[[0,0],[r-n,0],[0,r-n]]}})),U=n((e=>{e.Patterns={PATTERN000:0,PATTERN001:1,PATTERN010:2,PATTERN011:3,PATTERN100:4,PATTERN101:5,PATTERN110:6,PATTERN111:7};var t={N1:3,N2:3,N3:40,N4:10};e.isValid=function(e){return e!=null&&e!==``&&!isNaN(e)&&e>=0&&e<=7},e.from=function(t){return e.isValid(t)?parseInt(t,10):void 0},e.getPenaltyN1=function(e){let n=e.size,r=0,i=0,a=0,o=null,s=null;for(let c=0;c<n;c++){i=a=0,o=s=null;for(let l=0;l<n;l++){let n=e.get(c,l);n===o?i++:(i>=5&&(r+=t.N1+(i-5)),o=n,i=1),n=e.get(l,c),n===s?a++:(a>=5&&(r+=t.N1+(a-5)),s=n,a=1)}i>=5&&(r+=t.N1+(i-5)),a>=5&&(r+=t.N1+(a-5))}return r},e.getPenaltyN2=function(e){let n=e.size,r=0;for(let t=0;t<n-1;t++)for(let i=0;i<n-1;i++){let n=e.get(t,i)+e.get(t,i+1)+e.get(t+1,i)+e.get(t+1,i+1);(n===4||n===0)&&r++}return r*t.N2},e.getPenaltyN3=function(e){let n=e.size,r=0,i=0,a=0;for(let t=0;t<n;t++){i=a=0;for(let o=0;o<n;o++)i=i<<1&2047|e.get(t,o),o>=10&&(i===1488||i===93)&&r++,a=a<<1&2047|e.get(o,t),o>=10&&(a===1488||a===93)&&r++}return r*t.N3},e.getPenaltyN4=function(e){let n=0,r=e.data.length;for(let t=0;t<r;t++)n+=e.data[t];return Math.abs(Math.ceil(n*100/r/5)-10)*t.N4};function n(t,n,r){switch(t){case e.Patterns.PATTERN000:return(n+r)%2==0;case e.Patterns.PATTERN001:return n%2==0;case e.Patterns.PATTERN010:return r%3==0;case e.Patterns.PATTERN011:return(n+r)%3==0;case e.Patterns.PATTERN100:return(Math.floor(n/2)+Math.floor(r/3))%2==0;case e.Patterns.PATTERN101:return n*r%2+n*r%3==0;case e.Patterns.PATTERN110:return(n*r%2+n*r%3)%2==0;case e.Patterns.PATTERN111:return(n*r%3+(n+r)%2)%2==0;default:throw Error(`bad maskPattern:`+t)}}e.applyMask=function(e,t){let r=t.size;for(let i=0;i<r;i++)for(let a=0;a<r;a++)t.isReserved(a,i)||t.xor(a,i,n(e,a,i))},e.getBestMask=function(t,n){let r=Object.keys(e.Patterns).length,i=0,a=1/0;for(let o=0;o<r;o++){n(o),e.applyMask(o,t);let r=e.getPenaltyN1(t)+e.getPenaltyN2(t)+e.getPenaltyN3(t)+e.getPenaltyN4(t);e.applyMask(o,t),r<a&&(a=r,i=o)}return i}})),W=n((e=>{var t=Ue(),n=[1,1,1,1,1,1,1,1,1,1,2,2,1,2,2,4,1,2,4,4,2,4,4,4,2,4,6,5,2,4,6,6,2,5,8,8,4,5,8,8,4,5,8,11,4,8,10,11,4,9,12,16,4,9,16,16,6,10,12,18,6,10,17,16,6,11,16,19,6,13,18,21,7,14,21,25,8,16,20,25,8,17,23,25,9,17,23,34,9,18,25,30,10,20,27,32,12,21,29,35,12,23,34,37,12,25,34,40,13,26,35,42,14,28,38,45,15,29,40,48,16,31,43,51,17,33,45,54,18,35,48,57,19,37,51,60,19,38,53,63,20,40,56,66,21,43,59,70,22,45,62,74,24,47,65,77,25,49,68,81],r=[7,10,13,17,10,16,22,28,15,26,36,44,20,36,52,64,26,48,72,88,36,64,96,112,40,72,108,130,48,88,132,156,60,110,160,192,72,130,192,224,80,150,224,264,96,176,260,308,104,198,288,352,120,216,320,384,132,240,360,432,144,280,408,480,168,308,448,532,180,338,504,588,196,364,546,650,224,416,600,700,224,442,644,750,252,476,690,816,270,504,750,900,300,560,810,960,312,588,870,1050,336,644,952,1110,360,700,1020,1200,390,728,1050,1260,420,784,1140,1350,450,812,1200,1440,480,868,1290,1530,510,924,1350,1620,540,980,1440,1710,570,1036,1530,1800,570,1064,1590,1890,600,1120,1680,1980,630,1204,1770,2100,660,1260,1860,2220,720,1316,1950,2310,750,1372,2040,2430];e.getBlocksCount=function(e,r){switch(r){case t.L:return n[(e-1)*4+0];case t.M:return n[(e-1)*4+1];case t.Q:return n[(e-1)*4+2];case t.H:return n[(e-1)*4+3];default:return}},e.getTotalCodewordsCount=function(e,n){switch(n){case t.L:return r[(e-1)*4+0];case t.M:return r[(e-1)*4+1];case t.Q:return r[(e-1)*4+2];case t.H:return r[(e-1)*4+3];default:return}}})),G=n((e=>{var t=new Uint8Array(512),n=new Uint8Array(256);(function(){let e=1;for(let r=0;r<255;r++)t[r]=e,n[e]=r,e<<=1,e&256&&(e^=285);for(let e=255;e<512;e++)t[e]=t[e-255]})(),e.log=function(e){if(e<1)throw Error(`log(`+e+`)`);return n[e]},e.exp=function(e){return t[e]},e.mul=function(e,r){return e===0||r===0?0:t[n[e]+n[r]]}})),Ke=n((e=>{var t=G();e.mul=function(e,n){let r=new Uint8Array(e.length+n.length-1);for(let i=0;i<e.length;i++)for(let a=0;a<n.length;a++)r[i+a]^=t.mul(e[i],n[a]);return r},e.mod=function(e,n){let r=new Uint8Array(e);for(;r.length-n.length>=0;){let e=r[0];for(let i=0;i<n.length;i++)r[i]^=t.mul(n[i],e);let i=0;for(;i<r.length&&r[i]===0;)i++;r=r.slice(i)}return r},e.generateECPolynomial=function(n){let r=new Uint8Array([1]);for(let i=0;i<n;i++)r=e.mul(r,new Uint8Array([1,t.exp(i)]));return r}})),qe=n(((e,t)=>{var n=Ke();function r(e){this.genPoly=void 0,this.degree=e,this.degree&&this.initialize(this.degree)}r.prototype.initialize=function(e){this.degree=e,this.genPoly=n.generateECPolynomial(this.degree)},r.prototype.encode=function(e){if(!this.genPoly)throw Error(`Encoder not initialized`);let t=new Uint8Array(e.length+this.degree);t.set(e);let r=n.mod(t,this.genPoly),i=this.degree-r.length;if(i>0){let e=new Uint8Array(this.degree);return e.set(r,i),e}return r},t.exports=r})),Je=n((e=>{e.isValid=function(e){return!isNaN(e)&&e>=1&&e<=40}})),K=n((e=>{var t=`[0-9]+`,n=`[A-Z $%*+\\-./:]+`,r=`(?:[u3000-u303F]|[u3040-u309F]|[u30A0-u30FF]|[uFF00-uFFEF]|[u4E00-u9FAF]|[u2605-u2606]|[u2190-u2195]|u203B|[u2010u2015u2018u2019u2025u2026u201Cu201Du2225u2260]|[u0391-u0451]|[u00A7u00A8u00B1u00B4u00D7u00F7])+`;r=r.replace(/u/g,`\\u`);var i=`(?:(?![A-Z0-9 $%*+\\-./:]|`+r+`)(?:.|[\r
2
2
  ]))+`;e.KANJI=new RegExp(r,`g`),e.BYTE_KANJI=RegExp(`[^A-Z0-9 $%*+\\-./:]+`,`g`),e.BYTE=new RegExp(i,`g`),e.NUMERIC=new RegExp(t,`g`),e.ALPHANUMERIC=new RegExp(n,`g`);var a=RegExp(`^`+r+`$`),o=RegExp(`^[0-9]+$`),s=RegExp(`^[A-Z0-9 $%*+\\-./:]+$`);e.testKanji=function(e){return a.test(e)},e.testNumeric=function(e){return o.test(e)},e.testAlphanumeric=function(e){return s.test(e)}})),q=n((e=>{var t=Je(),n=K();e.NUMERIC={id:`Numeric`,bit:1,ccBits:[10,12,14]},e.ALPHANUMERIC={id:`Alphanumeric`,bit:2,ccBits:[9,11,13]},e.BYTE={id:`Byte`,bit:4,ccBits:[8,16,16]},e.KANJI={id:`Kanji`,bit:8,ccBits:[8,10,12]},e.MIXED={bit:-1},e.getCharCountIndicator=function(e,n){if(!e.ccBits)throw Error(`Invalid mode: `+e);if(!t.isValid(n))throw Error(`Invalid version: `+n);return n>=1&&n<10?e.ccBits[0]:n<27?e.ccBits[1]:e.ccBits[2]},e.getBestModeForData=function(t){return n.testNumeric(t)?e.NUMERIC:n.testAlphanumeric(t)?e.ALPHANUMERIC:n.testKanji(t)?e.KANJI:e.BYTE},e.toString=function(e){if(e&&e.id)return e.id;throw Error(`Invalid mode`)},e.isValid=function(e){return e&&e.bit&&e.ccBits};function r(t){if(typeof t!=`string`)throw Error(`Param is not a string`);switch(t.toLowerCase()){case`numeric`:return e.NUMERIC;case`alphanumeric`:return e.ALPHANUMERIC;case`kanji`:return e.KANJI;case`byte`:return e.BYTE;default:throw Error(`Unknown mode: `+t)}}e.from=function(t,n){if(e.isValid(t))return t;try{return r(t)}catch{return n}}})),Ye=n((e=>{var t=B(),n=W(),r=Ue(),i=q(),a=Je(),o=7973,s=t.getBCHDigit(o);function c(t,n,r){for(let i=1;i<=40;i++)if(n<=e.getCapacity(i,r,t))return i}function l(e,t){return i.getCharCountIndicator(e,t)+4}function u(e,t){let n=0;return e.forEach(function(e){let r=l(e.mode,t);n+=r+e.getBitsLength()}),n}function d(t,n){for(let r=1;r<=40;r++)if(u(t,r)<=e.getCapacity(r,n,i.MIXED))return r}e.from=function(e,t){return a.isValid(e)?parseInt(e,10):t},e.getCapacity=function(e,r,o){if(!a.isValid(e))throw Error(`Invalid QR Code version`);o===void 0&&(o=i.BYTE);let s=(t.getSymbolTotalCodewords(e)-n.getTotalCodewordsCount(e,r))*8;if(o===i.MIXED)return s;let c=s-l(o,e);switch(o){case i.NUMERIC:return Math.floor(c/10*3);case i.ALPHANUMERIC:return Math.floor(c/11*2);case i.KANJI:return Math.floor(c/13);case i.BYTE:default:return Math.floor(c/8)}},e.getBestVersionForData=function(e,t){let n,i=r.from(t,r.M);if(Array.isArray(e)){if(e.length>1)return d(e,i);if(e.length===0)return 1;n=e[0]}else n=e;return c(n.mode,n.getLength(),i)},e.getEncodedBits=function(e){if(!a.isValid(e)||e<7)throw Error(`Invalid QR Code version`);let n=e<<12;for(;t.getBCHDigit(n)-s>=0;)n^=o<<t.getBCHDigit(n)-s;return e<<12|n}})),J=n((e=>{var t=B(),n=1335,r=21522,i=t.getBCHDigit(n);e.getEncodedBits=function(e,a){let o=e.bit<<3|a,s=o<<10;for(;t.getBCHDigit(s)-i>=0;)s^=n<<t.getBCHDigit(s)-i;return(o<<10|s)^r}})),Y=n(((e,t)=>{var n=q();function r(e){this.mode=n.NUMERIC,this.data=e.toString()}r.getBitsLength=function(e){return 10*Math.floor(e/3)+(e%3?e%3*3+1:0)},r.prototype.getLength=function(){return this.data.length},r.prototype.getBitsLength=function(){return r.getBitsLength(this.data.length)},r.prototype.write=function(e){let t,n,r;for(t=0;t+3<=this.data.length;t+=3)n=this.data.substr(t,3),r=parseInt(n,10),e.put(r,10);let i=this.data.length-t;i>0&&(n=this.data.substr(t),r=parseInt(n,10),e.put(r,i*3+1))},t.exports=r})),Xe=n(((e,t)=>{var n=q(),r=`0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ $%*+-./:`.split(``);function i(e){this.mode=n.ALPHANUMERIC,this.data=e}i.getBitsLength=function(e){return 11*Math.floor(e/2)+e%2*6},i.prototype.getLength=function(){return this.data.length},i.prototype.getBitsLength=function(){return i.getBitsLength(this.data.length)},i.prototype.write=function(e){let t;for(t=0;t+2<=this.data.length;t+=2){let n=r.indexOf(this.data[t])*45;n+=r.indexOf(this.data[t+1]),e.put(n,11)}this.data.length%2&&e.put(r.indexOf(this.data[t]),6)},t.exports=i})),Ze=n(((e,t)=>{var n=q();function r(e){this.mode=n.BYTE,typeof e==`string`?this.data=new TextEncoder().encode(e):this.data=new Uint8Array(e)}r.getBitsLength=function(e){return e*8},r.prototype.getLength=function(){return this.data.length},r.prototype.getBitsLength=function(){return r.getBitsLength(this.data.length)},r.prototype.write=function(e){for(let t=0,n=this.data.length;t<n;t++)e.put(this.data[t],8)},t.exports=r})),Qe=n(((e,t)=>{var n=q(),r=B();function i(e){this.mode=n.KANJI,this.data=e}i.getBitsLength=function(e){return e*13},i.prototype.getLength=function(){return this.data.length},i.prototype.getBitsLength=function(){return i.getBitsLength(this.data.length)},i.prototype.write=function(e){let t;for(t=0;t<this.data.length;t++){let n=r.toSJIS(this.data[t]);if(n>=33088&&n<=40956)n-=33088;else if(n>=57408&&n<=60351)n-=49472;else throw Error(`Invalid SJIS character: `+this.data[t]+`
3
3
  Make sure your charset is UTF-8`);n=(n>>>8&255)*192+(n&255),e.put(n,13)}},t.exports=i})),$e=n(((e,t)=>{var n={single_source_shortest_paths:function(e,t,r){var i={},a={};a[t]=0;var o=n.PriorityQueue.make();o.push(t,0);for(var s,c,l,u,d,f,p,m,h;!o.empty();)for(l in s=o.pop(),c=s.value,u=s.cost,d=e[c]||{},d)d.hasOwnProperty(l)&&(f=d[l],p=u+f,m=a[l],h=a[l]===void 0,(h||m>p)&&(a[l]=p,o.push(l,p),i[l]=c));if(r!==void 0&&a[r]===void 0){var g=[`Could not find a path from `,t,` to `,r,`.`].join(``);throw Error(g)}return i},extract_shortest_path_from_predecessor_list:function(e,t){for(var n=[],r=t;r;)n.push(r),e[r],r=e[r];return n.reverse(),n},find_path:function(e,t,r){var i=n.single_source_shortest_paths(e,t,r);return n.extract_shortest_path_from_predecessor_list(i,r)},PriorityQueue:{make:function(e){var t=n.PriorityQueue,r={},i;for(i in e||={},t)t.hasOwnProperty(i)&&(r[i]=t[i]);return r.queue=[],r.sorter=e.sorter||t.default_sorter,r},default_sorter:function(e,t){return e.cost-t.cost},push:function(e,t){var n={value:e,cost:t};this.queue.push(n),this.queue.sort(this.sorter)},pop:function(){return this.queue.shift()},empty:function(){return this.queue.length===0}}};t!==void 0&&(t.exports=n)})),et=n((e=>{var t=q(),n=Y(),r=Xe(),i=Ze(),a=Qe(),o=K(),s=B(),c=$e();function l(e){return unescape(encodeURIComponent(e)).length}function u(e,t,n){let r=[],i;for(;(i=e.exec(n))!==null;)r.push({data:i[0],index:i.index,mode:t,length:i[0].length});return r}function d(e){let n=u(o.NUMERIC,t.NUMERIC,e),r=u(o.ALPHANUMERIC,t.ALPHANUMERIC,e),i,a;return s.isKanjiModeEnabled()?(i=u(o.BYTE,t.BYTE,e),a=u(o.KANJI,t.KANJI,e)):(i=u(o.BYTE_KANJI,t.BYTE,e),a=[]),n.concat(r,i,a).sort(function(e,t){return e.index-t.index}).map(function(e){return{data:e.data,mode:e.mode,length:e.length}})}function f(e,o){switch(o){case t.NUMERIC:return n.getBitsLength(e);case t.ALPHANUMERIC:return r.getBitsLength(e);case t.KANJI:return a.getBitsLength(e);case t.BYTE:return i.getBitsLength(e)}}function p(e){return e.reduce(function(e,t){let n=e.length-1>=0?e[e.length-1]:null;return n&&n.mode===t.mode?(e[e.length-1].data+=t.data,e):(e.push(t),e)},[])}function m(e){let n=[];for(let r=0;r<e.length;r++){let i=e[r];switch(i.mode){case t.NUMERIC:n.push([i,{data:i.data,mode:t.ALPHANUMERIC,length:i.length},{data:i.data,mode:t.BYTE,length:i.length}]);break;case t.ALPHANUMERIC:n.push([i,{data:i.data,mode:t.BYTE,length:i.length}]);break;case t.KANJI:n.push([i,{data:i.data,mode:t.BYTE,length:l(i.data)}]);break;case t.BYTE:n.push([{data:i.data,mode:t.BYTE,length:l(i.data)}])}}return n}function h(e,n){let r={},i={start:{}},a=[`start`];for(let o=0;o<e.length;o++){let s=e[o],c=[];for(let e=0;e<s.length;e++){let l=s[e],u=``+o+e;c.push(u),r[u]={node:l,lastCount:0},i[u]={};for(let e=0;e<a.length;e++){let o=a[e];r[o]&&r[o].node.mode===l.mode?(i[o][u]=f(r[o].lastCount+l.length,l.mode)-f(r[o].lastCount,l.mode),r[o].lastCount+=l.length):(r[o]&&(r[o].lastCount=l.length),i[o][u]=f(l.length,l.mode)+4+t.getCharCountIndicator(l.mode,n))}}a=c}for(let e=0;e<a.length;e++)i[a[e]].end=0;return{map:i,table:r}}function g(e,o){let c,l=t.getBestModeForData(e);if(c=t.from(o,l),c!==t.BYTE&&c.bit<l.bit)throw Error(`"`+e+`" cannot be encoded with mode `+t.toString(c)+`.
4
4
  Suggested mode is: `+t.toString(l));switch(c===t.KANJI&&!s.isKanjiModeEnabled()&&(c=t.BYTE),c){case t.NUMERIC:return new n(e);case t.ALPHANUMERIC:return new r(e);case t.KANJI:return new a(e);case t.BYTE:return new i(e)}}e.fromArray=function(e){return e.reduce(function(e,t){return typeof t==`string`?e.push(g(t,null)):t.data&&e.push(g(t.data,t.mode)),e},[])},e.fromString=function(t,n){let r=h(m(d(t,s.isKanjiModeEnabled())),n),i=c.find_path(r.map,`start`,`end`),a=[];for(let e=1;e<i.length-1;e++)a.push(r.table[i[e]].node);return e.fromArray(p(a))},e.rawSplit=function(t){return e.fromArray(d(t,s.isKanjiModeEnabled()))}})),tt=n((e=>{var t=B(),n=Ue(),r=We(),i=V(),a=Ge(),o=H(),s=U(),c=W(),l=qe(),u=Ye(),d=J(),f=q(),p=et();function m(e,t){let n=e.size,r=o.getPositions(t);for(let t=0;t<r.length;t++){let i=r[t][0],a=r[t][1];for(let t=-1;t<=7;t++)if(!(i+t<=-1||n<=i+t))for(let r=-1;r<=7;r++)a+r<=-1||n<=a+r||(t>=0&&t<=6&&(r===0||r===6)||r>=0&&r<=6&&(t===0||t===6)||t>=2&&t<=4&&r>=2&&r<=4?e.set(i+t,a+r,!0,!0):e.set(i+t,a+r,!1,!0))}}function h(e){let t=e.size;for(let n=8;n<t-8;n++){let t=n%2==0;e.set(n,6,t,!0),e.set(6,n,t,!0)}}function g(e,t){let n=a.getPositions(t);for(let t=0;t<n.length;t++){let r=n[t][0],i=n[t][1];for(let t=-2;t<=2;t++)for(let n=-2;n<=2;n++)t===-2||t===2||n===-2||n===2||t===0&&n===0?e.set(r+t,i+n,!0,!0):e.set(r+t,i+n,!1,!0)}}function _(e,t){let n=e.size,r=u.getEncodedBits(t),i,a,o;for(let t=0;t<18;t++)i=Math.floor(t/3),a=t%3+n-8-3,o=(r>>t&1)==1,e.set(i,a,o,!0),e.set(a,i,o,!0)}function v(e,t,n){let r=e.size,i=d.getEncodedBits(t,n),a,o;for(a=0;a<15;a++)o=(i>>a&1)==1,a<6?e.set(a,8,o,!0):a<8?e.set(a+1,8,o,!0):e.set(r-15+a,8,o,!0),a<8?e.set(8,r-a-1,o,!0):a<9?e.set(8,15-a-1+1,o,!0):e.set(8,15-a-1,o,!0);e.set(r-8,8,1,!0)}function y(e,t){let n=e.size,r=-1,i=n-1,a=7,o=0;for(let s=n-1;s>0;s-=2)for(s===6&&s--;;){for(let n=0;n<2;n++)if(!e.isReserved(i,s-n)){let r=!1;o<t.length&&(r=(t[o]>>>a&1)==1),e.set(i,s-n,r),a--,a===-1&&(o++,a=7)}if(i+=r,i<0||n<=i){i-=r,r=-r;break}}}function b(e,n,i){let a=new r;i.forEach(function(t){a.put(t.mode.bit,4),a.put(t.getLength(),f.getCharCountIndicator(t.mode,e)),t.write(a)});let o=(t.getSymbolTotalCodewords(e)-c.getTotalCodewordsCount(e,n))*8;for(a.getLengthInBits()+4<=o&&a.put(0,4);a.getLengthInBits()%8!=0;)a.putBit(0);let s=(o-a.getLengthInBits())/8;for(let e=0;e<s;e++)a.put(e%2?17:236,8);return x(a,e,n)}function x(e,n,r){let i=t.getSymbolTotalCodewords(n),a=i-c.getTotalCodewordsCount(n,r),o=c.getBlocksCount(n,r),s=o-i%o,u=Math.floor(i/o),d=Math.floor(a/o),f=d+1,p=u-d,m=new l(p),h=0,g=Array(o),_=Array(o),v=0,y=new Uint8Array(e.buffer);for(let e=0;e<o;e++){let t=e<s?d:f;g[e]=y.slice(h,h+t),_[e]=m.encode(g[e]),h+=t,v=Math.max(v,t)}let b=new Uint8Array(i),x=0,S,C;for(S=0;S<v;S++)for(C=0;C<o;C++)S<g[C].length&&(b[x++]=g[C][S]);for(S=0;S<p;S++)for(C=0;C<o;C++)b[x++]=_[C][S];return b}function S(e,n,r,a){let o;if(Array.isArray(e))o=p.fromArray(e);else if(typeof e==`string`){let t=n;if(!t){let n=p.rawSplit(e);t=u.getBestVersionForData(n,r)}o=p.fromString(e,t||40)}else throw Error(`Invalid data`);let c=u.getBestVersionForData(o,r);if(!c)throw Error(`The amount of data is too big to be stored in a QR Code`);if(!n)n=c;else if(n<c)throw Error(`
@@ -1 +1 @@
1
- import{o as e,r as t}from"./rolldown-runtime-DAXXjFlN.js";import{_ as n,f as r,p as i,r as a,t as o,u as s}from"./vendor-react-slxo-5GC.js";import{f as c}from"./infrastructure-BySW-NB0.js";import{N as l,Nt as u,P as d,a as f}from"./framework-Bn8ShCi0.js";import{G as p,Ic as m,J as h,Sr as g,W as _,rs as v,wc as y}from"./ui-components-DlauVk27.js";import{r as b}from"./vendor-ui-utils-C1OpMExs.js";import"./AdapterProvider-BIB-F0Qa.js";import{t as x}from"./plugin-form-BUDPowXG.js";import"./MetadataProvider-DlGQbrYS.js";import{n as S,t as C}from"./ExpressionProvider-BI-jCA0B.js";import{t as w}from"./ManagedByBadge-DtZfR2w_.js";import{t as T}from"./skeletons-C2aQsjPE.js";var E=t({RecordFormPage:()=>k}),D=e(n(),1),O=o();function k({mode:e}){let{appName:t,objectName:n,recordId:o}=r(),E=s(),[k]=i(),A=l(),{objects:j,loading:M}=d(),{t:N}=f(),{objectLabel:P}=m(),{user:F,getAuthConfig:I}=c(),[L,R]=(0,D.useState)({});(0,D.useEffect)(()=>{let e=!1;return I().then(t=>{e||R(t?.features??{})}).catch(()=>{}),()=>{e=!0}},[I]);let z=(0,D.useMemo)(()=>{if(e!==`create`)return;let t=[];for(let[e,n]of k.entries())e&&n&&t.push([e,n]);return t.length>0?Object.fromEntries(t):void 0},[e,k.toString()]),B=(0,D.useMemo)(()=>j.find(e=>e.name===n),[j,n]),V=`/apps/${t}`,H=`${V}/${n}`,U=e===`edit`&&o?`${V}/${n}/record/${encodeURIComponent(o)}`:H,W=(0,D.useCallback)(()=>{typeof window<`u`&&window.history.length>1?E(-1):E(U,{replace:!0})},[E,U]),G=B?P(B):n??``,K=e===`create`?N(`form.createTitle`,{object:G,defaultValue:`New ${G}`}):N(`form.editTitle`,{object:G,defaultValue:`Edit ${G}`}),q=(0,D.useCallback)(()=>{b.success(e===`create`?N(`form.createSuccess`,{object:G,defaultValue:`${G} created successfully`}):N(`form.updateSuccess`,{object:G,defaultValue:`${G} updated successfully`})),W()},[e,N,G,W]),J=(0,D.useCallback)(()=>{W()},[W]),Y=(0,D.useMemo)(()=>F?{name:F.name,email:F.email,role:F.role??`user`}:{name:`Anonymous`,email:``,role:`guest`},[F]),X=(0,D.useMemo)(()=>new u({user:Y,app:{name:t},data:{}}),[Y,t]),Z=(0,D.useMemo)(()=>B?.fields?Array.isArray(B.fields)?B.fields.filter(e=>typeof e==`string`?!0:S(e.visible,X)).map(e=>typeof e==`string`?e:e.name):Object.entries(B.fields).filter(([,e])=>S(e.visible,X)).map(([e])=>e):[],[B,X]);if(M)return(0,O.jsx)(T,{});if(!B)return(0,O.jsx)(`div`,{className:`flex h-full items-center justify-center p-4`,children:(0,O.jsxs)(_,{children:[(0,O.jsx)(`div`,{className:`mx-auto mb-4 flex h-12 w-12 items-center justify-center rounded-full bg-muted`,children:(0,O.jsx)(v,{className:`h-6 w-6 text-muted-foreground`})}),(0,O.jsx)(h,{children:N(`empty.objectNotFound`)}),(0,O.jsx)(p,{children:N(`empty.objectNotFoundDescription`,{name:n})}),(0,O.jsx)(`div`,{className:`mt-4`,children:(0,O.jsxs)(g,{variant:`outline`,onClick:()=>E(V),children:[(0,O.jsx)(y,{className:`mr-2 h-4 w-4`}),N(`empty.back`)]})})]})});let Q=B.form??B.formViews?.default??{},$=[`tabbed`,`wizard`,`split`].includes(Q.type)?Q.type:`simple`,ee=Array.isArray(Q.sections)&&Q.sections.length>0?{sections:Q.sections,defaultTab:Q.defaultTab,tabPosition:Q.tabPosition,allowSkip:Q.allowSkip,showStepIndicator:Q.showStepIndicator,splitDirection:Q.splitDirection,splitSize:Q.splitSize,splitResizable:Q.splitResizable}:{};return(0,O.jsx)(C,{user:Y,app:{name:t},data:{},features:L,children:(0,O.jsxs)(`div`,{className:`flex flex-col h-full overflow-hidden bg-background`,"data-testid":`record-form-page`,"data-mode":e,children:[(0,O.jsxs)(`header`,{className:`sticky top-0 z-10 flex items-center gap-3 border-b bg-background px-4 py-3 sm:px-6`,children:[(0,O.jsx)(g,{variant:`ghost`,size:`sm`,onClick:W,"data-testid":`record-form-page-back`,"aria-label":N(`common.back`,{defaultValue:`Back`}),children:(0,O.jsx)(y,{className:`h-4 w-4`})}),(0,O.jsxs)(`nav`,{"aria-label":`Breadcrumb`,className:`flex items-center gap-2 text-sm text-muted-foreground`,children:[(0,O.jsx)(a,{to:H,className:`hover:text-foreground transition-colors`,children:G}),(0,O.jsx)(`span`,{"aria-hidden":`true`,children:`/`}),(0,O.jsx)(`span`,{className:`text-foreground font-medium`,"data-testid":`record-form-page-title`,children:K}),(0,O.jsx)(w,{managedBy:B?.managedBy,className:`ml-1`})]})]}),(0,O.jsx)(`div`,{className:`flex-1 overflow-auto p-4 sm:p-6`,children:(0,O.jsx)(`div`,{className:`mx-auto max-w-4xl`,children:(0,O.jsx)(x,{schema:{type:`object-form`,formType:$,...ee,objectName:B.name,mode:e,recordId:e===`edit`?o:void 0,...z&&{initialValues:z},title:K,description:e===`create`?N(`form.createDescription`,{object:G,defaultValue:`Create a new ${G}.`}):N(`form.editDescription`,{object:G,defaultValue:`Edit this ${G}.`}),layout:`vertical`,fields:Z,subforms:B.form?.subforms??B.formViews?.default?.subforms,onSuccess:q,onCancel:J,showSubmit:!0,showCancel:!0,submitText:N(`form.saveRecord`,{defaultValue:`Save`}),cancelText:N(`common.cancel`,{defaultValue:`Cancel`})},dataSource:A??void 0},`${e}:${n}:${o??`new`}`)})})]})})}export{E as t};
1
+ import{o as e,r as t}from"./rolldown-runtime-DAXXjFlN.js";import{_ as n,f as r,p as i,r as a,t as o,u as s}from"./vendor-react-slxo-5GC.js";import{f as c}from"./infrastructure-BySW-NB0.js";import{N as l,Nt as u,P as d,a as f}from"./framework-CUm99d5f.js";import{G as p,Ic as m,J as h,Sr as g,W as _,rs as v,wc as y}from"./ui-components-DvVVxGRS.js";import{r as b}from"./vendor-ui-utils-C1OpMExs.js";import"./AdapterProvider-BcaDLM8t.js";import{t as x}from"./plugin-form-G3dyuFOt.js";import"./MetadataProvider-DboJnyDA.js";import{n as S,t as C}from"./ExpressionProvider-CD5Qq5aY.js";import{t as w}from"./ManagedByBadge-CQOEWdSz.js";import{t as T}from"./skeletons-9VTXs8YD.js";var E=t({RecordFormPage:()=>k}),D=e(n(),1),O=o();function k({mode:e}){let{appName:t,objectName:n,recordId:o}=r(),E=s(),[k]=i(),A=l(),{objects:j,loading:M}=d(),{t:N}=f(),{objectLabel:P}=m(),{user:F,getAuthConfig:I}=c(),[L,R]=(0,D.useState)({});(0,D.useEffect)(()=>{let e=!1;return I().then(t=>{e||R(t?.features??{})}).catch(()=>{}),()=>{e=!0}},[I]);let z=(0,D.useMemo)(()=>{if(e!==`create`)return;let t=[];for(let[e,n]of k.entries())e&&n&&t.push([e,n]);return t.length>0?Object.fromEntries(t):void 0},[e,k.toString()]),B=(0,D.useMemo)(()=>j.find(e=>e.name===n),[j,n]),V=`/apps/${t}`,H=`${V}/${n}`,U=e===`edit`&&o?`${V}/${n}/record/${encodeURIComponent(o)}`:H,W=(0,D.useCallback)(()=>{typeof window<`u`&&window.history.length>1?E(-1):E(U,{replace:!0})},[E,U]),G=B?P(B):n??``,K=e===`create`?N(`form.createTitle`,{object:G,defaultValue:`New ${G}`}):N(`form.editTitle`,{object:G,defaultValue:`Edit ${G}`}),q=(0,D.useCallback)(()=>{b.success(e===`create`?N(`form.createSuccess`,{object:G,defaultValue:`${G} created successfully`}):N(`form.updateSuccess`,{object:G,defaultValue:`${G} updated successfully`})),W()},[e,N,G,W]),J=(0,D.useCallback)(()=>{W()},[W]),Y=(0,D.useMemo)(()=>F?{name:F.name,email:F.email,role:F.role??`user`}:{name:`Anonymous`,email:``,role:`guest`},[F]),X=(0,D.useMemo)(()=>new u({user:Y,app:{name:t},data:{}}),[Y,t]),Z=(0,D.useMemo)(()=>B?.fields?Array.isArray(B.fields)?B.fields.filter(e=>typeof e==`string`?!0:S(e.visible,X)).map(e=>typeof e==`string`?e:e.name):Object.entries(B.fields).filter(([,e])=>S(e.visible,X)).map(([e])=>e):[],[B,X]);if(M)return(0,O.jsx)(T,{});if(!B)return(0,O.jsx)(`div`,{className:`flex h-full items-center justify-center p-4`,children:(0,O.jsxs)(_,{children:[(0,O.jsx)(`div`,{className:`mx-auto mb-4 flex h-12 w-12 items-center justify-center rounded-full bg-muted`,children:(0,O.jsx)(v,{className:`h-6 w-6 text-muted-foreground`})}),(0,O.jsx)(h,{children:N(`empty.objectNotFound`)}),(0,O.jsx)(p,{children:N(`empty.objectNotFoundDescription`,{name:n})}),(0,O.jsx)(`div`,{className:`mt-4`,children:(0,O.jsxs)(g,{variant:`outline`,onClick:()=>E(V),children:[(0,O.jsx)(y,{className:`mr-2 h-4 w-4`}),N(`empty.back`)]})})]})});let Q=B.form??B.formViews?.default??{},$=[`tabbed`,`wizard`,`split`].includes(Q.type)?Q.type:`simple`,ee=Array.isArray(Q.sections)&&Q.sections.length>0?{sections:Q.sections,defaultTab:Q.defaultTab,tabPosition:Q.tabPosition,allowSkip:Q.allowSkip,showStepIndicator:Q.showStepIndicator,splitDirection:Q.splitDirection,splitSize:Q.splitSize,splitResizable:Q.splitResizable}:{};return(0,O.jsx)(C,{user:Y,app:{name:t},data:{},features:L,children:(0,O.jsxs)(`div`,{className:`flex flex-col h-full overflow-hidden bg-background`,"data-testid":`record-form-page`,"data-mode":e,children:[(0,O.jsxs)(`header`,{className:`sticky top-0 z-10 flex items-center gap-3 border-b bg-background px-4 py-3 sm:px-6`,children:[(0,O.jsx)(g,{variant:`ghost`,size:`sm`,onClick:W,"data-testid":`record-form-page-back`,"aria-label":N(`common.back`,{defaultValue:`Back`}),children:(0,O.jsx)(y,{className:`h-4 w-4`})}),(0,O.jsxs)(`nav`,{"aria-label":`Breadcrumb`,className:`flex items-center gap-2 text-sm text-muted-foreground`,children:[(0,O.jsx)(a,{to:H,className:`hover:text-foreground transition-colors`,children:G}),(0,O.jsx)(`span`,{"aria-hidden":`true`,children:`/`}),(0,O.jsx)(`span`,{className:`text-foreground font-medium`,"data-testid":`record-form-page-title`,children:K}),(0,O.jsx)(w,{managedBy:B?.managedBy,className:`ml-1`})]})]}),(0,O.jsx)(`div`,{className:`flex-1 overflow-auto p-4 sm:p-6`,children:(0,O.jsx)(`div`,{className:`mx-auto max-w-4xl`,children:(0,O.jsx)(x,{schema:{type:`object-form`,formType:$,...ee,objectName:B.name,mode:e,recordId:e===`edit`?o:void 0,...z&&{initialValues:z},title:K,description:e===`create`?N(`form.createDescription`,{object:G,defaultValue:`Create a new ${G}.`}):N(`form.editDescription`,{object:G,defaultValue:`Edit this ${G}.`}),layout:`vertical`,fields:Z,subforms:B.form?.subforms??B.formViews?.default?.subforms,onSuccess:q,onCancel:J,showSubmit:!0,showCancel:!0,submitText:N(`form.saveRecord`,{defaultValue:`Save`}),cancelText:N(`common.cancel`,{defaultValue:`Cancel`})},dataSource:A??void 0},`${e}:${n}:${o??`new`}`)})})]})})}export{E as t};