@chaibuilder/pages 0.15.22 → 0.16.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 (84) hide show
  1. package/dist/{2AITGKQY-BQI4o1xG.js → 2AITGKQY-BFankGad.js} +2 -2
  2. package/dist/{2AITGKQY-DXm3iqhg.cjs → 2AITGKQY-BxEty5Ow.cjs} +1 -1
  3. package/dist/{NCMVHL6D-B3kd8MpE.js → NCMVHL6D-DFMKkQPN.js} +4 -4
  4. package/dist/{NCMVHL6D-C0TW9XJH.cjs → NCMVHL6D-DP-qw6yT.cjs} +1 -1
  5. package/dist/{ZDWCUMSJ-DzyqbIEt.cjs → ZDWCUMSJ-Cu1VTliO.cjs} +1 -1
  6. package/dist/{ZDWCUMSJ-IN3g-SXd.js → ZDWCUMSJ-DU81uAQq.js} +1 -1
  7. package/dist/{add-new-language-page-NXyJYXG-.js → add-new-language-page-0zC1CJZK.js} +2 -2
  8. package/dist/{add-new-language-page-zZoQgh6M.cjs → add-new-language-page-DQ46xqnc.cjs} +1 -1
  9. package/dist/{add-new-page-C7Kw3sZO.js → add-new-page-CUtZhDvi.js} +1 -1
  10. package/dist/{add-new-page-Cf_zoJPL.cjs → add-new-page-Ca2H2J-2.cjs} +1 -1
  11. package/dist/ai-panel-content-CV-HTsAs.cjs +1 -0
  12. package/dist/ai-panel-content-r2jlUBoR.js +52 -0
  13. package/dist/ai-panel-default-lang-D6RAQW1X.js +173 -0
  14. package/dist/ai-panel-default-lang-EH3w6g25.cjs +1 -0
  15. package/dist/ai-panel-message-bubble-Bl-aUeU4.cjs +1 -0
  16. package/dist/ai-panel-message-bubble-DPAaAMAZ.js +38 -0
  17. package/dist/ai-panel-other-lang-BeTdv7yM.js +133 -0
  18. package/dist/ai-panel-other-lang-_gGQTjZQ.cjs +1 -0
  19. package/dist/ai-panel-quick-prompts-CpzN48cl.js +46 -0
  20. package/dist/ai-panel-quick-prompts-DiNVPPAn.cjs +1 -0
  21. package/dist/ai-prompt-input-D-F23bdc.cjs +1 -0
  22. package/dist/ai-prompt-input-vAcIZSB1.js +133 -0
  23. package/dist/ai-translation-prompt-AImJlmDg.cjs +1 -0
  24. package/dist/ai-translation-prompt-BKyp1IW2.js +63 -0
  25. package/dist/{delete-page-CyqJ6iqb.js → delete-page-BS10zPLU.js} +1 -1
  26. package/dist/{delete-page-qrzBuLu5.cjs → delete-page-ClgtvB6n.cjs} +1 -1
  27. package/dist/{digital-asset-manager-BxM02CBp.js → digital-asset-manager-D_FFLECK.js} +1 -1
  28. package/dist/{digital-asset-manager-BfDE0iUu.cjs → digital-asset-manager-MK8ZL6Nd.cjs} +1 -1
  29. package/dist/{duplicate-page-CGKrJ-pm.cjs → duplicate-page-BaZrekqu.cjs} +1 -1
  30. package/dist/{duplicate-page-BGXDNCfU.js → duplicate-page-C1r4cCIJ.js} +9 -9
  31. package/dist/{dynamic-page-selector-C1ENQo3c.cjs → dynamic-page-selector-C4R_vhhz.cjs} +1 -1
  32. package/dist/{dynamic-page-selector-D0H0U30o.js → dynamic-page-selector-CjtnFkxO.js} +1 -1
  33. package/dist/index-C64wG61b.cjs +5 -0
  34. package/dist/{index-D2g32O6h.js → index-D_qadcqD.js} +869 -862
  35. package/dist/index.cjs +1 -1
  36. package/dist/index.d.ts +5 -3
  37. package/dist/index.js +7 -7
  38. package/dist/{json-diff-viewer-XF3MMhkA.js → json-diff-viewer-BURQmaIL.js} +1 -1
  39. package/dist/{json-diff-viewer-D03TdwEh.cjs → json-diff-viewer-CyZVbnpL.cjs} +1 -1
  40. package/dist/{lang-panel-8pMYi4Fn.js → lang-panel-C8yx7PSU.js} +33 -33
  41. package/dist/{lang-panel-BQiWaq2_.cjs → lang-panel-SUARS5YU.cjs} +1 -1
  42. package/dist/{mark-as-template-BGe_QmNY.js → mark-as-template-CUHypMlj.js} +1 -1
  43. package/dist/{mark-as-template-DwgrP1Vj.cjs → mark-as-template-DS-nfI06.cjs} +1 -1
  44. package/dist/{no-language-page-content-BiiD91y6.cjs → no-language-page-content-DZj3cmtM.cjs} +1 -1
  45. package/dist/{no-language-page-content-Cr6wq4o8.js → no-language-page-content-qoHrlxwD.js} +1 -1
  46. package/dist/{page-creator-PSrGtRIm.js → page-creator-C8VQGfap.js} +2 -2
  47. package/dist/{page-creator-Di9A1gxS.cjs → page-creator-HwE9ST54.cjs} +1 -1
  48. package/dist/{page-lock-request-DQT5Ur0g.js → page-lock-request-CBVKtxVj.js} +10 -10
  49. package/dist/{page-lock-request-Reyb6vZo.cjs → page-lock-request-Db7-x_EI.cjs} +1 -1
  50. package/dist/{page-locked-by-dialog-DF1_jPao.cjs → page-locked-by-dialog-CvRDaBcN.cjs} +1 -1
  51. package/dist/{page-locked-by-dialog-DgIr4-Gd.js → page-locked-by-dialog-DEC58QPA.js} +1 -1
  52. package/dist/{page-manager-new-BuLz6042.js → page-manager-new-B1PDwz2w.js} +67 -67
  53. package/dist/{page-manager-new-COui-em5.cjs → page-manager-new-CBxSkcYY.cjs} +1 -1
  54. package/dist/{page-manager-search-and-filter-DxqVJw_A.js → page-manager-search-and-filter-0eTSE1C1.js} +1 -1
  55. package/dist/{page-manager-search-and-filter-6_CVqZc_.cjs → page-manager-search-and-filter-BRLPHE64.cjs} +1 -1
  56. package/dist/{page-revisions-content-DagDCr7w.js → page-revisions-content-CKcp4He4.js} +10 -10
  57. package/dist/{page-revisions-content-BlM1X20k.cjs → page-revisions-content-CTrVTQ_s.cjs} +1 -1
  58. package/dist/prompt-helper-BtijECyh.cjs +51 -0
  59. package/dist/prompt-helper-CfyAlam9.js +175 -0
  60. package/dist/{publish-pages-content-6L8onxVt.cjs → publish-pages-content-B6HGaUtO.cjs} +1 -1
  61. package/dist/{publish-pages-content-eAcMLyLi.js → publish-pages-content-BMaeNHV2.js} +2 -2
  62. package/dist/{save-to-lib-BUen2a0-.cjs → save-to-lib-BKKTPv4h.cjs} +1 -1
  63. package/dist/{save-to-lib-C43iGfOH.js → save-to-lib-CccnzwO8.js} +1 -1
  64. package/dist/{seo-panel-DdE8DfMt.js → seo-panel-4KK4r-BP.js} +1 -1
  65. package/dist/{seo-panel-BseSTxFf.cjs → seo-panel-DL_rcWwC.cjs} +1 -1
  66. package/dist/server.cjs +238 -1
  67. package/dist/server.d.ts +50 -6
  68. package/dist/server.js +10324 -290
  69. package/dist/{shared-json-ld-D-S-SwbU.cjs → shared-json-ld-BuYzbmKx.cjs} +1 -1
  70. package/dist/{shared-json-ld-OwSauSop.js → shared-json-ld-DGW40Ccy.js} +41 -41
  71. package/dist/{slug-input-DYne39yC.cjs → slug-input--8SgDwYu.cjs} +1 -1
  72. package/dist/{slug-input-Bh4d19p2.js → slug-input-DH5w0H22.js} +1 -1
  73. package/dist/{theme-panel-footer-BnxQBiM2.js → theme-panel-footer-CHR7J97n.js} +1 -1
  74. package/dist/{theme-panel-footer-DLSf7QAN.cjs → theme-panel-footer-Co5VI_i9.cjs} +1 -1
  75. package/dist/{unmark-as-template-BTY-g4LE.cjs → unmark-as-template-B3h10oHA.cjs} +1 -1
  76. package/dist/{unmark-as-template-B9xuxdYK.js → unmark-as-template-DlA879QF.js} +1 -1
  77. package/dist/{unpublish-page-D0FunHFp.cjs → unpublish-page-Bfo_DuW5.cjs} +1 -1
  78. package/dist/{unpublish-page-CYmJyQH9.js → unpublish-page-JzGl35pF.js} +1 -1
  79. package/dist/{web-preview-y7dB2S91.js → web-preview-CJ6JyhJD.js} +1 -1
  80. package/dist/{web-preview-DDnJlhVc.cjs → web-preview-oG2epixb.cjs} +1 -1
  81. package/package.json +12 -12
  82. package/dist/ai-panel-content-BXnMSm-N.js +0 -614
  83. package/dist/ai-panel-content-xcOgRnxG.cjs +0 -142
  84. package/dist/index-CZxeSGRk.cjs +0 -5
