headroom-cms 0.1.9 → 0.1.11
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.
- package/README.md +11 -6
- package/admin/assets/{AdminsPage-Bt_ekZen.js → AdminsPage-BnzH9TL3.js} +1 -1
- package/admin/assets/AllContentPage-BtObN6oy.js +1 -0
- package/admin/assets/{ApiKeysPage-BfWCxGhC.js → ApiKeysPage-DEAa8eyC.js} +1 -1
- package/admin/assets/AuditPage-BN9yNsxh.js +1 -0
- package/admin/assets/BlockEditor-3wnisTOZ.js +176 -0
- package/admin/assets/BlockEditor-CQpF8tYb.css +1 -0
- package/admin/assets/BlockTypeEditPage-C2evAESK.js +1 -0
- package/admin/assets/BlockTypesPage-Dhkho6T_.js +1 -0
- package/admin/assets/{BulkActionBar-TRiXXLQd.js → BulkActionBar-BxdfUSrN.js} +1 -1
- package/admin/assets/CollectionEditPage-lOb4hEZy.js +1 -0
- package/admin/assets/{CollectionsPage-ClplrxNn.js → CollectionsPage-CgtOloa1.js} +1 -1
- package/admin/assets/{ContentCreatePage-DfYcEH1u.js → ContentCreatePage-LeQjahp_.js} +1 -1
- package/admin/assets/ContentEditPage-xczr4d_h.js +1 -0
- package/admin/assets/ContentField-pilCbdnA.js +1 -0
- package/admin/assets/ContentListPage-BAKDn1Xy.js +1 -0
- package/admin/assets/CustomBlockPreview-DNnTFM0z.js +479 -0
- package/admin/assets/FieldRenderer-DiOKvkWV.js +2 -0
- package/admin/assets/FilterBar-BZoa63zh.js +1 -0
- package/admin/assets/FloatingComposerController-D4uLQfUX-BMIvFCoE.js +1 -0
- package/admin/assets/IconPicker-CpIgiQTC.js +3 -0
- package/admin/assets/{LoginPage-DutieANA.js → LoginPage-D9ZsGLIi.js} +1 -1
- package/admin/assets/MediaField-CxccCFGQ.js +1 -0
- package/admin/assets/MediaPage-QvMaH2YJ.js +1 -0
- package/admin/assets/Pagination-Df9nQ7Z0.js +1 -0
- package/admin/assets/RelationshipPicker-B3Ftmqxp.js +1 -0
- package/admin/assets/{SiteSettingsPage-BtCC3RKc.js → SiteSettingsPage-6NvH7CiQ.js} +1 -1
- package/admin/assets/{SiteUserEditPage-ClHmp0T-.js → SiteUserEditPage-D5VaQ1Xq.js} +1 -1
- package/admin/assets/SiteUsersPage-BYVduiqs.js +1 -0
- package/admin/assets/{SitesPage-Bw_WBN6v.js → SitesPage-rfWWE0yK.js} +1 -1
- package/admin/assets/{SubmissionDetailPage-DS08LGxd.js → SubmissionDetailPage-BSUR685F.js} +1 -1
- package/admin/assets/SubmissionEditPage-DjLXHjWU.js +1 -0
- package/admin/assets/SubmissionListPage-DBxNEvde.js +1 -0
- package/admin/assets/{TagInput-BILCaC9b.js → TagInput-57c4DG1w.js} +1 -1
- package/admin/assets/{TagsPage-DdeZokow.js → TagsPage-BEO5AwCv.js} +1 -1
- package/admin/assets/{UsersPage-B0vLxjrg.js → UsersPage-BpIRorJ1.js} +1 -1
- package/admin/assets/{WebhookEditPage-SlJE4d3z.js → WebhookEditPage-D5xgi56h.js} +1 -1
- package/admin/assets/{WebhooksPage-C6lGZLpr.js → WebhooksPage-BY7AaiGr.js} +1 -1
- package/admin/assets/{card-hXVtlM0q.js → card-C9hfyHXf.js} +1 -1
- package/admin/assets/checkbox-DVJcwUt1.js +1 -0
- package/admin/assets/{collapsible-B414SspL.js → collapsible-D3d29uJp.js} +1 -1
- package/admin/assets/{command-fvBFHye4.js → command-Bfmj0MEL.js} +1 -1
- package/admin/assets/contentStatus-CkPi9Dh6.js +1 -0
- package/admin/assets/{core.esm-B_kcYf6n.js → core.esm-DdQHdRkd.js} +2 -2
- package/admin/assets/index-BB9Syqw2.css +1 -0
- package/admin/assets/index-Ce5pmRMj.js +18 -0
- package/admin/assets/media-url-DdCoIedP.js +1 -0
- package/admin/assets/popover-CzaQYEEP.js +1 -0
- package/admin/assets/radix-C5ZmWuuL.js +51 -0
- package/admin/assets/select-CrRhFGIi.js +1 -0
- package/admin/assets/serializeToText-2VrsuRUh.js +2 -0
- package/admin/assets/{sortable.esm-QyXA6fio.js → sortable.esm-qVEMoaTg.js} +1 -1
- package/admin/assets/{table-DLoIbCQ5.js → table-_3bMY0_z.js} +1 -1
- package/admin/assets/{textarea-vSXNxwTe.js → textarea-6fq0R6VV.js} +1 -1
- package/admin/assets/useAdminResolver-BJNPz3OG.js +1 -0
- package/admin/assets/useContent-Bs7nel7C.js +1 -0
- package/admin/assets/useContentSearch-B3aTjuCu.js +1 -0
- package/admin/assets/{useMedia-e3sqWm_t.js → useMedia-ae3s_ajC.js} +1 -1
- package/admin/assets/usePageTitle-C1r1-C00.js +1 -0
- package/admin/assets/useSiteUsers-DIaqgNSp.js +1 -0
- package/admin/assets/{useTags-f7AVSLuj.js → useTags-B-HgMVwo.js} +1 -1
- package/admin/assets/{useWebhooks-BH_r8-Mo.js → useWebhooks-BvZjUJkJ.js} +1 -1
- package/admin/assets/yjs-tXBm_srz.js +5 -0
- package/admin/favicon-16x16.png +0 -0
- package/admin/favicon-32x32.png +0 -0
- package/admin/icons/icon-180x180.png +0 -0
- package/admin/icons/icon-192x192.png +0 -0
- package/admin/icons/icon-512x512.png +0 -0
- package/admin/icons/maskable-icon-512x512.png +0 -0
- package/admin/index.html +3 -3
- package/admin/sw.js +1 -1
- package/dist/admin-site.d.ts +16 -2
- package/dist/admin-site.d.ts.map +1 -1
- package/dist/admin-site.js +10 -3
- package/dist/admin-site.js.map +1 -1
- package/dist/api.d.ts +7 -0
- package/dist/api.d.ts.map +1 -1
- package/dist/api.js +8 -1
- package/dist/api.js.map +1 -1
- package/dist/cdn-api.d.ts +25 -0
- package/dist/cdn-api.d.ts.map +1 -0
- package/dist/{cdn.js → cdn-api.js} +7 -139
- package/dist/cdn-api.js.map +1 -0
- package/dist/cdn-media.d.ts +26 -0
- package/dist/cdn-media.d.ts.map +1 -0
- package/dist/cdn-media.js +202 -0
- package/dist/cdn-media.js.map +1 -0
- package/dist/collaboration.d.ts +55 -0
- package/dist/collaboration.d.ts.map +1 -0
- package/dist/collaboration.js +141 -0
- package/dist/collaboration.js.map +1 -0
- package/dist/index.d.ts +27 -3
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +47 -12
- package/dist/index.js.map +1 -1
- package/dist/storage.d.ts +2 -0
- package/dist/storage.d.ts.map +1 -1
- package/dist/storage.js +33 -0
- package/dist/storage.js.map +1 -1
- package/lambda/api/bootstrap +0 -0
- package/lambda/image-lambda/node_modules/.package-lock.json +3 -3
- package/lambda/image-lambda/node_modules/semver/README.md +19 -4
- package/lambda/image-lambda/node_modules/semver/bin/semver.js +14 -10
- package/lambda/image-lambda/node_modules/semver/functions/truncate.js +48 -0
- package/lambda/image-lambda/node_modules/semver/index.js +2 -0
- package/lambda/image-lambda/node_modules/semver/internal/re.js +1 -1
- package/lambda/image-lambda/node_modules/semver/package.json +3 -3
- package/lambda/image-lambda/node_modules/semver/range.bnf +5 -4
- package/lambda/webhook-worker/bootstrap +0 -0
- package/package.json +1 -1
- package/src/admin-site.ts +26 -5
- package/src/api.ts +15 -1
- package/src/{cdn.ts → cdn-api.ts} +8 -161
- package/src/cdn-media.ts +250 -0
- package/src/collaboration.ts +187 -0
- package/src/index.ts +77 -14
- package/src/sst-env.d.ts +28 -0
- package/src/storage.ts +35 -0
- package/admin/assets/AllContentPage-CFqEMAl9.js +0 -1
- package/admin/assets/AuditPage-BE0XIUl2.js +0 -1
- package/admin/assets/BlockEditor-6wqsThJ7.js +0 -179
- package/admin/assets/BlockEditor-Cp_wZ2xN.css +0 -1
- package/admin/assets/BlockTypeEditPage-CuNJfZw0.js +0 -1
- package/admin/assets/BlockTypesPage-BIMBVxBs.js +0 -1
- package/admin/assets/CollectionEditPage-BqX_0cC2.js +0 -1
- package/admin/assets/ContentEditPage-D3Rvlktk.js +0 -2
- package/admin/assets/ContentListPage-zmO8Is4d.js +0 -1
- package/admin/assets/CustomBlockPreview-C6HqS4xv.js +0 -479
- package/admin/assets/FieldBuilder-36tfpSyM.js +0 -3
- package/admin/assets/FilterBar-DhRwTqFv.js +0 -1
- package/admin/assets/MediaField-J2TLG_fu.js +0 -1
- package/admin/assets/MediaPage-DZZKMGF4.js +0 -1
- package/admin/assets/RelationshipPicker-CDFs4TMW.js +0 -1
- package/admin/assets/SiteUsersPage-AyJvcVM7.js +0 -1
- package/admin/assets/SubmissionEditPage-Brf-DK2X.js +0 -1
- package/admin/assets/SubmissionListPage-DNMzQZHS.js +0 -1
- package/admin/assets/checkbox-WGrS3sUr.js +0 -1
- package/admin/assets/contentStatus-BmaiYVOm.js +0 -1
- package/admin/assets/index-Cir9tY_P.js +0 -18
- package/admin/assets/index-DACBYsKM.css +0 -1
- package/admin/assets/media-url-DIg_vSyf.js +0 -1
- package/admin/assets/popover-D5_HjjUC.js +0 -1
- package/admin/assets/radix-C1kb_NqW.js +0 -51
- package/admin/assets/select-_uJYxzeZ.js +0 -1
- package/admin/assets/serializeToText-DR_WnxiI.js +0 -2
- package/admin/assets/useAdminResolver-D-LlmquD.js +0 -1
- package/admin/assets/useContent-e8beBIuq.js +0 -1
- package/admin/assets/useContentSearch-DOjveB9t.js +0 -1
- package/admin/assets/useDebouncedValue-C-cQUcLG.js +0 -1
- package/admin/assets/usePageTitle-BNSba9_L.js +0 -1
- package/admin/assets/useSiteUsers-BdnvuM2E.js +0 -1
- package/dist/cdn.d.ts +0 -27
- package/dist/cdn.d.ts.map +0 -1
- package/dist/cdn.js.map +0 -1
|
@@ -0,0 +1 @@
|
|
|
1
|
+
.bn-block-outer{line-height:1.5;transition:margin .2s}.bn-block{flex-direction:column;display:flex}.bn-block-content{width:100%;padding:3px 0;transition:font-size .2s;display:flex}.bn-block-content.ProseMirror-selectednode>*,.ProseMirror-selectednode>.bn-block-content>*{border-radius:4px;outline:4px solid #64a0ff}.bn-block-content:before{content:"";height:0;margin-right:0;transition:all .2s;overflow:visible}.bn-inline-content{white-space:pre-wrap}.bn-block-group .bn-block-group{margin-left:24px}.bn-block-group .bn-block-group>.bn-block-outer{position:relative}.bn-block-group .bn-block-group>.bn-block-outer:not([data-prev-depth-changed]):before{content:" ";height:100%;transition:all .2s .1s;display:inline;position:absolute;left:-20px}.bn-block-group .bn-block-group>.bn-block-outer[data-prev-depth-change="-2"]:before{height:0}.bn-inline-content code{font-family:monospace}[data-prev-depth-change="1"]{--x:1}[data-prev-depth-change="2"]{--x:2}[data-prev-depth-change="3"]{--x:3}[data-prev-depth-change="4"]{--x:4}[data-prev-depth-change="5"]{--x:5}[data-prev-depth-change="-1"]{--x:-1}[data-prev-depth-change="-2"]{--x:-2}[data-prev-depth-change="-3"]{--x:-3}[data-prev-depth-change="-4"]{--x:-4}[data-prev-depth-change="-5"]{--x:-5}.bn-block-outer[data-prev-depth-change]{margin-left:calc(10px * var(--x))}.bn-block-outer[data-prev-depth-change] .bn-block-outer[data-prev-depth-change]{margin-left:0}[data-content-type=heading]{--level:3em}[data-content-type=heading][data-level="2"]{--level:2em}[data-content-type=heading][data-level="3"]{--level:1.3em}[data-content-type=heading][data-level="4"]{--level:1em}[data-content-type=heading][data-level="5"]{--level:.9em}[data-content-type=heading][data-level="6"]{--level:.8em}[data-prev-level="1"]{--prev-level:3em}[data-prev-level="2"]{--prev-level:2em}[data-prev-level="3"]{--prev-level:1.3em}[data-prev-level="4"]{--prev-level:1em}[data-prev-level="5"]{--prev-level:.9em}[data-prev-level="6"]{--prev-level:.8em}.bn-block-outer[data-prev-type=heading]>.bn-block>.bn-block-content{font-size:var(--prev-level);font-weight:700}.bn-block-outer:not([data-prev-type])>.bn-block>.bn-block-content[data-content-type=heading],.bn-block-outer:not([data-prev-type])>.bn-block>div[data-type=modification]>div[data-type=modification]>.bn-block-content[data-content-type=heading]{font-size:var(--level);font-weight:700}[data-content-type=quote] blockquote{color:#7d797a;border-left:2px solid #7d797a;margin:0;padding-left:1em}[data-content-type=divider] hr{border:none;border-top:1px solid #7d797a;flex:1;margin:.5em 0}.bn-block-content:before{content:"";margin-right:0}.bn-block-content[data-content-type=numberedListItem]:before{justify-content:center;min-width:24px;padding-right:4px;display:flex}[data-content-type=numberedListItem]{--index:attr(data-index)}[data-prev-type=numberedListItem]{--prev-index:attr(data-prev-index)}.bn-block-outer[data-prev-type=numberedListItem]:not([data-prev-index=none])>.bn-block>.bn-block-content:before{content:var(--prev-index) "."}.bn-block-outer:not([data-prev-type])>.bn-block>.bn-block-content[data-content-type=numberedListItem]:before,.bn-block-outer:not([data-prev-type])>.bn-block>div[data-type=modification]>.bn-block-content[data-content-type=numberedListItem]:before{content:var(--index) "."}.bn-block-content[data-content-type=bulletListItem]:before{justify-content:center;min-width:24px;padding-right:4px;display:flex}.bn-block-content[data-content-type=checkListItem]>div:has(>input){height:24px}.bn-block-content[data-content-type=checkListItem]>div>input{cursor:pointer;margin-left:4px;margin-right:8px;width:12px;height:24px;margin-block:0}.bn-block-content[data-content-type=checkListItem][data-checked=true] .bn-inline-content{text-decoration:line-through}.bn-block-content[data-text-alignment=center]{justify-content:center}.bn-block-content[data-text-alignment=right]{justify-content:flex-end}:is(.bn-block:has(>.bn-block-content>div>.bn-toggle-wrapper[data-show-children=false])>.bn-block-group,.bn-block:has(>.react-renderer>.bn-block-content>div>.bn-toggle-wrapper[data-show-children=false])>.bn-block-group){display:none}.bn-toggle-wrapper{align-items:center;display:flex}.bn-toggle-button{color:var(--bn-colors-editor-text);padding:3px}.bn-toggle-button>svg{width:18px;height:18px}.bn-toggle-wrapper[data-show-children=true] .bn-toggle-button{transform:rotate(90deg)}.bn-toggle-add-block-button{color:var(--bn-colors-side-menu);width:fit-content;margin-left:22px;padding-inline:2px;font-size:16px;font-weight:400}.bn-toggle-button,.bn-toggle-add-block-button{border-radius:var(--bn-border-radius-small);cursor:pointer;-webkit-user-select:none;user-select:none;background:0 0;border:none;display:flex}.bn-toggle-button:hover,.bn-toggle-add-block-button:hover{background-color:var(--bn-colors-hovered-background)}.bn-block-outer[data-prev-type=bulletListItem]>.bn-block>.bn-block-content:before,.bn-block-outer:not([data-prev-type])>.bn-block>.bn-block-content[data-content-type=bulletListItem]:before,.bn-block-outer:not([data-prev-type])>.bn-block>div[data-type=modification]>.bn-block-content[data-content-type=bulletListItem]:before{content:"•"}[data-content-type=bulletListItem]~.bn-block-group>.bn-block-outer[data-prev-type=bulletListItem]>.bn-block>.bn-block-content:before,[data-content-type=bulletListItem]~.bn-block-group>.bn-block-outer:not([data-prev-type])>.bn-block>.bn-block-content[data-content-type=bulletListItem]:before,[data-content-type=bulletListItem]~.bn-block-group>.bn-block-outer:not([data-prev-type])>.bn-block>div[data-type=modification]>.bn-block-content[data-content-type=bulletListItem]:before{content:"◦"}[data-content-type=bulletListItem]~.bn-block-group [data-content-type=bulletListItem]~.bn-block-group>.bn-block-outer[data-prev-type=bulletListItem]>.bn-block>.bn-block-content:before,[data-content-type=bulletListItem]~.bn-block-group [data-content-type=bulletListItem]~.bn-block-group>.bn-block-outer:not([data-prev-type])>.bn-block>.bn-block-content[data-content-type=bulletListItem]:before,[data-content-type=bulletListItem]~.bn-block-group [data-content-type=bulletListItem]~.bn-block-group>.bn-block-outer:not([data-prev-type])>.bn-block>div[data-type=modification]>.bn-block-content[data-content-type=bulletListItem]:before{content:"▪︎"}.bn-block-content[data-content-type=codeBlock]{color:#fff;background-color:#161616;border-radius:8px;position:relative}.bn-block-content[data-content-type=codeBlock]>pre{white-space:pre;tab-size:2;width:100%;margin:0;padding:24px;overflow-x:auto}.bn-block-content[data-content-type=codeBlock]>div{outline:none!important}.bn-block-content[data-content-type=codeBlock]>div>select{appearance:none;-webkit-user-select:none;user-select:none;cursor:pointer;color:#fff;opacity:0;background-color:#0000;border:none;font-size:.8em;transition:opacity .3s 1s;position:absolute;top:8px;left:18px;outline:none!important}.bn-block-content[data-content-type=codeBlock]>div>select>option{color:#000}.bn-block-content[data-content-type=codeBlock]:hover>div>select,.bn-block-content[data-content-type=codeBlock]>div>select:focus{opacity:.5;transition-delay:.1s}.bn-block-content[data-content-type=pageBreak]>div{border-top:2px dotted #7d797a;width:100%;height:0;margin-block:11px}@media print{.bn-block-content[data-content-type=pageBreak]>div{page-break-after:always}}[data-file-block] .bn-file-block-content-wrapper{cursor:pointer;-webkit-user-select:none;user-select:none;flex-direction:column;display:flex}:is([data-file-block] .bn-file-block-content-wrapper:has(.bn-add-file-button),[data-file-block] .bn-file-block-content-wrapper:has(.bn-file-name-with-icon)){width:100%}[data-file-block] .bn-add-file-button{color:#7d797a;background-color:#f2f1ee;border-radius:4px;align-items:center;gap:10px;padding:12px;display:flex}.bn-editor[contenteditable=true] [data-file-block] .bn-add-file-button:hover,[data-file-block] .bn-file-name-with-icon:hover,.ProseMirror-selectednode .bn-file-name-with-icon{background-color:#e1e1e1}[data-file-block] .bn-add-file-button-icon,[data-file-block] .bn-file-icon{width:24px;height:24px}[data-file-block] .bn-add-file-button-text{font-size:.9rem}[data-file-block] .bn-file-name-with-icon{border-radius:4px;gap:4px;padding:4px;display:flex}[data-file-block] .bn-file-caption{word-break:break-word;padding-block:4px;font-size:.8em}[data-file-block] .bn-file-caption:empty{padding-block:0}[data-file-block] .bn-resize-handle{cursor:ew-resize;background-color:#000;border:1px solid #fff;border-radius:4px;width:8px;height:30px;position:absolute}[data-file-block] .bn-visual-media-wrapper{align-items:center;max-width:100%;display:flex;position:relative}[data-file-block] .bn-visual-media{border-radius:4px;width:100%}[data-content-type=audio]>.bn-file-block-content-wrapper,.bn-audio{width:100%}.bn-block-content:has(.ProseMirror-trailingBreak:only-child):after{pointer-events:none;max-width:100%;margin-inline:-2px;font-style:italic}.bn-block:has(>.bn-block-content[data-text-color=gray]){color:#9b9a97}.bn-block:has(>.bn-block-content[data-text-color=brown]){color:#64473a}.bn-block:has(>.bn-block-content[data-text-color=red]){color:#e03e3e}.bn-block:has(>.bn-block-content[data-text-color=orange]){color:#d9730d}.bn-block:has(>.bn-block-content[data-text-color=yellow]){color:#dfab01}.bn-block:has(>.bn-block-content[data-text-color=green]){color:#4d6461}.bn-block:has(>.bn-block-content[data-text-color=blue]){color:#0b6e99}.bn-block:has(>.bn-block-content[data-text-color=purple]){color:#6940a5}.bn-block:has(>.bn-block-content[data-text-color=pink]){color:#ad1a72}.bn-block:has(>.bn-block-content[data-background-color=gray]){background-color:#ebeced}.bn-block:has(>.bn-block-content[data-background-color=brown]){background-color:#e9e5e3}.bn-block:has(>.bn-block-content[data-background-color=red]){background-color:#fbe4e4}.bn-block:has(>.bn-block-content[data-background-color=orange]){background-color:#f6e9d9}.bn-block:has(>.bn-block-content[data-background-color=yellow]){background-color:#fbf3db}.bn-block:has(>.bn-block-content[data-background-color=green]){background-color:#ddedea}.bn-block:has(>.bn-block-content[data-background-color=blue]){background-color:#ddebf1}.bn-block:has(>.bn-block-content[data-background-color=purple]){background-color:#eae4f2}.bn-block:has(>.bn-block-content[data-background-color=pink]){background-color:#f4dfeb}[data-text-alignment=left]{text-align:left!important;justify-content:flex-start!important}[data-text-alignment=center]{text-align:center!important;justify-content:center!important}[data-text-alignment=right]{text-align:right!important;justify-content:flex-end!important}[data-text-alignment=justify]{text-align:justify!important;justify-content:flex-start!important}.bn-block-column-list{flex-direction:row;display:flex}.bn-block-column{flex:1;padding:12px 20px;overflow-x:auto}.bn-block-column:first-child{padding-left:0}.bn-block-column:last-child{padding-right:0}.bn-thread-mark:not([data-orphan=true]){background:#ffc80026}.bn-thread-mark .bn-thread-mark-selected{background:#ffc80040}.ProseMirror .tableWrapper{overflow-x:auto}.ProseMirror table{border-collapse:collapse;table-layout:fixed;width:100%;overflow:hidden}.ProseMirror td,.ProseMirror th{vertical-align:top;box-sizing:border-box;position:relative}.ProseMirror td:not([data-colwidth]):not(.column-resize-dragging),.ProseMirror th:not([data-colwidth]):not(.column-resize-dragging){min-width:var(--default-cell-min-width)}.ProseMirror .column-resize-handle{z-index:20;pointer-events:none;background-color:#adf;width:4px;position:absolute;top:0;bottom:0;right:-2px}.ProseMirror.resize-cursor{cursor:ew-resize;cursor:col-resize}.ProseMirror .selectedCell:after{z-index:2;content:"";pointer-events:none;background:#c8c8ff66;position:absolute;inset:0}.bn-editor{font-synthesis:style weight;--N800:#172b4d;--N40:#dfe1e6;outline:none;padding-inline:54px}.bn-comment-editor{width:100%;padding:0}.bn-comment-editor .bn-editor{padding:0}.bn-default-styles p,.bn-default-styles h1,.bn-default-styles h2,.bn-default-styles h3,.bn-default-styles h4,.bn-default-styles h5,.bn-default-styles h6,.bn-default-styles li{font-size:inherit;margin:0;padding:0;min-width:2px!important}.bn-default-styles{-webkit-font-smoothing:antialiased;-moz-osx-font-smoothing:grayscale;font-family:Inter,SF Pro Display,-apple-system,BlinkMacSystemFont,Open Sans,Segoe UI,Roboto,Oxygen,Ubuntu,Cantarell,Fira Sans,Droid Sans,Helvetica Neue,sans-serif;font-size:16px;font-weight:400}.bn-table-drop-cursor{z-index:20;pointer-events:none;background-color:#adf;position:absolute}.bn-drag-preview{opacity:.001;padding:10px;position:absolute;top:0;left:0}.bn-editor .bn-collaboration-cursor__base{position:relative}.bn-editor .bn-collaboration-cursor__base .bn-collaboration-cursor__caret{width:2px;position:absolute;top:1px;bottom:-2px;left:-1px}.bn-editor .bn-collaboration-cursor__base .bn-collaboration-cursor__label{pointer-events:none;white-space:nowrap;-webkit-user-select:none;user-select:none;color:#0000;border-radius:0 1.5px 1.5px 0;max-width:4px;max-height:5px;padding:0;font-size:12px;font-style:normal;font-weight:600;line-height:normal;transition:all .2s;position:absolute;top:-1px;left:0;overflow:hidden}.bn-editor .bn-collaboration-cursor__base[data-active] .bn-collaboration-cursor__label{color:#0d0d0d;border-radius:3px 3px 3px 0;max-width:20rem;max-height:1.1rem;padding:.1rem .3rem;transition:all .2s;top:-17px;left:0}.bn-editor [data-content-type=table] .tableWrapper{--bn-table-widget-size:22px;--bn-table-handle-size: 9px ;padding:var(--bn-table-handle-size) var(--bn-table-widget-size) var(--bn-table-widget-size) var(--bn-table-handle-size);width:100%;position:relative;overflow-y:hidden}.bn-editor [data-content-type=table] table{word-break:break-word;width:auto!important}.bn-editor [data-content-type=table] th,.bn-editor [data-content-type=table] td{border:1px solid #ddd;padding:5px 10px}.bn-editor [data-content-type=table] th{text-align:left;font-weight:700}.bn-editor [data-content-type=table] th>p,.bn-editor [data-content-type=table] td>p{min-height:1.5rem}.ProseMirror td,.ProseMirror th{min-width:auto!important}.ProseMirror td:not([colwidth]):not(.column-resize-dragging),.ProseMirror th:not([colwidth]):not(.column-resize-dragging){min-width:var(--default-cell-min-width)!important}.prosemirror-dropcursor-block{transition-property:top,bottom;transition-duration:.15s;transition-timing-function:cubic-bezier(.4,0,.2,1)}.prosemirror-dropcursor-vertical{transition-property:left,right}[data-show-selection]{background-color:highlight;padding:2px 0}.bn-root{--bn-colors-editor-text:#3f3f3f;--bn-colors-editor-background:#fff;--bn-colors-menu-text:#3f3f3f;--bn-colors-menu-background:#fff;--bn-colors-tooltip-text:#3f3f3f;--bn-colors-tooltip-background:#efefef;--bn-colors-hovered-text:#3f3f3f;--bn-colors-hovered-background:#efefef;--bn-colors-selected-text:#fff;--bn-colors-selected-background:#3f3f3f;--bn-colors-disabled-text:#afafaf;--bn-colors-disabled-background:#efefef;--bn-colors-shadow:#cfcfcf;--bn-colors-border:#efefef;--bn-colors-side-menu:#cfcfcf;--bn-colors-highlights-gray-text:#9b9a97;--bn-colors-highlights-gray-background:#ebeced;--bn-colors-highlights-brown-text:#64473a;--bn-colors-highlights-brown-background:#e9e5e3;--bn-colors-highlights-red-text:#e03e3e;--bn-colors-highlights-red-background:#fbe4e4;--bn-colors-highlights-orange-text:#d9730d;--bn-colors-highlights-orange-background:#f6e9d9;--bn-colors-highlights-yellow-text:#dfab01;--bn-colors-highlights-yellow-background:#fbf3db;--bn-colors-highlights-green-text:#4d6461;--bn-colors-highlights-green-background:#ddedea;--bn-colors-highlights-blue-text:#0b6e99;--bn-colors-highlights-blue-background:#ddebf1;--bn-colors-highlights-purple-text:#6940a5;--bn-colors-highlights-purple-background:#eae4f2;--bn-colors-highlights-pink-text:#ad1a72;--bn-colors-highlights-pink-background:#f4dfeb;--bn-font-family:"Inter", "SF Pro Display", -apple-system, BlinkMacSystemFont, "Open Sans", "Segoe UI", "Roboto", "Oxygen", "Ubuntu", "Cantarell", "Fira Sans", "Droid Sans", "Helvetica Neue", sans-serif;--bn-border-radius:6px;--bn-shadow-medium:0 4px 12px var(--bn-colors-shadow);--bn-shadow-light:0 2px 6px var(--bn-colors-border);--bn-border:1px solid var(--bn-colors-border);--bn-border-radius-small:max(var(--bn-border-radius) - 2px, 1px);--bn-border-radius-medium:var(--bn-border-radius);--bn-border-radius-large:max(var(--bn-border-radius) + 2px, 1px)}.bn-root[data-color-scheme=dark]{--bn-colors-editor-text:#cfcfcf;--bn-colors-editor-background:#1f1f1f;--bn-colors-menu-text:#cfcfcf;--bn-colors-menu-background:#1f1f1f;--bn-colors-tooltip-text:#cfcfcf;--bn-colors-tooltip-background:#161616;--bn-colors-hovered-text:#cfcfcf;--bn-colors-hovered-background:#161616;--bn-colors-selected-text:#cfcfcf;--bn-colors-selected-background:#0f0f0f;--bn-colors-disabled-text:#3f3f3f;--bn-colors-disabled-background:#161616;--bn-colors-shadow:#0f0f0f;--bn-colors-border:#161616;--bn-colors-side-menu:#7f7f7f;--bn-colors-highlights-gray-text:#bebdb8;--bn-colors-highlights-gray-background:#9b9a97;--bn-colors-highlights-brown-text:#8e6552;--bn-colors-highlights-brown-background:#64473a;--bn-colors-highlights-red-text:#ec4040;--bn-colors-highlights-red-background:#be3434;--bn-colors-highlights-orange-text:#e3790d;--bn-colors-highlights-orange-background:#b7600a;--bn-colors-highlights-yellow-text:#dfab01;--bn-colors-highlights-yellow-background:#b58b00;--bn-colors-highlights-green-text:#6b8b87;--bn-colors-highlights-green-background:#4d6461;--bn-colors-highlights-blue-text:#0e87bc;--bn-colors-highlights-blue-background:#0b6e99;--bn-colors-highlights-purple-text:#8552d7;--bn-colors-highlights-purple-background:#6940a5;--bn-colors-highlights-pink-text:#da208f;--bn-colors-highlights-pink-background:#ad1a72}.bn-root{font-family:var(--bn-font-family)}.bn-editor{background-color:var(--bn-colors-editor-background);border-radius:var(--bn-border-radius-large);color:var(--bn-colors-editor-text)}.bn-react-node-view-renderer{flex-direction:column;width:100%;display:flex}.bn-block-group .bn-block:not(:has(.bn-toggle-wrapper)) .bn-block-group .bn-block-outer:not([data-prev-depth-changed]):before{border-left:1px solid var(--bn-colors-side-menu)}.bn-block-content:has(.ProseMirror-trailingBreak:only-child):after{color:var(--bn-colors-side-menu)}.bn-root .bn-color-icon{border:var(--bn-border);border-radius:var(--bn-border-radius-small);justify-content:center;align-items:center;display:flex}.bn-error-text{color:red;font-size:12px}[data-style-type=textColor][data-value=gray],[data-text-color=gray]{color:var(--bn-colors-highlights-gray-text)}[data-style-type=textColor][data-value=brown],[data-text-color=brown]{color:var(--bn-colors-highlights-brown-text)}[data-style-type=textColor][data-value=red],[data-text-color=red]{color:var(--bn-colors-highlights-red-text)}[data-style-type=textColor][data-value=orange],[data-text-color=orange]{color:var(--bn-colors-highlights-orange-text)}[data-style-type=textColor][data-value=yellow],[data-text-color=yellow]{color:var(--bn-colors-highlights-yellow-text)}[data-style-type=textColor][data-value=green],[data-text-color=green]{color:var(--bn-colors-highlights-green-text)}[data-style-type=textColor][data-value=blue],[data-text-color=blue]{color:var(--bn-colors-highlights-blue-text)}[data-style-type=textColor][data-value=purple],[data-text-color=purple]{color:var(--bn-colors-highlights-purple-text)}[data-style-type=textColor][data-value=pink],[data-text-color=pink]{color:var(--bn-colors-highlights-pink-text)}[data-style-type=backgroundColor][data-value=gray],[data-background-color=gray]{background-color:var(--bn-colors-highlights-gray-background)}[data-style-type=backgroundColor][data-value=brown],[data-background-color=brown]{background-color:var(--bn-colors-highlights-brown-background)}[data-style-type=backgroundColor][data-value=red],[data-background-color=red]{background-color:var(--bn-colors-highlights-red-background)}[data-style-type=backgroundColor][data-value=orange],[data-background-color=orange]{background-color:var(--bn-colors-highlights-orange-background)}[data-style-type=backgroundColor][data-value=yellow],[data-background-color=yellow]{background-color:var(--bn-colors-highlights-yellow-background)}[data-style-type=backgroundColor][data-value=green],[data-background-color=green]{background-color:var(--bn-colors-highlights-green-background)}[data-style-type=backgroundColor][data-value=blue],[data-background-color=blue]{background-color:var(--bn-colors-highlights-blue-background)}[data-style-type=backgroundColor][data-value=purple],[data-background-color=purple]{background-color:var(--bn-colors-highlights-purple-background)}[data-style-type=backgroundColor][data-value=pink],[data-background-color=pink]{background-color:var(--bn-colors-highlights-pink-background)}.bn-root{--bn-ui-base-z-index:0}.bn-side-menu{height:30px}.bn-side-menu[data-block-type=heading][data-level="1"]{height:78px}.bn-side-menu[data-block-type=heading][data-level="2"]{height:54px}.bn-side-menu[data-block-type=heading][data-level="3"]{height:37px}.bn-side-menu[data-block-type=file]{height:38px}.bn-side-menu[data-block-type=audio]{height:60px}.bn-side-menu[data-url=false]{height:54px}.bn-threads-sidebar{border-radius:var(--bn-border-radius-medium);flex-direction:column;gap:10px;display:flex;overflow:auto}.bn-thread-expand-prompt .mantine-Text-root,.bn-thread .bn-header-text{color:var(--bn-colors-menu-text)}.bn-threads-sidebar .bn-thread .bn-editor{background-color:#0000}.bn-threads-sidebar .bn-thread.selected{background-color:#f5f9fd;border:2px solid #c2dcf8}.dark .bn-threads-sidebar .bn-thread.selected{background-color:#20242a;border:2px solid #23405b}.bn-root em-emoji-picker{max-height:100%}.bn-shadcn svg:not([class*=size-]){width:revert;height:revert}.bn-shadcn svg{pointer-events:all}.bn-shadcn .bn-editor a{color:revert;-webkit-text-decoration:revert;text-decoration:revert}.bn-shadcn .bn-editor:focus-visible{outline:none}.bn-shadcn .bn-side-menu{justify-content:center;align-items:center;display:flex}.bn-shadcn .bn-side-menu .bn-button{height:24px;padding:0}.bn-shadcn .bn-select{max-height:var(--radix-select-content-available-height)}.bn-shadcn .bn-menu-dropdown{max-height:var(--radix-dropdown-menu-content-available-height)}.bn-shadcn .bn-color-picker-dropdown{overflow:auto}.bn-shadcn .bn-extend-button-add-remove-columns{cursor:col-resize}.bn-shadcn .bn-extend-button-add-remove-rows{cursor:row-resize}.bn-shadcn .bn-toolbar{max-width:100vw;overflow-x:auto}.bn-shadcn .bn-comment-actions-wrapper{justify-content:flex-end;display:flex}.bn-shadcn .bn-table-cell-handle{height:12px;padding:0 4px}.bn-shadcn .bn-thread .bn-resolved-text{font-size:14px;font-style:italic}.bn-shadcn .bn-combobox-error{color:var(--bn-colors-highlights-red-background);font-weight:700}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{j as e}from"./tanstack-Bs3zYPPV.js";import{u as R,f as U,r as o}from"./react-vendor-C2CvUxFh.js";import{W as b,aF as V,S as T,aG as G,aH as W,aI as z,x as J,L as u,I as K,a0 as B,B as x,a as Q,D as X,i as Y,T as Z,k as ee,l as se,m as te,n as ae,o as ie,v as h}from"./index-Ce5pmRMj.js";import{I as ne,a as re,F as le}from"./IconPicker-CpIgiQTC.js";import{i as oe}from"./format-C88SDH8g.js";import{T as ce}from"./textarea-6fq0R6VV.js";import{C as de,a as me,b as pe,c as ue}from"./card-C9hfyHXf.js";import{C as $,a as D,b as F}from"./collapsible-D3d29uJp.js";import{C as xe}from"./CustomBlockPreview-DNnTFM0z.js";import{F as he}from"./FieldRenderer-DiOKvkWV.js";import{u as N}from"./useContentSearch-B3aTjuCu.js";import{u as je}from"./usePageTitle-C1r1-C00.js";import"./radix-C5ZmWuuL.js";import"./core.esm-DdQHdRkd.js";import"./sortable.esm-qVEMoaTg.js";import"./select-CrRhFGIi.js";import"./checkbox-DVJcwUt1.js";import"./popover-CzaQYEEP.js";import"./media-url-DdCoIedP.js";import"./MediaField-CxccCFGQ.js";import"./useMedia-ae3s_ajC.js";import"./ContentField-pilCbdnA.js";import"./command-Bfmj0MEL.js";function fe({fields:a,previewTemplate:s,previewData:t,onPreviewDataChange:i,blockTypeName:l,blockTypeLabel:d,blockTypeIcon:v}){const n=N(s,300),g=N(t,300);return e.jsxs("div",{className:"space-y-4",children:[e.jsx(he,{fields:a,values:t,onChange:i}),e.jsx(b,{}),e.jsx("div",{className:"overflow-hidden rounded-md border p-4",children:e.jsx(xe,{blockType:{name:l,label:d,icon:v,fields:a,previewTemplate:n},props:g,blocksToHTML:()=>""})})]})}function Ue(){const{host:a,name:s}=R(),t=s==="new",{data:i,isLoading:l}=V(a,t?"":s);return!t&&l?e.jsxs("div",{className:"space-y-4",children:[e.jsx(T,{className:"h-8 w-64"}),e.jsx(T,{className:"h-64 w-full"})]}):t?e.jsx(C,{host:a,isNew:!0}):i?e.jsx(C,{host:a,isNew:!1,blockType:i},i.name):e.jsx("p",{className:"text-muted-foreground",children:"Block type not found."})}function C({host:a,isNew:s,blockType:t}){const i=U(),l=G(a),d=W(a,t?.name??""),v=z(a,t?.name??""),[n,g]=o.useState(t?.name??""),[j,y]=o.useState(t?.label??""),[f,P]=o.useState(t?.icon??""),[S,L]=o.useState(!s),I=new Set((t?.fields??[]).map(r=>r.name).filter(Boolean)),[c,E]=o.useState(t?.fields??[]),[m,O]=o.useState(t?.previewTemplate??""),[p,q]=o.useState(t?.previewData??{}),[H,w]=o.useState(!1),_=J();je({title:s?"New Block Type":t?.label??n,showBack:!0,backTo:`/sites/${a}/settings/block-types`});async function A(r){r.preventDefault();try{s?(await l.mutateAsync({name:n,label:j,icon:f,fields:c,previewTemplate:m||void 0,previewData:Object.keys(p).length>0?p:void 0}),h.success("Block type created"),i(`/sites/${a}/settings/block-types/${n}`)):(await d.mutateAsync({label:j,icon:f,fields:c,previewTemplate:m||void 0,previewData:Object.keys(p).length>0?p:void 0}),h.success("Block type updated"))}catch(k){h.error(s?"Failed to create":"Failed to update",{description:k instanceof Error?k.message:void 0})}}async function M(){try{await v.mutateAsync(),h.success("Block type deleted"),i(`/sites/${a}/settings/block-types`)}catch(r){h.error("Failed to delete",{description:r instanceof Error?r.message:void 0})}}return e.jsxs("div",{className:"mx-auto max-w-2xl",children:[!_&&e.jsx("h1",{className:"mb-6 text-2xl font-semibold",children:s?"New Block Type":`Edit: ${t?.label??n}`}),e.jsxs(de,{children:[e.jsx(me,{children:e.jsx(pe,{children:"Block Type Settings"})}),e.jsx(ue,{children:e.jsxs("form",{onSubmit:A,className:"space-y-4",children:[e.jsxs("div",{className:"space-y-2",children:[e.jsx(u,{htmlFor:"name",children:"Name"}),e.jsx(ne,{id:"name",value:n,onChange:g,onBlur:()=>{n&&!S&&y(oe(n))},readOnly:!s,placeholder:"e.g. hero_banner",required:!0})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(u,{htmlFor:"label",children:"Label"}),e.jsx(K,{id:"label",value:j,onChange:r=>{y(r.target.value),L(!0)},required:!0})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(u,{children:"Icon"}),e.jsx(re,{value:f,onChange:P})]}),e.jsx(b,{}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(u,{children:"Block Fields"}),e.jsx(le,{fields:c,onChange:E,existingFieldNames:I})]}),e.jsx(b,{}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(u,{htmlFor:"preview-template",children:"Preview Template (Liquid + Tailwind)"}),e.jsx("p",{className:"text-xs text-muted-foreground",children:"Optional. Use Liquid syntax to render a preview. Tailwind utility classes are supported."}),e.jsx(ce,{id:"preview-template",value:m,onChange:r=>O(r.target.value),rows:6,placeholder:'<div class="p-4">{{ title }}</div>',className:"font-mono text-sm"}),c.length>0&&e.jsx(ge,{fields:c})]}),(m||c.length>0)&&e.jsxs($,{children:[e.jsxs(D,{className:"flex w-full items-center gap-2 text-sm font-medium",children:[e.jsx(B,{className:"h-4 w-4 transition-transform [[data-state=open]>&]:rotate-90"}),"Preview"]}),e.jsx(F,{className:"mt-2",children:e.jsx(fe,{fields:c,previewTemplate:m,previewData:p,onPreviewDataChange:q,blockTypeName:n,blockTypeLabel:j,blockTypeIcon:f})})]}),e.jsxs("div",{className:"flex gap-2",children:[e.jsxs(x,{type:"submit",disabled:l.isPending||d.isPending,children:[(l.isPending||d.isPending)&&e.jsx(Q,{className:"mr-2 h-4 w-4 animate-spin"}),s?"Create":"Save"]}),e.jsx(x,{type:"button",variant:"outline",onClick:()=>i(`/sites/${a}/settings/block-types`),children:"Cancel"})]})]})})]}),!s&&e.jsx("div",{className:"mt-6",children:e.jsxs(X,{open:H,onOpenChange:w,children:[e.jsx(Y,{asChild:!0,children:e.jsxs(x,{variant:"destructive",children:[e.jsx(Z,{className:"mr-2 h-4 w-4"}),"Delete Block Type"]})}),e.jsxs(ee,{children:[e.jsxs(se,{children:[e.jsx(te,{children:"Delete block type?"}),e.jsx(ae,{children:"This will permanently delete this block type."})]}),e.jsxs(ie,{children:[e.jsx(x,{variant:"outline",onClick:()=>w(!1),children:"Cancel"}),e.jsx(x,{variant:"destructive",onClick:M,children:"Delete"})]})]})]})})]})}function ve(a){const s=a.name;switch(a.type){case"media":return`{{ ${s}.url | media_url }} {{ ${s}.alt }} {{ ${s}.width }}`;case"content":return`{{ ${s}.title }} {{ ${s}.id }}`;case"boolean":return`{% if ${s} %}...{% endif %}`;case"array":{const t=a.options?.itemFields;if(t&&t.length>0){const i=t.map(l=>`item.${l.name}`).join(" }} {{ ");return`{% for item in ${s} %}{{ ${i} }}{% endfor %}`}return`{% for item in ${s} %}{{ item }}{% endfor %}`}case"select":return a.options?.multiple?`{% for item in ${s} %}{{ item }}{% endfor %}`:`{{ ${s} }}`;case"container":{const t=a.options?.fields;return t&&t.length>0?t.map(i=>`{{ ${s}.${i.name} }}`).join(" "):`{{ ${s}.fieldName }}`}case"blocks":return`{{ ${s} | blocks_html }} or {{ ${s} | blocks_text }}`;default:return`{{ ${s} }}`}}function ge({fields:a}){return e.jsxs($,{children:[e.jsxs(D,{className:"flex items-center gap-1 text-xs text-muted-foreground hover:text-foreground",children:[e.jsx(B,{className:"h-3 w-3 transition-transform [[data-state=open]>&]:rotate-90"}),"Template variables"]}),e.jsx(F,{children:e.jsx("div",{className:"mt-1 rounded-md border bg-muted/50 p-2 font-mono text-xs space-y-0.5",children:a.map(s=>e.jsxs("div",{className:"flex gap-2",children:[e.jsxs("span",{className:"text-muted-foreground shrink-0",children:[s.label,":"]}),e.jsx("code",{children:ve(s)})]},s.name))})})]})}export{Ue as BlockTypeEditPage};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{j as s}from"./tanstack-Bs3zYPPV.js";import{u as h,f as j}from"./react-vendor-C2CvUxFh.js";import{aD as p,x as u,B as c,P as o,S as f,aE as N}from"./index-Ce5pmRMj.js";import{T as g,a as y,b as r,c as l,d as k,e as n}from"./table-_3bMY0_z.js";import{u as T}from"./usePageTitle-C1r1-C00.js";import"./radix-C5ZmWuuL.js";function $(){const{host:a}=h(),i=j(),{data:t,isLoading:m}=p(a),d=u();return T({title:"Block Types",actions:s.jsx(c,{size:"sm",onClick:()=>i(`/sites/${a}/settings/block-types/new`),children:s.jsx(o,{className:"h-4 w-4"})})}),s.jsxs("div",{children:[!d&&s.jsxs("div",{className:"mb-6 flex items-center justify-between",children:[s.jsx("h1",{className:"text-2xl font-semibold",children:"Block Types"}),s.jsxs(c,{onClick:()=>i(`/sites/${a}/settings/block-types/new`),children:[s.jsx(o,{className:"mr-2 h-4 w-4"}),"New Block Type"]})]}),m?s.jsx("div",{className:"space-y-2",children:Array.from({length:3}).map((e,x)=>s.jsx(f,{className:"h-12 w-full"},x))}):t?.items.length?s.jsxs(g,{children:[s.jsx(y,{children:s.jsxs(r,{children:[s.jsx(l,{children:"Name"}),s.jsx(l,{children:"Label"}),s.jsx(l,{children:"Icon"}),s.jsx(l,{children:"Fields"})]})}),s.jsx(k,{children:t.items.map(e=>s.jsxs(r,{className:"cursor-pointer",onClick:()=>i(`/sites/${a}/settings/block-types/${e.name}`),children:[s.jsx(n,{className:"font-mono text-sm",children:e.name}),s.jsx(n,{children:e.label}),s.jsx(n,{children:e.icon?s.jsx(N,{name:e.icon,className:"h-4 w-4 text-muted-foreground"}):s.jsx("span",{className:"text-muted-foreground",children:"—"})}),s.jsx(n,{className:"text-muted-foreground",children:e.fields?.length??0})]},e.name))})]}):s.jsx("p",{className:"text-muted-foreground",children:"No block types defined."})]})}export{$ as BlockTypesPage};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{j as e}from"./tanstack-Bs3zYPPV.js";import{r as m}from"./react-vendor-C2CvUxFh.js";import{B as a,a as t,X as x,D as h,k as j,l as p,m as u,n as D,o as b}from"./index-
|
|
1
|
+
import{j as e}from"./tanstack-Bs3zYPPV.js";import{r as m}from"./react-vendor-C2CvUxFh.js";import{B as a,a as t,X as x,D as h,k as j,l as p,m as u,n as D,o as b}from"./index-Ce5pmRMj.js";function k({selectedCount:i,onPublish:n,onUnpublish:r,onDelete:o,onClear:c,isPending:s}){const[d,l]=m.useState(!1);return e.jsxs(e.Fragment,{children:[e.jsxs("div",{className:"mb-4 flex items-center gap-3 rounded-md border bg-muted/50 px-4 py-2",children:[e.jsxs("span",{className:"text-sm font-medium",children:[i," selected"]}),e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsxs(a,{size:"sm",variant:"outline",onClick:n,disabled:s,children:[s&&e.jsx(t,{className:"mr-1 h-3 w-3 animate-spin"}),"Publish"]}),e.jsx(a,{size:"sm",variant:"outline",onClick:r,disabled:s,children:"Unpublish"}),e.jsx(a,{size:"sm",variant:"destructive",onClick:()=>l(!0),disabled:s,children:"Delete"})]}),e.jsx(a,{size:"sm",variant:"ghost",onClick:c,className:"ml-auto",disabled:s,children:e.jsx(x,{className:"h-4 w-4"})})]}),e.jsx(h,{open:d,onOpenChange:l,children:e.jsxs(j,{children:[e.jsxs(p,{children:[e.jsxs(u,{children:["Delete ",i," item",i!==1?"s":"","?"]}),e.jsx(D,{children:"This action cannot be undone. The selected content items will be permanently deleted."})]}),e.jsxs(b,{children:[e.jsx(a,{variant:"outline",onClick:()=>l(!1),children:"Cancel"}),e.jsxs(a,{variant:"destructive",onClick:async()=>{l(!1),await o()},disabled:s,children:[s&&e.jsx(t,{className:"mr-1 h-3 w-3 animate-spin"}),"Delete"]})]})]})})]})}export{k as B};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{j as e}from"./tanstack-Bs3zYPPV.js";import{r,u as je,f as be}from"./react-vendor-C2CvUxFh.js";import{ai as pe,a0 as fe,y as ve,ax as Ce,B as N,T as K,I as L,P as Se,ay as Ne,S as U,x as ye,w as ke,az as De,aA as Ee,aB as Pe,L as m,aC as Ie,W as z,a as Fe,D as Le,i as Re,k as Te,l as Ae,m as Be,n as we,o as Oe,v as P}from"./index-Ce5pmRMj.js";import{I as Q,F as qe,a as $e}from"./IconPicker-CpIgiQTC.js";import{i as Z,c as Me}from"./format-C88SDH8g.js";import{C as O}from"./checkbox-DVJcwUt1.js";import{C as W,a as Y,b as G,c as X}from"./card-C9hfyHXf.js";import{u as _e}from"./usePageTitle-C1r1-C00.js";import{S as q,a as $,b as M,c as _,d as g}from"./select-CrRhFGIi.js";import{C as Ve,b as He,c as Ue,P as ze,D as We,e as Ye}from"./core.esm-DdQHdRkd.js";import{u as Ge,S as Xe,v as Je,a as Ke}from"./sortable.esm-qVEMoaTg.js";import{C as Qe,a as Ze,b as es}from"./collapsible-D3d29uJp.js";import"./radix-C5ZmWuuL.js";import"./textarea-6fq0R6VV.js";import"./popover-CzaQYEEP.js";function ss({id:l,relationship:s,onChange:a,onRemove:u,collections:j,readOnlyName:p,defaultExpanded:f}){const[b,k]=r.useState(f??!1),[d,D]=r.useState(!!s.label),{attributes:v,listeners:o,setNodeRef:i,transform:c,transition:C}=Ge({id:l}),y={transform:Ve.Transform.toString(c),transition:C};function x(n){a({...s,...n})}const I=j.find(n=>n.name===s.targetCollection)?.label??s.targetCollection;return e.jsx("div",{ref:i,style:y,className:"rounded-md border bg-card",children:e.jsxs(Qe,{open:b,onOpenChange:k,children:[e.jsxs("div",{className:"flex items-center gap-2 p-2",children:[e.jsx("button",{type:"button",className:"cursor-grab touch-none text-muted-foreground hover:text-foreground",...v,...o,children:e.jsx(pe,{className:"h-4 w-4"})}),e.jsx(Ze,{asChild:!0,children:e.jsx("button",{type:"button",className:"flex items-center",children:e.jsx(fe,{className:ve("h-4 w-4 transition-transform",b&&"rotate-90")})})}),e.jsx("span",{className:"min-w-[80px] text-sm font-mono",children:s.name||"unnamed"}),e.jsx(Ce,{className:"h-3 w-3 text-muted-foreground"}),e.jsx("span",{className:"text-xs text-muted-foreground",children:I}),e.jsx("span",{className:"flex-1 truncate text-sm text-muted-foreground",children:s.label}),e.jsx(N,{type:"button",variant:"ghost",size:"sm",onClick:u,className:"text-destructive",children:e.jsx(K,{className:"h-3 w-3"})})]}),e.jsx(es,{children:e.jsxs("div",{className:"space-y-3 border-t p-3",children:[e.jsxs("div",{className:"grid grid-cols-2 gap-2",children:[e.jsxs("div",{className:"space-y-1",children:[e.jsx("label",{className:"text-xs text-muted-foreground",children:"Name"}),e.jsx(Q,{value:s.name,onChange:n=>x({name:n}),onBlur:()=>{s.name&&!d&&x({label:Z(s.name)})},readOnly:p,className:"h-8 text-sm"})]}),e.jsxs("div",{className:"space-y-1",children:[e.jsx("label",{className:"text-xs text-muted-foreground",children:"Label"}),e.jsx(L,{value:s.label,onChange:n=>{x({label:n.target.value}),D(!0)},className:"h-8 text-sm"})]})]}),e.jsxs("div",{className:"space-y-1",children:[e.jsx("label",{className:"text-xs text-muted-foreground",children:"Target Collection"}),e.jsxs(q,{value:s.targetCollection,onValueChange:n=>x({targetCollection:n}),children:[e.jsx($,{className:"h-8 text-sm",children:e.jsx(M,{placeholder:"Select collection..."})}),e.jsx(_,{children:j.map(n=>e.jsx(g,{value:n.name,children:n.label},n.name))})]})]}),e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(O,{id:`${l}-multiple`,checked:s.multiple,onCheckedChange:n=>x({multiple:!!n})}),e.jsx("label",{htmlFor:`${l}-multiple`,className:"text-sm",children:"Allow multiple"})]})]})})]})})}function ts({relationships:l,onChange:s,collections:a,existingRelNames:u}){const j=He(Ue(ze)),p=l.map((o,i)=>`rel-${i}`),[f,b]=r.useState(null);function k(){b(l.length),s([...l,{name:"",label:"",targetCollection:"",multiple:!1}])}function d(o,i){const c=[...l];c[o]=i,s(c)}function D(o){s(l.filter((i,c)=>c!==o))}function v(o){const{active:i,over:c}=o;if(c&&i.id!==c.id){const C=p.indexOf(String(i.id)),y=p.indexOf(String(c.id));s(Ke(l,C,y))}}return e.jsx(We,{sensors:j,collisionDetection:Ye,onDragEnd:v,children:e.jsx(Xe,{items:p,strategy:Je,children:e.jsxs("div",{className:"space-y-2",children:[l.map((o,i)=>e.jsx(ss,{id:`rel-${i}`,relationship:o,onChange:c=>d(i,c),onRemove:()=>D(i),collections:a,readOnlyName:!!(u?.has(o.name)&&o.name),defaultExpanded:i===f},`rel-${i}`)),e.jsxs(N,{type:"button",variant:"outline",size:"sm",onClick:k,children:[e.jsx(Se,{className:"mr-2 h-3 w-3"})," Add Relationship"]})]})})})}const as=["text","textarea","number","boolean","select","array"],ls=["url","email","date","datetime","content","blocks"];function vs(){const{host:l,name:s}=je(),a=s==="new",{data:u,isLoading:j}=Ne(l,a?"":s);return!a&&j?e.jsxs("div",{className:"space-y-4",children:[e.jsx(U,{className:"h-8 w-64"}),e.jsx(U,{className:"h-64 w-full"})]}):a?e.jsx(J,{host:l,isNew:!0}):u?e.jsx(J,{host:l,isNew:!1,collection:u},u.name):e.jsx("p",{className:"text-muted-foreground",children:"Collection not found."})}function J({host:l,isNew:s,collection:a}){const u=be(),j=ye(),{collections:p}=ke(),f=De(l),b=Ee(l,a?.name??""),k=Pe(l,a?.name??""),[d,D]=r.useState(a?.name??""),[v,o]=r.useState(a?.label??""),[i,c]=r.useState(a?.labelSingular??""),[C,y]=r.useState(a?.slug??""),[x,I]=r.useState(a?.singleton??!1),[n,ee]=r.useState(a?.mode??"content"),[R,se]=r.useState(a?.requireAuth??!1),h=n==="submission",[te,ae]=r.useState(!s),[le,ne]=r.useState(!s),[ie,re]=r.useState(!s),oe=new Set((a?.fields??[]).map(t=>t.name).filter(Boolean)),T=[{name:"blocks",label:"Blocks",type:"blocks",options:{}}],[E,F]=r.useState(a?.fields??(s&&!x?T:[])),[A,ce]=r.useState(a?.relationships??[]),de=new Set((a?.relationships??[]).map(t=>t.name).filter(Boolean)),[B,ue]=r.useState(a?.mobileNavPriority??0),[w,me]=r.useState(a?.icon??""),[xe,V]=r.useState(!1);_e({title:s?"New Collection":a?.label??d,showBack:!0,backTo:`/sites/${l}/settings/collections`});function he(){if(!d)return;const t=Z(d);te||o(t),le||c(Me(t)),ie||y(d.replace(/_/g,"-"))}async function H(t){t?.preventDefault();try{s?(await f.mutateAsync({name:d,label:v,labelSingular:i,slug:C,singleton:h?!1:x,fields:E,relationships:A,mobileNavPriority:B,icon:w,mode:n,requireAuth:h?R:void 0}),P.success("Collection created"),u(`/sites/${l}/settings/collections/${d}`)):(await b.mutateAsync({label:v,labelSingular:i,slug:h?void 0:C,singleton:h?!1:x,fields:E,relationships:A,mobileNavPriority:B,icon:w,mode:n,requireAuth:h?R:void 0}),P.success("Collection updated"))}catch(S){P.error(s?"Failed to create":"Failed to update",{description:S instanceof Error?S.message:void 0})}}async function ge(){try{await k.mutateAsync(),P.success("Collection deleted"),u(`/sites/${l}/settings/collections`)}catch(t){P.error("Failed to delete",{description:t instanceof Error?t.message:void 0})}}return e.jsxs("div",{className:"mx-auto max-w-2xl",children:[!j&&e.jsx("h1",{className:"mb-6 text-2xl font-semibold",children:s?"New Collection":`Edit: ${a?.label??d}`}),e.jsxs(W,{children:[e.jsx(Y,{children:e.jsx(G,{children:"Collection Settings"})}),e.jsx(X,{children:e.jsxs("form",{onSubmit:H,className:"space-y-4","aria-label":"Collection settings",children:[e.jsxs("div",{className:"space-y-2",children:[e.jsx(m,{htmlFor:"name",children:"Name"}),e.jsx(Q,{id:"name",value:d,onChange:D,onBlur:he,readOnly:!s,placeholder:"e.g. blog_posts",required:!0})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(m,{htmlFor:"mode",children:"Mode"}),e.jsxs(q,{value:n,onValueChange:t=>{ee(t),t==="submission"&&s&&(I(!1),F(E.filter(S=>as.includes(S.type)))),t==="content"&&s&&E.length===0&&F(T)},disabled:!s,children:[e.jsx($,{id:"mode",children:e.jsx(M,{})}),e.jsxs(_,{children:[e.jsx(g,{value:"content",children:"Content"}),e.jsx(g,{value:"submission",children:"Submissions"})]})]}),!s&&e.jsx("p",{className:"text-xs text-muted-foreground",children:"Mode cannot be changed after creation."})]}),h&&e.jsx("div",{className:"rounded-md border border-blue-200 bg-blue-50 p-3 text-sm text-blue-800 dark:border-blue-800 dark:bg-blue-950 dark:text-blue-200",children:e.jsxs("div",{className:"flex items-start gap-2",children:[e.jsx(Ie,{className:"mt-0.5 h-4 w-4 shrink-0"}),e.jsxs("div",{children:[e.jsx("p",{className:"font-medium",children:"Submission Collection"}),e.jsxs("p",{className:"mt-1",children:["Submissions are created via the API:"," ",e.jsxs("code",{className:"rounded bg-blue-100 px-1 dark:bg-blue-900",children:["POST /v1/","{site}","/submit/",d||"{collection}"]})]})]})]})}),h&&e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(O,{id:"requireAuth",checked:R,onCheckedChange:t=>se(!!t)}),e.jsx(m,{htmlFor:"requireAuth",children:"Require authentication (site users must be logged in to submit)"})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(m,{htmlFor:"label",children:"Label"}),e.jsx(L,{id:"label",value:v,onChange:t=>{o(t.target.value),ae(!0)},required:!0})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(m,{htmlFor:"label-singular",children:"Label Singular"}),e.jsx(L,{id:"label-singular",value:i,onChange:t=>{c(t.target.value),ne(!0)},required:!0})]}),!h&&e.jsxs("div",{className:"space-y-2",children:[e.jsx(m,{htmlFor:"slug",children:"Slug"}),e.jsx(L,{id:"slug",value:C,onChange:t=>{y(t.target.value),re(!0)},required:!0})]}),!h&&e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(O,{id:"singleton",checked:x,onCheckedChange:t=>{const S=!!t;I(S),s&&F(S?[]:T)},disabled:!s}),e.jsx(m,{htmlFor:"singleton",children:"Singleton (single entry, no list)"})]}),e.jsx(z,{}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(m,{children:"Fields"}),e.jsx(qe,{fields:E,onChange:F,excludeTypes:h?ls:void 0,existingFieldNames:oe})]}),e.jsx(z,{}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(m,{children:"Relationships"}),e.jsx(ts,{relationships:A,onChange:ce,collections:p,existingRelNames:de})]})]})})]}),e.jsxs(W,{className:"mt-6",children:[e.jsx(Y,{children:e.jsx(G,{children:"Navigation"})}),e.jsxs(X,{className:"space-y-4",children:[e.jsxs("div",{className:"space-y-2",children:[e.jsx(m,{children:"Icon"}),e.jsx($e,{value:w,onChange:me})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(m,{htmlFor:"mobileNavPriority",children:"Bottom Nav Priority"}),e.jsxs(q,{value:String(B),onValueChange:t=>ue(Number(t)),children:[e.jsx($,{id:"mobileNavPriority",children:e.jsx(M,{})}),e.jsxs(_,{children:[e.jsx(g,{value:"0",children:"0 - Hidden"}),e.jsx(g,{value:"1",children:"1"}),e.jsx(g,{value:"2",children:"2"}),e.jsx(g,{value:"3",children:"3"}),e.jsx(g,{value:"4",children:"4"}),e.jsx(g,{value:"5",children:"5 - Highest"})]})]}),e.jsx("p",{className:"text-xs text-muted-foreground",children:"Collections with priority > 0 appear in the mobile bottom navigation bar."})]})]})]}),e.jsxs("div",{className:"mt-6 flex justify-end gap-2",children:[e.jsx(N,{type:"button",variant:"outline",onClick:()=>u(`/sites/${l}/settings/collections`),children:"Cancel"}),e.jsxs(N,{onClick:H,disabled:f.isPending||b.isPending,children:[(f.isPending||b.isPending)&&e.jsx(Fe,{className:"mr-2 h-4 w-4 animate-spin"}),s?"Create":"Save"]})]}),!s&&e.jsx("div",{className:"mt-6",children:e.jsxs(Le,{open:xe,onOpenChange:V,children:[e.jsx(Re,{asChild:!0,children:e.jsxs(N,{variant:"destructive",children:[e.jsx(K,{className:"mr-2 h-4 w-4"}),"Delete Collection"]})}),e.jsxs(Te,{children:[e.jsxs(Ae,{children:[e.jsx(Be,{children:"Delete collection?"}),e.jsx(we,{children:"This will permanently delete the collection and all its content."})]}),e.jsxs(Oe,{children:[e.jsx(N,{variant:"outline",onClick:()=>V(!1),children:"Cancel"}),e.jsx(N,{variant:"destructive",onClick:ge,children:"Delete"})]})]})]})})]})}export{vs as CollectionEditPage};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{j as e}from"./tanstack-Bs3zYPPV.js";import{u as j,f as u}from"./react-vendor-C2CvUxFh.js";import{
|
|
1
|
+
import{j as e}from"./tanstack-Bs3zYPPV.js";import{u as j,f as u}from"./react-vendor-C2CvUxFh.js";import{aw as f,x as g,B as o,P as c,S as b,j as r}from"./index-Ce5pmRMj.js";import{T as p,a as N,b as d,c as i,d as C,e as n}from"./table-_3bMY0_z.js";import{u as w}from"./usePageTitle-C1r1-C00.js";import"./radix-C5ZmWuuL.js";function $(){const{host:l}=j(),a=u(),{data:t,isLoading:m}=f(l),x=g();return w({title:"Collections",actions:e.jsx(o,{size:"sm",onClick:()=>a(`/sites/${l}/settings/collections/new`),children:e.jsx(c,{className:"h-4 w-4"})})}),e.jsxs("div",{children:[!x&&e.jsxs("div",{className:"mb-6 flex items-center justify-between",children:[e.jsx("h1",{className:"text-2xl font-semibold",children:"Collections"}),e.jsxs(o,{onClick:()=>a(`/sites/${l}/settings/collections/new`),children:[e.jsx(c,{className:"mr-2 h-4 w-4"}),"New Collection"]})]}),m?e.jsx("div",{className:"space-y-2",children:Array.from({length:3}).map((s,h)=>e.jsx(b,{className:"h-12 w-full"},h))}):t?.items.length?e.jsxs(p,{children:[e.jsx(N,{children:e.jsxs(d,{children:[e.jsx(i,{children:"Name"}),e.jsx(i,{children:"Label"}),e.jsx(i,{children:"Type"}),e.jsx(i,{children:"Fields"})]})}),e.jsx(C,{children:t.items.map(s=>e.jsxs(d,{className:"cursor-pointer",onClick:()=>a(`/sites/${l}/settings/collections/${s.name}`),children:[e.jsx(n,{className:"font-mono text-sm",children:s.name}),e.jsx(n,{children:s.label}),e.jsx(n,{children:s.singleton?e.jsx(r,{variant:"secondary",children:"Singleton"}):e.jsx(r,{variant:"outline",children:"Collection"})}),e.jsx(n,{className:"text-muted-foreground",children:s.fields?.length??0})]},s.name))})]}):e.jsx("p",{className:"text-muted-foreground",children:"No collections defined."})]})}export{$ as CollectionsPage};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{j as e}from"./tanstack-Bs3zYPPV.js";import{u as E,f as P,r as i,m as I,N as T}from"./react-vendor-C2CvUxFh.js";import{w as F,x as k,L as g,I as h,B as f,a as A,v as p,C as B}from"./index-
|
|
1
|
+
import{j as e}from"./tanstack-Bs3zYPPV.js";import{u as E,f as P,r as i,m as I,N as T}from"./react-vendor-C2CvUxFh.js";import{w as F,x as k,L as g,I as h,B as f,a as A,v as p,C as B}from"./index-Ce5pmRMj.js";import{e as L}from"./useContent-Bs7nel7C.js";import{C as D,a as H,b as M,c as q}from"./card-C9hfyHXf.js";import{u as R}from"./usePageTitle-C1r1-C00.js";import{s as z}from"./format-C88SDH8g.js";import"./radix-C5ZmWuuL.js";function X(){const{host:a,collection:s}=E(),c=P(),{collections:C}=F(),o=L(a),[l,j]=i.useState(""),[u,d]=i.useState(""),[v,b]=i.useState(!1),[m,x]=i.useState(null),N=k(),[S]=I(),r=C.find(t=>t.name===s),$=S.get("from")==="recent"?`/sites/${a}/content`:`/sites/${a}/content/${s}`;if(R({title:`New ${r?.labelSingular??s}`,showBack:!0,backTo:$}),r?.singleton){const t=r.singletonContentId?`/sites/${a}/content/${s}/${r.singletonContentId}`:`/sites/${a}/content/${s}`;return e.jsx(T,{to:t,replace:!0})}function y(t){j(t),v||d(z(t))}async function w(t){t.preventDefault(),x(null);try{const n=await o.mutateAsync({collection:s,title:l,slug:u||void 0});p.success("Content created"),c(`/sites/${a}/content/${s}/${n.contentId}`)}catch(n){n instanceof B&&n.status===409?x("A content item with this slug already exists. Choose a different slug."):p.error("Failed to create content",{description:n instanceof Error?n.message:void 0})}}return e.jsxs("div",{className:"mx-auto max-w-2xl",children:[!N&&e.jsxs("h1",{className:"mb-6 text-2xl font-semibold",children:["New ",r?.labelSingular??s]}),e.jsxs(D,{children:[e.jsx(H,{children:e.jsx(M,{children:"Details"})}),e.jsx(q,{children:e.jsxs("form",{onSubmit:w,className:"space-y-4",children:[e.jsxs("div",{className:"space-y-2",children:[e.jsx(g,{htmlFor:"title",children:"Title"}),e.jsx(h,{id:"title",value:l,onChange:t=>y(t.target.value),required:!0,autoFocus:!0})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(g,{htmlFor:"slug",children:"Slug"}),e.jsx(h,{id:"slug",value:u,onChange:t=>{d(t.target.value),b(!0)}})]}),m&&e.jsx("p",{className:"text-sm text-destructive",children:m}),e.jsxs("div",{className:"flex gap-2",children:[e.jsxs(f,{type:"submit",disabled:!l||o.isPending,children:[o.isPending&&e.jsx(A,{className:"mr-2 h-4 w-4 animate-spin"}),"Create"]}),e.jsx(f,{type:"button",variant:"outline",onClick:()=>c(-1),children:"Cancel"})]})]})})]})]})}export{X as ContentCreatePage};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{a as Bs,u as Pn,b as En,j as e}from"./tanstack-Bs3zYPPV.js";import{r as s,u as Ln,f as Tn,m as In,L as Un}from"./react-vendor-C2CvUxFh.js";import{f as Fn,g as St,h as On,i as Ct,j as Bn,k as qn,l as $n,m as Vn,n as _n,o as Mn,p as Hn,q as Jn,r as wt}from"./useContent-Bs7nel7C.js";import{C as Ee,v as V,E as qs,e as ls,u as $s,F as zn,G as Ss,B as P,y as cs,J as Kn,K as Yn,M as Qn,N as Gn,S as fe,O as Rt,Q as Nt,R as ns,V as as,W as Dt,Y as At,Z as Pt,_ as Et,U as Wn,$ as Xn,w as Zn,d as ea,x as sa,L as Ze,I as it,a0 as Lt,X as rt,a1 as ta,a2 as lt,a3 as na,a4 as ct,a5 as aa,j as ia,a as ve,a6 as ot,a7 as dt,a8 as ra,a9 as ut,aa as Cs,ab as la,ac as ca,D as Es,k as Ls,l as Ts,m as Is,n as Us,o as Fs,i as oa,T as da}from"./index-Ce5pmRMj.js";import{A as Tt,a as It,b as Ut,c as Ft,d as Ot,e as Bt,f as qt,g as $t,T as ua}from"./TagInput-57c4DG1w.js";import{a as ts,f as Se}from"./format-C88SDH8g.js";import{u as Vt}from"./useAdminResolver-BJNPz3OG.js";import{u as ha}from"./usePageTitle-C1r1-C00.js";import{s as Oe,T as fa,d as ma}from"./serializeToText-2VrsuRUh.js";import{S as pa,a as ga,b as ba,c as xa,d as ws,e as va,f as ya,g as ja}from"./select-CrRhFGIi.js";import{T as ka}from"./textarea-6fq0R6VV.js";import{C as Ue,c as Fe,a as ht,b as ft}from"./card-C9hfyHXf.js";import{C as _t,a as Mt,b as Ht}from"./collapsible-D3d29uJp.js";import{u as Sa}from"./useTags-B-HgMVwo.js";import{M as Ca}from"./MediaField-CxccCFGQ.js";import{m as wa}from"./media-url-DdCoIedP.js";import{R as Ra}from"./RelationshipPicker-B3Ftmqxp.js";import{A as Na,a as Da,i as Aa,F as Pa,b as es,C as Ea}from"./FieldRenderer-DiOKvkWV.js";import{g as La,a as Ta,b as Ia}from"./contentStatus-CkPi9Dh6.js";import{O as Ua,f as Fa,g as is,e as Jt,w as Rs,a as Oa,t as Ba,r as Ns,b as qa,c as $a,d as Va,h as _a,i as mt,j as Ma,D as Ha}from"./yjs-tXBm_srz.js";import"./radix-C5ZmWuuL.js";import"./useMedia-ae3s_ajC.js";import"./core.esm-DdQHdRkd.js";import"./sortable.esm-qVEMoaTg.js";import"./ContentField-pilCbdnA.js";import"./popover-CzaQYEEP.js";import"./command-Bfmj0MEL.js";import"./useContentSearch-B3aTjuCu.js";import"./checkbox-DVJcwUt1.js";const Ja=3e3,za="__HEADROOM_API_URL__".replace(/\/+$/,"");function Ka(r,t,i,a,l,c=Ja,f,h={}){const m=Fn(r,t),u=s.useRef(null),v=s.useRef(i?JSON.stringify(i):""),x=s.useRef(void 0),[S,w]=s.useState(null),[j,L]=s.useState(null),C=s.useRef(!1),R=s.useRef(!1),y=s.useRef(!1),k=s.useRef(!1),N=s.useRef(!1),[$,M]=s.useState(!1),_=s.useRef(!1),E=s.useCallback(O=>{_.current!==O&&(_.current=O,M(O))},[]),D=s.useRef(f);s.useEffect(()=>{D.current=f},[f]);const T=s.useRef(h.onBeforeFirstSave);s.useEffect(()=>{T.current=h.onBeforeFirstSave},[h.onBeforeFirstSave]);const X=s.useRef(h.onStaleBaseConflict);s.useEffect(()=>{X.current=h.onStaleBaseConflict},[h.onStaleBaseConflict]);const K=s.useRef(h.getCurrentParams);s.useEffect(()=>{K.current=h.getCurrentParams},[h.getCurrentParams]);const se=s.useCallback(O=>{N.current||JSON.stringify(O)===v.current||(u.current=O,E(!0),clearTimeout(x.current),x.current=window.setTimeout(async()=>{if(!u.current)return;if(!k.current&&T.current)try{if(!(await T.current()).ok)return;k.current=!0}catch{return}if(!u.current||R.current)return;const I=u.current,H=JSON.stringify(I);y.current=!0,m.mutate(I,{onSuccess:A=>{if(y.current=!1,C.current){C.current=!1;return}u.current===I&&(u.current=null,E(!1)),v.current=H,w(Date.now()),A?.blockId&&L(A.blockId),D.current?.(A)},onError:A=>{if(y.current=!1,A instanceof Ee&&A.code==="SLUG_TAKEN")a?.();else if(A instanceof Ee&&A.code==="LOCK_HELD")k.current=!1,l?.(A);else if(A instanceof Ee&&A.code==="STALE_BASE"){const J=A.body;X.current?.(J?.currentUpdatedAt??0,J?.currentBlockId??"")}else A instanceof Ee&&A.status===400?V.error("Auto-save failed",{description:A.message}):A instanceof Ee&&A.status>=500&&V.error("Auto-save failed",{description:"The server returned an error. Reload to continue editing safely."})}})},c))},[m,a,l,c,E]),re=s.useCallback(async O=>{clearTimeout(x.current),R.current=!0;try{let B=null;if(u.current?B={...u.current}:O?.createVersion&&K.current&&(B=K.current()),!B)return;if(O?.createVersion&&(B.createVersion=!0),!k.current&&T.current)try{if(!(await T.current()).ok)return;k.current=!0}catch{return}const I=JSON.stringify(B);u.current=null,E(!1);const H=await m.mutateAsync(B);v.current=I,w(Date.now()),H?.blockId&&L(H.blockId)}finally{R.current=!1}},[m,E]),Z=s.useCallback(()=>{clearTimeout(x.current),u.current=null,E(!1)},[E]),Q=s.useCallback(()=>{k.current=!1},[]),F=s.useCallback(O=>{v.current=JSON.stringify(O),k.current=!1},[]),le=s.useCallback(()=>{clearTimeout(x.current),u.current=null,E(!1),C.current=!0,L(null),k.current=!1},[E]),o=s.useCallback(()=>{N.current=!0,clearTimeout(x.current)},[]),d=s.useCallback(()=>{N.current=!1},[]);return s.useEffect(()=>()=>{if(clearTimeout(x.current),u.current){const{sessionId:O,...B}=u.current,I=JSON.stringify(B),H=qs(),A=`${za}/v1/admin/sites/${r}/content/${t}/draft`;fetch(A,{method:"PUT",body:I,headers:{"Content-Type":"application/json",...H?{Authorization:`Bearer ${H}`}:{}},keepalive:!0}).catch(()=>{}),u.current=null}},[r,t]),{schedule:se,flush:re,cancel:Z,resetBaseline:F,discard:le,pause:o,resume:d,markLockReleased:Q,isDirty:$,isSaving:m.isPending,lastSavedAt:S,lastSavedBlockId:j,getIsSavingSync:()=>y.current,getHasPending:()=>u.current!==null}}const pt="headroom:idleHintShown",Ya="__HEADROOM_API_URL__".replace(/\/+$/,""),Qa=5e3,Ga=3600*1e3,Wa=6e4,Ds=2e3;function Xa(r){const t=`headroom:editSession:${r}`;let i=sessionStorage.getItem(t);return i||(i=zn(),sessionStorage.setItem(t,i)),i}const As=new Map;function Za(r,t,i={}){const a=ls(),{user:l}=$s(),c=Bs(),[f,h]=s.useState("viewing"),[m,u]=s.useState(null),[v,x]=s.useState(null),[S,w]=s.useState([]),[j,L]=s.useState(!1),[C,R]=s.useState(!1),y=t?Xa(t):"",k=s.useRef(0),N=s.useRef(!1),$=s.useRef(!1),M=s.useRef(!1),_=s.useRef(null),E=s.useRef(null),D=s.useRef(0),T=s.useRef(null),X=s.useRef(i.getIsDirty),K=s.useRef(i.getIsSaving),se=s.useRef(i.getIsSavingSync),re=s.useRef(i.onIdleRelease);s.useEffect(()=>{X.current=i.getIsDirty,K.current=i.getIsSaving,se.current=i.getIsSavingSync,re.current=i.onIdleRelease});const Z=s.useCallback(async(b=!1)=>{if(!r||!t||!y)return null;const q=`${r}:${t}:${b?"force":"edit"}`,U=As.get(q);if(U)return U;const ee=a.apiFetch(`/v1/admin/sites/${r}/content/${t}/edit-lock`,{method:"POST",body:JSON.stringify({sessionId:y,force:b,email:l?.email,name:l?.name})}).finally(()=>{As.delete(q)});return As.set(q,ee),ee},[a,r,t,y,l?.email,l?.name]),Q=s.useCallback(async()=>{if(!(!r||!t||!y)&&!$.current&&!M.current){$.current=!0,M.current=!0;try{await a.apiFetch(`/v1/admin/sites/${r}/content/${t}/edit-lock`,{method:"DELETE",body:JSON.stringify({sessionId:y})})}catch{}finally{M.current=!1}}},[a,r,t,y]),F=s.useCallback(()=>{_.current&&(clearTimeout(_.current),_.current=null),E.current&&(clearTimeout(E.current),E.current=null)},[]),le=s.useRef(()=>{}),o=s.useCallback(()=>{const b=X.current?X.current():!1,q=K.current?K.current():!1,U=se.current?se.current():!1;if(b||q||U){E.current=setTimeout(()=>le.current(),1e3);return}if(N.current){N.current=!1,Q(),re.current?.(),h("idle-released"),u(null),x(null),w([]),R(!1);try{typeof window<"u"&&window.sessionStorage&&(window.sessionStorage.getItem(pt)||(V("Released editing — others can edit now."),window.sessionStorage.setItem(pt,"1")))}catch{}}},[Q]);s.useEffect(()=>{le.current=o},[o]);const d=s.useCallback(()=>{F(),_.current=setTimeout(o,Wa)},[F,o]),O=s.useCallback(()=>{if(C){F();return}N.current&&d()},[C,F,d]),B=s.useRef(C);s.useEffect(()=>{const b=B.current;B.current=C,b!==C&&(C?F():N.current&&d())},[C,F,d]);const I=s.useCallback(async()=>{if(!r||!t||!y||!l)return{ok:!1,holder:null};if(Date.now()<D.current)return{ok:!1,holder:T.current};try{const b=await Z(!1);if(!b||!b.acquired){const q=b?.lockHolder??null;return D.current=Date.now()+Ds,T.current=q,h("blocked-edit"),u(q),R(b?.collaborationEnabled??!1),k.current||(k.current=Date.now()),{ok:!1,holder:q}}return N.current=!0,$.current=!1,D.current=0,T.current=null,h("editing"),u(b.lockHolder??null),x(b.takeoverReason),R(b.collaborationEnabled),d(),{ok:!0}}catch(b){const q=b;if(q.status===409){const U=q.body?.lockHolder??null,ee=q.body?.collaborationEnabled??!1;if(U&&U.sub===l.sub&&U.sessionId!==y)try{const G=await Z(!1);if(G?.acquired)return N.current=!0,$.current=!1,D.current=0,T.current=null,h("editing"),u(G.lockHolder??null),x(G.takeoverReason),R(G.collaborationEnabled),d(),{ok:!0}}catch{}return D.current=Date.now()+Ds,T.current=U,h("blocked-edit"),u(U),R(ee),k.current||(k.current=Date.now()),{ok:!1,holder:U}}return h("error"),{ok:!1,holder:null}}},[r,t,y,l,Z,d]);s.useEffect(()=>{if(!r||!t||!y)return;const b=()=>{if(!N.current||$.current||M.current)return;$.current=!0;const q=qs(),U=`${Ya}/v1/admin/sites/${r}/content/${t}/edit-lock`;fetch(U,{method:"DELETE",body:JSON.stringify({sessionId:y}),headers:{"Content-Type":"application/json",...q?{Authorization:`Bearer ${q}`}:{}},keepalive:!0}).catch(()=>{})};return window.addEventListener("beforeunload",b),()=>window.removeEventListener("beforeunload",b)},[r,t,y]);const H=s.useRef(Q),A=s.useRef(F);s.useEffect(()=>{H.current=Q,A.current=F},[Q,F]),s.useEffect(()=>()=>{A.current(),N.current&&(N.current=!1,H.current())},[r,t,y]);const J=f==="blocked-edit"&&!j,ye=s.useCallback(b=>{if(k.current&&Date.now()-k.current>Ga){L(!0),h("poll-ceiling");return}const q=b.lock;if(!q)D.current=0,T.current=null,u(null),R(!1),w([]),h("idle-released"),k.current=0;else{u(q.heldBy),R(q.collaborationEnabled);const U=(q.accessRequests??[]).filter(ee=>ee.sub!==l?.sub);w(U)}},[l?.sub]);Pn({queryKey:["sites",r,"edit-lock",t],queryFn:async()=>{try{const b=await a.apiFetch(`/v1/admin/sites/${r}/content/${t}/edit-lock`);return ye(b),b}catch{return{lock:m?{heldBy:m,expiresAt:0,collaborationEnabled:C,accessRequests:[]}:null}}},enabled:J,refetchInterval:J?Qa:!1,refetchIntervalInBackground:!1,retry:!1});const ne=En({mutationFn:()=>a.apiFetch(`/v1/admin/sites/${r}/content/${t}/edit-lock/access-requests`,{method:"POST",body:JSON.stringify({sessionId:y,email:l?.email,name:l?.name})})}),g=s.useCallback(async()=>{const b=await Z(!0);return b?.acquired&&(N.current=!0,$.current=!1,D.current=0,T.current=null,h("editing"),u(b.lockHolder??null),x(b.takeoverReason),R(b.collaborationEnabled),d(),c.invalidateQueries({queryKey:["sites",r,"edit-lock",t]})),b},[Z,c,r,t,d]),Be=s.useCallback(async()=>I(),[I]),Y=s.useCallback(b=>{N.current=!1,F(),D.current=Date.now()+Ds,T.current=b.lockHolder??null,h("blocked-edit"),u(b.lockHolder??null),x(b.takeoverReason??null),k.current||(k.current=Date.now())},[F]),os=s.useCallback(()=>{F(),N.current&&(N.current=!1,Q()),D.current=0,T.current=null,h("viewing"),u(null),x(null),R(!1),w([]),k.current=0},[F,Q]),ds=s.useCallback(()=>{F(),h("stale-reload-pending")},[F]),de=s.useCallback(()=>{h("editing"),N.current&&d()},[d]),me=s.useCallback(()=>{F(),D.current=0,T.current=null,h("read-only-explicit")},[F]),je=s.useCallback(()=>{h("viewing")},[]);return{status:f,lockHolder:m,takeoverReason:v,accessRequests:S,sessionId:y,pollCeiling:j,collaborationEnabled:C,acquireLock:Z,releaseLock:Q,tryAcquireForEdit:I,bumpIdleTimer:O,requestCollaboration:ne,forceTakeover:g,takeEditing:Be,endEditing:os,setStaleReloadPending:ds,resumeEditingAfterStale:de,setReadOnlyExplicit:me,exitReadOnly:je,onAutosaveConflict:Y,setAccessRequests:w,setCollaborationEnabled:R}}function ei({host:r,contentId:t,isDirty:i,serverBlockId:a,serverUpdatedAt:l,onSilentReload:c,onStaleWithDirty:f,onTabHidden:h,onTabVisibleResume:m,minHiddenMs:u=3e4}){const v=Bs(),x=s.useRef(null),S=s.useRef(i),w=s.useRef(a),j=s.useRef(l),L=s.useRef(c),C=s.useRef(f),R=s.useRef(h),y=s.useRef(m),k=s.useRef(u);s.useEffect(()=>{S.current=i,w.current=a,j.current=l,L.current=c,C.current=f,R.current=h,y.current=m,k.current=u},[i,a,l,c,f,h,m,u]),s.useEffect(()=>{if(typeof document>"u"||!r||!t)return;const N=["sites",r,"content-detail",t];let $=!1;const M=async()=>{if(typeof document>"u")return;if(document.visibilityState==="hidden"){x.current=Date.now(),R.current&&R.current();return}if(document.visibilityState!=="visible")return;const _=x.current;if(x.current=null,_==null)return;if(Date.now()-_<k.current){y.current&&y.current();return}if(await v.refetchQueries({queryKey:[...N],exact:!0}),$)return;const D=v.getQueryData([...N]);if(!D){y.current&&y.current();return}const T=D.draft?.updatedAt,X=D.draft?.blockId,K=j.current??0,se=w.current??null;if(!(typeof T=="number"&&T>K||X!=null&&X!==se)){y.current&&y.current();return}$||(S.current?C.current(D):(y.current&&y.current(),L.current(D)))};return document.addEventListener("visibilitychange",M),()=>{$=!0,document.removeEventListener("visibilitychange",M)}},[r,t,v])}function Vs(){return"__HEADROOM_COLLAB_ENABLED__"!=="false"}function gt({variant:r="read-only-explicit",lockHolder:t,onRequestCollaboration:i,onForceTakeover:a,onDiscardPending:l,onViewReadOnly:c,onResumeEditing:f,isRequesting:h,requestSent:m}){if(r==="poll-ceiling")return e.jsx("div",{className:"bg-amber-50 border border-amber-200 rounded-lg p-4 mb-4","data-testid":"edit-lock-banner","data-variant":"poll-ceiling",children:e.jsxs("div",{className:"flex items-start gap-3",children:[e.jsx(Ss,{className:"h-5 w-5 text-amber-600 mt-0.5 shrink-0"}),e.jsxs("div",{className:"flex-1",children:[e.jsx("p",{className:"font-medium text-amber-900",children:"Lock check paused"}),e.jsx("p",{className:"text-sm text-amber-700 mt-1",children:"Refresh the page to retry."})]})]})});const u=Vs(),v=t?.name||t?.email||"another user";return r==="blocked-edit"?e.jsx("div",{className:"bg-amber-50 border border-amber-200 rounded-lg p-4 mb-4","data-testid":"edit-lock-banner","data-variant":"blocked-edit",children:e.jsxs("div",{className:"flex items-start gap-3",children:[e.jsx(Ss,{className:"h-5 w-5 text-amber-600 mt-0.5 shrink-0"}),e.jsxs("div",{className:"flex-1",children:[e.jsxs("p",{className:"font-medium text-amber-900",children:[v," is editing this content"]}),e.jsxs("p",{className:"text-sm text-amber-700 mt-1",children:["Your changes are pending and will be saved when ",v," finishes."]}),e.jsxs("div",{className:"flex flex-wrap gap-2 mt-3 items-center",children:[u&&i&&e.jsx(P,{size:"sm",variant:"outline",onClick:i,disabled:h||m,"data-testid":"request-collaboration-btn",children:m?"Request sent":"Request collaboration"}),l&&e.jsx(P,{size:"sm",variant:"ghost",onClick:l,"data-testid":"discard-pending-btn",children:"Discard pending changes"}),c&&e.jsx(P,{size:"sm",variant:"ghost",onClick:c,"data-testid":"view-read-only-btn",children:"View read-only"}),a&&e.jsx(P,{size:"sm",variant:"destructive",onClick:a,"data-testid":"force-takeover-btn",children:"Take over"})]})]})]})}):e.jsx("div",{className:"bg-amber-50 border border-amber-200 rounded-lg p-4 mb-4","data-testid":"edit-lock-banner","data-variant":"read-only-explicit",children:e.jsxs("div",{className:"flex items-start gap-3",children:[e.jsx(Ss,{className:"h-5 w-5 text-amber-600 mt-0.5 shrink-0"}),e.jsxs("div",{className:"flex-1",children:[e.jsxs("p",{className:"font-medium text-amber-900",children:["Editing: ",v]}),e.jsx("p",{className:"text-sm text-amber-700 mt-1",children:u?"This content is being edited. You can view it read-only or ask to collaborate.":"This content is being edited. You can view it read-only until the editor is finished."}),e.jsxs("div",{className:"flex gap-2 mt-3",children:[u&&i&&e.jsx(P,{size:"sm",variant:"outline",onClick:i,disabled:h||m,"data-testid":"request-collaboration-btn",children:m?"Request sent":"Request collaboration"}),f&&e.jsx(P,{size:"sm",variant:"ghost",onClick:f,"data-testid":"resume-editing-btn",children:"Resume editing"})]})]})]})})}function si({open:r,trigger:t,updatedBy:i,updatedAt:a,onReload:l,onCancel:c}){const f=a>0?ts(a):"just now";return e.jsx(Tt,{open:r,children:e.jsxs(It,{"data-testid":"stale-reload-modal","data-trigger":t,onEscapeKeyDown:h=>h.preventDefault(),children:[e.jsxs(Ut,{children:[e.jsx(Ft,{children:"This content was updated"}),e.jsx(Ot,{children:t==="save-conflict"?e.jsxs(e.Fragment,{children:["Your save couldn't go through —"," ",e.jsx("strong",{"data-testid":"stale-reload-updated-by",children:i})," ",e.jsxs("span",{className:"text-muted-foreground","data-testid":"stale-reload-updated-at",children:["(",f,")"]})," ","updated this content since you started editing. Reload to see the latest version (your unsaved changes will be lost), or cancel to keep editing — your next save will hit the same conflict."]}):e.jsxs(e.Fragment,{children:["This content was updated by"," ",e.jsx("strong",{"data-testid":"stale-reload-updated-by",children:i})," ",e.jsxs("span",{className:"text-muted-foreground","data-testid":"stale-reload-updated-at",children:["(",f,")"]})," ","while this tab was inactive. Reload to see the latest version (your unsaved changes will be lost), or cancel to keep editing your version — the next save will be rejected if it conflicts."]})})]}),e.jsxs(Bt,{children:[e.jsx(qt,{onClick:c,"data-testid":"stale-reload-cancel-btn",children:"Cancel"}),e.jsx($t,{onClick:l,"data-testid":"stale-reload-reload-btn",children:"Reload"})]})]})})}function ti({lines:r}){return e.jsx("div",{className:"font-mono text-sm leading-relaxed",children:r.map((t,i)=>e.jsx("div",{style:{paddingLeft:`${t.indent*1.5}rem`},className:cs("min-h-[1.5em]",t.type==="label"&&"text-muted-foreground font-semibold mt-1",t.type==="heading"&&"font-bold",t.type==="empty"&&"h-2"),children:t.text},i))})}function Os(r){switch(r.kind){case"draft":return"Draft";case"published":return"Published";case"history":return Se(r.createdAt)}}function rs(r){switch(r.kind){case"draft":return"draft";case"published":return"published";case"history":return`history:${r.blockId}`}}function bt({value:r,onChange:t,isPublished:i,versions:a,exclude:l,size:c}){const f=l?rs(l):null;function h(m){if(m==="draft")t({kind:"draft"});else if(m==="published")t({kind:"published"});else if(m.startsWith("history:")){const u=m.slice(8),v=a.find(x=>x.blockId===u);v&&t({kind:"history",blockId:v.blockId,createdAt:v.createdAt,title:v.title})}}return e.jsxs(pa,{value:rs(r),onValueChange:h,children:[e.jsx(ga,{size:c,children:e.jsx(ba,{children:Os(r)})}),e.jsxs(xa,{position:"popper",children:[f!=="draft"&&e.jsx(ws,{value:"draft",children:"Draft"}),i&&f!=="published"&&e.jsx(ws,{value:"published",children:"Published"}),a.length>0&&e.jsxs(e.Fragment,{children:[e.jsx(va,{}),e.jsxs(ya,{children:[e.jsx(ja,{children:"Version History"}),a.map(m=>{const u=`history:${m.blockId}`;return u===f?null:e.jsx(ws,{value:u,children:Se(m.createdAt)},u)})]})]})]})]})}function xt({ref:r,host:t,contentId:i,collectionFields:a,isSingleton:l,draftBody:c,draftMetadata:f,collectionRelationships:h,draftRelationships:m}){const u=r?.kind==="published",v=r?.kind==="history",x=v?r.blockId:null,{data:S,isLoading:w}=St(t,i,u),{data:j,isLoading:L}=On(t,i,v?x:null),C=s.useMemo(()=>(h??[]).map(k=>({name:k.name,label:k.label})),[h]);function R(k){if(C.length!==0)return{defs:C,values:k??{}}}const y=s.useMemo(()=>{if(!r)return[];if(r.kind==="draft")return c?Oe(a,c,l?void 0:f,R(m)):[];if(r.kind==="published"){if(!S)return[];const $=l?void 0:{title:S.title,slug:S.slug,snippet:S.snippet,tags:S.tags},M=S.relationships;return Oe(a,S.fields??{},$,R(M))}if(!j)return[];const k=l?void 0:{title:j.title,slug:j.slug,snippet:j.snippet,tags:j.tags},N=j.relationships;return Oe(a,j.body??{},k,R(N))},[r,c,f,m,S,j,a,l,C]);return r?r.kind==="draft"?{lines:y,isLoading:!1,hasData:!!c}:r.kind==="published"?{lines:y,isLoading:w,hasData:!!S}:{lines:y,isLoading:L,hasData:!!j}:{lines:[],isLoading:!1,hasData:!1}}function ni({open:r,onOpenChange:t,host:i,contentId:a,collectionFields:l,isSingleton:c,isPublished:f,draftBody:h,draftMetadata:m,initialVersion:u,collectionRelationships:v,draftRelationships:x}){const[S,w]=s.useState(u??{kind:"published"}),[j,L]=s.useState({kind:"draft"}),[C,R]=s.useState(r),[y,k]=s.useState(u);if((r!==C||u!==y)&&(R(r),k(u),r)){const T=u??{kind:"published"};w(T),L(T.kind==="draft"?{kind:"published"}:{kind:"draft"})}rs(S)===rs(j)&&(S.kind!=="draft"?L({kind:"draft"}):f&&L({kind:"published"}));const{data:N}=Ct(i,a),$=N?.items??[],M={host:i,contentId:a,collectionFields:l,isSingleton:c,draftBody:h,draftMetadata:m,collectionRelationships:v,draftRelationships:x},_=xt({ref:r?S:null,...M}),E=xt({ref:r?j:null,...M}),D=_.isLoading;return e.jsx(Kn,{open:r,onOpenChange:t,children:e.jsxs(Yn,{className:"w-[calc(100vw-2rem)] sm:max-w-2xl overflow-y-auto pt-[env(safe-area-inset-top,0px)] pr-[env(safe-area-inset-right,0px)]",children:[e.jsx(Qn,{children:e.jsxs(Gn,{className:"flex items-center gap-2",children:[e.jsx("span",{className:"text-muted-foreground text-sm font-normal",children:"Viewing"}),e.jsx(bt,{value:S,onChange:w,isPublished:f,versions:$,size:"sm"})]})}),D&&e.jsxs("div",{className:"space-y-4 p-4",children:[e.jsx(fe,{className:"h-6 w-48"}),e.jsx(fe,{className:"h-4 w-full"}),e.jsx(fe,{className:"h-4 w-full"}),e.jsx(fe,{className:"h-4 w-2/3"})]}),!D&&!_.hasData&&e.jsx("p",{className:"p-4 text-sm text-muted-foreground",children:"No data available for this version."}),!D&&_.hasData&&e.jsx("div",{className:"p-4",children:e.jsxs(Rt,{defaultValue:"changes",children:[e.jsxs(Nt,{variant:"line",className:"mb-4",children:[e.jsx(ns,{value:"content",children:"Content"}),e.jsx(ns,{value:"changes",children:"Changes"})]}),e.jsx(as,{value:"content",children:e.jsx(ti,{lines:_.lines})}),e.jsxs(as,{value:"changes",children:[e.jsxs("div",{className:"flex items-center gap-2 mb-4",children:[e.jsx("span",{className:"text-sm text-muted-foreground",children:"Compare with"}),e.jsx(bt,{value:j,onChange:L,isPublished:f,versions:$,exclude:S,size:"sm"})]}),E.isLoading?e.jsxs("div",{className:"space-y-4",children:[e.jsx(fe,{className:"h-4 w-full"}),e.jsx(fe,{className:"h-4 w-full"}),e.jsx(fe,{className:"h-4 w-2/3"})]}):E.hasData?e.jsx(fa,{left:E.lines,right:_.lines,leftLabel:Os(j),rightLabel:Os(S)}):e.jsx("p",{className:"text-sm text-muted-foreground italic",children:"No data available for comparison."})]})]})})]})})}const Ps=3e4;class ai extends Ua{constructor(t){super(),this.doc=t,this.clientID=t.clientID,this.states=new Map,this.meta=new Map,this._checkInterval=setInterval(()=>{const i=is();this.getLocalState()!==null&&Ps/2<=i-this.meta.get(this.clientID).lastUpdated&&this.setLocalState(this.getLocalState());const a=[];this.meta.forEach((l,c)=>{c!==this.clientID&&Ps<=i-l.lastUpdated&&this.states.has(c)&&a.push(c)}),a.length>0&&ii(this,a,"timeout")},Fa(Ps/10)),t.on("destroy",()=>{this.destroy()}),this.setLocalState({})}destroy(){this.emit("destroy",[this]),this.setLocalState(null),super.destroy(),clearInterval(this._checkInterval)}getLocalState(){return this.states.get(this.clientID)||null}setLocalState(t){const i=this.clientID,a=this.meta.get(i),l=a===void 0?0:a.clock+1,c=this.states.get(i);t===null?this.states.delete(i):this.states.set(i,t),this.meta.set(i,{clock:l,lastUpdated:is()});const f=[],h=[],m=[],u=[];t===null?u.push(i):c==null?t!=null&&f.push(i):(h.push(i),Jt(c,t)||m.push(i)),(f.length>0||m.length>0||u.length>0)&&this.emit("change",[{added:f,updated:m,removed:u},"local"]),this.emit("update",[{added:f,updated:h,removed:u},"local"])}setLocalStateField(t,i){const a=this.getLocalState();a!==null&&this.setLocalState({...a,[t]:i})}getStates(){return this.states}}const ii=(r,t,i)=>{const a=[];for(let l=0;l<t.length;l++){const c=t[l];if(r.states.has(c)){if(r.states.delete(c),c===r.clientID){const f=r.meta.get(c);r.meta.set(c,{clock:f.clock+1,lastUpdated:is()})}a.push(c)}}a.length>0&&(r.emit("change",[{added:[],updated:[],removed:a},i]),r.emit("update",[{added:[],updated:[],removed:a},i]))},vt=(r,t,i=r.states)=>{const a=t.length,l=$a();Rs(l,a);for(let c=0;c<a;c++){const f=t[c],h=i.get(f)||null,m=r.meta.get(f).clock;Rs(l,f),Rs(l,m),Oa(l,JSON.stringify(h))}return Ba(l)},ri=(r,t,i)=>{const a=Va(t),l=is(),c=[],f=[],h=[],m=[],u=Ns(a);for(let v=0;v<u;v++){const x=Ns(a);let S=Ns(a);const w=JSON.parse(qa(a)),j=r.meta.get(x),L=r.states.get(x),C=j===void 0?0:j.clock;(C<S||C===S&&w===null&&r.states.has(x))&&(w===null?x===r.clientID&&r.getLocalState()!=null?S++:r.states.delete(x):r.states.set(x,w),r.meta.set(x,{clock:S,lastUpdated:l}),j===void 0&&w!==null?c.push(x):j!==void 0&&w===null?m.push(x):w!==null&&(Jt(w,L)||h.push(x),f.push(x)))}(c.length>0||h.length>0||m.length>0)&&r.emit("change",[{added:c,updated:h,removed:m},i]),(c.length>0||f.length>0||m.length>0)&&r.emit("update",[{added:c,updated:f,removed:m},i])},yt=[1e3,2e3,4e3,8e3,16e3];class _s{awareness;ws=null;doc;room;wsUrl;ticket;getTicket;reconnectAttempt=0;reconnectTimer=null;connected=!1;destroyed=!1;pendingUpdates=[];pendingFieldUpdates=[];static MAX_PENDING_FIELD_UPDATES=100;statusListeners=new Set;constructor(t){this.doc=t.doc,this.room=t.room,this.wsUrl=t.wsUrl,this.ticket=t.ticket,this.getTicket=t.getTicket,this.awareness=new ai(this.doc),this.awareness.setLocalStateField("user",t.user),this.doc.on("update",this.handleDocUpdate),this.awareness.on("update",this.handleAwarenessUpdate),this.connect()}onStatus(t){return this.statusListeners.add(t),()=>{this.statusListeners.delete(t)}}connect(){if(this.destroyed)return;this.statusListeners.forEach(i=>i("connecting"));const t=`${this.wsUrl}?ticket=${encodeURIComponent(this.ticket)}&room=${encodeURIComponent(this.room)}`;this.ws=new WebSocket(t),this.ws.onopen=()=>{this.connected=!0,this.reconnectAttempt=0,this.statusListeners.forEach(l=>l("connected"));const i=_a(this.doc);this.ws.send(JSON.stringify({action:"yjs",type:"sync-step-1",data:Ie(i)}));const a=vt(this.awareness,[this.doc.clientID]);this.ws.send(JSON.stringify({action:"awareness",data:Ie(a)}))},this.ws.onmessage=i=>{const a=JSON.parse(i.data);switch(a.action){case"yjs":this.handleYjsMessage(a);break;case"field":this.fieldListeners.forEach(l=>l(a));break;case"awareness":this.handleAwarenessMessage(a);break;case"presence":this.presenceListeners.forEach(l=>l(a));break;case"leader-change":this.leaderChangeListeners.forEach(l=>l(a));break;case"collaboration-disabled":this.collabDisabledListeners.forEach(l=>l());break;case"publish-requested":this.publishRequestedListeners.forEach(l=>l(a));break;case"save-version-requested":this.saveVersionRequestedListeners.forEach(l=>l(a));break;case"publish-in-progress":this.publishInProgressListeners.forEach(l=>l());break;case"published":this.publishedListeners.forEach(l=>l(a));break}},this.ws.onclose=()=>{this.connected=!1,this.statusListeners.forEach(i=>i("disconnected")),this.scheduleReconnect()},this.ws.onerror=()=>{this.ws?.close()}}handleDocUpdate=(t,i)=>{i!=="remote"&&(this.connected?this.sendYjsUpdate(t):this.pendingUpdates.push(t))};sendYjsUpdate(t){this.ws?.send(JSON.stringify({action:"yjs",type:"update",data:Ie(t)}))}flushPendingUpdates(){for(const t of this.pendingUpdates)this.sendYjsUpdate(t);this.pendingUpdates=[]}handleYjsMessage(t){const i=jt(t.data);switch(t.type){case"sync-step-1":{const a=Ma(this.doc,i);this.ws.send(JSON.stringify({action:"yjs",type:"sync-step-2",data:Ie(a)}));break}case"sync-step-2":mt(this.doc,i,"remote"),this.flushPendingUpdates(),this.flushPendingFieldUpdates();break;case"update":mt(this.doc,i,"remote");break}}fieldListeners=new Set;onFieldUpdate(t){return this.fieldListeners.add(t),()=>{this.fieldListeners.delete(t)}}sendFieldUpdate(t,i){if(!this.connected){const a=this.pendingFieldUpdates.findIndex(l=>l.field===t);a>=0?this.pendingFieldUpdates[a]={field:t,value:i}:(this.pendingFieldUpdates.length>=_s.MAX_PENDING_FIELD_UPDATES&&this.pendingFieldUpdates.shift(),this.pendingFieldUpdates.push({field:t,value:i}));return}this.ws?.send(JSON.stringify({action:"field",field:t,value:i}))}flushPendingFieldUpdates(){for(const{field:t,value:i}of this.pendingFieldUpdates)this.ws?.send(JSON.stringify({action:"field",field:t,value:i}));this.pendingFieldUpdates=[]}presenceListeners=new Set;onPresence(t){return this.presenceListeners.add(t),()=>{this.presenceListeners.delete(t)}}leaderChangeListeners=new Set;onLeaderChange(t){return this.leaderChangeListeners.add(t),()=>{this.leaderChangeListeners.delete(t)}}collabDisabledListeners=new Set;onCollabDisabled(t){return this.collabDisabledListeners.add(t),()=>{this.collabDisabledListeners.delete(t)}}sendDisableCollab(){this.connected&&this.ws?.send(JSON.stringify({action:"disable-collab"}))}publishRequestedListeners=new Set;onPublishRequested(t){return this.publishRequestedListeners.add(t),()=>{this.publishRequestedListeners.delete(t)}}saveVersionRequestedListeners=new Set;onSaveVersionRequested(t){return this.saveVersionRequestedListeners.add(t),()=>{this.saveVersionRequestedListeners.delete(t)}}publishInProgressListeners=new Set;onPublishInProgress(t){return this.publishInProgressListeners.add(t),()=>{this.publishInProgressListeners.delete(t)}}publishedListeners=new Set;onPublished(t){return this.publishedListeners.add(t),()=>{this.publishedListeners.delete(t)}}sendRequestPublish(){this.connected&&this.ws?.send(JSON.stringify({action:"request-publish"}))}sendRequestSaveVersion(){this.connected&&this.ws?.send(JSON.stringify({action:"request-save-version"}))}sendPublishInProgress(){this.connected&&this.ws?.send(JSON.stringify({action:"publish-in-progress"}))}sendPublished(t){this.connected&&this.ws?.send(JSON.stringify({action:"published",...t?.contentId?{contentId:t.contentId}:{},...t?.version!==void 0?{version:t.version}:{}}))}handleAwarenessUpdate=({added:t,updated:i,removed:a})=>{if(!this.connected)return;const l=vt(this.awareness,[...t,...i,...a]);this.ws?.send(JSON.stringify({action:"awareness",data:Ie(l)}))};handleAwarenessMessage(t){const i=jt(t.data);ri(this.awareness,i,"remote")}scheduleReconnect(){if(this.destroyed)return;const t=yt[Math.min(this.reconnectAttempt,yt.length-1)];this.reconnectAttempt++,this.reconnectTimer=window.setTimeout(async()=>{try{this.ticket=await this.getTicket()}catch{this.statusListeners.forEach(i=>i("disconnected"));return}this.connect()},t)}destroy(){this.destroyed=!0,this.reconnectTimer&&clearTimeout(this.reconnectTimer),this.doc.off("update",this.handleDocUpdate),this.awareness.off("update",this.handleAwarenessUpdate),this.awareness.destroy(),this.ws?.close()}}function Ie(r){let t="";for(let a=0;a<r.length;a+=8192)t+=String.fromCharCode(...r.subarray(a,a+8192));return btoa(t)}function jt(r){const t=atob(r),i=new Uint8Array(t.length);for(let a=0;a<t.length;a++)i[a]=t.charCodeAt(a);return i}const ss=["#3b82f6","#ef4444","#10b981","#f59e0b","#8b5cf6","#ec4899","#14b8a6","#f97316"];function li(r,t,i,a){const{user:l}=$s(),[c,f]=s.useState(null),[h,m]=s.useState("disconnected"),[u,v]=s.useState([]),[x,S]=s.useState({}),w=s.useRef(null),j=s.useRef(a?.onCollabDisabled),L=s.useRef(a?.onPublishRequested),C=s.useRef(a?.onSaveVersionRequested),R=s.useRef(a?.onPublishInProgress),y=s.useRef(a?.onPublished);s.useEffect(()=>{j.current=a?.onCollabDisabled,L.current=a?.onPublishRequested,C.current=a?.onSaveVersionRequested,R.current=a?.onPublishInProgress,y.current=a?.onPublished},[a?.onCollabDisabled,a?.onPublishRequested,a?.onSaveVersionRequested,a?.onPublishInProgress,a?.onPublished]);const k="__HEADROOM_COLLAB_WS_URL__",N=Vs(),$=N&&!!c&&h==="connected";s.useEffect(()=>{if(!N||!k||!l||!i)return;const o=new Ha;w.current=o;const d=`${r}/${t}`,O=async()=>{const H=qs();if(!H)throw new Error("No access token");const A="__HEADROOM_API_URL__".replace(/\/+$/,""),J=await fetch(`${A}/v1/admin/sites/${r}/content/${t}/collab/ticket`,{method:"POST",headers:{Authorization:`Bearer ${H}`,"Content-Type":"application/json"},body:JSON.stringify({room:d})});if(!J.ok)throw new Error(`Ticket request failed: ${J.status}`);return(await J.json()).ticket};let B=!1,I=null;return O().then(H=>{if(B)return;const A=kt(l.sub)%ss.length;I=new _s({wsUrl:k,room:d,ticket:H,getTicket:O,doc:o,user:{sub:l.sub,name:l.name||l.email,color:ss[A]}}),I.onStatus(m),I.onPresence(J=>{v(J.connections.filter(ne=>ne.connectionId!==J.youAre).map(ne=>({sub:ne.adminSub,name:ne.adminName,color:ne.color})));const ye=J.connections.find(ne=>ne.connectionId===J.youAre);le(ye?.isLeader??!1)}),I.onCollabDisabled(()=>{j.current?.()}),I.onPublishRequested(()=>L.current?.()),I.onSaveVersionRequested(()=>C.current?.()),I.onPublishInProgress(()=>R.current?.()),I.onPublished(J=>y.current?.({contentId:J.contentId,version:J.version})),f(I)}).catch(()=>{B||m("disconnected")}),()=>{B=!0,I?.destroy(),o.destroy(),f(null),m("disconnected")}},[r,t,l?.sub,i,k]);const M=s.useCallback(o=>{if(!c||!l||!w.current)return;const d=w.current.getXmlFragment(`document-store-${o}`),O=kt(l.sub)%ss.length;return{provider:c,fragment:d,user:{name:l.email,color:ss[O]}}},[c,l]);s.useEffect(()=>{if(!c){S({});return}const o=()=>{const d={};c.awareness.getStates().forEach(B=>{const I=B?.user?.sub;if(!I)return;const H=B.activeField??null;d[I]=H}),S(d)};return o(),c.awareness.on("change",o),()=>{c.awareness.off("change",o)}},[c]);const _=s.useMemo(()=>u.map(o=>({...o,activeField:x[o.sub]??null})),[u,x]),E=s.useCallback(o=>{c&&c.awareness.setLocalStateField("activeField",o)},[c]),D=s.useRef(new Set),T=s.useCallback(o=>(D.current.add(o),()=>{D.current.delete(o)}),[]);s.useEffect(()=>{if(c)return c.onFieldUpdate(o=>{D.current.forEach(d=>d(o.field,o.value))})},[c]);const X=s.useCallback((o,d)=>{c?.sendFieldUpdate(o,d)},[c]),K=s.useCallback(()=>{c?.sendDisableCollab()},[c]),se=s.useCallback(()=>{c?.sendRequestPublish()},[c]),re=s.useCallback(()=>{c?.sendRequestSaveVersion()},[c]),Z=s.useCallback(()=>{c?.sendPublishInProgress()},[c]),Q=s.useCallback(o=>{c?.sendPublished(o)},[c]),[F,le]=s.useState(!1);return s.useEffect(()=>{if(c)return c.onLeaderChange(o=>{le(o.leaderSub===l?.sub)})},[c,l]),{active:$,status:h,editors:_,isLeader:F,getBlockNoteCollab:M,updateField:X,onRemoteFieldChange:T,setActiveField:E,sendDisableCollab:K,sendRequestPublish:se,sendRequestSaveVersion:re,sendPublishInProgress:Z,sendPublished:Q}}function kt(r){let t=0;for(let i=0;i<r.length;i++)t=(t<<5)-t+r.charCodeAt(i)|0;return Math.abs(t)}function ci({status:r,editors:t}){return t.length===0&&r==="connected"?null:e.jsxs("div",{className:"flex items-center gap-2 px-3 py-1.5 bg-muted/50 rounded-md text-sm","data-testid":"collaboration-bar",children:[e.jsxs("div",{className:"flex items-center gap-1.5","aria-label":r,children:[e.jsx("span",{"data-testid":"collaboration-bar-status-dot","data-status":r,className:cs("h-2 w-2 rounded-full",r==="connected"&&"bg-green-500",r==="connecting"&&"bg-yellow-500 animate-pulse",r==="disconnected"&&"bg-red-500")}),e.jsx("span",{className:"text-muted-foreground text-xs",children:r==="connected"?"Live":r==="connecting"?"Connecting...":"Offline"})]}),t.length>0&&e.jsxs(e.Fragment,{children:[e.jsx(Dt,{orientation:"vertical",className:"h-4"}),e.jsx("div",{className:"flex -space-x-1.5",children:t.map(i=>e.jsxs(At,{children:[e.jsx(Pt,{asChild:!0,children:e.jsx(Na,{className:"h-6 w-6 border-2",style:{borderColor:i.color},"aria-label":i.name,children:e.jsx(Da,{className:"text-[10px]",style:{backgroundColor:i.color+"20"},children:Aa(i.name)})})}),e.jsx(Et,{children:i.name})]},i.sub))}),e.jsxs("span",{className:"text-muted-foreground text-xs",children:[t.length," other ",t.length===1?"editor":"editors"]})]})]})}function oi({host:r,contentId:t,collaborationEnabled:i,hasConnectedPeers:a,isLockHolder:l,sessionId:c,onChange:f,onBeforeDisable:h}){const[m,u]=s.useState(!1),v=ls();if(!Vs()||!l)return null;const x=async()=>{const C=!i;u(!0);try{if(!C)try{h?.()}catch{}await v.apiFetch(`/v1/admin/sites/${r}/content/${t}/edit-lock/collaboration`,{method:"POST",body:JSON.stringify({collaborationEnabled:C,sessionId:c})}),f(C)}catch{V.error("Failed to update collaboration setting")}finally{u(!1)}},S=i&&a,w=m||S,j=S?"Cannot stop sharing while other editors are connected":null,L=e.jsxs(P,{variant:i?"default":"outline",size:"sm",disabled:w,onClick:x,"aria-pressed":i,children:[i?e.jsx(Wn,{className:"h-4 w-4"}):e.jsx(Xn,{className:"h-4 w-4"}),i?"Collaborating":"Collaborate"]});return j?e.jsxs(At,{children:[e.jsx(Pt,{asChild:!0,children:L}),e.jsx(Et,{children:j})]}):L}function di(r,t,i,a,l){const c=s.useRef(new Set),f=ls();s.useEffect(()=>{const h=new Set(a.map(m=>m.sub));for(const m of Array.from(c.current))h.has(m)||c.current.delete(m)},[a]),s.useEffect(()=>{for(const h of a){if(c.current.has(h.sub))continue;c.current.add(h.sub);const m=h.name||h.email||"Someone";V(`${m} wants to collaborate`,{action:{label:"Allow",onClick:()=>{f.apiFetch(`/v1/admin/sites/${r}/content/${t}/edit-lock/collaboration`,{method:"POST",body:JSON.stringify({collaborationEnabled:!0,sessionId:i})}).then(()=>l()).catch(()=>V.error("Failed to enable collaboration"))}},cancel:{label:"Decline",onClick:()=>{f.apiFetch(`/v1/admin/sites/${r}/content/${t}/edit-lock/access-requests/${h.sub}?sessionId=${i}`,{method:"DELETE"}).catch(()=>V.error("Failed to decline request"))}},duration:1/0})}},[a,r,t,i,l,f])}function Hi(){const{host:r,collection:t,id:i}=Ln(),{data:a,isLoading:l}=Bn(r,i);return l?e.jsxs("div",{className:"space-y-4",children:[e.jsx(fe,{className:"h-8 w-64"}),e.jsx(fe,{className:"h-64 w-full"})]}):a?.content?e.jsx(ui,{host:r,collection:t,contentId:i,content:a.content,draft:a.draft,publishedBlockId:a.publishedBlockId}):e.jsx("p",{className:"text-muted-foreground",children:"Content not found."})}function ui({host:r,collection:t,contentId:i,content:a,draft:l,publishedBlockId:c}){const f=Tn(),h=ls(),m=Bs(),{collections:u}=Zn(),v=qn(r,i),x=$n(r,i),S=Vn(r,i),w=_n(r,i),j=Mn(r,i),L=Hn(r,i),C=l?{title:l.title??a.title,slug:l.slug??a.slug??"",snippet:l.snippet??a.snippet??"",tags:l.tags??a.tags??[],cover:l.cover??a.cover??null,body:l.body??{},relationships:l.relationships??{}}:void 0,{user:R}=$s(),{data:y}=ea(),k=R?(y?.superAdminIds??[]).includes(R.sub):!1,N=s.useRef(null),$=s.useCallback(async()=>{const n=N.current;return n?n():{ok:!0}},[]),M=typeof l?.updatedAt=="number"?l.updatedAt:0,[_,E]=s.useState(M),D=s.useRef(M);s.useEffect(()=>{D.current=_},[_]);const T=s.useRef(()=>{}),X=s.useRef(()=>{}),[K,se]=s.useState(!1),re=s.useRef(!1),Z=s.useRef(!1),Q=s.useRef(()=>!1),F=s.useRef(()=>!1),le=s.useRef(null),o=Za(r,i,{getIsDirty:()=>Q.current()||re.current,getIsSaving:()=>Z.current,getIsSavingSync:()=>F.current(),onIdleRelease:()=>le.current?.()}),d=li(r,i,o.collaborationEnabled,{onCollabDisabled:()=>o.setCollaborationEnabled(!1),onPublishRequested:()=>T.current(),onSaveVersionRequested:()=>X.current(),onPublishInProgress:()=>se(!0),onPublished:()=>{se(!1),V.success("Content published")}}),[O,B]=s.useState(null),I=d.active?1e4:void 0,H=s.useCallback(n=>{const p=n,W=(p?.accessRequests??[]).filter(Te=>Te.sub!==R?.sub);o.setAccessRequests(W),typeof p?.updatedAt=="number"&&(E(p.updatedAt),xs(!1))},[o,R?.sub]),A=s.useRef(null),J=s.useCallback(()=>{A.current?.()},[]),ye=s.useRef(null),ne=s.useCallback(()=>ye.current?.()??{},[]),g=Ka(r,i,C,()=>{B("This slug is already in use by another item in this collection")},n=>{o.onAutosaveConflict({lockHolder:n.body?.lockHolder??void 0,takeoverReason:n.body?.takeoverReason??"expired"})},I,H,{onBeforeFirstSave:$,onStaleBaseConflict:J,getCurrentParams:ne});N.current=o.tryAcquireForEdit,re.current=g.isDirty,Z.current=g.isSaving,Q.current=g.getHasPending,F.current=g.getIsSavingSync,le.current=g.markLockReleased;const Be=o.bumpIdleTimer;s.useEffect(()=>{g.lastSavedAt!=null&&Be()},[g.lastSavedAt,Be]);const Y=(o.status==="blocked-edit"||o.status==="read-only-explicit"||o.status==="stale-reload-pending"||o.status==="poll-ceiling")&&!o.collaborationEnabled;di(r,i,o.sessionId,o.accessRequests,()=>o.setCollaborationEnabled(!0));const{data:os}=Sa(r),ds=os?.map(n=>n.tag),de=u.find(n=>n.name===t),me=s.useMemo(()=>de?.fields??[],[de?.fields]),je=s.useMemo(()=>de?.relationships??[],[de?.relationships]),b=de?.singleton??!1,q=sa(),[U,ee]=s.useState(l?.title??a.title),[G,Ce]=s.useState(l?.slug??a.slug??""),[ce,we]=s.useState(l?.snippet??a.snippet??""),Ms=l?.autoSnippet??"",[pe,Re]=s.useState(l?.tags??a.tags??[]),[ae,Ne]=s.useState(l?.cover??a.cover??null),[ge,De]=s.useState(l?.body??{}),[be,Ae]=s.useState(l?.relationships??{}),[zt,us]=s.useState(0),[Kt,Yt]=s.useState(!1),[Qt,qe]=s.useState(!1),[Gt,Le]=s.useState(!1),[Wt,$e]=s.useState(null),[hs,Ve]=s.useState(!1),[Xt,_e]=s.useState(!1),[Zt,Me]=s.useState(!1),[He,Hs]=s.useState(""),[en,fs]=s.useState(!1),[ms,Js]=s.useState(""),zs=Jn(r,i),te=s.useCallback(()=>({title:U,slug:G,snippet:ce,tags:pe,cover:ae,body:ge,relationships:be,...o.sessionId?{sessionId:o.sessionId}:{},...D.current?{baseUpdatedAt:D.current}:{}}),[U,G,ce,pe,ae,ge,be,o.sessionId]);s.useEffect(()=>{ye.current=te},[te]);const sn=d.active?n=>{ee(n),d.updateField("title",n)}:n=>{ee(n),g.schedule({...te(),title:n})},tn=d.active?n=>{Ce(n),B(null),d.updateField("slug",n)}:n=>{Ce(n),B(null),g.schedule({...te(),slug:n})},nn=d.active?n=>{we(n),d.updateField("snippet",n)}:n=>{we(n),g.schedule({...te(),snippet:n})},an=d.active?n=>{Re(n),d.updateField("tags",n)}:n=>{Re(n),g.schedule({...te(),tags:n})},Ks=d.active?n=>{Ne(n),d.updateField("cover",n)}:n=>{Ne(n),g.schedule({...te(),cover:n})},rn=d.active?n=>{De(n),d.updateField("body",n)}:n=>{De(n),g.schedule({...te(),body:n})},ln=d.active?n=>{Ae(n),d.updateField("relationships",n)}:n=>{Ae(n),g.schedule({...te(),relationships:n})},Je=d.active,ze=d.setActiveField,ps=s.useCallback(n=>{Je&&ze(n)},[Je,ze]),gs=s.useCallback(()=>{Je&&ze(null)},[Je,ze]);s.useEffect(()=>{if(d.active)return d.onRemoteFieldChange((n,p)=>{switch(n){case"title":ee(p);break;case"slug":Ce(p);break;case"snippet":we(p);break;case"tags":Re(p);break;case"cover":Ne(p);break;case"body":De(p);break;case"relationships":Ae(p);break}d.isLeader&&g.schedule(te())})},[d.active,d.onRemoteFieldChange,d.isLeader]);const Ys=d.active?d.isLeader:!0;s.useEffect(()=>{if(!d.active||!Ys)return;g.schedule(te());const n=window.setInterval(()=>{g.schedule(te())},1e4);return()=>window.clearInterval(n)},[Ys,d.active]);const Qs=g.lastSavedBlockId??l?.blockId,ke=s.useCallback(n=>{const p=n.draft,z=n.content;if(!p&&!z)return;const W={title:p?.title??z?.title??"",slug:p?.slug??z?.slug??"",snippet:p?.snippet??z?.snippet??"",tags:p?.tags??z?.tags??[],cover:p?.cover??z?.cover??null,body:p?.body??{},relationships:p?.relationships??{}};ee(W.title),Ce(W.slug),we(W.snippet),Re(W.tags),Ne(W.cover),De(W.body),Ae(W.relationships);const Te=p?.updatedAt??0;E(Te),g.resetBaseline(W),us(js=>js+1)},[g]),[oe,bs]=s.useState(null),cn=s.useMemo(()=>oe?.updatedBy?[oe.updatedBy]:[],[oe?.updatedBy]),{resolve:Gs}=Vt(cn),on=s.useMemo(()=>{const n=oe?.updatedBy??"";if(!n)return"another admin";const p=Gs(n);return!p||p===n?"another admin":p},[oe?.updatedBy,Gs]),[dn,xs]=s.useState(!1),Ke=s.useRef(null),Ws=o.setStaleReloadPending,Ye=s.useCallback((n,p)=>{g.pause(),Ke.current={title:U,slug:G,snippet:ce,tags:pe,cover:ae,body:ge,relationships:be};const z=n.draft?.updatedAt??0,W=n.draft?.updatedBy??"";bs({trigger:p,updatedBy:W,updatedAt:z,latest:n}),Ws()},[g,Ws,U,G,ce,pe,ae,ge,be]),Qe=o.endEditing,un=s.useCallback(()=>{const n=oe;n&&ke(n.latest),Ke.current=null,bs(null),xs(!1),g.resume(),Qe()},[oe,ke,g,Qe]),Xs=o.resumeEditingAfterStale,hn=s.useCallback(()=>{const n=Ke.current;n&&(ee(n.title),Ce(n.slug),we(n.snippet),Re(n.tags),Ne(n.cover),De(n.body),Ae(n.relationships),us(p=>p+1),g.resetBaseline(n),Ke.current=null),bs(null),xs(!0),g.resume(),Xs()},[g,Xs]),Pe=s.useCallback(async()=>(await m.invalidateQueries({queryKey:["sites",r,"content-detail",i]}),m.getQueryData(["sites",r,"content-detail",i])??null),[m,r,i]),fn=s.useCallback(async()=>{g.cancel();const n=await Pe();n&&ke(n),Qe()},[g,Pe,ke,Qe]),Zs=o.setReadOnlyExplicit,mn=s.useCallback(async()=>{g.cancel();const n=await Pe();n&&ke(n),Zs()},[g,Pe,ke,Zs]),et=s.useCallback(async()=>{const n=await Pe();n&&Ye(n,"save-conflict")},[Pe,Ye]);s.useEffect(()=>{A.current=()=>void et()},[et]);const pn=s.useCallback(()=>{g.pause()},[g]),gn=s.useCallback(()=>{g.resume()},[g]),bn=s.useCallback(n=>{Ye(n,"tab-refocus")},[Ye]);ei({host:r,contentId:i,isDirty:g.isDirty,serverBlockId:Qs,serverUpdatedAt:_,onSilentReload:ke,onStaleWithDirty:bn,onTabHidden:pn,onTabVisibleResume:gn});const ue=La(a.publishedAt,a.lastPublishedAt,c,Qs,a.scheduledAt,a.scheduledFailed),Ge=Ta(ue),We=Ia(ue),{data:xe}=St(r,i,!!a.publishedAt),he=s.useMemo(()=>{if(!hs||!xe)return null;const n=b?void 0:{title:xe.title,slug:xe.slug,snippet:xe.snippet,tags:xe.tags},p=je.map(ie=>({name:ie.name,label:ie.label})),z=xe.relationships,W=p.length>0?{defs:p,values:z??{}}:void 0,Te=Oe(me,xe.fields??{},n,W),js=b?void 0:{title:U,slug:G,snippet:ce,tags:pe},Nn=p.length>0?{defs:p,values:be}:void 0,Dn=Oe(me,ge,js,Nn),An=ma(Te,Dn,{comparator:(ie,ks)=>ie.text===ks.text&&ie.indent===ks.indent&&ie.type===ks.type});let nt=0,at=0;for(const ie of An)ie.added?nt+=ie.count??0:ie.removed&&(at+=ie.count??0);return{added:nt,removed:at}},[hs,xe,me,je,b,U,G,ce,pe,ge,be]),[xn]=In(),vn=xn.get("from")==="recent"?`/sites/${r}/content`:`/sites/${r}/content/${t}`;ha({title:b?de?.label??t:U||"Untitled",showBack:!b,backTo:b?void 0:vn,badge:{label:Ge.label,variant:Ge.variant}});function Xe(){if(d.active&&!d.isLeader){d.sendRequestPublish();return}if(a.publishedAt&&a.slug&&G!==a.slug){_e(!0);return}ue==="published-changes"?Ve(!0):vs()}async function vs(){d.active&&d.isLeader&&d.sendPublishInProgress();try{await g.flush({createVersion:!0});const p=(await v.mutateAsync(void 0))?.updatedAt;typeof p=="number"&&p>0&&E(p),g.discard(),o.endEditing(),V.success("Content published"),d.active&&d.isLeader&&d.sendPublished({contentId:i})}catch(n){if(n instanceof Ee&&n.code==="SLUG_TAKEN"){B("This slug is already in use by another item in this collection"),V.error("Slug already in use",{description:"Please choose a different slug before publishing."});return}V.error("Failed to publish",{description:n instanceof Error?n.message:void 0})}finally{}}function yn(){if(d.active&&!d.isLeader){d.sendRequestSaveVersion();return}g.flush({createVersion:!0})}s.useEffect(()=>{T.current=Xe,X.current=()=>{g.flush({createVersion:!0})}});async function jn(){try{const p=(await x.mutateAsync())?.updatedAt;typeof p=="number"&&p>0&&E(p),Le(!1),o.endEditing(),V.success("Content unpublished")}catch(n){V.error("Failed to unpublish",{description:n instanceof Error?n.message:void 0})}}async function kn(){try{g.discard();const n=await h.apiFetch(`/v1/admin/sites/${r}/content/${i}/published`);await zs.mutateAsync();const p={title:n.title??"",slug:n.slug??"",snippet:n.snippet??"",tags:n.tags??[],cover:n.cover??null,body:n.fields??{},relationships:n.relationships??{}};ee(p.title),Ce(p.slug),we(p.snippet),Re(p.tags),Ne(p.cover),De(p.body),Ae(p.relationships),us(z=>z+1),g.resetBaseline(p),V.success("Changes discarded")}catch(n){V.error("Failed to discard changes",{description:n instanceof Error?n.message:void 0})}}async function Sn(){try{await S.mutateAsync(),o.endEditing(),V.success("Content deleted"),f(`/sites/${r}/content/${t}`)}catch(n){V.error("Failed to delete",{description:n instanceof Error?n.message:void 0})}}async function Cn(){if(He)try{await g.flush({createVersion:!0});const n=new Date(He).getTime(),z=(await j.mutateAsync(n))?.updatedAt;typeof z=="number"&&z>0&&E(z),Me(!1),Hs(""),o.endEditing(),V.success("Content scheduled for publishing")}catch(n){V.error("Failed to schedule",{description:n instanceof Error?n.message:void 0})}}async function wn(){try{const p=(await L.mutateAsync())?.updatedAt;typeof p=="number"&&p>0&&E(p),o.endEditing(),V.success("Schedule cancelled")}catch(n){V.error("Failed to cancel schedule",{description:n instanceof Error?n.message:void 0})}}async function Rn(){if(ms)try{const n=new Date(ms).getTime();await w.mutateAsync(n),fs(!1),V.success("Publish date updated")}catch(n){V.error("Failed to update publish date",{description:n instanceof Error?n.message:void 0})}}function ys(n){const p=new Date(n),z=p.getTimezoneOffset();return new Date(p.getTime()-z*6e4).toISOString().slice(0,16)}const st=e.jsx("div",{className:`space-y-6 ${Y?"pointer-events-none opacity-60 select-none":""}`,"aria-readonly":Y||void 0,children:me.length>0?e.jsx(Pa,{fields:me,values:ge,onChange:rn},zt):e.jsx(Ue,{children:e.jsx(Fe,{className:"py-8 text-center",children:e.jsxs("p",{className:"text-sm text-muted-foreground",children:["No fields defined for this collection."," ",e.jsx(Un,{to:`/sites/${r}/settings/collections/${t}`,className:"underline",children:"Configure fields"})]})})})}),tt=e.jsxs("div",{className:`space-y-6 ${Y?"pointer-events-none opacity-60 select-none":""}`,"aria-readonly":Y||void 0,children:[!b&&e.jsx(Ue,{children:e.jsxs(Fe,{className:"space-y-4 pt-4",children:[e.jsxs("div",{className:"space-y-2",children:[e.jsxs(Ze,{htmlFor:"title",className:"flex items-center",children:["Title",e.jsx(es,{field:"title",editors:d.editors})]}),e.jsx(it,{id:"title",value:U,onChange:n=>sn(n.target.value),onFocus:()=>ps("title"),onBlur:gs})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsxs(Ze,{htmlFor:"slug",className:"flex items-center",children:["Slug",e.jsx(es,{field:"slug",editors:d.editors})]}),e.jsx(it,{id:"slug",value:G,onChange:n=>tn(n.target.value),onFocus:()=>ps("slug"),onBlur:gs,className:O?"border-destructive":""}),O&&e.jsx("p",{className:"text-sm text-destructive",children:O})]}),e.jsxs(_t,{defaultOpen:!!ce,children:[e.jsxs(Mt,{className:"flex w-full items-center gap-2 text-sm font-medium",children:[e.jsx(Lt,{className:"h-4 w-4 transition-transform [[data-state=open]>&]:rotate-90"}),"Snippet",e.jsx("span",{className:"text-xs text-muted-foreground",children:"(auto-generated if empty)"}),e.jsx(es,{field:"snippet",editors:d.editors})]}),e.jsxs(Ht,{className:"mt-2 space-y-2",children:[e.jsx(ka,{id:"snippet",value:ce,onChange:n=>nn(n.target.value),onFocus:()=>ps("snippet"),onBlur:gs,rows:3,placeholder:"Brief summary of this content..."}),!ce&&Ms&&e.jsxs("p",{className:"text-xs italic text-muted-foreground",children:["Auto-generated: ",Ms]})]})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(Ze,{children:"Cover Image"}),ae?e.jsxs("div",{className:"flex items-center gap-3 rounded-md border p-2 cursor-pointer hover:bg-muted/50 transition-colors",onClick:()=>qe(!0),children:[e.jsx("img",{src:wa(ae.url),alt:ae.alt??ae.filename??"",className:"h-10 w-10 rounded object-cover bg-muted"}),e.jsx("span",{className:"flex-1 truncate text-sm",children:ae.filename??ae.alt??ae.id}),e.jsx(P,{type:"button",variant:"ghost",size:"sm",onClick:n=>{n.stopPropagation(),Ks(null)},children:e.jsx(rt,{className:"h-3 w-3"})})]}):e.jsxs(P,{type:"button",variant:"outline",className:"w-full",onClick:()=>qe(!0),children:[e.jsx(ta,{className:"mr-2 h-4 w-4"}),"Select Image"]}),e.jsx(Ca,{open:Qt,onClose:()=>qe(!1),onSelect:n=>{Ks({id:n.mediaId,url:n.url,width:n.width??0,height:n.height??0,alt:n.alt,caption:n.caption,filename:n.filename}),qe(!1)},allowedTypes:["image/*"]})]})]})}),!b&&e.jsxs(Ue,{children:[e.jsx(ht,{children:e.jsxs(ft,{className:"flex items-center",children:["Tags",e.jsx(es,{field:"tags",editors:d.editors})]})}),e.jsx(Fe,{children:e.jsx(ua,{tags:pe,onChange:an,suggestions:ds})})]}),je.length>0&&e.jsx(Ra,{relationships:je,values:be,onChange:ln,host:r}),e.jsxs(Ue,{children:[e.jsx(ht,{children:e.jsx(ft,{children:"Info"})}),e.jsxs(Fe,{className:"space-y-2 text-sm",children:[e.jsxs("div",{className:"flex justify-between",children:[e.jsx("span",{className:"text-muted-foreground",children:"Collection"}),e.jsx("span",{children:a.collection})]}),e.jsxs("div",{className:"flex justify-between",children:[e.jsx("span",{className:"text-muted-foreground",children:"ID"}),e.jsx("span",{className:"font-mono text-xs",children:a.contentId})]}),a.publishedAt?e.jsxs(e.Fragment,{children:[e.jsxs("div",{className:"flex justify-between items-center",children:[e.jsx("span",{className:"text-muted-foreground",children:"Published"}),en?e.jsxs("div",{className:"flex items-center gap-1",children:[e.jsx("input",{type:"datetime-local",value:ms,onChange:n=>Js(n.target.value),className:"text-xs border rounded px-1 py-0.5",max:ys(Date.now())}),e.jsx(P,{variant:"ghost",size:"sm",className:"h-6 w-6 p-0",onClick:Rn,disabled:w.isPending,children:e.jsx(lt,{className:"h-3 w-3"})}),e.jsx(P,{variant:"ghost",size:"sm",className:"h-6 w-6 p-0",onClick:()=>fs(!1),children:e.jsx(rt,{className:"h-3 w-3"})})]}):e.jsxs("span",{className:"cursor-pointer hover:underline",title:Se(a.publishedAt),onClick:()=>{Js(ys(a.publishedAt)),fs(!0)},children:[ts(a.publishedAt),e.jsx(na,{className:"inline ml-1 h-3 w-3 text-muted-foreground"})]})]}),a.lastPublishedAt&&a.lastPublishedAt!==a.publishedAt&&e.jsxs("div",{className:"flex justify-between",children:[e.jsx("span",{className:"text-muted-foreground",children:"Last published"}),e.jsx("span",{title:Se(a.lastPublishedAt),children:ts(a.lastPublishedAt)})]})]}):a.lastPublishedAt?e.jsxs("div",{className:"flex justify-between",children:[e.jsx("span",{className:"text-muted-foreground",children:"Last published"}),e.jsx("span",{title:Se(a.lastPublishedAt),children:ts(a.lastPublishedAt)})]}):null,ue==="scheduled"&&a.scheduledAt&&e.jsxs("div",{className:"flex justify-between items-center",children:[e.jsx("span",{className:"text-muted-foreground",children:"Scheduled for"}),e.jsxs("span",{className:"flex items-center gap-1",children:[e.jsx(ct,{className:"h-3 w-3"}),Se(a.scheduledAt)]})]}),ue==="schedule-failed"&&e.jsx("div",{className:"text-destructive text-xs",children:"Scheduled publishing failed after multiple attempts."}),a.publishedAt&&e.jsxs(P,{variant:"outline",size:"sm",className:"w-full mt-2",onClick:()=>{$e({kind:"published"}),Le(!0)},children:[e.jsx(aa,{className:"mr-2 h-4 w-4"}),"View published"]})]})]}),e.jsx(mi,{host:r,contentId:i,onViewVersion:n=>{$e({kind:"history",blockId:n.blockId,createdAt:n.createdAt,title:n.title}),Le(!0)}}),!b&&e.jsx(fi,{deleteOpen:Kt,setDeleteOpen:Yt,onDelete:Sn,host:r,contentId:i})]});return e.jsx(Ea.Provider,{value:d.active?d:null,children:e.jsxs("div",{className:"mx-auto max-w-6xl",children:[o.collaborationEnabled&&e.jsx("div",{className:"mb-3",children:e.jsx(ci,{status:d.status,editors:d.editors})}),o.status==="poll-ceiling"&&e.jsx(gt,{variant:"poll-ceiling"}),(o.status==="blocked-edit"||o.status==="read-only-explicit")&&o.lockHolder&&e.jsx(gt,{variant:o.status,lockHolder:o.lockHolder,onRequestCollaboration:()=>o.requestCollaboration.mutate(),isRequesting:o.requestCollaboration.isPending,requestSent:o.requestCollaboration.isSuccess,onDiscardPending:o.status==="blocked-edit"?()=>void fn():void 0,onViewReadOnly:o.status==="blocked-edit"?()=>void mn():void 0,onResumeEditing:o.status==="read-only-explicit"?()=>o.exitReadOnly():void 0,onForceTakeover:o.status==="blocked-edit"&&k?()=>void o.forceTakeover():void 0}),o.status==="read-only-explicit"&&!o.lockHolder&&e.jsxs("div",{className:"bg-emerald-50 border border-emerald-200 rounded-lg p-4 mb-4 flex items-center justify-between gap-3","data-testid":"lock-available-banner",children:[e.jsx("p",{className:"text-sm text-emerald-900",children:"Lock available — you can take over editing now."}),e.jsx(P,{size:"sm",onClick:()=>void o.takeEditing(),"data-testid":"take-editing-btn",children:"Take editing"})]}),!q&&e.jsxs("div",{className:"mb-4 flex flex-wrap items-center gap-2 md:mb-6 md:flex-nowrap md:gap-3 md:justify-between",children:[e.jsxs("div",{className:"flex min-w-0 items-center gap-2 md:gap-3",children:[e.jsx("h1",{className:"truncate text-xl font-semibold md:text-2xl",children:b?de?.label??t:U||"Untitled"}),e.jsx(ia,{variant:Ge.variant,children:Ge.label}),g.isSaving&&e.jsxs("span",{className:"flex items-center gap-1 text-xs text-muted-foreground",children:[e.jsx(ve,{className:"h-3 w-3 animate-spin"}),"Saving..."]}),!g.isSaving&&g.lastSavedAt&&e.jsxs("span",{className:"flex items-center gap-1 text-xs text-muted-foreground",children:[e.jsx(lt,{className:"h-3 w-3"}),"Saved"]}),dn&&e.jsxs("span",{className:"flex items-center gap-1 text-xs text-amber-700",title:"Your edits are based on an older version. The next save may be rejected.","data-testid":"stale-base-indicator",children:[e.jsx("span",{className:"inline-block h-2 w-2 rounded-full bg-amber-500"}),"Older version"]})]}),e.jsxs("div",{className:"flex gap-2 ml-auto",children:[e.jsx(oi,{host:r,contentId:i,collaborationEnabled:o.collaborationEnabled,hasConnectedPeers:d.editors.length>0,isLockHolder:o.status==="editing",sessionId:o.sessionId,onChange:n=>o.setCollaborationEnabled(n),onBeforeDisable:d.sendDisableCollab}),e.jsxs(P,{variant:"outline",size:"sm",onClick:yn,disabled:g.isSaving||Y,className:"px-3",children:[g.isSaving&&e.jsx(ve,{className:"mr-2 h-4 w-4 animate-spin"}),"Save Draft"]}),ue==="scheduled"&&e.jsxs(e.Fragment,{children:[e.jsxs(P,{variant:"outline",size:"sm",onClick:wn,disabled:L.isPending||Y,className:"px-3",children:[L.isPending&&e.jsx(ve,{className:"mr-2 h-4 w-4 animate-spin"}),"Cancel Schedule"]}),e.jsxs(P,{size:"sm",onClick:Xe,disabled:v.isPending||K||Y,className:"px-3",children:[(v.isPending||K)&&e.jsx(ve,{className:"mr-2 h-4 w-4 animate-spin"}),"Publish Now"]})]}),ue!=="scheduled"&&We&&e.jsxs("div",{className:"flex",children:[e.jsxs(P,{size:"sm",onClick:Xe,disabled:v.isPending||K||Y,className:cs("px-3",!a.publishedAt&&"rounded-r-none"),children:[(v.isPending||K)&&e.jsx(ve,{className:"mr-2 h-4 w-4 animate-spin"}),We]}),!a.publishedAt&&e.jsxs(ot,{children:[e.jsx(dt,{asChild:!0,children:e.jsx(P,{size:"sm",className:"rounded-l-none border-l px-2",disabled:v.isPending||K||Y,children:e.jsx(ra,{className:"h-4 w-4"})})}),e.jsx(ut,{align:"end",children:e.jsxs(Cs,{onClick:()=>Me(!0),disabled:Y,children:[e.jsx(ct,{className:"mr-2 h-4 w-4"}),"Schedule for later"]})})]})]}),a.publishedAt&&e.jsxs(ot,{children:[e.jsx(dt,{asChild:!0,children:e.jsx(P,{variant:"outline",size:"sm",className:"size-8 p-0",disabled:Y,children:e.jsx(la,{className:"h-4 w-4"})})}),e.jsxs(ut,{align:"end",children:[ue==="published-changes"&&e.jsxs(Cs,{onClick:kn,disabled:zs.isPending||Y,children:[e.jsx(ca,{className:"mr-2 h-4 w-4"}),"Discard Changes"]}),e.jsx(Cs,{onClick:jn,className:"text-destructive focus:text-destructive",disabled:Y,children:"Unpublish"})]})]})]})]}),q?e.jsxs(Rt,{defaultValue:"content",children:[e.jsxs("div",{className:"mb-2 flex items-center",children:[e.jsxs(Nt,{variant:"line",children:[e.jsx(ns,{value:"content",children:"Content"}),e.jsx(ns,{value:"info",children:"Info"})]}),e.jsxs("div",{className:"ml-auto flex gap-2",children:[e.jsxs(P,{variant:"outline",size:"sm",onClick:()=>g.flush({createVersion:!0}),disabled:g.isSaving||Y,children:[g.isSaving&&e.jsx(ve,{className:"mr-1 h-3 w-3 animate-spin"}),"Save"]}),ue!=="scheduled"&&We&&e.jsxs(P,{size:"sm",onClick:Xe,disabled:v.isPending||Y,children:[v.isPending&&e.jsx(ve,{className:"mr-1 h-3 w-3 animate-spin"}),We]})]})]}),e.jsx(as,{value:"content",className:"mt-0",children:st}),e.jsx(as,{value:"info",className:"mt-0",children:tt})]}):e.jsxs("div",{className:"grid gap-6 lg:grid-cols-3",children:[e.jsx("div",{className:"lg:col-span-2",children:st}),e.jsx("div",{children:tt})]}),e.jsx(ni,{open:Gt,onOpenChange:n=>{Le(n),n||$e(null)},host:r,contentId:i,collectionFields:me,isSingleton:b,isPublished:!!a.publishedAt,draftBody:ge,draftMetadata:b?void 0:{title:U,slug:G,snippet:ce,tags:pe},initialVersion:Wt,collectionRelationships:je,draftRelationships:be}),e.jsx(si,{open:!!oe,trigger:oe?.trigger??"tab-refocus",updatedBy:on,updatedAt:oe?.updatedAt??0,onReload:un,onCancel:hn}),e.jsx(Tt,{open:hs,onOpenChange:Ve,children:e.jsxs(It,{children:[e.jsxs(Ut,{children:[e.jsx(Ft,{children:"Publish changes?"}),e.jsx(Ot,{children:he?e.jsxs(e.Fragment,{children:[he.added>0&&e.jsxs("span",{className:"text-green-600",children:["+",he.added," added"]}),he.added>0&&he.removed>0&&", ",he.removed>0&&e.jsxs("span",{className:"text-red-600",children:["-",he.removed," removed"]}),he.added===0&&he.removed===0&&e.jsx("span",{children:"No visible changes detected."})]}):"This will update the published version with your current changes."})]}),e.jsx("div",{className:"mb-2",children:e.jsx(P,{variant:"link",className:"p-0 h-auto text-sm",onClick:()=>{Ve(!1),$e({kind:"draft"}),Le(!0)},children:"View full diff"})}),e.jsxs(Bt,{children:[e.jsx(qt,{children:"Cancel"}),e.jsx($t,{onClick:()=>{Ve(!1),vs()},children:"Publish Update"})]})]})}),e.jsx(Es,{open:Xt,onOpenChange:_e,children:e.jsxs(Ls,{children:[e.jsxs(Ts,{children:[e.jsx(Is,{children:"Slug change detected"}),e.jsxs(Us,{children:["You are changing the slug from “",a.slug,"” to “",G,"”. This may break external bookmarks and SEO links."]})]}),e.jsx(hi,{host:r,contentId:i}),e.jsxs(Fs,{children:[e.jsx(P,{variant:"outline",onClick:()=>_e(!1),children:"Cancel"}),e.jsx(P,{onClick:()=>{_e(!1),vs()},children:"Publish Anyway"})]})]})}),e.jsx(Es,{open:Zt,onOpenChange:Me,children:e.jsxs(Ls,{children:[e.jsxs(Ts,{children:[e.jsx(Is,{children:"Schedule publishing"}),e.jsx(Us,{children:"Choose a date and time to automatically publish this content. Times are rounded to the nearest 15-minute interval."})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(Ze,{htmlFor:"schedule-date",children:"Publish at"}),e.jsx("input",{id:"schedule-date",type:"datetime-local",value:He,onChange:n=>Hs(n.target.value),min:ys(Date.now()+1200*1e3),className:"w-full rounded-md border px-3 py-2 text-sm",step:"900"})]}),e.jsxs(Fs,{children:[e.jsx(P,{variant:"outline",onClick:()=>Me(!1),children:"Cancel"}),e.jsxs(P,{onClick:Cn,disabled:!He||j.isPending,children:[j.isPending&&e.jsx(ve,{className:"mr-2 h-4 w-4 animate-spin"}),"Schedule"]})]})]})})]})})}function hi({host:r,contentId:t}){const{data:i}=wt(r,t,!0);return!i||i.count===0?null:e.jsxs("div",{className:"rounded-md border border-yellow-500/50 bg-yellow-50 p-3 text-sm dark:bg-yellow-950/30",children:[e.jsxs("p",{className:"font-medium text-yellow-800 dark:text-yellow-200",children:["This content is referenced by ",i.count," other"," ",i.count===1?"item":"items",":"]}),e.jsxs("ul",{className:"mt-1 list-disc pl-5 text-yellow-700 dark:text-yellow-300",children:[i.items.slice(0,5).map(a=>e.jsxs("li",{children:[a.title," (",a.collection,")"]},`${a.contentId}-${a.fieldName}`)),i.items.length>5&&e.jsxs("li",{children:["and ",i.items.length-5," more..."]})]})]})}function fi({deleteOpen:r,setDeleteOpen:t,onDelete:i,host:a,contentId:l}){const{data:c}=wt(a,l,r);return e.jsxs(e.Fragment,{children:[e.jsx(Dt,{}),e.jsxs(Es,{open:r,onOpenChange:t,children:[e.jsx(oa,{asChild:!0,children:e.jsxs(P,{variant:"destructive",className:"w-full",children:[e.jsx(da,{className:"mr-2 h-4 w-4"}),"Delete"]})}),e.jsxs(Ls,{children:[e.jsxs(Ts,{children:[e.jsx(Is,{children:"Delete content?"}),e.jsx(Us,{children:"This action cannot be undone. The content will be permanently deleted."})]}),c&&c.count>0&&e.jsxs("div",{className:"rounded-md border border-yellow-500/50 bg-yellow-50 p-3 text-sm dark:bg-yellow-950/30",children:[e.jsxs("p",{className:"font-medium text-yellow-800 dark:text-yellow-200",children:["This content is referenced by ",c.count," other"," ",c.count===1?"item":"items",":"]}),e.jsxs("ul",{className:"mt-1 list-disc pl-5 text-yellow-700 dark:text-yellow-300",children:[c.items.slice(0,5).map(f=>e.jsxs("li",{children:[f.title," (",f.collection,")"]},`${f.contentId}-${f.fieldName}`)),c.items.length>5&&e.jsxs("li",{children:["and ",c.items.length-5," more..."]})]})]}),e.jsxs(Fs,{children:[e.jsx(P,{variant:"outline",onClick:()=>t(!1),children:"Cancel"}),e.jsx(P,{variant:"destructive",onClick:i,children:"Delete"})]})]})]})]})}function mi({host:r,contentId:t,onViewVersion:i}){const{data:a}=Ct(r,t),[l,c]=s.useState(!1),f=a?.items??[],h=f.map(u=>u.createdBy).filter(Boolean),{resolve:m}=Vt(h);return f.length===0?null:e.jsx(Ue,{children:e.jsx(Fe,{className:"pt-4",children:e.jsxs(_t,{open:l,onOpenChange:c,children:[e.jsxs(Mt,{className:"flex w-full items-center gap-2 text-sm font-medium",children:[e.jsx(Lt,{className:cs("h-4 w-4 transition",l&&"rotate-90")}),"Version History (",f.length,")"]}),e.jsx(Ht,{className:"mt-2",children:e.jsx("div",{className:"space-y-1",children:f.map((u,v)=>e.jsxs("button",{className:"py-1 text-sm hover:bg-muted rounded px-1 -mx-1 transition-colors w-full text-left",onClick:()=>i(u),children:[e.jsx("span",{children:Se(u.createdAt)}),u.createdBy&&e.jsx("span",{className:"ml-2 text-muted-foreground",children:m(u.createdBy)}),u.title&&e.jsx("span",{className:"ml-2 text-muted-foreground",children:u.title})]},`${u.createdAt}-${v}`))})})]})})})}export{Hi as ContentEditPage};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{j as e}from"./tanstack-Bs3zYPPV.js";import{r as C,u as P}from"./react-vendor-C2CvUxFh.js";import{C as w,b as D,c as F,P as k,D as E,e as O}from"./core.esm-DdQHdRkd.js";import{u as R,S as z,v as B,a as L}from"./sortable.esm-qVEMoaTg.js";import{ai as T,ad as h,j as v,B as p,X as b,P as V}from"./index-Ce5pmRMj.js";import{P as G,a as M,b as Q}from"./popover-CzaQYEEP.js";import{C as q,a as A,b as X,c as _,d as H,e as J}from"./command-Bfmj0MEL.js";import{u as K,a as U}from"./useContentSearch-B3aTjuCu.js";function ce({field:l,value:r,onChange:s}){const{host:o}=P(),c=l.options,i=!!c?.multiple,a=c?.collections;return i?e.jsx(Y,{host:o,collections:a,value:r??[],onChange:s}):e.jsx(W,{host:o,collections:a,value:r,onChange:s})}function W({host:l,collections:r,value:s,onChange:o}){const[c,i]=C.useState(!1),a=s?[s.contentId]:[];function n(d){o(d),i(!1)}return e.jsx("div",{children:s?e.jsxs("div",{className:"flex items-center gap-3 rounded-md border p-2",children:[e.jsx(h,{className:"h-4 w-4 shrink-0 text-muted-foreground"}),e.jsx("span",{className:"flex-1 truncate text-sm",children:s.title}),e.jsx(v,{variant:"secondary",children:s.collection}),e.jsx(p,{type:"button",variant:"ghost",size:"sm",onClick:()=>o(null),children:e.jsx(b,{className:"h-3 w-3"})})]}):e.jsx(y,{host:l,collections:r,selectedIds:a,open:c,onOpenChange:i,onSelect:n,trigger:e.jsxs(p,{type:"button",variant:"outline",children:[e.jsx(h,{className:"mr-2 h-4 w-4"}),"Select Content"]})})})}function Y({host:l,collections:r,value:s,onChange:o}){const c=D(F(k)),[i,a]=C.useState(!1),n=s??[],d=n.map(t=>t.contentId),j=n.map(t=>t.contentId);function x(t){o([...n,t]),a(!1)}function f(t){o(n.filter((m,u)=>u!==t))}function g(t){const{active:m,over:u}=t;if(u&&m.id!==u.id){const I=n.findIndex(S=>S.contentId===String(m.id)),N=n.findIndex(S=>S.contentId===String(u.id));I!==-1&&N!==-1&&o(L(n,I,N))}}return e.jsx(E,{sensors:c,collisionDetection:O,onDragEnd:g,children:e.jsx(z,{items:d,strategy:B,children:e.jsxs("div",{className:"space-y-2",children:[n.map(t=>e.jsx(Z,{id:t.contentId,contentRef:t,onRemove:()=>f(n.indexOf(t))},t.contentId)),e.jsx(y,{host:l,collections:r,selectedIds:j,open:i,onOpenChange:a,onSelect:x,trigger:e.jsxs(p,{type:"button",variant:"outline",size:"sm",children:[e.jsx(V,{className:"mr-2 h-3 w-3"}),"Add Content"]})})]})})})}function Z({id:l,contentRef:r,onRemove:s}){const{attributes:o,listeners:c,setNodeRef:i,transform:a,transition:n}=R({id:l}),d={transform:w.Transform.toString(a),transition:n};return e.jsxs("div",{ref:i,style:d,className:"flex items-center gap-2 rounded-md border p-2",children:[e.jsx("button",{type:"button",className:"cursor-grab touch-none text-muted-foreground hover:text-foreground",...o,...c,children:e.jsx(T,{className:"h-4 w-4"})}),e.jsx(h,{className:"h-4 w-4 shrink-0 text-muted-foreground"}),e.jsx("span",{className:"flex-1 truncate text-sm",children:r.title}),e.jsx(v,{variant:"secondary",children:r.collection}),e.jsx(p,{type:"button",variant:"ghost",size:"sm",onClick:s,className:"text-destructive",children:e.jsx(b,{className:"h-3 w-3"})})]})}function y({host:l,collections:r,selectedIds:s,open:o,onOpenChange:c,onSelect:i,trigger:a,status:n}){const[d,j]=C.useState(""),x=K(d,300),{data:f,isLoading:g}=U(l,x,r,n);return e.jsxs(G,{open:o,onOpenChange:c,children:[e.jsx(M,{asChild:!0,children:a}),e.jsx(Q,{className:"w-80 p-0",align:"start",children:e.jsxs(q,{shouldFilter:!1,children:[e.jsx(A,{placeholder:"Search content...",value:d,onValueChange:j}),e.jsx(X,{children:g?e.jsx("p",{className:"py-6 text-center text-sm text-muted-foreground",children:"Searching..."}):e.jsxs(e.Fragment,{children:[e.jsx(_,{children:"No content found."}),e.jsx(H,{heading:x.length===0?"Recent":void 0,children:f?.items.map(t=>{const m=s.includes(t.contentId);return e.jsxs(J,{value:t.contentId,disabled:m,onSelect:()=>i({contentId:t.contentId,collection:t.collection,slug:t.slug??"",title:t.title}),children:[e.jsx(h,{className:"h-4 w-4"}),e.jsx("span",{className:"flex-1 truncate",children:t.title}),e.jsx(v,{variant:"outline",className:"text-xs",children:t.collection})]},t.contentId)})})]})})]})})]})}export{ce as C,Z as S,y as a};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{j as s}from"./tanstack-Bs3zYPPV.js";import{u as Ce,f as ke,r as S}from"./react-vendor-C2CvUxFh.js";import{w as ye,x as Ae,B as R,P as ie,v as w,z as de,I as oe,X as B,A as Pe,L as z,j as T,S as Te,a as _e,y as Ie}from"./index-Ce5pmRMj.js";import{d as $e,e as Fe,a as Ve,b as Be,c as De}from"./useContent-Bs7nel7C.js";import{u as Le}from"./useTags-B-HgMVwo.js";import{u as Ue}from"./useContentSearch-B3aTjuCu.js";import{u as qe}from"./usePageTitle-C1r1-C00.js";import{u as Me}from"./useFilterParams-DYdEuWPE.js";import{m as ue}from"./media-url-DdCoIedP.js";import{u as Re,F as ze}from"./FilterBar-BZoa63zh.js";import{C as Oe,c as Ee}from"./card-C9hfyHXf.js";import{C as Z}from"./checkbox-DVJcwUt1.js";import{P as He,a as We,b as Xe}from"./popover-CzaQYEEP.js";import{S as C,a as k,b as y,c as A,d as o}from"./select-CrRhFGIi.js";import{T as Ze,a as Ge,b as he,c as D,d as Qe,e as L}from"./table-_3bMY0_z.js";import{a as I,f as xe}from"./format-C88SDH8g.js";import{g as me,a as ge}from"./contentStatus-CkPi9Dh6.js";import{B as Je}from"./BulkActionBar-BxdfUSrN.js";import{P as Ke}from"./Pagination-Df9nQ7Z0.js";import"./radix-C5ZmWuuL.js";import"./command-Bfmj0MEL.js";const O=3,fe=[{value:"updated_desc",label:"Last updated"},{value:"updated_asc",label:"Oldest updated"},{value:"title_asc",label:"Title A–Z",requiresCollection:!0},{value:"title_desc",label:"Title Z–A",requiresCollection:!0},{value:"created_desc",label:"Newest created"},{value:"created_asc",label:"Oldest created"}],G=[{value:"all",label:"All statuses"},{value:"draft",label:"Draft"},{value:"published",label:"Published"},{value:"changed",label:"Changed"},{value:"unpublished",label:"Unpublished"},{value:"scheduled",label:"Scheduled"}];function bs(){const{host:c,collection:r}=Ce(),_=ke(),{collections:pe}=ye(),[i,a]=Me([{key:"q",defaultValue:""},{key:"search",defaultValue:"prefix"},{key:"tag",defaultValue:""},{key:"status",defaultValue:""},{key:"sort",defaultValue:"updated_desc"},{key:"relatedTo",defaultValue:""},{key:"relField",defaultValue:""},{key:"page",defaultValue:"1"},{key:"perPage",defaultValue:"20"},{key:"after",defaultValue:""}]),$=i.search,x=i.tag||void 0,m=i.status||void 0,g=i.sort,j=i.relatedTo,v=i.relField,b=Number(i.page)||1,E=Number(i.perPage)||20,Q=S.useMemo(()=>{const e=i.after;return e?e.split(","):[]},[i.after]),[F,V]=S.useState(i.q),[u,t]=S.useState(new Set),H=Ae(),f=pe.find(e=>e.name===r),U=f?.relationships??[],{data:J}=Re(c,j||void 0),K=S.useMemo(()=>{if(!j||!v)return null;const e=U.find(n=>n.name===v);return{type:"relationship",relName:v,relLabel:e?.label??v,contentId:j,contentTitle:J??"Loading..."}},[j,v,U,J]);qe({title:f?.label??r??"",actions:f?.singleton?void 0:s.jsx(R,{size:"sm",onClick:()=>_(`/sites/${c}/content/${r}/new`),children:s.jsx(ie,{className:"h-4 w-4"})})});const h=Ue(F,300);S.useEffect(()=>{h!==i.q&&a({q:h})},[h,i.q,a]);const N=S.useCallback(()=>{a({page:"1",after:""}),t(new Set)},[a]),je=S.useMemo(()=>{const e={};return h&&(e.q=h,e.search=$),x&&(e.tag=x),m&&(e.status=m),g!=="updated_desc"&&(e.sort=g),j&&(e.relatedTo=j),v&&(e.relField=v),e.limit=E,e},[h,$,x,m,g,j,v,E]),ve=b>1?Q[b-2]:void 0,{data:P,isLoading:be}=$e(c,r,je,ve),W=Fe(c),Y=Ve(c),ee=Be(c),se=De(c),{data:ae}=Le(c),q=S.useMemo(()=>ae?.map(e=>e.tag)??[],[ae]);if(f?.singleton&&P?.items.length===1)return _(`/sites/${c}/content/${r}/${P.items[0].contentId}`,{replace:!0}),null;const M=P?.items,X=M?.map(e=>e.contentId)??[],te=X.length>0&&X.every(e=>u.has(e));function le(e){t(n=>{const l=new Set(n);return l.has(e)?l.delete(e):l.add(e),l})}function Ne(){t(te?new Set:new Set(X))}const ne=!!(h||x||m||j),re=!!h,ce=[$!=="prefix"?1:0,x?1:0,m?1:0,g!=="updated_desc"?1:0].reduce((e,n)=>e+n,0),Se=Y.isPending||ee.isPending||se.isPending;async function we(){try{const e=await W.mutateAsync({collection:r,title:f?.label??r});w.success("Singleton content recreated"),_(`/sites/${c}/content/${r}/${e.contentId}`)}catch(e){w.error("Failed to recreate singleton",{description:e instanceof Error?e.message:void 0})}}return s.jsxs("div",{children:[!H&&s.jsxs("div",{className:"mb-6 flex items-center justify-between",children:[s.jsx("h1",{className:"text-2xl font-semibold",children:f?.label??r}),!f?.singleton&&s.jsxs(R,{onClick:()=>_(`/sites/${c}/content/${r}/new`),children:[s.jsx(ie,{className:"mr-2 h-4 w-4"}),"New"]})]}),u.size>0?s.jsx(Je,{selectedCount:u.size,onPublish:async()=>{const e=[...u],l=(await Y.mutateAsync(e)).filter(d=>d.status==="rejected").length;l?w.error(`${l} of ${e.length} failed to publish`):w.success(`${e.length} item(s) published`),N()},onUnpublish:async()=>{const e=[...u],l=(await ee.mutateAsync(e)).filter(d=>d.status==="rejected").length;l?w.error(`${l} of ${e.length} failed to unpublish`):w.success(`${e.length} item(s) unpublished`),N()},onDelete:async()=>{const e=[...u],l=(await se.mutateAsync(e)).filter(d=>d.status==="rejected").length;l?w.error(`${l} of ${e.length} failed to delete`):w.success(`${e.length} item(s) deleted`),N()},onClear:()=>t(new Set),isPending:Se}):H?s.jsxs("div",{className:"mb-4 flex items-center gap-2",children:[s.jsxs("div",{className:"relative flex-1",children:[s.jsx(de,{className:"absolute left-2.5 top-2.5 h-4 w-4 text-muted-foreground"}),s.jsx(oe,{placeholder:"Search...",value:F,onChange:e=>{V(e.target.value),N()},className:"pl-8 pr-8"}),F&&s.jsx("button",{onClick:()=>{V(""),N()},className:"absolute right-2 top-2.5 text-muted-foreground hover:text-foreground",children:s.jsx(B,{className:"h-4 w-4"})})]}),s.jsxs(He,{children:[s.jsx(We,{asChild:!0,children:s.jsxs(R,{variant:"outline",size:"icon",className:"relative shrink-0","aria-label":"Filters",children:[s.jsx(Pe,{className:"h-4 w-4"}),ce>0&&s.jsx("span",{className:"absolute -right-1 -top-1 flex h-4 w-4 items-center justify-center rounded-full bg-primary text-[10px] text-primary-foreground",children:ce})]})}),s.jsxs(Xe,{className:"w-64 space-y-3",align:"end",children:[s.jsxs("div",{className:"space-y-2",children:[s.jsx(z,{className:"text-xs font-medium",children:"Search Mode"}),s.jsxs(C,{value:$,onValueChange:e=>{a({search:e,page:"1",after:""}),t(new Set)},children:[s.jsx(k,{children:s.jsx(y,{})}),s.jsxs(A,{children:[s.jsx(o,{value:"prefix",children:"Starts with"}),s.jsx(o,{value:"full",children:"Contains"})]})]})]}),q.length>0&&s.jsxs("div",{className:"space-y-2",children:[s.jsx(z,{className:"text-xs font-medium",children:"Tag"}),s.jsxs(C,{value:x??"__all__",onValueChange:e=>{a({tag:e==="__all__"?"":e,page:"1",after:""}),t(new Set)},children:[s.jsx(k,{children:s.jsx(y,{})}),s.jsxs(A,{children:[s.jsx(o,{value:"__all__",children:"All tags"}),q.map(e=>s.jsx(o,{value:e,children:e},e))]})]})]}),s.jsxs("div",{className:"space-y-2",children:[s.jsx(z,{className:"text-xs font-medium",children:"Status"}),s.jsxs(C,{value:m??"all",onValueChange:e=>{a({status:e==="all"?"":e,page:"1",after:""}),t(new Set)},children:[s.jsx(k,{children:s.jsx(y,{})}),s.jsx(A,{children:G.map(e=>s.jsx(o,{value:e.value??"all",children:e.label},e.value??"all"))})]})]}),s.jsxs("div",{className:"space-y-2",children:[s.jsx(z,{className:"text-xs font-medium",children:"Sort"}),s.jsxs(C,{value:g,onValueChange:e=>{a({sort:e,page:"1",after:""}),t(new Set)},disabled:re,children:[s.jsx(k,{children:s.jsx(y,{})}),s.jsx(A,{children:fe.map(e=>s.jsx(o,{value:e.value,disabled:e.requiresCollection&&!r,children:e.label},e.value))})]})]})]})]})]}):s.jsxs("div",{className:"mb-4 flex flex-wrap items-center gap-2",children:[s.jsxs("div",{className:"relative flex items-center",children:[s.jsx(de,{className:"absolute left-2.5 h-4 w-4 text-muted-foreground"}),s.jsx(oe,{placeholder:"Search titles...",value:F,onChange:e=>{V(e.target.value),N()},className:"w-56 pl-8 pr-8"}),F&&s.jsx("button",{onClick:()=>{V(""),N()},className:"absolute right-2 text-muted-foreground hover:text-foreground",children:s.jsx(B,{className:"h-4 w-4"})})]}),s.jsxs(C,{value:$,onValueChange:e=>{a({search:e,page:"1",after:""}),t(new Set)},children:[s.jsx(k,{className:"w-[130px]",children:s.jsx(y,{})}),s.jsxs(A,{children:[s.jsx(o,{value:"prefix",children:"Starts with"}),s.jsx(o,{value:"full",children:"Contains"})]})]}),q.length>0&&s.jsxs(C,{value:x??"__all__",onValueChange:e=>{a({tag:e==="__all__"?"":e,page:"1",after:""}),t(new Set)},children:[s.jsx(k,{className:"w-[140px]",children:s.jsx(y,{placeholder:"Tag"})}),s.jsxs(A,{children:[s.jsx(o,{value:"__all__",children:"All tags"}),q.map(e=>s.jsx(o,{value:e,children:e},e))]})]}),s.jsxs(C,{value:m??"all",onValueChange:e=>{a({status:e==="all"?"":e,page:"1",after:""}),t(new Set)},children:[s.jsx(k,{className:"w-[150px]",children:s.jsx(y,{})}),s.jsx(A,{children:G.map(e=>s.jsx(o,{value:e.value??"all",children:e.label},e.value??"all"))})]}),s.jsx("div",{className:"ml-auto",children:s.jsxs(C,{value:g,onValueChange:e=>{a({sort:e,page:"1",after:""}),t(new Set)},disabled:re,children:[s.jsx(k,{className:"w-[170px]",children:s.jsx(y,{})}),s.jsx(A,{children:fe.map(e=>s.jsx(o,{value:e.value,disabled:e.requiresCollection&&!r,children:e.label},e.value))})]})})]}),U.length>0&&s.jsx("div",{className:"mb-3",children:s.jsx(ze,{relationships:U,activeFilters:K?[K]:[],onFilterAdd:e=>{a({relatedTo:e.contentId,relField:e.relName,page:"1",after:""}),t(new Set)},onFilterRemove:()=>{a({relatedTo:"",relField:"",page:"1",after:""}),t(new Set)}})}),ne&&u.size===0&&s.jsxs("div",{className:"mb-3 flex flex-wrap items-center gap-1.5",children:[h&&s.jsxs(T,{variant:"secondary",className:"gap-1",children:["Search: ",h,s.jsx("button",{onClick:()=>{V(""),N()},children:s.jsx(B,{className:"h-3 w-3"})})]}),x&&s.jsxs(T,{variant:"secondary",className:"gap-1",children:["Tag: ",x,s.jsx("button",{onClick:()=>{a({tag:"",page:"1",after:""}),t(new Set)},children:s.jsx(B,{className:"h-3 w-3"})})]}),m&&s.jsxs(T,{variant:"secondary",className:"gap-1",children:["Status: ",G.find(e=>e.value===m)?.label,s.jsx("button",{onClick:()=>{a({status:"",page:"1",after:""}),t(new Set)},children:s.jsx(B,{className:"h-3 w-3"})})]})]}),be?s.jsx("div",{className:"space-y-2",children:Array.from({length:5}).map((e,n)=>s.jsx(Te,{className:"h-12 w-full"},n))}):M?.length?s.jsxs(s.Fragment,{children:[H?s.jsx("div",{className:"grid gap-3 sm:grid-cols-2","data-testid":"content-card-view",children:M.map(e=>{const n=me(e.publishedAt,e.lastPublishedAt,e.publishedBlockId,e.lastDraftBlockId,e.scheduledAt,e.scheduledFailed),l=ge(n),d=e.tags??[];return s.jsx(Oe,{className:Ie("cursor-pointer gap-0 overflow-hidden py-0 transition-shadow hover:shadow-md",u.has(e.contentId)&&"ring-2 ring-primary"),onClick:()=>_(`/sites/${c}/content/${r}/${e.contentId}`),children:s.jsxs(Ee,{className:"p-3",children:[s.jsxs("div",{className:"flex items-start gap-3 min-w-0",children:[e.cover?.url&&s.jsx("img",{src:ue(e.cover.url),alt:e.cover.alt??"",className:"h-12 w-12 rounded object-cover flex-shrink-0"}),s.jsxs("div",{className:"min-w-0 flex-1",children:[s.jsxs("div",{className:"flex items-center gap-2 min-w-0",children:[s.jsx("span",{className:"font-medium truncate",children:e.draftTitle||e.title||"Untitled"}),s.jsx(T,{variant:l.variant,className:"shrink-0",children:l.label})]}),(e.draftSlug||e.slug)&&s.jsxs("p",{className:"text-xs text-muted-foreground truncate mt-0.5",children:["/",e.draftSlug||e.slug]}),s.jsx("p",{className:"text-xs text-muted-foreground mt-1",children:g.startsWith("created")?e.createdAt?I(e.createdAt):"—":e.lastDraftAt?I(e.lastDraftAt):"—"})]}),s.jsx(Z,{checked:u.has(e.contentId),onCheckedChange:()=>le(e.contentId),onClick:p=>p.stopPropagation(),className:"mt-1"})]}),d.length>0&&s.jsx("div",{className:"mt-2 flex flex-wrap gap-1",children:d.slice(0,O).map(p=>s.jsx(T,{variant:"outline",className:"text-[10px] px-1.5 py-0",children:p},p))})]})},e.contentId)})}):s.jsxs(Ze,{children:[s.jsx(Ge,{children:s.jsxs(he,{children:[s.jsx(D,{className:"w-10",children:s.jsx(Z,{checked:te,onCheckedChange:Ne,"aria-label":"Select all"})}),s.jsx(D,{children:"Title"}),s.jsx(D,{children:"Slug"}),s.jsx(D,{children:"Status"}),s.jsx(D,{children:g.startsWith("created")?"Created":"Updated"})]})}),s.jsx(Qe,{children:M.map(e=>{const n=me(e.publishedAt,e.lastPublishedAt,e.publishedBlockId,e.lastDraftBlockId),l=ge(n),d=e.tags??[];return s.jsxs(he,{className:"cursor-pointer",onClick:()=>_(`/sites/${c}/content/${r}/${e.contentId}`),children:[s.jsx(L,{onClick:p=>p.stopPropagation(),children:s.jsx(Z,{checked:u.has(e.contentId),onCheckedChange:()=>le(e.contentId),"aria-label":`Select ${e.draftTitle||e.title||"Untitled"}`})}),s.jsx(L,{className:"font-medium",children:s.jsxs("div",{className:"flex items-center gap-3",children:[e.cover?.url&&s.jsx("img",{src:ue(e.cover.url),alt:e.cover.alt??"",className:"h-8 w-8 rounded object-cover flex-shrink-0"}),s.jsxs("div",{className:"min-w-0",children:[s.jsx("span",{children:e.draftTitle||e.title||"Untitled"}),d.length>0&&s.jsxs("div",{className:"mt-0.5 flex flex-wrap gap-1",children:[d.slice(0,O).map(p=>s.jsx(T,{variant:"outline",className:"text-[10px] px-1.5 py-0 font-normal text-muted-foreground",children:p},p)),d.length>O&&s.jsxs("span",{className:"text-[10px] text-muted-foreground",children:["+",d.length-O," more"]})]})]})]})}),s.jsx(L,{className:"text-muted-foreground text-sm",children:e.draftSlug||e.slug||"—"}),s.jsx(L,{children:s.jsx(T,{variant:l.variant,children:l.label})}),s.jsx(L,{className:"text-muted-foreground",children:g.startsWith("created")?e.createdAt?I(e.createdAt):"—":e.scheduledAt&&!e.publishedAt?s.jsxs("span",{title:xe(e.scheduledAt),children:["Scheduled ",I(e.scheduledAt)]}):e.publishedAt?s.jsx("span",{title:xe(e.publishedAt),children:I(e.publishedAt)}):e.lastDraftAt?I(e.lastDraftAt):"—"})]},e.contentId)})})]}),s.jsx(Ke,{page:b,hasNext:!!P?.hasMore,hasPrevious:b>1,onNext:()=>{if(P?.items.length){const e=P.items[P.items.length-1].contentId,n=[...Q.slice(0,b-1),e];a({page:String(b+1),after:n.join(",")})}else a({page:String(b+1)});t(new Set)},onPrevious:()=>{const e=b-1;a(e<=1?{page:"1",after:""}:{page:String(e)}),t(new Set)},perPage:E,onPerPageChange:e=>{a({perPage:String(e),page:"1",after:""}),t(new Set)}})]}):f?.singleton?s.jsxs("div",{className:"space-y-4",children:[s.jsx("p",{className:"text-muted-foreground",children:"Singleton content is missing. Click below to recreate it."}),s.jsxs(R,{onClick:we,disabled:W.isPending,children:[W.isPending&&s.jsx(_e,{className:"mr-2 h-4 w-4 animate-spin"}),"Recreate ",f.label]})]}):s.jsx("p",{className:"text-muted-foreground",children:ne?"No content matches the current filters.":"No content yet."})]})}export{bs as ContentListPage};
|