@@ -1 +1 @@
1
- "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const e=require("react/jsx-runtime"),M=require("@chaibuilder/sdk"),I=require("@tanstack/react-query"),c=require("./index-CZxeSGRk.cjs"),s=require("@chaibuilder/sdk/ui"),G=require("lodash-es"),f=require("lucide-react"),x=require("react"),E=require("sonner"),q=()=>{const t=c.useApiUrl(),d=c.useFetch();return I.useQuery({queryKey:[c.ACTIONS.GET_GLOBAL_JSONLD_ITEMS],queryFn:async()=>d(t,{action:c.ACTIONS.GET_GLOBAL_JSONLD_ITEMS})})},U=({show:t,onClose:d,initialData:n})=>e.jsx(s.Dialog,{open:t,onOpenChange:()=>d(),children:t&&e.jsx(_,{show:t,onClose:d,initialData:n})}),_=({show:t,onClose:d,initialData:n})=>{const[r,p]=x.useState({name:"",content:"",description:"",enabledByDefaultForNewPages:!1}),[N,C]=x.useState(!1),{data:g}=c.useCurrentPage(),{mutateAsync:A,isPending:j}=c.useAddGlobalSchema(),{mutateAsync:u}=c.useTogglePageGlobalSchema(),v=I.useQueryClient();x.useEffect(()=>{p(n?{name:n.name,description:n.description,content:JSON.stringify(n.jsonld,null,2),enabledByDefaultForNewPages:!1}:{name:"",description:"",content:"",enabledByDefaultForNewPages:!1}),C(!1)},[t,n]);const i=async()=>{if(!r.name||!r.content){E.toast.error("Please enter a name and content");return}const l=c.parseJSONWithPlaceholders(r.content);if(!l.isValid){E.toast.error("Invalid JSON-LD content");return}const b={name:r.name,jsonld:l.parsed,addToExistingPages:N,addToNewPages:r.enabledByDefaultForNewPages,description:r.description};n!=null&&n.primaryPageId&&(b.primaryPage=n.primaryPageId);const w=await A(b);g!=null&&g.id&&(w!=null&&w.id)&&!(n!=null&&n.primaryPageId)&&(await u({schemaId:w.id,pageId:g.id,enabled:!0}),v.invalidateQueries({queryKey:[c.ACTIONS.GET_LANGUAGE_PAGES,g.id]})),d()};return e.jsxs(s.DialogContent,{className:"flex max-w-xl flex-col overflow-y-auto",children:[e.jsx(s.DialogHeader,{children:e.jsx(s.DialogTitle,{children:"Add New Shared JSON-LD Schema"})}),e.jsxs("div",{className:"flex max-h-[75vh] flex-col space-y-2 overflow-y-auto",children:[(n==null?void 0:n.languageCode)&&e.jsxs(s.Alert,{className:"border-blue-200 bg-blue-50",children:[e.jsx(f.Info,{className:"h-4 w-4 text-blue-600"}),e.jsxs(s.AlertDescription,{className:"text-sm text-blue-800",children:["You are creating a ",e.jsx("span",{className:"font-semibold",children:n.languageCode})," language version of this schema. This will be linked to the default language schema."]})]}),e.jsxs("div",{children:[e.jsx(s.Label,{htmlFor:"new-name",children:"Schema Name"}),e.jsx(s.Input,{id:"new-name",value:r.name,onChange:l=>p({...r,name:l.target.value}),placeholder:"e.g., Product Schema",className:"text-xs"})]}),e.jsxs("div",{children:[e.jsx(s.Label,{htmlFor:"new-description",children:"Description"}),e.jsx(s.Input,{id:"new-description",value:r.description||"",onChange:l=>p({...r,description:l.target.value}),placeholder:"Brief description of this schema"})]}),e.jsxs("div",{children:[e.jsx(s.Label,{htmlFor:"new-content",children:"JSON-LD Content"}),e.jsx(c.SmartJsonInput,{id:"new-content",value:r.content||"{}",onChange:l=>p({...r,content:l}),placeholder:"Enter JSON-LD markup...",rows:10})]}),!(n!=null&&n.primaryPageId)&&e.jsxs("div",{className:"flex flex-col gap-3 pt-2",children:[e.jsxs("div",{className:"flex items-center space-x-2",children:[e.jsx("input",{type:"checkbox",id:"add-to-all-existing",checked:N,onChange:l=>C(l.target.checked),className:"h-5 w-5 cursor-pointer rounded focus:outline-none focus:ring-2 focus:ring-primary focus:ring-offset-1"}),e.jsxs(s.Label,{htmlFor:"add-to-all-existing",children:[e.jsx("div",{children:"Add to all existing pages"}),e.jsx("div",{className:"text-xs font-light text-muted-foreground",children:"This schema will be added to all existing pages on your site"})]})]}),e.jsxs("div",{className:"flex items-center space-x-2",children:[e.jsx("input",{type:"checkbox",id:"new-enabled",checked:r.enabledByDefaultForNewPages,onChange:l=>p({...r,enabledByDefaultForNewPages:l.target.checked}),className:"h-5 w-5 cursor-pointer rounded focus:outline-none focus:ring-2 focus:ring-primary focus:ring-offset-1"}),e.jsxs(s.Label,{htmlFor:"new-enabled",children:[e.jsx("div",{children:"Enabled by default for new pages"}),e.jsx("div",{className:"text-xs font-light text-muted-foreground",children:"New pages will automatically include this schema"})]})]})]}),e.jsx("div",{className:"border-t pt-3",children:e.jsxs("div",{className:"flex items-center justify-end gap-2",children:[e.jsx(s.Button,{disabled:j,variant:"outline",type:"button",size:"sm",onClick:()=>d(),children:"Cancel"}),e.jsx(s.Button,{disabled:j,type:"button",size:"sm",onClick:i,children:j?e.jsxs(e.Fragment,{children:[e.jsx(f.Loader,{className:"h-4 w-4 animate-spin"})," Adding"]}):e.jsxs(e.Fragment,{children:["Add Schema",(n==null?void 0:n.languageCode)&&` (${n.languageCode})`]})})]})})]})]})},H=({id:t,onClose:d})=>e.jsx(s.Dialog,{open:!!t,onOpenChange:()=>d(),children:t&&e.jsx(Q,{id:t,onClose:d})}),Q=({id:t,onClose:d})=>{const[n,r]=x.useState({name:"",content:"",description:"",enabledByDefaultForNewPages:!1}),[p,N]=x.useState(!1),[C,g]=x.useState(!1),[A,j]=x.useState(!1),{data:u}=q(),{mutateAsync:v,isPending:i}=c.useUpdateGlobalSchema(),{mutateAsync:l}=c.useApplySchemaToAllPages(),{mutateAsync:b}=c.useRemoveSchemaFromAllPages();x.useEffect(()=>{var m,D;if(t&&u){const y=u.find(P=>P.id===t);y&&(r({name:y.name,description:((m=y.metadata)==null?void 0:m.description)||"",content:JSON.stringify(y.jsonld,null,2),enabledByDefaultForNewPages:((D=y.metadata)==null?void 0:D.addToNewPages)||!1}),j(!!y.primaryPage))}},[t,u]);const w=async()=>{if(!n.name||!n.content){E.toast.error("Please enter a name and content");return}const m=c.parseJSONWithPlaceholders(n.content);if(!m.isValid){E.toast.error("Invalid JSON-LD content");return}const D={id:t,name:n.name,jsonld:m.parsed,addToNewPages:n.enabledByDefaultForNewPages,description:n.description};await v(D),d()},F=async()=>{try{await l(t)}finally{N(!1)}},T=async()=>{try{await b(t)}finally{g(!1)}};return e.jsxs(s.DialogContent,{className:"flex max-w-xl flex-col overflow-y-auto",children:[e.jsx(s.DialogHeader,{children:e.jsx(s.DialogTitle,{children:"Edit Shared JSON-LD Schema"})}),e.jsxs("div",{className:"flex max-h-[75vh] flex-col space-y-2 overflow-y-auto",children:[!A&&e.jsxs("div",{className:"flex items-center justify-between rounded-lg border border-blue-300 bg-blue-500/10 p-2",children:[e.jsxs("div",{children:[e.jsx("div",{className:"text-sm font-medium text-blue-900",children:"Manage Existing Pages"}),e.jsx("div",{className:"text-xs text-blue-700",children:"Add or remove this schema from all existing pages on your site"})]}),e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(s.Button,{size:"sm",className:"text-xs",variant:"outline",onClick:()=>N(!0),children:"Add to all existing"}),e.jsx(s.Button,{size:"sm",variant:"ghost",className:"text-xs",onClick:()=>g(!0),children:"Remove from all"})]})]}),e.jsxs("div",{children:[e.jsx(s.Label,{htmlFor:"edit-name",children:"Schema Name"}),e.jsx(s.Input,{id:"edit-name",value:n.name,onChange:m=>r({...n,name:m.target.value}),placeholder:"e.g., Product Schema",className:"text-xs"})]}),e.jsxs("div",{children:[e.jsx(s.Label,{htmlFor:"edit-description",children:"Description"}),e.jsx(s.Input,{id:"edit-description",value:n.description||"",onChange:m=>r({...n,description:m.target.value}),placeholder:"Brief description of this schema"})]}),e.jsxs("div",{children:[e.jsx(s.Label,{htmlFor:"edit-content",children:"JSON-LD Content"}),e.jsx(c.SmartJsonInput,{id:"edit-content",value:n.content||"{}",onChange:m=>r({...n,content:m}),placeholder:"Enter JSON-LD markup...",rows:10})]}),!A&&e.jsxs("div",{className:"flex items-center space-x-2",children:[e.jsx("input",{type:"checkbox",id:"edit-enabled",checked:n.enabledByDefaultForNewPages,onChange:m=>r({...n,enabledByDefaultForNewPages:m.target.checked}),className:"h-5 w-5 cursor-pointer rounded focus:outline-none focus:ring-2 focus:ring-primary focus:ring-offset-1"}),e.jsxs(s.Label,{htmlFor:"edit-enabled",children:[e.jsx("div",{children:"Enabled by default for new pages"}),e.jsx("div",{className:"text-xs font-light text-muted-foreground",children:"New pages will automatically include this schema"})]})]}),e.jsx("div",{className:"border-t pt-3",children:e.jsxs("div",{className:"flex items-center justify-end gap-2",children:[e.jsx(s.Button,{disabled:i,variant:"outline",type:"button",size:"sm",onClick:()=>d(),children:"Cancel"}),e.jsx(s.Button,{disabled:i,type:"button",size:"sm",onClick:w,children:i?e.jsxs(e.Fragment,{children:[e.jsx(f.Loader,{className:"h-4 w-4 animate-spin"})," Updating"]}):"Update Schema"})]})})]}),e.jsx(s.AlertDialog,{open:p,onOpenChange:N,children:e.jsxs(s.AlertDialogContent,{children:[e.jsxs(s.AlertDialogHeader,{children:[e.jsx(s.AlertDialogTitle,{children:"Add to All Existing Pages?"}),e.jsxs(s.AlertDialogDescription,{children:["This will add the schema ",e.jsx("span",{className:"font-medium",children:n.name})," to all existing pages on your site. This action cannot be undone automatically."]})]}),e.jsxs(s.AlertDialogFooter,{children:[e.jsx(s.AlertDialogCancel,{children:"Cancel"}),e.jsx(s.AlertDialogAction,{onClick:F,children:"Add to All"})]})]})}),e.jsx(s.AlertDialog,{open:C,onOpenChange:g,children:e.jsxs(s.AlertDialogContent,{children:[e.jsxs(s.AlertDialogHeader,{children:[e.jsx(s.AlertDialogTitle,{children:"Remove from All Pages?"}),e.jsxs(s.AlertDialogDescription,{children:["This will remove the schema ",e.jsx("span",{className:"font-medium",children:n.name})," from all existing pages on your site. This action cannot be undone automatically."]})]}),e.jsxs(s.AlertDialogFooter,{children:[e.jsx(s.AlertDialogCancel,{children:"Cancel"}),e.jsx(s.AlertDialogAction,{onClick:T,className:"bg-red-500 hover:bg-red-600",children:"Remove from All"})]})]})})]})};function V(){const[t,d]=x.useState(!1),[n,r]=x.useState(void 0),[p,N]=x.useState(null),[C,g]=x.useState(null),[A,j]=x.useState(null),{data:u,isLoading:v}=q(),{selectedLang:i}=M.useLanguages(),{data:l}=c.useCurrentPage(),{data:b}=c.useLanguagePages(),{mutateAsync:w}=c.useDeleteGlobalSchema(),{mutateAsync:F}=c.useTogglePageGlobalSchema(),T=x.useMemo(()=>b==null?void 0:b.find(a=>!a.primaryPage&&a.lang===""),[b]),m=x.useMemo(()=>(T==null?void 0:T.globalJsonLds)||[],[T]),D=x.useMemo(()=>u?G.filter(u,o=>o.primaryPage===null&&o.lang==="").map(o=>{const h=i?G.find(u,S=>S.primaryPage===o.id&&S.lang===i):null;return{defaultSchema:o,languageVersion:h,displayItem:h||o,hasLanguageVersion:!!h}}):[],[u,i]),[y,P]=x.useState([]),L=y.length>0?y:(l==null?void 0:l.globalJsonLds)||[];x.useEffect(()=>{l!=null&&l.globalJsonLds&&P(l.globalJsonLds)},[l==null?void 0:l.globalJsonLds]);const z=async a=>{if(!(l!=null&&l.id))return;j(a);const o=L.includes(a),h=o?L.filter(S=>S!==a):[...L,a];P(h);try{await F({schemaId:a,pageId:l.id,enabled:!o})}catch{P(l.globalJsonLds)}finally{j(null)}},R=async a=>{j(a);try{await w(a)}finally{j(null)}};return e.jsxs("div",{className:"rounded border bg-muted p-2",children:[e.jsxs("div",{className:"flex items-center justify-between pb-2",children:[e.jsxs("div",{children:[e.jsx("div",{className:"text-xs font-medium",children:"Shared JSON-LD Templates"}),e.jsx("div",{className:"w-full text-xs text-gray-500",children:"Manage reusable JSON-LD schemas that can be applied across multiple pages"})]}),!i&&e.jsxs(s.Tooltip,{delayDuration:0,children:[e.jsx(s.TooltipTrigger,{type:"button",disabled:v,className:"rounded-full bg-primary p-1 text-primary-foreground hover:bg-primary/80",onClick:a=>{a.stopPropagation(),d(!0)},children:v?e.jsx(f.Loader,{className:"h-4 w-4 animate-spin"}):e.jsx(f.Plus,{className:"h-4 w-4"})}),e.jsx(s.TooltipContent,{children:"Add new schema"})]})]}),e.jsxs(s.ScrollArea,{className:"max-h-96 overflow-y-auto",children:[e.jsxs("div",{className:"space-y-2",children:[(!u||(u==null?void 0:u.length)===0)&&!v&&e.jsx("div",{className:"flex items-center justify-center px-2 py-4 text-xs",children:"No shared JSON-LD found"}),D.map(({defaultSchema:a,displayItem:o,hasLanguageVersion:h})=>{var k,B;const S=L.includes(o.id),O=m.includes(a.id),J=h&&i?O:S;return e.jsxs(s.Card,{className:`relative border-gray-300 p-0 shadow-none transition-all ${A===o.id?"pointer-events-none":""}`,children:[A===o.id&&e.jsx("div",{className:"absolute bottom-0 left-0 right-0 top-0 z-50 flex items-center justify-center rounded-xl bg-white/80",children:e.jsx(f.Loader,{className:"h-5 w-5 animate-spin text-primary"})}),e.jsx(s.CardHeader,{className:"p-2",children:e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsxs("div",{className:"flex items-center gap-3",children:[(h||!i)&&e.jsxs(s.Tooltip,{delayDuration:0,children:[e.jsx(s.TooltipTrigger,{asChild:!0,children:e.jsx("input",{type:"checkbox",checked:J,onChange:()=>z(a.id),disabled:!!(h&&i),className:"h-5 w-5 cursor-pointer rounded focus:outline-none focus:ring-2 focus:ring-primary focus:ring-offset-1"})}),h&&i&&e.jsx(s.TooltipContent,{children:"Using the default language state"})]}),e.jsxs("div",{children:[e.jsxs(s.CardTitle,{className:"flex items-center gap-2 text-sm leading-none",children:[o.name,h&&i&&e.jsxs("span",{className:"text-xs font-normal text-muted-foreground",children:["(",i,")"]}),J&&e.jsx("span",{className:"sr-only text-xs font-normal text-muted-foreground",children:"Enabled"})]}),((k=o==null?void 0:o.metadata)==null?void 0:k.description)&&e.jsx("p",{className:"mt-1 text-xs leading-none text-muted-foreground",children:(B=o==null?void 0:o.metadata)==null?void 0:B.description})]})]}),e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("div",{className:"mx-2 h-6 w-px bg-border"}),e.jsxs(s.Tooltip,{delayDuration:0,children:[e.jsx(s.TooltipTrigger,{asChild:!0,children:e.jsx(s.Button,{type:"button",variant:"ghost",size:"icon",className:"h-5 w-5 p-0",onClick:()=>g(o.id),children:e.jsx(f.Eye,{className:"h-4 w-4"})})}),e.jsx(s.TooltipContent,{children:"View schema"})]}),(h||!i)&&e.jsxs(e.Fragment,{children:[e.jsxs(s.Tooltip,{delayDuration:0,children:[e.jsx(s.TooltipTrigger,{asChild:!0,children:e.jsx(s.Button,{type:"button",variant:"ghost",size:"icon",className:"h-5 w-5 p-0",onClick:()=>N(o.id),children:e.jsx(f.Edit,{className:"h-4 w-4"})})}),e.jsx(s.TooltipContent,{children:"Edit schema"})]}),e.jsxs(s.AlertDialog,{children:[e.jsxs(s.Tooltip,{delayDuration:0,children:[e.jsx(s.TooltipTrigger,{asChild:!0,children:e.jsx(s.AlertDialogTrigger,{className:"flex h-5 w-5 items-center justify-center rounded-md text-red-500 hover:bg-red-100 hover:text-red-800",children:e.jsx(f.Trash,{className:"h-4 w-4"})})}),e.jsx(s.TooltipContent,{children:"Delete schema"})]}),e.jsxs(s.AlertDialogContent,{children:[e.jsxs(s.AlertDialogHeader,{children:[e.jsx(s.AlertDialogTitle,{children:"Delete Schema"}),e.jsxs(s.AlertDialogDescription,{children:["Are you sure you want to delete"," ",e.jsx("span",{className:"font-medium",children:o.name}),"? This action cannot be undone."]})]}),e.jsxs(s.AlertDialogFooter,{children:[e.jsx(s.AlertDialogCancel,{type:"button",children:"Cancel"}),e.jsx(s.AlertDialogAction,{type:"button",onClick:()=>R(o.id),className:"bg-red-500 text-white hover:bg-red-600",children:"Delete"})]})]})]})]})]})]})}),!h&&i&&e.jsx(s.CardContent,{className:"px-2 pb-2",children:e.jsxs("div",{className:"flex w-full flex-col items-center justify-center rounded-lg border bg-gray-100 py-3",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsxs("div",{className:"max-w-xl text-center text-xs text-gray-500",children:["Not available in '",i,"' language. Default language JSONLD will be used."]}),O&&e.jsx("span",{className:"rounded-full bg-green-100 px-2 py-0.5 text-xs font-medium text-green-700",children:"Enabled in default"})]}),e.jsx(s.Button,{type:"button",size:"sm",variant:"outline",className:"mt-2",onClick:()=>{r({name:a.name,description:a.description||"",jsonld:a.jsonld,languageCode:i,primaryPageId:a.id}),d(!0)},children:"Copy & Edit from default language"})]})})]},a.id)})]}),v&&e.jsx("div",{className:"flex items-center justify-center p-4",children:e.jsx(f.Loader,{className:"h-5 w-5 animate-spin"})})]}),e.jsx(U,{show:t,onClose:()=>{d(!1),r(void 0)},initialData:n}),e.jsx(H,{id:p,onClose:()=>N(null)}),e.jsx(K,{schema:u==null?void 0:u.find(a=>a.id===C),onClose:()=>g(null)})]})}const K=({schema:t,onClose:d})=>e.jsx(s.Dialog,{open:!!t,onOpenChange:d,children:e.jsxs(s.DialogContent,{className:"max-w-2xl",children:[e.jsx(s.DialogHeader,{children:e.jsxs(s.DialogTitle,{className:"flex items-center gap-2",children:[t==null?void 0:t.name,(t==null?void 0:t.lang)&&e.jsxs("span",{className:"text-sm font-normal text-muted-foreground",children:["(",t.lang,")"]})]})}),e.jsxs("div",{className:"space-y-3",children:[(t==null?void 0:t.description)&&e.jsxs("div",{children:[e.jsx("div",{className:"text-xs font-medium text-muted-foreground",children:"Description"}),e.jsx("div",{className:"text-sm",children:t.description})]}),e.jsxs("div",{children:[e.jsx("div",{className:"mb-2 text-xs font-medium text-muted-foreground",children:"JSON-LD Schema"}),e.jsx(s.Textarea,{value:JSON.stringify(t==null?void 0:t.jsonld,null,2),readOnly:!0,className:"font-mono text-xs",rows:15})]})]})]})});exports.default=V;
1
+ "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const e=require("react/jsx-runtime"),M=require("@chaibuilder/sdk"),I=require("@tanstack/react-query"),c=require("./index-C64wG61b.cjs"),s=require("@chaibuilder/sdk/ui"),G=require("lodash-es"),f=require("lucide-react"),x=require("react"),E=require("sonner"),q=()=>{const t=c.useApiUrl(),d=c.useFetch();return I.useQuery({queryKey:[c.ACTIONS.GET_GLOBAL_JSONLD_ITEMS],queryFn:async()=>d(t,{action:c.ACTIONS.GET_GLOBAL_JSONLD_ITEMS})})},U=({show:t,onClose:d,initialData:n})=>e.jsx(s.Dialog,{open:t,onOpenChange:()=>d(),children:t&&e.jsx(_,{show:t,onClose:d,initialData:n})}),_=({show:t,onClose:d,initialData:n})=>{const[r,p]=x.useState({name:"",content:"",description:"",enabledByDefaultForNewPages:!1}),[N,C]=x.useState(!1),{data:g}=c.useCurrentPage(),{mutateAsync:A,isPending:j}=c.useAddGlobalSchema(),{mutateAsync:u}=c.useTogglePageGlobalSchema(),v=I.useQueryClient();x.useEffect(()=>{p(n?{name:n.name,description:n.description,content:JSON.stringify(n.jsonld,null,2),enabledByDefaultForNewPages:!1}:{name:"",description:"",content:"",enabledByDefaultForNewPages:!1}),C(!1)},[t,n]);const i=async()=>{if(!r.name||!r.content){E.toast.error("Please enter a name and content");return}const l=c.parseJSONWithPlaceholders(r.content);if(!l.isValid){E.toast.error("Invalid JSON-LD content");return}const b={name:r.name,jsonld:l.parsed,addToExistingPages:N,addToNewPages:r.enabledByDefaultForNewPages,description:r.description};n!=null&&n.primaryPageId&&(b.primaryPage=n.primaryPageId);const w=await A(b);g!=null&&g.id&&(w!=null&&w.id)&&!(n!=null&&n.primaryPageId)&&(await u({schemaId:w.id,pageId:g.id,enabled:!0}),v.invalidateQueries({queryKey:[c.ACTIONS.GET_LANGUAGE_PAGES,g.id]})),d()};return e.jsxs(s.DialogContent,{className:"flex max-w-xl flex-col overflow-y-auto",children:[e.jsx(s.DialogHeader,{children:e.jsx(s.DialogTitle,{children:"Add New Shared JSON-LD Schema"})}),e.jsxs("div",{className:"flex max-h-[75vh] flex-col space-y-2 overflow-y-auto",children:[(n==null?void 0:n.languageCode)&&e.jsxs(s.Alert,{className:"border-blue-200 bg-blue-50",children:[e.jsx(f.Info,{className:"h-4 w-4 text-blue-600"}),e.jsxs(s.AlertDescription,{className:"text-sm text-blue-800",children:["You are creating a ",e.jsx("span",{className:"font-semibold",children:n.languageCode})," language version of this schema. This will be linked to the default language schema."]})]}),e.jsxs("div",{children:[e.jsx(s.Label,{htmlFor:"new-name",children:"Schema Name"}),e.jsx(s.Input,{id:"new-name",value:r.name,onChange:l=>p({...r,name:l.target.value}),placeholder:"e.g., Product Schema",className:"text-xs"})]}),e.jsxs("div",{children:[e.jsx(s.Label,{htmlFor:"new-description",children:"Description"}),e.jsx(s.Input,{id:"new-description",value:r.description||"",onChange:l=>p({...r,description:l.target.value}),placeholder:"Brief description of this schema"})]}),e.jsxs("div",{children:[e.jsx(s.Label,{htmlFor:"new-content",children:"JSON-LD Content"}),e.jsx(c.SmartJsonInput,{id:"new-content",value:r.content||"{}",onChange:l=>p({...r,content:l}),placeholder:"Enter JSON-LD markup...",rows:10})]}),!(n!=null&&n.primaryPageId)&&e.jsxs("div",{className:"flex flex-col gap-3 pt-2",children:[e.jsxs("div",{className:"flex items-center space-x-2",children:[e.jsx("input",{type:"checkbox",id:"add-to-all-existing",checked:N,onChange:l=>C(l.target.checked),className:"h-5 w-5 cursor-pointer rounded focus:outline-none focus:ring-2 focus:ring-primary focus:ring-offset-1"}),e.jsxs(s.Label,{htmlFor:"add-to-all-existing",children:[e.jsx("div",{children:"Add to all existing pages"}),e.jsx("div",{className:"text-xs font-light text-muted-foreground",children:"This schema will be added to all existing pages on your site"})]})]}),e.jsxs("div",{className:"flex items-center space-x-2",children:[e.jsx("input",{type:"checkbox",id:"new-enabled",checked:r.enabledByDefaultForNewPages,onChange:l=>p({...r,enabledByDefaultForNewPages:l.target.checked}),className:"h-5 w-5 cursor-pointer rounded focus:outline-none focus:ring-2 focus:ring-primary focus:ring-offset-1"}),e.jsxs(s.Label,{htmlFor:"new-enabled",children:[e.jsx("div",{children:"Enabled by default for new pages"}),e.jsx("div",{className:"text-xs font-light text-muted-foreground",children:"New pages will automatically include this schema"})]})]})]}),e.jsx("div",{className:"border-t pt-3",children:e.jsxs("div",{className:"flex items-center justify-end gap-2",children:[e.jsx(s.Button,{disabled:j,variant:"outline",type:"button",size:"sm",onClick:()=>d(),children:"Cancel"}),e.jsx(s.Button,{disabled:j,type:"button",size:"sm",onClick:i,children:j?e.jsxs(e.Fragment,{children:[e.jsx(f.Loader,{className:"h-4 w-4 animate-spin"})," Adding"]}):e.jsxs(e.Fragment,{children:["Add Schema",(n==null?void 0:n.languageCode)&&` (${n.languageCode})`]})})]})})]})]})},H=({id:t,onClose:d})=>e.jsx(s.Dialog,{open:!!t,onOpenChange:()=>d(),children:t&&e.jsx(Q,{id:t,onClose:d})}),Q=({id:t,onClose:d})=>{const[n,r]=x.useState({name:"",content:"",description:"",enabledByDefaultForNewPages:!1}),[p,N]=x.useState(!1),[C,g]=x.useState(!1),[A,j]=x.useState(!1),{data:u}=q(),{mutateAsync:v,isPending:i}=c.useUpdateGlobalSchema(),{mutateAsync:l}=c.useApplySchemaToAllPages(),{mutateAsync:b}=c.useRemoveSchemaFromAllPages();x.useEffect(()=>{var m,D;if(t&&u){const y=u.find(P=>P.id===t);y&&(r({name:y.name,description:((m=y.metadata)==null?void 0:m.description)||"",content:JSON.stringify(y.jsonld,null,2),enabledByDefaultForNewPages:((D=y.metadata)==null?void 0:D.addToNewPages)||!1}),j(!!y.primaryPage))}},[t,u]);const w=async()=>{if(!n.name||!n.content){E.toast.error("Please enter a name and content");return}const m=c.parseJSONWithPlaceholders(n.content);if(!m.isValid){E.toast.error("Invalid JSON-LD content");return}const D={id:t,name:n.name,jsonld:m.parsed,addToNewPages:n.enabledByDefaultForNewPages,description:n.description};await v(D),d()},F=async()=>{try{await l(t)}finally{N(!1)}},T=async()=>{try{await b(t)}finally{g(!1)}};return e.jsxs(s.DialogContent,{className:"flex max-w-xl flex-col overflow-y-auto",children:[e.jsx(s.DialogHeader,{children:e.jsx(s.DialogTitle,{children:"Edit Shared JSON-LD Schema"})}),e.jsxs("div",{className:"flex max-h-[75vh] flex-col space-y-2 overflow-y-auto",children:[!A&&e.jsxs("div",{className:"flex items-center justify-between rounded-lg border border-blue-300 bg-blue-500/10 p-2",children:[e.jsxs("div",{children:[e.jsx("div",{className:"text-sm font-medium text-blue-900",children:"Manage Existing Pages"}),e.jsx("div",{className:"text-xs text-blue-700",children:"Add or remove this schema from all existing pages on your site"})]}),e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(s.Button,{size:"sm",className:"text-xs",variant:"outline",onClick:()=>N(!0),children:"Add to all existing"}),e.jsx(s.Button,{size:"sm",variant:"ghost",className:"text-xs",onClick:()=>g(!0),children:"Remove from all"})]})]}),e.jsxs("div",{children:[e.jsx(s.Label,{htmlFor:"edit-name",children:"Schema Name"}),e.jsx(s.Input,{id:"edit-name",value:n.name,onChange:m=>r({...n,name:m.target.value}),placeholder:"e.g., Product Schema",className:"text-xs"})]}),e.jsxs("div",{children:[e.jsx(s.Label,{htmlFor:"edit-description",children:"Description"}),e.jsx(s.Input,{id:"edit-description",value:n.description||"",onChange:m=>r({...n,description:m.target.value}),placeholder:"Brief description of this schema"})]}),e.jsxs("div",{children:[e.jsx(s.Label,{htmlFor:"edit-content",children:"JSON-LD Content"}),e.jsx(c.SmartJsonInput,{id:"edit-content",value:n.content||"{}",onChange:m=>r({...n,content:m}),placeholder:"Enter JSON-LD markup...",rows:10})]}),!A&&e.jsxs("div",{className:"flex items-center space-x-2",children:[e.jsx("input",{type:"checkbox",id:"edit-enabled",checked:n.enabledByDefaultForNewPages,onChange:m=>r({...n,enabledByDefaultForNewPages:m.target.checked}),className:"h-5 w-5 cursor-pointer rounded focus:outline-none focus:ring-2 focus:ring-primary focus:ring-offset-1"}),e.jsxs(s.Label,{htmlFor:"edit-enabled",children:[e.jsx("div",{children:"Enabled by default for new pages"}),e.jsx("div",{className:"text-xs font-light text-muted-foreground",children:"New pages will automatically include this schema"})]})]}),e.jsx("div",{className:"border-t pt-3",children:e.jsxs("div",{className:"flex items-center justify-end gap-2",children:[e.jsx(s.Button,{disabled:i,variant:"outline",type:"button",size:"sm",onClick:()=>d(),children:"Cancel"}),e.jsx(s.Button,{disabled:i,type:"button",size:"sm",onClick:w,children:i?e.jsxs(e.Fragment,{children:[e.jsx(f.Loader,{className:"h-4 w-4 animate-spin"})," Updating"]}):"Update Schema"})]})})]}),e.jsx(s.AlertDialog,{open:p,onOpenChange:N,children:e.jsxs(s.AlertDialogContent,{children:[e.jsxs(s.AlertDialogHeader,{children:[e.jsx(s.AlertDialogTitle,{children:"Add to All Existing Pages?"}),e.jsxs(s.AlertDialogDescription,{children:["This will add the schema ",e.jsx("span",{className:"font-medium",children:n.name})," to all existing pages on your site. This action cannot be undone automatically."]})]}),e.jsxs(s.AlertDialogFooter,{children:[e.jsx(s.AlertDialogCancel,{children:"Cancel"}),e.jsx(s.AlertDialogAction,{onClick:F,children:"Add to All"})]})]})}),e.jsx(s.AlertDialog,{open:C,onOpenChange:g,children:e.jsxs(s.AlertDialogContent,{children:[e.jsxs(s.AlertDialogHeader,{children:[e.jsx(s.AlertDialogTitle,{children:"Remove from All Pages?"}),e.jsxs(s.AlertDialogDescription,{children:["This will remove the schema ",e.jsx("span",{className:"font-medium",children:n.name})," from all existing pages on your site. This action cannot be undone automatically."]})]}),e.jsxs(s.AlertDialogFooter,{children:[e.jsx(s.AlertDialogCancel,{children:"Cancel"}),e.jsx(s.AlertDialogAction,{onClick:T,className:"bg-red-500 hover:bg-red-600",children:"Remove from All"})]})]})})]})};function V(){const[t,d]=x.useState(!1),[n,r]=x.useState(void 0),[p,N]=x.useState(null),[C,g]=x.useState(null),[A,j]=x.useState(null),{data:u,isLoading:v}=q(),{selectedLang:i}=M.useLanguages(),{data:l}=c.useCurrentPage(),{data:b}=c.useLanguagePages(),{mutateAsync:w}=c.useDeleteGlobalSchema(),{mutateAsync:F}=c.useTogglePageGlobalSchema(),T=x.useMemo(()=>b==null?void 0:b.find(a=>!a.primaryPage&&a.lang===""),[b]),m=x.useMemo(()=>(T==null?void 0:T.globalJsonLds)||[],[T]),D=x.useMemo(()=>u?G.filter(u,o=>o.primaryPage===null&&o.lang==="").map(o=>{const h=i?G.find(u,S=>S.primaryPage===o.id&&S.lang===i):null;return{defaultSchema:o,languageVersion:h,displayItem:h||o,hasLanguageVersion:!!h}}):[],[u,i]),[y,P]=x.useState([]),L=y.length>0?y:(l==null?void 0:l.globalJsonLds)||[];x.useEffect(()=>{l!=null&&l.globalJsonLds&&P(l.globalJsonLds)},[l==null?void 0:l.globalJsonLds]);const z=async a=>{if(!(l!=null&&l.id))return;j(a);const o=L.includes(a),h=o?L.filter(S=>S!==a):[...L,a];P(h);try{await F({schemaId:a,pageId:l.id,enabled:!o})}catch{P(l.globalJsonLds)}finally{j(null)}},R=async a=>{j(a);try{await w(a)}finally{j(null)}};return e.jsxs("div",{className:"rounded border bg-muted p-2",children:[e.jsxs("div",{className:"flex items-center justify-between pb-2",children:[e.jsxs("div",{children:[e.jsx("div",{className:"text-xs font-medium",children:"Shared JSON-LD Templates"}),e.jsx("div",{className:"w-full text-xs text-gray-500",children:"Manage reusable JSON-LD schemas that can be applied across multiple pages"})]}),!i&&e.jsxs(s.Tooltip,{delayDuration:0,children:[e.jsx(s.TooltipTrigger,{type:"button",disabled:v,className:"rounded-full bg-primary p-1 text-primary-foreground hover:bg-primary/80",onClick:a=>{a.stopPropagation(),d(!0)},children:v?e.jsx(f.Loader,{className:"h-4 w-4 animate-spin"}):e.jsx(f.Plus,{className:"h-4 w-4"})}),e.jsx(s.TooltipContent,{children:"Add new schema"})]})]}),e.jsxs(s.ScrollArea,{className:"max-h-96 overflow-y-auto",children:[e.jsxs("div",{className:"space-y-2",children:[(!u||(u==null?void 0:u.length)===0)&&!v&&e.jsx("div",{className:"flex items-center justify-center px-2 py-4 text-xs",children:"No shared JSON-LD found"}),D.map(({defaultSchema:a,displayItem:o,hasLanguageVersion:h})=>{var k,B;const S=L.includes(o.id),O=m.includes(a.id),J=h&&i?O:S;return e.jsxs(s.Card,{className:`relative border-gray-300 p-0 shadow-none transition-all ${A===o.id?"pointer-events-none":""}`,children:[A===o.id&&e.jsx("div",{className:"absolute bottom-0 left-0 right-0 top-0 z-50 flex items-center justify-center rounded-xl bg-white/80",children:e.jsx(f.Loader,{className:"h-5 w-5 animate-spin text-primary"})}),e.jsx(s.CardHeader,{className:"p-2",children:e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsxs("div",{className:"flex items-center gap-3",children:[(h||!i)&&e.jsxs(s.Tooltip,{delayDuration:0,children:[e.jsx(s.TooltipTrigger,{asChild:!0,children:e.jsx("input",{type:"checkbox",checked:J,onChange:()=>z(a.id),disabled:!!(h&&i),className:"h-5 w-5 cursor-pointer rounded focus:outline-none focus:ring-2 focus:ring-primary focus:ring-offset-1"})}),h&&i&&e.jsx(s.TooltipContent,{children:"Using the default language state"})]}),e.jsxs("div",{children:[e.jsxs(s.CardTitle,{className:"flex items-center gap-2 text-sm leading-none",children:[o.name,h&&i&&e.jsxs("span",{className:"text-xs font-normal text-muted-foreground",children:["(",i,")"]}),J&&e.jsx("span",{className:"sr-only text-xs font-normal text-muted-foreground",children:"Enabled"})]}),((k=o==null?void 0:o.metadata)==null?void 0:k.description)&&e.jsx("p",{className:"mt-1 text-xs leading-none text-muted-foreground",children:(B=o==null?void 0:o.metadata)==null?void 0:B.description})]})]}),e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("div",{className:"mx-2 h-6 w-px bg-border"}),e.jsxs(s.Tooltip,{delayDuration:0,children:[e.jsx(s.TooltipTrigger,{asChild:!0,children:e.jsx(s.Button,{type:"button",variant:"ghost",size:"icon",className:"h-5 w-5 p-0",onClick:()=>g(o.id),children:e.jsx(f.Eye,{className:"h-4 w-4"})})}),e.jsx(s.TooltipContent,{children:"View schema"})]}),(h||!i)&&e.jsxs(e.Fragment,{children:[e.jsxs(s.Tooltip,{delayDuration:0,children:[e.jsx(s.TooltipTrigger,{asChild:!0,children:e.jsx(s.Button,{type:"button",variant:"ghost",size:"icon",className:"h-5 w-5 p-0",onClick:()=>N(o.id),children:e.jsx(f.Edit,{className:"h-4 w-4"})})}),e.jsx(s.TooltipContent,{children:"Edit schema"})]}),e.jsxs(s.AlertDialog,{children:[e.jsxs(s.Tooltip,{delayDuration:0,children:[e.jsx(s.TooltipTrigger,{asChild:!0,children:e.jsx(s.AlertDialogTrigger,{className:"flex h-5 w-5 items-center justify-center rounded-md text-red-500 hover:bg-red-100 hover:text-red-800",children:e.jsx(f.Trash,{className:"h-4 w-4"})})}),e.jsx(s.TooltipContent,{children:"Delete schema"})]}),e.jsxs(s.AlertDialogContent,{children:[e.jsxs(s.AlertDialogHeader,{children:[e.jsx(s.AlertDialogTitle,{children:"Delete Schema"}),e.jsxs(s.AlertDialogDescription,{children:["Are you sure you want to delete"," ",e.jsx("span",{className:"font-medium",children:o.name}),"? This action cannot be undone."]})]}),e.jsxs(s.AlertDialogFooter,{children:[e.jsx(s.AlertDialogCancel,{type:"button",children:"Cancel"}),e.jsx(s.AlertDialogAction,{type:"button",onClick:()=>R(o.id),className:"bg-red-500 text-white hover:bg-red-600",children:"Delete"})]})]})]})]})]})]})}),!h&&i&&e.jsx(s.CardContent,{className:"px-2 pb-2",children:e.jsxs("div",{className:"flex w-full flex-col items-center justify-center rounded-lg border bg-gray-100 py-3",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsxs("div",{className:"max-w-xl text-center text-xs text-gray-500",children:["Not available in '",i,"' language. Default language JSONLD will be used."]}),O&&e.jsx("span",{className:"rounded-full bg-green-100 px-2 py-0.5 text-xs font-medium text-green-700",children:"Enabled in default"})]}),e.jsx(s.Button,{type:"button",size:"sm",variant:"outline",className:"mt-2",onClick:()=>{r({name:a.name,description:a.description||"",jsonld:a.jsonld,languageCode:i,primaryPageId:a.id}),d(!0)},children:"Copy & Edit from default language"})]})})]},a.id)})]}),v&&e.jsx("div",{className:"flex items-center justify-center p-4",children:e.jsx(f.Loader,{className:"h-5 w-5 animate-spin"})})]}),e.jsx(U,{show:t,onClose:()=>{d(!1),r(void 0)},initialData:n}),e.jsx(H,{id:p,onClose:()=>N(null)}),e.jsx(K,{schema:u==null?void 0:u.find(a=>a.id===C),onClose:()=>g(null)})]})}const K=({schema:t,onClose:d})=>e.jsx(s.Dialog,{open:!!t,onOpenChange:d,children:e.jsxs(s.DialogContent,{className:"max-w-2xl",children:[e.jsx(s.DialogHeader,{children:e.jsxs(s.DialogTitle,{className:"flex items-center gap-2",children:[t==null?void 0:t.name,(t==null?void 0:t.lang)&&e.jsxs("span",{className:"text-sm font-normal text-muted-foreground",children:["(",t.lang,")"]})]})}),e.jsxs("div",{className:"space-y-3",children:[(t==null?void 0:t.description)&&e.jsxs("div",{children:[e.jsx("div",{className:"text-xs font-medium text-muted-foreground",children:"Description"}),e.jsx("div",{className:"text-sm",children:t.description})]}),e.jsxs("div",{children:[e.jsx("div",{className:"mb-2 text-xs font-medium text-muted-foreground",children:"JSON-LD Schema"}),e.jsx(s.Textarea,{value:JSON.stringify(t==null?void 0:t.jsonld,null,2),readOnly:!0,className:"font-mono text-xs",rows:15})]})]})]})});exports.default=V;
@@ -1,24 +1,24 @@
1
1
  import { jsx as e, jsxs as n, Fragment as j } from "react/jsx-runtime";
2
2
  import { useLanguages as me } from "@chaibuilder/sdk";
3
3
  import { useQuery as he, useQueryClient as ue } from "@tanstack/react-query";
4
- import { ak as ge, al as fe, A as U, ap as te, au as pe, av as se, aw as re, ax as de, ay as xe, az as Ne, aA as be, g as ye, aB as ve } from "./index-D2g32O6h.js";
4
+ import { am as ge, an as fe, A as U, ar as le, aw as pe, ax as se, ay as re, az as de, aA as xe, aB as Ne, aC as be, g as ye, aD as ve } from "./index-D_qadcqD.js";
5
5
  import { Dialog as $, DialogContent as W, DialogHeader as Y, DialogTitle as X, Alert as we, AlertDescription as Ae, Label as y, Input as G, Button as v, AlertDialog as _, AlertDialogContent as R, AlertDialogHeader as M, AlertDialogTitle as q, AlertDialogDescription as H, AlertDialogFooter as Q, AlertDialogCancel as V, AlertDialogAction as K, Tooltip as E, TooltipTrigger as J, TooltipContent as O, ScrollArea as Ce, Card as Se, CardHeader as Pe, CardTitle as Te, AlertDialogTrigger as De, CardContent as Le, Textarea as Ee } from "@chaibuilder/sdk/ui";
6
6
  import { filter as Je, find as Oe } from "lodash-es";
7
7
  import { Info as Fe, Loader as F, Plus as ke, Eye as je, Edit as Ge, Trash as Be } from "lucide-react";
8
8
  import { useState as g, useEffect as Z, useMemo as z } from "react";
9
9
  import { toast as B } from "sonner";
10
10
  const oe = () => {
11
- const l = ge(), i = fe();
11
+ const t = ge(), i = fe();
12
12
  return he({
13
13
  queryKey: [U.GET_GLOBAL_JSONLD_ITEMS],
14
- queryFn: async () => i(l, { action: U.GET_GLOBAL_JSONLD_ITEMS })
14
+ queryFn: async () => i(t, { action: U.GET_GLOBAL_JSONLD_ITEMS })
15
15
  });
16
16
  }, Ie = ({
17
- show: l,
17
+ show: t,
18
18
  onClose: i,
19
19
  initialData: a
20
- }) => /* @__PURE__ */ e($, { open: l, onOpenChange: () => i(), children: l && /* @__PURE__ */ e(ze, { show: l, onClose: i, initialData: a }) }), ze = ({
21
- show: l,
20
+ }) => /* @__PURE__ */ e($, { open: t, onOpenChange: () => i(), children: t && /* @__PURE__ */ e(ze, { show: t, onClose: i, initialData: a }) }), ze = ({
21
+ show: t,
22
22
  onClose: i,
23
23
  initialData: a
24
24
  }) => {
@@ -27,7 +27,7 @@ const oe = () => {
27
27
  content: "",
28
28
  description: "",
29
29
  enabledByDefaultForNewPages: !1
30
- }), [x, P] = g(!1), { data: u } = te(), { mutateAsync: C, isPending: p } = pe(), { mutateAsync: c } = se(), w = ue();
30
+ }), [x, P] = g(!1), { data: u } = le(), { mutateAsync: C, isPending: p } = pe(), { mutateAsync: c } = se(), w = ue();
31
31
  Z(() => {
32
32
  f(a ? {
33
33
  name: a.name,
@@ -35,20 +35,20 @@ const oe = () => {
35
35
  content: JSON.stringify(a.jsonld, null, 2),
36
36
  enabledByDefaultForNewPages: !1
37
37
  } : { name: "", description: "", content: "", enabledByDefaultForNewPages: !1 }), P(!1);
38
- }, [l, a]);
38
+ }, [t, a]);
39
39
  const o = async () => {
40
40
  if (!d.name || !d.content) {
41
41
  B.error("Please enter a name and content");
42
42
  return;
43
43
  }
44
- const t = de(d.content);
45
- if (!t.isValid) {
44
+ const l = de(d.content);
45
+ if (!l.isValid) {
46
46
  B.error("Invalid JSON-LD content");
47
47
  return;
48
48
  }
49
49
  const N = {
50
50
  name: d.name,
51
- jsonld: t.parsed,
51
+ jsonld: l.parsed,
52
52
  addToExistingPages: x,
53
53
  addToNewPages: d.enabledByDefaultForNewPages,
54
54
  description: d.description
@@ -81,7 +81,7 @@ const oe = () => {
81
81
  {
82
82
  id: "new-name",
83
83
  value: d.name,
84
- onChange: (t) => f({ ...d, name: t.target.value }),
84
+ onChange: (l) => f({ ...d, name: l.target.value }),
85
85
  placeholder: "e.g., Product Schema",
86
86
  className: "text-xs"
87
87
  }
@@ -94,7 +94,7 @@ const oe = () => {
94
94
  {
95
95
  id: "new-description",
96
96
  value: d.description || "",
97
- onChange: (t) => f({ ...d, description: t.target.value }),
97
+ onChange: (l) => f({ ...d, description: l.target.value }),
98
98
  placeholder: "Brief description of this schema"
99
99
  }
100
100
  )
@@ -106,7 +106,7 @@ const oe = () => {
106
106
  {
107
107
  id: "new-content",
108
108
  value: d.content || "{}",
109
- onChange: (t) => f({ ...d, content: t }),
109
+ onChange: (l) => f({ ...d, content: l }),
110
110
  placeholder: "Enter JSON-LD markup...",
111
111
  rows: 10
112
112
  }
@@ -120,7 +120,7 @@ const oe = () => {
120
120
  type: "checkbox",
121
121
  id: "add-to-all-existing",
122
122
  checked: x,
123
- onChange: (t) => P(t.target.checked),
123
+ onChange: (l) => P(l.target.checked),
124
124
  className: "h-5 w-5 cursor-pointer rounded focus:outline-none focus:ring-2 focus:ring-primary focus:ring-offset-1"
125
125
  }
126
126
  ),
@@ -136,7 +136,7 @@ const oe = () => {
136
136
  type: "checkbox",
137
137
  id: "new-enabled",
138
138
  checked: d.enabledByDefaultForNewPages,
139
- onChange: (t) => f({ ...d, enabledByDefaultForNewPages: t.target.checked }),
139
+ onChange: (l) => f({ ...d, enabledByDefaultForNewPages: l.target.checked }),
140
140
  className: "h-5 w-5 cursor-pointer rounded focus:outline-none focus:ring-2 focus:ring-primary focus:ring-offset-1"
141
141
  }
142
142
  ),
@@ -158,17 +158,17 @@ const oe = () => {
158
158
  ] }) })
159
159
  ] })
160
160
  ] });
161
- }, Ue = ({ id: l, onClose: i }) => /* @__PURE__ */ e($, { open: !!l, onOpenChange: () => i(), children: l && /* @__PURE__ */ e(_e, { id: l, onClose: i }) }), _e = ({ id: l, onClose: i }) => {
161
+ }, Ue = ({ id: t, onClose: i }) => /* @__PURE__ */ e($, { open: !!t, onOpenChange: () => i(), children: t && /* @__PURE__ */ e(_e, { id: t, onClose: i }) }), _e = ({ id: t, onClose: i }) => {
162
162
  const [a, d] = g({
163
163
  name: "",
164
164
  content: "",
165
165
  description: "",
166
166
  enabledByDefaultForNewPages: !1
167
- }), [f, x] = g(!1), [P, u] = g(!1), [C, p] = g(!1), { data: c } = oe(), { mutateAsync: w, isPending: o } = xe(), { mutateAsync: t } = Ne(), { mutateAsync: N } = be();
167
+ }), [f, x] = g(!1), [P, u] = g(!1), [C, p] = g(!1), { data: c } = oe(), { mutateAsync: w, isPending: o } = xe(), { mutateAsync: l } = Ne(), { mutateAsync: N } = be();
168
168
  Z(() => {
169
169
  var m, D;
170
- if (l && c) {
171
- const b = c.find((L) => L.id === l);
170
+ if (t && c) {
171
+ const b = c.find((L) => L.id === t);
172
172
  b && (d({
173
173
  name: b.name,
174
174
  description: ((m = b.metadata) == null ? void 0 : m.description) || "",
@@ -176,7 +176,7 @@ const oe = () => {
176
176
  enabledByDefaultForNewPages: ((D = b.metadata) == null ? void 0 : D.addToNewPages) || !1
177
177
  }), p(!!b.primaryPage));
178
178
  }
179
- }, [l, c]);
179
+ }, [t, c]);
180
180
  const A = async () => {
181
181
  if (!a.name || !a.content) {
182
182
  B.error("Please enter a name and content");
@@ -188,7 +188,7 @@ const oe = () => {
188
188
  return;
189
189
  }
190
190
  const D = {
191
- id: l,
191
+ id: t,
192
192
  name: a.name,
193
193
  jsonld: m.parsed,
194
194
  addToNewPages: a.enabledByDefaultForNewPages,
@@ -197,13 +197,13 @@ const oe = () => {
197
197
  await w(D), i();
198
198
  }, I = async () => {
199
199
  try {
200
- await t(l);
200
+ await l(t);
201
201
  } finally {
202
202
  x(!1);
203
203
  }
204
204
  }, T = async () => {
205
205
  try {
206
- await N(l);
206
+ await N(t);
207
207
  } finally {
208
208
  u(!1);
209
209
  }
@@ -314,7 +314,7 @@ const oe = () => {
314
314
  ] });
315
315
  };
316
316
  function Xe() {
317
- const [l, i] = g(!1), [a, d] = g(void 0), [f, x] = g(null), [P, u] = g(null), [C, p] = g(null), { data: c, isLoading: w } = oe(), { selectedLang: o } = me(), { data: t } = te(), { data: N } = ye(), { mutateAsync: A } = ve(), { mutateAsync: I } = se(), T = z(() => N == null ? void 0 : N.find((s) => !s.primaryPage && s.lang === ""), [N]), m = z(() => (T == null ? void 0 : T.globalJsonLds) || [], [T]), D = z(() => c ? Je(c, (r) => r.primaryPage === null && r.lang === "").map((r) => {
317
+ const [t, i] = g(!1), [a, d] = g(void 0), [f, x] = g(null), [P, u] = g(null), [C, p] = g(null), { data: c, isLoading: w } = oe(), { selectedLang: o } = me(), { data: l } = le(), { data: N } = ye(), { mutateAsync: A } = ve(), { mutateAsync: I } = se(), T = z(() => N == null ? void 0 : N.find((s) => !s.primaryPage && s.lang === ""), [N]), m = z(() => (T == null ? void 0 : T.globalJsonLds) || [], [T]), D = z(() => c ? Je(c, (r) => r.primaryPage === null && r.lang === "").map((r) => {
318
318
  const h = o ? Oe(c, (S) => S.primaryPage === r.id && S.lang === o) : null;
319
319
  return {
320
320
  defaultSchema: r,
@@ -323,23 +323,23 @@ function Xe() {
323
323
  displayItem: h || r,
324
324
  hasLanguageVersion: !!h
325
325
  };
326
- }) : [], [c, o]), [b, L] = g([]), k = b.length > 0 ? b : (t == null ? void 0 : t.globalJsonLds) || [];
326
+ }) : [], [c, o]), [b, L] = g([]), k = b.length > 0 ? b : (l == null ? void 0 : l.globalJsonLds) || [];
327
327
  Z(() => {
328
- t != null && t.globalJsonLds && L(t.globalJsonLds);
329
- }, [t == null ? void 0 : t.globalJsonLds]);
328
+ l != null && l.globalJsonLds && L(l.globalJsonLds);
329
+ }, [l == null ? void 0 : l.globalJsonLds]);
330
330
  const ie = async (s) => {
331
- if (!(t != null && t.id)) return;
331
+ if (!(l != null && l.id)) return;
332
332
  p(s);
333
333
  const r = k.includes(s), h = r ? k.filter((S) => S !== s) : [...k, s];
334
334
  L(h);
335
335
  try {
336
336
  await I({
337
337
  schemaId: s,
338
- pageId: t.id,
338
+ pageId: l.id,
339
339
  enabled: !r
340
340
  });
341
341
  } catch {
342
- L(t.globalJsonLds);
342
+ L(l.globalJsonLds);
343
343
  } finally {
344
344
  p(null);
345
345
  }
@@ -377,7 +377,7 @@ function Xe() {
377
377
  /* @__PURE__ */ n("div", { className: "space-y-2", children: [
378
378
  (!c || (c == null ? void 0 : c.length) === 0) && !w && /* @__PURE__ */ e("div", { className: "flex items-center justify-center px-2 py-4 text-xs", children: "No shared JSON-LD found" }),
379
379
  D.map(({ defaultSchema: s, displayItem: r, hasLanguageVersion: h }) => {
380
- var ae, le;
380
+ var ae, te;
381
381
  const S = k.includes(r.id), ee = m.includes(s.id), ne = h && o ? ee : S;
382
382
  return /* @__PURE__ */ n(
383
383
  Se,
@@ -410,7 +410,7 @@ function Xe() {
410
410
  ] }),
411
411
  ne && /* @__PURE__ */ e("span", { className: "sr-only text-xs font-normal text-muted-foreground", children: "Enabled" })
412
412
  ] }),
413
- ((ae = r == null ? void 0 : r.metadata) == null ? void 0 : ae.description) && /* @__PURE__ */ e("p", { className: "mt-1 text-xs leading-none text-muted-foreground", children: (le = r == null ? void 0 : r.metadata) == null ? void 0 : le.description })
413
+ ((ae = r == null ? void 0 : r.metadata) == null ? void 0 : ae.description) && /* @__PURE__ */ e("p", { className: "mt-1 text-xs leading-none text-muted-foreground", children: (te = r == null ? void 0 : r.metadata) == null ? void 0 : te.description })
414
414
  ] })
415
415
  ] }),
416
416
  /* @__PURE__ */ n("div", { className: "flex items-center gap-2", children: [
@@ -516,7 +516,7 @@ function Xe() {
516
516
  /* @__PURE__ */ e(
517
517
  Ie,
518
518
  {
519
- show: l,
519
+ show: t,
520
520
  onClose: () => {
521
521
  i(!1), d(void 0);
522
522
  },
@@ -533,26 +533,26 @@ function Xe() {
533
533
  )
534
534
  ] });
535
535
  }
536
- const Re = ({ schema: l, onClose: i }) => /* @__PURE__ */ e($, { open: !!l, onOpenChange: i, children: /* @__PURE__ */ n(W, { className: "max-w-2xl", children: [
536
+ const Re = ({ schema: t, onClose: i }) => /* @__PURE__ */ e($, { open: !!t, onOpenChange: i, children: /* @__PURE__ */ n(W, { className: "max-w-2xl", children: [
537
537
  /* @__PURE__ */ e(Y, { children: /* @__PURE__ */ n(X, { className: "flex items-center gap-2", children: [
538
- l == null ? void 0 : l.name,
539
- (l == null ? void 0 : l.lang) && /* @__PURE__ */ n("span", { className: "text-sm font-normal text-muted-foreground", children: [
538
+ t == null ? void 0 : t.name,
539
+ (t == null ? void 0 : t.lang) && /* @__PURE__ */ n("span", { className: "text-sm font-normal text-muted-foreground", children: [
540
540
  "(",
541
- l.lang,
541
+ t.lang,
542
542
  ")"
543
543
  ] })
544
544
  ] }) }),
545
545
  /* @__PURE__ */ n("div", { className: "space-y-3", children: [
546
- (l == null ? void 0 : l.description) && /* @__PURE__ */ n("div", { children: [
546
+ (t == null ? void 0 : t.description) && /* @__PURE__ */ n("div", { children: [
547
547
  /* @__PURE__ */ e("div", { className: "text-xs font-medium text-muted-foreground", children: "Description" }),
548
- /* @__PURE__ */ e("div", { className: "text-sm", children: l.description })
548
+ /* @__PURE__ */ e("div", { className: "text-sm", children: t.description })
549
549
  ] }),
550
550
  /* @__PURE__ */ n("div", { children: [
551
551
  /* @__PURE__ */ e("div", { className: "mb-2 text-xs font-medium text-muted-foreground", children: "JSON-LD Schema" }),
552
552
  /* @__PURE__ */ e(
553
553
  Ee,
554
554
  {
555
- value: JSON.stringify(l == null ? void 0 : l.jsonld, null, 2),
555
+ value: JSON.stringify(t == null ? void 0 : t.jsonld, null, 2),
556
556
  readOnly: !0,
557
557
  className: "font-mono text-xs",
558
558
  rows: 15
@@ -1 +1 @@
1
- "use strict";const s=require("react/jsx-runtime"),u=require("./index-CZxeSGRk.cjs"),b=require("@chaibuilder/sdk/ui"),d=require("react"),j=e=>{if(!e)return{base:e,extension:null};const n=e.lastIndexOf(".");if(n<=0)return{base:e,extension:null};const t=e.substring(n);return{base:e.substring(0,n),extension:t}},x=e=>{if(!e)return e;const{base:n}=j(e);return n};function E(e,n){const t=(e||"").split("/").filter(Boolean);let r="",a=!0;if(n.slug==="/"){const i=t.pop()||"";if(u.LANGUAGES[i])a=!0;else{r=i;const l=t.pop()||"";a=!!u.LANGUAGES[l]}}else if(n.parent)t.length&&(r=t.pop()||"");else if(t.length){r=t.pop()||"";const i=t.pop()||"";a=!!u.LANGUAGES[i]}return{initSlug:r,prefix:a}}const v=e=>e&&x(e),C=(e,n)=>{const t=x(e||"");return!t||t==="/"?`/${n}`:`${t}/${n}`};function A({value:e,onChange:n,placeholder:t,parentSlug:r,onValidationChange:a,disabled:i=!1,fullSlug:l}){const[g,p]=d.useState(e),[o,f]=d.useState(null);d.useEffect(()=>{p(e)},[e]);const h=S=>{const c=S.target.value.replace(/\//g,"").replace(/\s+/g,"-").replace(/[^a-zA-Z0-9-_.]/g,"-").replace(/-+/g,"-").replace(/^-+/,"").toLowerCase(),m=(c.match(/\./g)||[]).length,N=m<=1;m>1?f("Invalid slug. Only one dot (.) is allowed in the slug"):f(null),a&&a(N),p(c),n(c)};return s.jsxs("div",{children:[r&&s.jsx("div",{className:"mb-1 flex items-center",children:s.jsxs("span",{className:"text-xs text-gray-500",children:["Parent: ",s.jsx("span",{className:"font-mono text-gray-900",children:v(r)})]})}),s.jsxs("div",{className:"relative",children:[s.jsx(b.Input,{disabled:i,value:g,onChange:h,placeholder:t,className:o?"border-red-500":""}),o&&s.jsx("div",{className:"mt-1 text-xs text-red-500",children:o})]}),l&&l!=="undefined"&&s.jsx("div",{className:"mt-1 flex items-center",children:s.jsxs("span",{className:"text-xs text-gray-500",children:["Complete Slug: ",s.jsx("span",{className:"font-mono text-gray-900",children:l})]})})]})}exports.SlugInput=A;exports.combineParentChildSlugs=C;exports.parseSlugForEdit=E;exports.removeSlugExtension=x;
1
+ "use strict";const s=require("react/jsx-runtime"),u=require("./index-C64wG61b.cjs"),b=require("@chaibuilder/sdk/ui"),d=require("react"),j=e=>{if(!e)return{base:e,extension:null};const n=e.lastIndexOf(".");if(n<=0)return{base:e,extension:null};const t=e.substring(n);return{base:e.substring(0,n),extension:t}},x=e=>{if(!e)return e;const{base:n}=j(e);return n};function E(e,n){const t=(e||"").split("/").filter(Boolean);let r="",a=!0;if(n.slug==="/"){const i=t.pop()||"";if(u.LANGUAGES[i])a=!0;else{r=i;const l=t.pop()||"";a=!!u.LANGUAGES[l]}}else if(n.parent)t.length&&(r=t.pop()||"");else if(t.length){r=t.pop()||"";const i=t.pop()||"";a=!!u.LANGUAGES[i]}return{initSlug:r,prefix:a}}const v=e=>e&&x(e),C=(e,n)=>{const t=x(e||"");return!t||t==="/"?`/${n}`:`${t}/${n}`};function A({value:e,onChange:n,placeholder:t,parentSlug:r,onValidationChange:a,disabled:i=!1,fullSlug:l}){const[g,p]=d.useState(e),[o,f]=d.useState(null);d.useEffect(()=>{p(e)},[e]);const h=S=>{const c=S.target.value.replace(/\//g,"").replace(/\s+/g,"-").replace(/[^a-zA-Z0-9-_.]/g,"-").replace(/-+/g,"-").replace(/^-+/,"").toLowerCase(),m=(c.match(/\./g)||[]).length,N=m<=1;m>1?f("Invalid slug. Only one dot (.) is allowed in the slug"):f(null),a&&a(N),p(c),n(c)};return s.jsxs("div",{children:[r&&s.jsx("div",{className:"mb-1 flex items-center",children:s.jsxs("span",{className:"text-xs text-gray-500",children:["Parent: ",s.jsx("span",{className:"font-mono text-gray-900",children:v(r)})]})}),s.jsxs("div",{className:"relative",children:[s.jsx(b.Input,{disabled:i,value:g,onChange:h,placeholder:t,className:o?"border-red-500":""}),o&&s.jsx("div",{className:"mt-1 text-xs text-red-500",children:o})]}),l&&l!=="undefined"&&s.jsx("div",{className:"mt-1 flex items-center",children:s.jsxs("span",{className:"text-xs text-gray-500",children:["Complete Slug: ",s.jsx("span",{className:"font-mono text-gray-900",children:l})]})})]})}exports.SlugInput=A;exports.combineParentChildSlugs=C;exports.parseSlugForEdit=E;exports.removeSlugExtension=x;
@@ -1,5 +1,5 @@
1
1
  import { jsxs as i, jsx as o } from "react/jsx-runtime";
2
- import { L as d } from "./index-D2g32O6h.js";
2
+ import { L as d } from "./index-D_qadcqD.js";
3
3
  import { Input as v } from "@chaibuilder/sdk/ui";
4
4
  import { useState as x, useEffect as C } from "react";
5
5
  const y = (e) => {
@@ -1,5 +1,5 @@
1
1
  import { jsxs as c, jsx as a } from "react/jsx-runtime";
2
- import { u, a as d, t as h } from "./index-D2g32O6h.js";
2
+ import { u, a as d, t as h } from "./index-D_qadcqD.js";
3
3
  import { useTheme as b, useTranslation as g } from "@chaibuilder/sdk";
4
4
  import { Button as o } from "@chaibuilder/sdk/ui";
5
5
  const x = () => {
@@ -1 +1 @@
1
- "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const e=require("react/jsx-runtime"),s=require("./index-CZxeSGRk.cjs"),o=require("@chaibuilder/sdk"),r=require("@chaibuilder/sdk/ui"),h=()=>{const[t]=o.useTheme(),{mutate:c,isPending:i}=s.usePublishPages(),{mutateAsync:n,isPending:u}=s.useUpdateWebsiteSettings(),{t:a}=o.useTranslation(),l=()=>{n({settings:{theme:t}})},d=async()=>{await n({settings:{theme:t}}),c({ids:["THEME"]},{onSuccess:()=>{s.throwConfetti("BOTTOM_RIGHT")}})};return e.jsxs("div",{className:"flex items-center justify-center gap-x-3 border-t bg-white py-3",children:[e.jsx(r.Button,{size:"sm",variant:"outline",disabled:i||u,onClick:l,children:a("Save draft")}),e.jsx(r.Button,{size:"sm",disabled:i||u,onClick:d,children:a("Publish")})]})};exports.default=h;
1
+ "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const e=require("react/jsx-runtime"),s=require("./index-C64wG61b.cjs"),o=require("@chaibuilder/sdk"),r=require("@chaibuilder/sdk/ui"),h=()=>{const[t]=o.useTheme(),{mutate:c,isPending:i}=s.usePublishPages(),{mutateAsync:n,isPending:u}=s.useUpdateWebsiteSettings(),{t:a}=o.useTranslation(),l=()=>{n({settings:{theme:t}})},d=async()=>{await n({settings:{theme:t}}),c({ids:["THEME"]},{onSuccess:()=>{s.throwConfetti("BOTTOM_RIGHT")}})};return e.jsxs("div",{className:"flex items-center justify-center gap-x-3 border-t bg-white py-3",children:[e.jsx(r.Button,{size:"sm",variant:"outline",disabled:i||u,onClick:l,children:a("Save draft")}),e.jsx(r.Button,{size:"sm",disabled:i||u,onClick:d,children:a("Publish")})]})};exports.default=h;
@@ -1 +1 @@
1
- "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const e=require("react/jsx-runtime"),u=require("./index-CZxeSGRk.cjs"),d=require("@chaibuilder/sdk"),t=require("@chaibuilder/sdk/ui"),m=require("react"),p=({page:i,onClose:n})=>{const{t:a}=d.useTranslation(),[r,s]=m.useState(!1),o=u.useUnmarkAsTemplate(),l=()=>{s(!0),o.mutate(i,{onSuccess:()=>{s(!1),n()},onError:()=>{s(!1)}})};return e.jsx(t.Dialog,{open:!0,onOpenChange:n,children:e.jsxs(t.DialogContent,{children:[e.jsxs(t.DialogHeader,{children:[e.jsx(t.DialogTitle,{children:a("Unmark as template")}),e.jsx(t.DialogDescription,{className:"space-y-1 py-4 text-xs text-slate-500",children:a("Are you sure you want to unmark this page as a template?")})]}),e.jsxs(t.DialogFooter,{className:r?"pointer-events-none opacity-75":"",children:[e.jsx(t.Button,{variant:"outline",onClick:c=>{c.stopPropagation(),n()},children:a("Cancel")}),e.jsx(t.Button,{variant:"default",disabled:r,onClick:l,children:a("Unmark as template")})]})]})})};exports.default=p;
1
+ "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const e=require("react/jsx-runtime"),u=require("./index-C64wG61b.cjs"),d=require("@chaibuilder/sdk"),t=require("@chaibuilder/sdk/ui"),m=require("react"),p=({page:i,onClose:n})=>{const{t:a}=d.useTranslation(),[r,s]=m.useState(!1),o=u.useUnmarkAsTemplate(),l=()=>{s(!0),o.mutate(i,{onSuccess:()=>{s(!1),n()},onError:()=>{s(!1)}})};return e.jsx(t.Dialog,{open:!0,onOpenChange:n,children:e.jsxs(t.DialogContent,{children:[e.jsxs(t.DialogHeader,{children:[e.jsx(t.DialogTitle,{children:a("Unmark as template")}),e.jsx(t.DialogDescription,{className:"space-y-1 py-4 text-xs text-slate-500",children:a("Are you sure you want to unmark this page as a template?")})]}),e.jsxs(t.DialogFooter,{className:r?"pointer-events-none opacity-75":"",children:[e.jsx(t.Button,{variant:"outline",onClick:c=>{c.stopPropagation(),n()},children:a("Cancel")}),e.jsx(t.Button,{variant:"default",disabled:r,onClick:l,children:a("Unmark as template")})]})]})})};exports.default=p;
@@ -1,5 +1,5 @@
1
1
  import { jsx as e, jsxs as o } from "react/jsx-runtime";
2
- import { o as p } from "./index-D2g32O6h.js";
2
+ import { o as p } from "./index-D_qadcqD.js";
3
3
  import { useTranslation as u } from "@chaibuilder/sdk";
4
4
  import { Dialog as d, DialogContent as g, DialogHeader as h, DialogTitle as f, DialogDescription as k, DialogFooter as D, Button as s } from "@chaibuilder/sdk/ui";
5
5
  import { useState as x } from "react";
@@ -1 +1 @@
1
- "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const n=require("react/jsx-runtime"),u=require("./index-CZxeSGRk.cjs"),c=require("@chaibuilder/sdk"),s=require("@chaibuilder/sdk/ui"),d=({page:i,onClose:t})=>{const{t:e}=c.useTranslation(),{mutate:r,isPending:l}=u.useUnpublishPage(),o=async()=>{r(i,{onSuccess:t})};return n.jsx(s.Dialog,{open:!!i,onOpenChange:t,children:n.jsxs(s.DialogContent,{children:[n.jsxs(s.DialogHeader,{children:[n.jsx(s.DialogTitle,{children:e("Confirm action")}),n.jsxs(s.DialogDescription,{children:[e("Are you sure you want to unpublish")," ",n.jsx("b",{children:(i==null?void 0:i.name)??(i==null?void 0:i.slug)}),"?"]})]}),n.jsxs(s.DialogFooter,{children:[n.jsx(s.Button,{variant:"outline",onClick:t,children:e("Cancel")}),n.jsx(s.Button,{variant:"destructive",disabled:l,onClick:o,children:e(l?"Updating...":"Unpublish")})]})]})})};exports.default=d;
1
+ "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const n=require("react/jsx-runtime"),u=require("./index-C64wG61b.cjs"),c=require("@chaibuilder/sdk"),s=require("@chaibuilder/sdk/ui"),d=({page:i,onClose:t})=>{const{t:e}=c.useTranslation(),{mutate:r,isPending:l}=u.useUnpublishPage(),o=async()=>{r(i,{onSuccess:t})};return n.jsx(s.Dialog,{open:!!i,onOpenChange:t,children:n.jsxs(s.DialogContent,{children:[n.jsxs(s.DialogHeader,{children:[n.jsx(s.DialogTitle,{children:e("Confirm action")}),n.jsxs(s.DialogDescription,{children:[e("Are you sure you want to unpublish")," ",n.jsx("b",{children:(i==null?void 0:i.name)??(i==null?void 0:i.slug)}),"?"]})]}),n.jsxs(s.DialogFooter,{children:[n.jsx(s.Button,{variant:"outline",onClick:t,children:e("Cancel")}),n.jsx(s.Button,{variant:"destructive",disabled:l,onClick:o,children:e(l?"Updating...":"Unpublish")})]})]})})};exports.default=d;
@@ -1,5 +1,5 @@
1
1
  import { jsx as o, jsxs as l } from "react/jsx-runtime";
2
- import { l as u } from "./index-D2g32O6h.js";
2
+ import { l as u } from "./index-D_qadcqD.js";
3
3
  import { useTranslation as a } from "@chaibuilder/sdk";
4
4
  import { Dialog as h, DialogContent as d, DialogHeader as m, DialogTitle as b, DialogDescription as D, DialogFooter as f, Button as s } from "@chaibuilder/sdk/ui";
5
5
  const g = ({ page: n, onClose: t }) => {
@@ -4,7 +4,7 @@ import { Button as s } from "@chaibuilder/sdk/ui";
4
4
  import { useAtom as h } from "jotai";
5
5
  import { map as p } from "lodash-es";
6
6
  import { Smartphone as w, Tablet as f, Laptop as u, LaptopMinimal as x } from "lucide-react";
7
- import { p as v, T as _ } from "./index-D2g32O6h.js";
7
+ import { p as v, T as _ } from "./index-D_qadcqD.js";
8
8
  const b = [
9
9
  {
10
10
  title: "mobile_xs_title",
@@ -1 +1 @@
1
- "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const e=require("react/jsx-runtime"),o=require("react"),a=require("@chaibuilder/sdk/ui"),h=require("jotai"),x=require("lodash-es"),n=require("lucide-react"),c=require("./index-CZxeSGRk.cjs"),m=[{title:"mobile_xs_title",content:"mobile_xs_content",icon:e.jsx(n.Smartphone,{className:"h-4 w-4"}),width:400},{title:"tablet_md_title",content:"tablet_md_content",icon:e.jsx(n.Tablet,{className:"h-4 w-4"}),width:800},{title:"desktop_xl_title",content:"desktop_xl_content",icon:e.jsx(n.Laptop,{className:"h-4 w-4"}),width:1200},{title:"large_desktop_2xl_title",content:"large_desktop_2xl_content",icon:e.jsx(n.LaptopMinimal,{className:"h-4 w-4"}),width:1600}],w=({currentWidth:t,width:s,icon:l,setIframeWidth:i})=>e.jsx(a.Button,{className:"px-3 py-3",onClick:()=>i(s),variant:s===t?"default":"ghost",children:l}),p=()=>{const[t,s]=o.useState(1200),l=r=>s(r),[i,d]=h.useAtom(c.previewUrlAtom);if(!i)return null;const u=()=>{d("")};return e.jsxs("div",{className:"absolute inset-0 z-[999999] flex h-screen w-screen flex-col overflow-hidden bg-gray-100",children:[e.jsxs("div",{className:"flex h-[50px] items-center justify-center border-b border-gray-200 px-4 shadow-sm",children:[e.jsx("div",{className:"flex items-center justify-center rounded-md border border-gray-300",children:x.map(m,r=>o.createElement(w,{...r,setIframeWidth:l,key:r.title,currentWidth:t}))})," ",e.jsx(c.Tooltip,{content:"Exit Preview",delayDuration:0,children:e.jsx(a.Button,{variant:"destructive",size:"sm",onClick:u,children:e.jsx("svg",{width:"15",height:"15",viewBox:"0 0 15 15",fill:"none",xmlns:"http://www.w3.org/2000/svg",children:e.jsx("path",{d:"M2 3C2 2.44772 2.44772 2 3 2H12C12.5523 2 13 2.44772 13 3V12C13 12.5523 12.5523 13 12 13H3C2.44772 13 2 12.5523 2 12V3ZM12 3H3V12H12V3Z",fill:"currentColor","fill-rule":"evenodd","clip-rule":"evenodd"})})})})]}),e.jsx("iframe",{style:{width:`${t}px`,transition:"width 0.3s ease-in-out"},className:"no-scrollbar mx-auto h-full overflow-y-auto border bg-white",src:i})]})};exports.default=p;
1
+ "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const e=require("react/jsx-runtime"),o=require("react"),a=require("@chaibuilder/sdk/ui"),h=require("jotai"),x=require("lodash-es"),n=require("lucide-react"),c=require("./index-C64wG61b.cjs"),m=[{title:"mobile_xs_title",content:"mobile_xs_content",icon:e.jsx(n.Smartphone,{className:"h-4 w-4"}),width:400},{title:"tablet_md_title",content:"tablet_md_content",icon:e.jsx(n.Tablet,{className:"h-4 w-4"}),width:800},{title:"desktop_xl_title",content:"desktop_xl_content",icon:e.jsx(n.Laptop,{className:"h-4 w-4"}),width:1200},{title:"large_desktop_2xl_title",content:"large_desktop_2xl_content",icon:e.jsx(n.LaptopMinimal,{className:"h-4 w-4"}),width:1600}],w=({currentWidth:t,width:s,icon:l,setIframeWidth:i})=>e.jsx(a.Button,{className:"px-3 py-3",onClick:()=>i(s),variant:s===t?"default":"ghost",children:l}),p=()=>{const[t,s]=o.useState(1200),l=r=>s(r),[i,d]=h.useAtom(c.previewUrlAtom);if(!i)return null;const u=()=>{d("")};return e.jsxs("div",{className:"absolute inset-0 z-[999999] flex h-screen w-screen flex-col overflow-hidden bg-gray-100",children:[e.jsxs("div",{className:"flex h-[50px] items-center justify-center border-b border-gray-200 px-4 shadow-sm",children:[e.jsx("div",{className:"flex items-center justify-center rounded-md border border-gray-300",children:x.map(m,r=>o.createElement(w,{...r,setIframeWidth:l,key:r.title,currentWidth:t}))})," ",e.jsx(c.Tooltip,{content:"Exit Preview",delayDuration:0,children:e.jsx(a.Button,{variant:"destructive",size:"sm",onClick:u,children:e.jsx("svg",{width:"15",height:"15",viewBox:"0 0 15 15",fill:"none",xmlns:"http://www.w3.org/2000/svg",children:e.jsx("path",{d:"M2 3C2 2.44772 2.44772 2 3 2H12C12.5523 2 13 2.44772 13 3V12C13 12.5523 12.5523 13 12 13H3C2.44772 13 2 12.5523 2 12V3ZM12 3H3V12H12V3Z",fill:"currentColor","fill-rule":"evenodd","clip-rule":"evenodd"})})})})]}),e.jsx("iframe",{style:{width:`${t}px`,transition:"width 0.3s ease-in-out"},className:"no-scrollbar mx-auto h-full overflow-y-auto border bg-white",src:i})]})};exports.default=p;
package/package.json CHANGED
@@ -3,7 +3,7 @@
3
3
  "author": "Suraj Air",
4
4
  "license": "Private",
5
5
  "homepage": "https://chaibuilder.com",
6
- "version": "0.15.22",
6
+ "version": "0.16.0",
7
7
  "type": "module",
8
8
  "files": [
9
9
  "dist"
@@ -56,16 +56,9 @@
56
56
  "require": "./dist/pages.css"
57
57
  }
58
58
  },
59
- "scripts": {
60
- "dev": "vite",
61
- "build": "tsc -b && vite build",
62
- "lint": "eslint .",
63
- "preview": "vite preview",
64
- "test": "vitest"
65
- },
66
59
  "peerDependencies": {
67
60
  "@chaibuilder/runtime": "2.2.0",
68
- "@chaibuilder/sdk": "3.0.27",
61
+ "@chaibuilder/sdk": "3.1.3",
69
62
  "@types/react": "*",
70
63
  "@types/react-dom": "*",
71
64
  "jotai": "2.14.0",
@@ -82,7 +75,7 @@
82
75
  },
83
76
  "dependencies": {
84
77
  "@chaibuilder/runtime": "2.2.0",
85
- "@chaibuilder/sdk": "3.0.27",
78
+ "@chaibuilder/sdk": "3.1.3",
86
79
  "@mhsdesign/jit-browser-tailwindcss": "^0.4.2",
87
80
  "@radix-ui/react-icons": "^1.3.2",
88
81
  "@supabase/supabase-js": "2.50.3",
@@ -158,5 +151,12 @@
158
151
  "node": ">=21.0.0",
159
152
  "pnpm": ">=8.0.0"
160
153
  },
161
- "engineStrict": true
162
- }
154
+ "engineStrict": true,
155
+ "scripts": {
156
+ "dev": "vite",
157
+ "build": "tsc -b && vite build",
158
+ "lint": "eslint .",
159
+ "preview": "vite preview",
160
+ "test": "vitest"
161
+ }
162
+ }