@mevdragon/vidfarm-devcli 0.2.13 → 0.3.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +11 -4
- package/SKILL.director.md +97 -0
- package/SKILL.platform.md +66 -6
- package/dist/src/cli.js +137 -1524
- package/dist/src/dev-serve.js +169 -0
- package/package.json +5 -24
- package/.env.example +0 -60
- package/auto-create-hyperframe-templates/AUTO_CREATE_HYPERFRAME_TEMPLATES.md +0 -275
- package/auto-create-hyperframe-templates/extractor-system-prompt.md +0 -128
- package/auto-create-hyperframe-templates/input-manifest.schema.json +0 -56
- package/auto-create-hyperframe-templates/lambda-memory-estimator.md +0 -118
- package/auto-create-hyperframe-templates/production-graph.schema.json +0 -314
- package/auto-create-hyperframe-templates/runbook.md +0 -198
- package/auto-create-hyperframe-templates/scripts/create-hyperframe-template.mjs +0 -368
- package/auto-create-hyperframe-templates/template-plan.schema.json +0 -311
- package/auto-create-hyperframe-templates/template-planner-prompt.md +0 -144
- package/auto-create-templates/AUTO_CREATE_TEMPLATES.md +0 -599
- package/auto-create-templates/extractor-system-prompt.md +0 -119
- package/auto-create-templates/production-graph.schema.json +0 -276
- package/auto-create-templates/runbook.md +0 -140
- package/auto-create-templates/template-plan.schema.json +0 -301
- package/auto-create-templates/template-planner-prompt.md +0 -137
- package/dist/src/account-pages-legacy.js +0 -9336
- package/dist/src/account-pages-legacy.js.map +0 -1
- package/dist/src/account-pages.js +0 -61
- package/dist/src/account-pages.js.map +0 -1
- package/dist/src/app.js +0 -14023
- package/dist/src/app.js.map +0 -1
- package/dist/src/cli.js.map +0 -1
- package/dist/src/composition-runtime.js +0 -581
- package/dist/src/composition-runtime.js.map +0 -1
- package/dist/src/config.js +0 -140
- package/dist/src/config.js.map +0 -1
- package/dist/src/context.js +0 -492
- package/dist/src/context.js.map +0 -1
- package/dist/src/dev-app-legacy.js +0 -694
- package/dist/src/dev-app-legacy.js.map +0 -1
- package/dist/src/dev-app.js +0 -6
- package/dist/src/dev-app.js.map +0 -1
- package/dist/src/domain.js +0 -2
- package/dist/src/domain.js.map +0 -1
- package/dist/src/editor-chat-history.js +0 -82
- package/dist/src/editor-chat-history.js.map +0 -1
- package/dist/src/editor-chat.js +0 -311
- package/dist/src/editor-chat.js.map +0 -1
- package/dist/src/frontend/flockposter-cache-store.js +0 -124
- package/dist/src/frontend/flockposter-cache-store.js.map +0 -1
- package/dist/src/frontend/homepage-client.js +0 -117
- package/dist/src/frontend/homepage-client.js.map +0 -1
- package/dist/src/frontend/homepage-shared.js +0 -4
- package/dist/src/frontend/homepage-shared.js.map +0 -1
- package/dist/src/frontend/homepage-store.js +0 -28
- package/dist/src/frontend/homepage-store.js.map +0 -1
- package/dist/src/frontend/homepage-view.js +0 -260
- package/dist/src/frontend/homepage-view.js.map +0 -1
- package/dist/src/frontend/page-runtime-client.js +0 -103
- package/dist/src/frontend/page-runtime-client.js.map +0 -1
- package/dist/src/frontend/page-runtime-store.js +0 -9
- package/dist/src/frontend/page-runtime-store.js.map +0 -1
- package/dist/src/frontend/sentry.js +0 -42
- package/dist/src/frontend/sentry.js.map +0 -1
- package/dist/src/frontend/template-editor-chat.js +0 -3767
- package/dist/src/frontend/template-editor-chat.js.map +0 -1
- package/dist/src/help-page.js +0 -333
- package/dist/src/help-page.js.map +0 -1
- package/dist/src/homepage.js +0 -919
- package/dist/src/homepage.js.map +0 -1
- package/dist/src/hyperframes/composition.js +0 -180
- package/dist/src/hyperframes/composition.js.map +0 -1
- package/dist/src/index.js +0 -16
- package/dist/src/index.js.map +0 -1
- package/dist/src/instrument.js +0 -30
- package/dist/src/instrument.js.map +0 -1
- package/dist/src/lib/crypto.js +0 -45
- package/dist/src/lib/crypto.js.map +0 -1
- package/dist/src/lib/dev-log.js +0 -54
- package/dist/src/lib/dev-log.js.map +0 -1
- package/dist/src/lib/display-name.js +0 -11
- package/dist/src/lib/display-name.js.map +0 -1
- package/dist/src/lib/ids.js +0 -24
- package/dist/src/lib/ids.js.map +0 -1
- package/dist/src/lib/images.js +0 -19
- package/dist/src/lib/images.js.map +0 -1
- package/dist/src/lib/json.js +0 -15
- package/dist/src/lib/json.js.map +0 -1
- package/dist/src/lib/template-dna.js +0 -543
- package/dist/src/lib/template-dna.js.map +0 -1
- package/dist/src/lib/template-paths.js +0 -28
- package/dist/src/lib/template-paths.js.map +0 -1
- package/dist/src/lib/template-style-options.js +0 -203
- package/dist/src/lib/template-style-options.js.map +0 -1
- package/dist/src/lib/time.js +0 -7
- package/dist/src/lib/time.js.map +0 -1
- package/dist/src/lib/video-quality-harness.js +0 -60
- package/dist/src/lib/video-quality-harness.js.map +0 -1
- package/dist/src/page-runtime.js +0 -2
- package/dist/src/page-runtime.js.map +0 -1
- package/dist/src/page-shell.js +0 -2393
- package/dist/src/page-shell.js.map +0 -1
- package/dist/src/primitive-context.js +0 -299
- package/dist/src/primitive-context.js.map +0 -1
- package/dist/src/primitive-registry.js +0 -2181
- package/dist/src/primitive-registry.js.map +0 -1
- package/dist/src/primitive-sdk.js +0 -4
- package/dist/src/primitive-sdk.js.map +0 -1
- package/dist/src/primitives/remotion/html-image.js +0 -30
- package/dist/src/primitives/remotion/html-image.js.map +0 -1
- package/dist/src/primitives/remotion/media-slideshow.js +0 -60
- package/dist/src/primitives/remotion/media-slideshow.js.map +0 -1
- package/dist/src/react-page-shell.js +0 -35
- package/dist/src/react-page-shell.js.map +0 -1
- package/dist/src/ready-post-schedule-component.js +0 -1515
- package/dist/src/ready-post-schedule-component.js.map +0 -1
- package/dist/src/registry.js +0 -296
- package/dist/src/registry.js.map +0 -1
- package/dist/src/runtime.js +0 -31
- package/dist/src/runtime.js.map +0 -1
- package/dist/src/services/api-call-history.js +0 -249
- package/dist/src/services/api-call-history.js.map +0 -1
- package/dist/src/services/auth.js +0 -152
- package/dist/src/services/auth.js.map +0 -1
- package/dist/src/services/billing.js +0 -231
- package/dist/src/services/billing.js.map +0 -1
- package/dist/src/services/chat-threads.js +0 -92
- package/dist/src/services/chat-threads.js.map +0 -1
- package/dist/src/services/fork-access.js +0 -94
- package/dist/src/services/fork-access.js.map +0 -1
- package/dist/src/services/ghostcut.js +0 -132
- package/dist/src/services/ghostcut.js.map +0 -1
- package/dist/src/services/hyperframes.js +0 -1014
- package/dist/src/services/hyperframes.js.map +0 -1
- package/dist/src/services/job-capacity.js +0 -14
- package/dist/src/services/job-capacity.js.map +0 -1
- package/dist/src/services/job-logs.js +0 -197
- package/dist/src/services/job-logs.js.map +0 -1
- package/dist/src/services/jobs.js +0 -136
- package/dist/src/services/jobs.js.map +0 -1
- package/dist/src/services/media-processing.js +0 -743
- package/dist/src/services/media-processing.js.map +0 -1
- package/dist/src/services/primitive-media-lambda.js +0 -280
- package/dist/src/services/primitive-media-lambda.js.map +0 -1
- package/dist/src/services/providers.js +0 -2870
- package/dist/src/services/providers.js.map +0 -1
- package/dist/src/services/rate-limits.js +0 -237
- package/dist/src/services/rate-limits.js.map +0 -1
- package/dist/src/services/remotion.js +0 -688
- package/dist/src/services/remotion.js.map +0 -1
- package/dist/src/services/serverless-auth.js +0 -374
- package/dist/src/services/serverless-auth.js.map +0 -1
- package/dist/src/services/serverless-jobs.js +0 -1074
- package/dist/src/services/serverless-jobs.js.map +0 -1
- package/dist/src/services/serverless-provider-keys.js +0 -401
- package/dist/src/services/serverless-provider-keys.js.map +0 -1
- package/dist/src/services/serverless-records.js +0 -1086
- package/dist/src/services/serverless-records.js.map +0 -1
- package/dist/src/services/serverless-template-configs.js +0 -67
- package/dist/src/services/serverless-template-configs.js.map +0 -1
- package/dist/src/services/storage.js +0 -382
- package/dist/src/services/storage.js.map +0 -1
- package/dist/src/services/template-certification.js +0 -475
- package/dist/src/services/template-certification.js.map +0 -1
- package/dist/src/services/template-loader.js +0 -99
- package/dist/src/services/template-loader.js.map +0 -1
- package/dist/src/services/template-runtime-bundles.js +0 -217
- package/dist/src/services/template-runtime-bundles.js.map +0 -1
- package/dist/src/services/template-sources.js +0 -1017
- package/dist/src/services/template-sources.js.map +0 -1
- package/dist/src/services/video-normalization.js +0 -2
- package/dist/src/services/video-normalization.js.map +0 -1
- package/dist/src/services/webhooks.js +0 -62
- package/dist/src/services/webhooks.js.map +0 -1
- package/dist/src/template-editor-pages.js +0 -6624
- package/dist/src/template-editor-pages.js.map +0 -1
- package/dist/src/template-editor-shell.js +0 -2713
- package/dist/src/template-editor-shell.js.map +0 -1
- package/dist/src/template-sdk.js +0 -4
- package/dist/src/template-sdk.js.map +0 -1
- package/dist/src/worker.js +0 -17
- package/dist/src/worker.js.map +0 -1
- package/public/assets/homepage-app.js +0 -54
- package/public/assets/homepage-client-app.js +0 -80
- package/public/assets/page-runtime-client-app.js +0 -94
- package/readme.secret.md +0 -89
- package/templates/vidfarm_template_0000/README.md +0 -106
- package/templates/vidfarm_template_0000/SKILL.md +0 -266
- package/templates/vidfarm_template_0000/assets/Abel-Regular.ttf +0 -0
- package/templates/vidfarm_template_0000/assets/DMSerifDisplay-Regular.ttf +0 -0
- package/templates/vidfarm_template_0000/assets/Montserrat[wght].ttf +0 -0
- package/templates/vidfarm_template_0000/assets/SourceCodePro[wght].ttf +0 -0
- package/templates/vidfarm_template_0000/assets/TikTokSans-SemiBold.ttf +0 -0
- package/templates/vidfarm_template_0000/assets/Yesteryear-Regular.ttf +0 -0
- package/templates/vidfarm_template_0000/composition.json +0 -11
- package/templates/vidfarm_template_0000/src/lib/images.js +0 -221
- package/templates/vidfarm_template_0000/src/remotion/Root.js +0 -33
- package/templates/vidfarm_template_0000/src/remotion/index.js +0 -3
- package/templates/vidfarm_template_0000/src/sdk.js +0 -3
- package/templates/vidfarm_template_0000/src/style-options.js +0 -200
- package/templates/vidfarm_template_0000/src/template-dna.js +0 -9
- package/templates/vidfarm_template_0000/src/template.js +0 -1566
- package/templates/vidfarm_template_0000/template.config.json +0 -21
|
@@ -1,1515 +0,0 @@
|
|
|
1
|
-
import { escapeJsonForHtml } from "./page-shell.js";
|
|
2
|
-
export function renderReadyPostScheduleStyles() {
|
|
3
|
-
return `.ready-post-schedule-modal {
|
|
4
|
-
width: min(880px, calc(100vw - 28px));
|
|
5
|
-
padding: 0;
|
|
6
|
-
border: 1px solid rgba(191, 164, 109, 0.36);
|
|
7
|
-
border-radius: var(--radius-md);
|
|
8
|
-
background: var(--paper-strong);
|
|
9
|
-
color: var(--ink);
|
|
10
|
-
box-shadow: 0 28px 72px rgba(15, 23, 42, 0.18);
|
|
11
|
-
}
|
|
12
|
-
|
|
13
|
-
.ready-post-schedule-modal::backdrop {
|
|
14
|
-
background: rgba(36, 48, 65, 0.26);
|
|
15
|
-
backdrop-filter: blur(8px);
|
|
16
|
-
}
|
|
17
|
-
|
|
18
|
-
.ready-post-schedule-head {
|
|
19
|
-
display: grid;
|
|
20
|
-
gap: 8px;
|
|
21
|
-
padding: 22px 22px 18px;
|
|
22
|
-
border-bottom: 1px solid var(--line);
|
|
23
|
-
background: rgba(222, 192, 129, 0.1);
|
|
24
|
-
}
|
|
25
|
-
|
|
26
|
-
.ready-post-schedule-head h2 {
|
|
27
|
-
font-size: clamp(1.8rem, 4vw, 2.5rem);
|
|
28
|
-
}
|
|
29
|
-
|
|
30
|
-
.ready-post-schedule-body {
|
|
31
|
-
display: grid;
|
|
32
|
-
gap: 14px;
|
|
33
|
-
padding: 20px 22px 22px;
|
|
34
|
-
}
|
|
35
|
-
|
|
36
|
-
.ready-post-schedule-grid {
|
|
37
|
-
display: grid;
|
|
38
|
-
grid-template-columns: minmax(320px, 1fr) minmax(280px, 0.74fr);
|
|
39
|
-
gap: 16px;
|
|
40
|
-
align-items: start;
|
|
41
|
-
}
|
|
42
|
-
|
|
43
|
-
.ready-post-calendar {
|
|
44
|
-
display: grid;
|
|
45
|
-
gap: 12px;
|
|
46
|
-
padding: 14px;
|
|
47
|
-
border: 1px solid rgba(209, 219, 233, 0.96);
|
|
48
|
-
border-radius: 18px;
|
|
49
|
-
background: rgba(255, 255, 255, 0.62);
|
|
50
|
-
}
|
|
51
|
-
|
|
52
|
-
.ready-post-calendar-head {
|
|
53
|
-
display: flex;
|
|
54
|
-
align-items: center;
|
|
55
|
-
justify-content: space-between;
|
|
56
|
-
gap: 10px;
|
|
57
|
-
}
|
|
58
|
-
|
|
59
|
-
.ready-post-calendar-title {
|
|
60
|
-
color: #2f3748;
|
|
61
|
-
font-weight: 800;
|
|
62
|
-
letter-spacing: -0.02em;
|
|
63
|
-
}
|
|
64
|
-
|
|
65
|
-
.ready-post-calendar-nav {
|
|
66
|
-
display: flex;
|
|
67
|
-
gap: 6px;
|
|
68
|
-
}
|
|
69
|
-
|
|
70
|
-
.ready-post-calendar-nav button {
|
|
71
|
-
width: 38px;
|
|
72
|
-
min-width: 38px;
|
|
73
|
-
min-height: 38px;
|
|
74
|
-
padding: 0;
|
|
75
|
-
}
|
|
76
|
-
|
|
77
|
-
.ready-post-calendar-weekdays,
|
|
78
|
-
.ready-post-calendar-days {
|
|
79
|
-
display: grid;
|
|
80
|
-
grid-template-columns: repeat(7, minmax(0, 1fr));
|
|
81
|
-
gap: 6px;
|
|
82
|
-
}
|
|
83
|
-
|
|
84
|
-
.ready-post-calendar-weekdays span {
|
|
85
|
-
color: var(--muted);
|
|
86
|
-
font-size: 0.72rem;
|
|
87
|
-
font-weight: 800;
|
|
88
|
-
text-align: center;
|
|
89
|
-
text-transform: uppercase;
|
|
90
|
-
}
|
|
91
|
-
|
|
92
|
-
.ready-post-calendar-day {
|
|
93
|
-
position: relative;
|
|
94
|
-
display: grid;
|
|
95
|
-
place-items: center;
|
|
96
|
-
min-width: 0;
|
|
97
|
-
min-height: 52px;
|
|
98
|
-
padding: 0;
|
|
99
|
-
border-color: rgba(209, 219, 233, 0.78);
|
|
100
|
-
background: rgba(255, 255, 255, 0.76);
|
|
101
|
-
border-radius: 14px;
|
|
102
|
-
color: #2f3748;
|
|
103
|
-
font-size: 0.9rem;
|
|
104
|
-
font-weight: 700;
|
|
105
|
-
}
|
|
106
|
-
|
|
107
|
-
.ready-post-calendar-day-number {
|
|
108
|
-
line-height: 1;
|
|
109
|
-
}
|
|
110
|
-
|
|
111
|
-
.ready-post-calendar-day-preview {
|
|
112
|
-
position: absolute;
|
|
113
|
-
right: 7px;
|
|
114
|
-
bottom: 6px;
|
|
115
|
-
min-width: 18px;
|
|
116
|
-
padding: 2px 5px;
|
|
117
|
-
border-radius: 999px;
|
|
118
|
-
background: rgba(255, 252, 247, 0.92);
|
|
119
|
-
color: #536176;
|
|
120
|
-
font-size: 0.58rem;
|
|
121
|
-
font-weight: 900;
|
|
122
|
-
line-height: 1.1;
|
|
123
|
-
}
|
|
124
|
-
|
|
125
|
-
.ready-post-calendar-day.has-posts {
|
|
126
|
-
border-color: rgba(83, 114, 89, 0.34);
|
|
127
|
-
background: rgba(83, 114, 89, 0.11);
|
|
128
|
-
}
|
|
129
|
-
|
|
130
|
-
.ready-post-calendar-day.has-posts::after {
|
|
131
|
-
content: "";
|
|
132
|
-
position: absolute;
|
|
133
|
-
left: 50%;
|
|
134
|
-
bottom: 8px;
|
|
135
|
-
width: 18px;
|
|
136
|
-
height: 3px;
|
|
137
|
-
border-radius: 999px;
|
|
138
|
-
background: rgba(83, 114, 89, 0.58);
|
|
139
|
-
transform: translateX(-50%);
|
|
140
|
-
}
|
|
141
|
-
|
|
142
|
-
.ready-post-calendar-day.has-many-posts::after {
|
|
143
|
-
display: none;
|
|
144
|
-
}
|
|
145
|
-
|
|
146
|
-
.ready-post-calendar-day.has-many-posts {
|
|
147
|
-
background: rgba(191, 164, 109, 0.2);
|
|
148
|
-
border-color: rgba(191, 164, 109, 0.44);
|
|
149
|
-
}
|
|
150
|
-
|
|
151
|
-
.ready-post-calendar-day.is-muted {
|
|
152
|
-
opacity: 0.42;
|
|
153
|
-
}
|
|
154
|
-
|
|
155
|
-
.ready-post-calendar-day.is-today {
|
|
156
|
-
border-color: rgba(191, 164, 109, 0.85);
|
|
157
|
-
}
|
|
158
|
-
|
|
159
|
-
.ready-post-calendar-day.is-selected {
|
|
160
|
-
background: #243041;
|
|
161
|
-
color: #fffaf2;
|
|
162
|
-
border-color: #243041;
|
|
163
|
-
}
|
|
164
|
-
|
|
165
|
-
.ready-post-calendar-day.is-selected::after {
|
|
166
|
-
background: rgba(255, 250, 242, 0.78);
|
|
167
|
-
}
|
|
168
|
-
|
|
169
|
-
.ready-post-calendar-day.is-selected .ready-post-calendar-day-preview {
|
|
170
|
-
background: rgba(255, 250, 242, 0.18);
|
|
171
|
-
color: rgba(255, 250, 242, 0.9);
|
|
172
|
-
}
|
|
173
|
-
|
|
174
|
-
.ready-post-calendar-popover {
|
|
175
|
-
position: fixed;
|
|
176
|
-
z-index: 999;
|
|
177
|
-
display: grid;
|
|
178
|
-
width: min(390px, calc(100vw - 32px));
|
|
179
|
-
gap: 12px;
|
|
180
|
-
padding: 14px;
|
|
181
|
-
border: 1px solid rgba(191, 164, 109, 0.28);
|
|
182
|
-
border-radius: 18px;
|
|
183
|
-
background: rgba(255, 252, 247, 0.98);
|
|
184
|
-
box-shadow: 0 18px 44px rgba(37, 45, 61, 0.18);
|
|
185
|
-
}
|
|
186
|
-
|
|
187
|
-
.ready-post-calendar-popover[hidden] {
|
|
188
|
-
display: none;
|
|
189
|
-
}
|
|
190
|
-
|
|
191
|
-
.ready-post-calendar-popover-title {
|
|
192
|
-
padding-right: 30px;
|
|
193
|
-
color: #2f3748;
|
|
194
|
-
font-size: 0.95rem;
|
|
195
|
-
font-weight: 800;
|
|
196
|
-
}
|
|
197
|
-
|
|
198
|
-
.ready-post-calendar-popover-close {
|
|
199
|
-
position: absolute;
|
|
200
|
-
top: 10px;
|
|
201
|
-
right: 10px;
|
|
202
|
-
display: inline-flex;
|
|
203
|
-
align-items: center;
|
|
204
|
-
justify-content: center;
|
|
205
|
-
width: 26px;
|
|
206
|
-
min-width: 26px;
|
|
207
|
-
height: 26px;
|
|
208
|
-
min-height: 26px;
|
|
209
|
-
padding: 0;
|
|
210
|
-
border: 1px solid rgba(209, 219, 233, 0.8);
|
|
211
|
-
border-radius: 999px;
|
|
212
|
-
background: rgba(255, 255, 255, 0.72);
|
|
213
|
-
color: var(--muted);
|
|
214
|
-
box-shadow: none;
|
|
215
|
-
font-size: 0.95rem;
|
|
216
|
-
line-height: 1;
|
|
217
|
-
}
|
|
218
|
-
|
|
219
|
-
.ready-post-calendar-popover-close:hover {
|
|
220
|
-
background: rgba(255, 255, 255, 0.95);
|
|
221
|
-
color: #2f3748;
|
|
222
|
-
transform: none;
|
|
223
|
-
box-shadow: none;
|
|
224
|
-
}
|
|
225
|
-
|
|
226
|
-
.ready-post-calendar-popover-list {
|
|
227
|
-
display: grid;
|
|
228
|
-
gap: 10px;
|
|
229
|
-
max-height: min(360px, calc(100vh - 180px));
|
|
230
|
-
overflow: auto;
|
|
231
|
-
padding-right: 2px;
|
|
232
|
-
}
|
|
233
|
-
|
|
234
|
-
.ready-post-calendar-popover-item {
|
|
235
|
-
display: grid;
|
|
236
|
-
gap: 6px;
|
|
237
|
-
padding: 10px 11px;
|
|
238
|
-
border: 1px solid rgba(209, 219, 233, 0.72);
|
|
239
|
-
border-radius: 14px;
|
|
240
|
-
background: rgba(255, 255, 255, 0.72);
|
|
241
|
-
}
|
|
242
|
-
|
|
243
|
-
.ready-post-calendar-popover-time {
|
|
244
|
-
color: var(--muted);
|
|
245
|
-
font-size: 0.72rem;
|
|
246
|
-
font-weight: 800;
|
|
247
|
-
letter-spacing: 0.08em;
|
|
248
|
-
text-transform: uppercase;
|
|
249
|
-
}
|
|
250
|
-
|
|
251
|
-
.ready-post-calendar-popover-item a {
|
|
252
|
-
color: #2f3748;
|
|
253
|
-
font-size: 0.95rem;
|
|
254
|
-
font-weight: 700;
|
|
255
|
-
line-height: 1.18;
|
|
256
|
-
text-decoration: none;
|
|
257
|
-
}
|
|
258
|
-
|
|
259
|
-
.ready-post-calendar-popover-item a:hover {
|
|
260
|
-
text-decoration: underline;
|
|
261
|
-
}
|
|
262
|
-
|
|
263
|
-
.ready-post-calendar-popover-linkless {
|
|
264
|
-
color: #2f3748;
|
|
265
|
-
font-size: 0.95rem;
|
|
266
|
-
font-weight: 700;
|
|
267
|
-
line-height: 1.18;
|
|
268
|
-
}
|
|
269
|
-
|
|
270
|
-
.ready-post-calendar-popover-summary,
|
|
271
|
-
.ready-post-calendar-popover-channel {
|
|
272
|
-
color: var(--muted);
|
|
273
|
-
font-size: 0.78rem;
|
|
274
|
-
line-height: 1.35;
|
|
275
|
-
}
|
|
276
|
-
|
|
277
|
-
.ready-post-calendar-popover-channel {
|
|
278
|
-
font-weight: 800;
|
|
279
|
-
}
|
|
280
|
-
|
|
281
|
-
.ready-post-schedule-side {
|
|
282
|
-
display: grid;
|
|
283
|
-
gap: 14px;
|
|
284
|
-
}
|
|
285
|
-
|
|
286
|
-
.ready-post-datetime-row {
|
|
287
|
-
display: grid;
|
|
288
|
-
grid-template-columns: minmax(0, 1fr) minmax(118px, 0.46fr);
|
|
289
|
-
gap: 10px;
|
|
290
|
-
align-items: end;
|
|
291
|
-
}
|
|
292
|
-
|
|
293
|
-
.ready-post-datetime-row .label-group {
|
|
294
|
-
min-width: 0;
|
|
295
|
-
}
|
|
296
|
-
|
|
297
|
-
.ready-post-datetime-shell {
|
|
298
|
-
position: relative;
|
|
299
|
-
min-width: 0;
|
|
300
|
-
cursor: pointer;
|
|
301
|
-
}
|
|
302
|
-
|
|
303
|
-
.ready-post-datetime-shell input {
|
|
304
|
-
min-width: 0;
|
|
305
|
-
padding-right: 44px;
|
|
306
|
-
cursor: pointer;
|
|
307
|
-
}
|
|
308
|
-
|
|
309
|
-
.ready-post-datetime-icon {
|
|
310
|
-
pointer-events: none;
|
|
311
|
-
position: absolute;
|
|
312
|
-
right: 16px;
|
|
313
|
-
top: 50%;
|
|
314
|
-
width: 18px;
|
|
315
|
-
height: 18px;
|
|
316
|
-
transform: translateY(-50%);
|
|
317
|
-
color: #243041;
|
|
318
|
-
}
|
|
319
|
-
|
|
320
|
-
.ready-post-timezone-select {
|
|
321
|
-
min-width: 0;
|
|
322
|
-
padding-inline: 14px;
|
|
323
|
-
text-overflow: ellipsis;
|
|
324
|
-
}
|
|
325
|
-
|
|
326
|
-
.ready-post-channel-picker {
|
|
327
|
-
position: relative;
|
|
328
|
-
display: grid;
|
|
329
|
-
gap: 8px;
|
|
330
|
-
}
|
|
331
|
-
|
|
332
|
-
.ready-post-channel-trigger {
|
|
333
|
-
display: flex;
|
|
334
|
-
align-items: center;
|
|
335
|
-
justify-content: flex-start;
|
|
336
|
-
width: 100%;
|
|
337
|
-
min-height: 54px;
|
|
338
|
-
gap: 10px;
|
|
339
|
-
padding: 8px 14px;
|
|
340
|
-
border: 1px solid var(--line);
|
|
341
|
-
border-radius: 999px;
|
|
342
|
-
background: rgba(255, 255, 255, 0.92);
|
|
343
|
-
color: var(--ink);
|
|
344
|
-
box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.8);
|
|
345
|
-
}
|
|
346
|
-
|
|
347
|
-
.ready-post-channel-trigger.is-placeholder {
|
|
348
|
-
color: var(--muted);
|
|
349
|
-
}
|
|
350
|
-
|
|
351
|
-
.ready-post-channel-trigger:hover {
|
|
352
|
-
transform: none;
|
|
353
|
-
}
|
|
354
|
-
|
|
355
|
-
.ready-post-channel-avatar {
|
|
356
|
-
display: inline-flex;
|
|
357
|
-
align-items: center;
|
|
358
|
-
justify-content: center;
|
|
359
|
-
width: 34px;
|
|
360
|
-
height: 34px;
|
|
361
|
-
flex: 0 0 34px;
|
|
362
|
-
overflow: hidden;
|
|
363
|
-
border: 1px solid rgba(209, 219, 233, 0.96);
|
|
364
|
-
border-radius: 999px;
|
|
365
|
-
background: #f3efe5;
|
|
366
|
-
color: #243041;
|
|
367
|
-
font-size: 0.72rem;
|
|
368
|
-
font-weight: 800;
|
|
369
|
-
}
|
|
370
|
-
|
|
371
|
-
.ready-post-channel-avatar img {
|
|
372
|
-
width: 100%;
|
|
373
|
-
height: 100%;
|
|
374
|
-
object-fit: cover;
|
|
375
|
-
}
|
|
376
|
-
|
|
377
|
-
.ready-post-channel-copy {
|
|
378
|
-
display: grid;
|
|
379
|
-
min-width: 0;
|
|
380
|
-
text-align: left;
|
|
381
|
-
line-height: 1.2;
|
|
382
|
-
}
|
|
383
|
-
|
|
384
|
-
.ready-post-channel-title {
|
|
385
|
-
overflow: hidden;
|
|
386
|
-
color: #2f3748;
|
|
387
|
-
font-weight: 800;
|
|
388
|
-
text-overflow: ellipsis;
|
|
389
|
-
white-space: nowrap;
|
|
390
|
-
}
|
|
391
|
-
|
|
392
|
-
.ready-post-channel-meta {
|
|
393
|
-
overflow: hidden;
|
|
394
|
-
color: var(--muted);
|
|
395
|
-
font-size: 0.82rem;
|
|
396
|
-
text-overflow: ellipsis;
|
|
397
|
-
white-space: nowrap;
|
|
398
|
-
}
|
|
399
|
-
|
|
400
|
-
.ready-post-channel-menu {
|
|
401
|
-
position: absolute;
|
|
402
|
-
top: calc(100% + 8px);
|
|
403
|
-
right: 0;
|
|
404
|
-
left: 0;
|
|
405
|
-
z-index: 80;
|
|
406
|
-
display: grid;
|
|
407
|
-
gap: 8px;
|
|
408
|
-
max-height: 330px;
|
|
409
|
-
padding: 10px;
|
|
410
|
-
border: 1px solid rgba(191, 164, 109, 0.28);
|
|
411
|
-
border-radius: 18px;
|
|
412
|
-
background: rgba(255, 252, 247, 0.98);
|
|
413
|
-
box-shadow: 0 18px 44px rgba(37, 45, 61, 0.18);
|
|
414
|
-
}
|
|
415
|
-
|
|
416
|
-
.ready-post-email-instructions {
|
|
417
|
-
display: grid;
|
|
418
|
-
gap: 8px;
|
|
419
|
-
}
|
|
420
|
-
|
|
421
|
-
.ready-post-email-instructions[hidden] {
|
|
422
|
-
display: none;
|
|
423
|
-
}
|
|
424
|
-
|
|
425
|
-
.ready-post-email-instructions textarea {
|
|
426
|
-
min-height: 118px;
|
|
427
|
-
resize: vertical;
|
|
428
|
-
border-radius: 16px;
|
|
429
|
-
padding: 12px 14px;
|
|
430
|
-
font-size: 1rem;
|
|
431
|
-
font-weight: 400;
|
|
432
|
-
line-height: 1.45;
|
|
433
|
-
background: rgba(255, 255, 255, 0.88);
|
|
434
|
-
}
|
|
435
|
-
|
|
436
|
-
.ready-post-channel-menu[hidden] {
|
|
437
|
-
display: none;
|
|
438
|
-
}
|
|
439
|
-
|
|
440
|
-
.ready-post-channel-search {
|
|
441
|
-
min-height: 42px;
|
|
442
|
-
padding: 10px 13px;
|
|
443
|
-
border-radius: 14px;
|
|
444
|
-
}
|
|
445
|
-
|
|
446
|
-
.ready-post-channel-list {
|
|
447
|
-
display: grid;
|
|
448
|
-
gap: 6px;
|
|
449
|
-
overflow: auto;
|
|
450
|
-
max-height: 244px;
|
|
451
|
-
}
|
|
452
|
-
|
|
453
|
-
.ready-post-channel-option {
|
|
454
|
-
display: flex;
|
|
455
|
-
justify-content: flex-start;
|
|
456
|
-
width: 100%;
|
|
457
|
-
min-height: 48px;
|
|
458
|
-
gap: 10px;
|
|
459
|
-
padding: 7px 9px;
|
|
460
|
-
border: 0;
|
|
461
|
-
border-radius: 12px;
|
|
462
|
-
background: transparent;
|
|
463
|
-
box-shadow: none;
|
|
464
|
-
}
|
|
465
|
-
|
|
466
|
-
.ready-post-channel-option:hover,
|
|
467
|
-
.ready-post-channel-option.is-selected {
|
|
468
|
-
background: rgba(222, 192, 129, 0.18);
|
|
469
|
-
transform: none;
|
|
470
|
-
box-shadow: none;
|
|
471
|
-
}
|
|
472
|
-
|
|
473
|
-
.ready-post-channel-empty {
|
|
474
|
-
padding: 12px;
|
|
475
|
-
color: var(--muted);
|
|
476
|
-
font-size: 0.9rem;
|
|
477
|
-
}
|
|
478
|
-
|
|
479
|
-
.ready-post-schedule-note {
|
|
480
|
-
display: none;
|
|
481
|
-
padding: 12px 14px;
|
|
482
|
-
border: 1px solid rgba(120, 138, 166, 0.24);
|
|
483
|
-
border-radius: 18px;
|
|
484
|
-
background: rgba(255, 255, 255, 0.72);
|
|
485
|
-
color: #5b6d8f;
|
|
486
|
-
font-size: 0.92rem;
|
|
487
|
-
line-height: 1.5;
|
|
488
|
-
}
|
|
489
|
-
|
|
490
|
-
.ready-post-schedule-note[data-visible="true"] {
|
|
491
|
-
display: block;
|
|
492
|
-
}
|
|
493
|
-
|
|
494
|
-
.ready-post-schedule-note[data-tone="info"] {
|
|
495
|
-
border-color: rgba(84, 120, 184, 0.28);
|
|
496
|
-
background: rgba(238, 245, 255, 0.82);
|
|
497
|
-
color: #4d6591;
|
|
498
|
-
}
|
|
499
|
-
|
|
500
|
-
.ready-post-schedule-note[data-tone="success"] {
|
|
501
|
-
border-color: rgba(64, 139, 92, 0.28);
|
|
502
|
-
background: rgba(237, 248, 240, 0.82);
|
|
503
|
-
color: #326744;
|
|
504
|
-
}
|
|
505
|
-
|
|
506
|
-
.ready-post-schedule-note[data-tone="error"] {
|
|
507
|
-
border-color: rgba(190, 83, 73, 0.32);
|
|
508
|
-
background: rgba(255, 241, 239, 0.88);
|
|
509
|
-
color: #a34239;
|
|
510
|
-
}
|
|
511
|
-
|
|
512
|
-
.ready-post-schedule-toast {
|
|
513
|
-
position: absolute;
|
|
514
|
-
right: 28px;
|
|
515
|
-
bottom: 86px;
|
|
516
|
-
z-index: 4;
|
|
517
|
-
max-width: min(420px, calc(100% - 56px));
|
|
518
|
-
padding: 10px 13px;
|
|
519
|
-
border: 1px solid rgba(191, 164, 109, 0.38);
|
|
520
|
-
border-radius: 14px;
|
|
521
|
-
background: rgba(35, 43, 58, 0.94);
|
|
522
|
-
color: #fff;
|
|
523
|
-
font-size: 0.9rem;
|
|
524
|
-
line-height: 1.35;
|
|
525
|
-
box-shadow: 0 18px 42px rgba(20, 24, 34, 0.22);
|
|
526
|
-
opacity: 0;
|
|
527
|
-
pointer-events: none;
|
|
528
|
-
transform: translateY(8px);
|
|
529
|
-
transition: opacity 160ms ease, transform 160ms ease;
|
|
530
|
-
}
|
|
531
|
-
|
|
532
|
-
.ready-post-schedule-toast[data-visible="true"] {
|
|
533
|
-
opacity: 1;
|
|
534
|
-
transform: translateY(0);
|
|
535
|
-
}
|
|
536
|
-
|
|
537
|
-
.ready-post-schedule-actions {
|
|
538
|
-
justify-content: flex-end;
|
|
539
|
-
}
|
|
540
|
-
|
|
541
|
-
@media (max-width: 920px) {
|
|
542
|
-
.ready-post-actions {
|
|
543
|
-
justify-content: flex-start;
|
|
544
|
-
}
|
|
545
|
-
|
|
546
|
-
.ready-post-grid {
|
|
547
|
-
grid-template-columns: 1fr;
|
|
548
|
-
height: auto;
|
|
549
|
-
overflow: visible;
|
|
550
|
-
}
|
|
551
|
-
|
|
552
|
-
.ready-post-carousel,
|
|
553
|
-
.ready-post-slide {
|
|
554
|
-
min-height: 0;
|
|
555
|
-
}
|
|
556
|
-
|
|
557
|
-
.ready-post-phone-stage {
|
|
558
|
-
height: auto;
|
|
559
|
-
min-height: 560px;
|
|
560
|
-
}
|
|
561
|
-
|
|
562
|
-
.ready-post-schedule-toast {
|
|
563
|
-
right: 18px;
|
|
564
|
-
bottom: 74px;
|
|
565
|
-
max-width: calc(100% - 36px);
|
|
566
|
-
}
|
|
567
|
-
|
|
568
|
-
.ready-post-phone {
|
|
569
|
-
width: min(340px, 100%);
|
|
570
|
-
height: auto;
|
|
571
|
-
}
|
|
572
|
-
|
|
573
|
-
.ready-post-detail-column {
|
|
574
|
-
overflow: visible;
|
|
575
|
-
padding-right: 0;
|
|
576
|
-
}
|
|
577
|
-
|
|
578
|
-
.ready-post-asset {
|
|
579
|
-
align-items: flex-start;
|
|
580
|
-
flex-direction: column;
|
|
581
|
-
}
|
|
582
|
-
|
|
583
|
-
.ready-post-asset-actions,
|
|
584
|
-
.ready-post-asset-actions .button {
|
|
585
|
-
width: 100%;
|
|
586
|
-
}
|
|
587
|
-
|
|
588
|
-
.ready-post-title-row,
|
|
589
|
-
.ready-post-schedule-grid {
|
|
590
|
-
grid-template-columns: 1fr;
|
|
591
|
-
display: grid;
|
|
592
|
-
}
|
|
593
|
-
|
|
594
|
-
.ready-post-actions {
|
|
595
|
-
max-width: 100%;
|
|
596
|
-
overflow-x: auto;
|
|
597
|
-
padding-bottom: 2px;
|
|
598
|
-
}
|
|
599
|
-
|
|
600
|
-
.ready-post-calendar-day {
|
|
601
|
-
min-height: 38px;
|
|
602
|
-
}
|
|
603
|
-
}
|
|
604
|
-
`;
|
|
605
|
-
}
|
|
606
|
-
export function renderReadyPostScheduleModal() {
|
|
607
|
-
return `<dialog class="ready-post-schedule-modal" data-schedule-modal>
|
|
608
|
-
<div class="ready-post-schedule-head">
|
|
609
|
-
<div class="label">Schedule post</div>
|
|
610
|
-
<h2>Choose a slot</h2>
|
|
611
|
-
<p>This is a UI preview only. It does not create a scheduled post yet.</p>
|
|
612
|
-
</div>
|
|
613
|
-
<form method="dialog" class="ready-post-schedule-body">
|
|
614
|
-
<div class="ready-post-schedule-grid">
|
|
615
|
-
<section class="ready-post-calendar" aria-label="Schedule calendar">
|
|
616
|
-
<div class="ready-post-calendar-head">
|
|
617
|
-
<div class="ready-post-calendar-title" data-schedule-calendar-title></div>
|
|
618
|
-
<div class="ready-post-calendar-nav">
|
|
619
|
-
<button type="button" class="secondary" data-schedule-prev-month aria-label="Previous month">‹</button>
|
|
620
|
-
<button type="button" class="secondary" data-schedule-next-month aria-label="Next month">›</button>
|
|
621
|
-
</div>
|
|
622
|
-
</div>
|
|
623
|
-
<div class="ready-post-calendar-weekdays" aria-hidden="true">
|
|
624
|
-
<span>Sun</span><span>Mon</span><span>Tue</span><span>Wed</span><span>Thu</span><span>Fri</span><span>Sat</span>
|
|
625
|
-
</div>
|
|
626
|
-
<div class="ready-post-calendar-days" data-schedule-calendar-days></div>
|
|
627
|
-
<input type="hidden" name="schedule_date" data-schedule-date>
|
|
628
|
-
</section>
|
|
629
|
-
<div class="ready-post-schedule-side">
|
|
630
|
-
<div class="ready-post-datetime-row">
|
|
631
|
-
<label class="label-group">
|
|
632
|
-
<span class="label">Date & time</span>
|
|
633
|
-
<span class="ready-post-datetime-shell" data-schedule-datetime-shell>
|
|
634
|
-
<input type="datetime-local" name="schedule_datetime" data-schedule-datetime>
|
|
635
|
-
<svg class="ready-post-datetime-icon" viewBox="0 0 20 20" fill="none" stroke="currentColor" stroke-width="1.8" stroke-linecap="round" stroke-linejoin="round" aria-hidden="true"><circle cx="10" cy="10" r="7.2"></circle><path d="M10 6.4v4l2.7 1.6"></path></svg>
|
|
636
|
-
</span>
|
|
637
|
-
</label>
|
|
638
|
-
<label class="label-group">
|
|
639
|
-
<span class="label">Timezone</span>
|
|
640
|
-
<select class="ready-post-timezone-select" name="schedule_timezone" data-schedule-timezone></select>
|
|
641
|
-
</label>
|
|
642
|
-
</div>
|
|
643
|
-
<label class="label-group">
|
|
644
|
-
<span class="label">Channel</span>
|
|
645
|
-
<span class="ready-post-channel-picker" data-schedule-channel-picker>
|
|
646
|
-
<button type="button" class="ready-post-channel-trigger" data-schedule-channel-trigger aria-haspopup="listbox" aria-expanded="false"></button>
|
|
647
|
-
<span class="ready-post-channel-menu" data-schedule-channel-menu hidden>
|
|
648
|
-
<input class="ready-post-channel-search" type="search" data-schedule-channel-search placeholder="Search channels" autocomplete="off">
|
|
649
|
-
<span class="ready-post-channel-list" data-schedule-channel-list role="listbox"></span>
|
|
650
|
-
</span>
|
|
651
|
-
<input type="hidden" name="schedule_channel" data-schedule-channel-value>
|
|
652
|
-
</span>
|
|
653
|
-
</label>
|
|
654
|
-
<label class="label-group ready-post-email-instructions" data-schedule-email-instructions hidden>
|
|
655
|
-
<span class="label">Additional instructions</span>
|
|
656
|
-
<textarea name="additional_notes" data-schedule-additional-notes maxlength="4000" placeholder="Example: publish this to LinkedIn after approval, adapt the caption for Reddit, or send to the Douyin team for localization."></textarea>
|
|
657
|
-
</label>
|
|
658
|
-
</div>
|
|
659
|
-
</div>
|
|
660
|
-
<div class="ready-post-schedule-note" data-schedule-note role="status" aria-live="polite"></div>
|
|
661
|
-
<div class="toolbar ready-post-schedule-actions">
|
|
662
|
-
<button type="button" class="secondary" data-schedule-close>Close</button>
|
|
663
|
-
<button type="button" data-schedule-submit disabled>Schedule</button>
|
|
664
|
-
</div>
|
|
665
|
-
</form>
|
|
666
|
-
<div class="ready-post-schedule-toast" data-schedule-toast role="status" aria-live="polite"></div>
|
|
667
|
-
<div class="ready-post-calendar-popover" data-schedule-post-popover hidden></div>
|
|
668
|
-
</dialog>`;
|
|
669
|
-
}
|
|
670
|
-
export function renderReadyPostScheduleData(boot) {
|
|
671
|
-
return `<script id="ready-post-schedule-data" type="application/json">${escapeJsonForHtml(boot)}</script>`;
|
|
672
|
-
}
|
|
673
|
-
export function renderReadyPostScheduleScript() {
|
|
674
|
-
return `<script>
|
|
675
|
-
(() => {
|
|
676
|
-
const scheduleBoot = (() => {
|
|
677
|
-
try {
|
|
678
|
-
return JSON.parse(document.getElementById("ready-post-schedule-data")?.textContent || "{}");
|
|
679
|
-
} catch {
|
|
680
|
-
return {};
|
|
681
|
-
}
|
|
682
|
-
})();
|
|
683
|
-
document.addEventListener("click", (event) => {
|
|
684
|
-
const scheduleTrigger = event.target.closest("[data-schedule]");
|
|
685
|
-
if (scheduleTrigger) {
|
|
686
|
-
scheduleBoot.scheduleEndpoint = scheduleTrigger.dataset.scheduleEndpoint || scheduleBoot.scheduleEndpoint || null;
|
|
687
|
-
const modal = document.querySelector("[data-schedule-modal]");
|
|
688
|
-
if (modal?.showModal) {
|
|
689
|
-
modal.showModal();
|
|
690
|
-
} else if (modal) {
|
|
691
|
-
modal.setAttribute("open", "");
|
|
692
|
-
}
|
|
693
|
-
void refreshScheduleCalendar();
|
|
694
|
-
}
|
|
695
|
-
if (event.target.closest("[data-schedule-close]")) {
|
|
696
|
-
const modal = document.querySelector("[data-schedule-modal]");
|
|
697
|
-
if (modal?.close) {
|
|
698
|
-
modal.close();
|
|
699
|
-
} else if (modal) {
|
|
700
|
-
modal.removeAttribute("open");
|
|
701
|
-
}
|
|
702
|
-
}
|
|
703
|
-
if (event.target.closest("[data-schedule-post-popover-close]")) {
|
|
704
|
-
closePostPopover();
|
|
705
|
-
}
|
|
706
|
-
});
|
|
707
|
-
document.querySelector("[data-schedule-modal]")?.addEventListener("click", (event) => {
|
|
708
|
-
if (event.target === event.currentTarget) {
|
|
709
|
-
event.currentTarget.close?.();
|
|
710
|
-
}
|
|
711
|
-
});
|
|
712
|
-
const channelPicker = document.querySelector("[data-schedule-channel-picker]");
|
|
713
|
-
const channelTrigger = document.querySelector("[data-schedule-channel-trigger]");
|
|
714
|
-
const channelMenu = document.querySelector("[data-schedule-channel-menu]");
|
|
715
|
-
const channelSearch = document.querySelector("[data-schedule-channel-search]");
|
|
716
|
-
const channelList = document.querySelector("[data-schedule-channel-list]");
|
|
717
|
-
const channelValueInput = document.querySelector("[data-schedule-channel-value]");
|
|
718
|
-
const emailInstructions = document.querySelector("[data-schedule-email-instructions]");
|
|
719
|
-
const additionalNotesInput = document.querySelector("[data-schedule-additional-notes]");
|
|
720
|
-
const scheduleDateInput = document.querySelector("[data-schedule-date]");
|
|
721
|
-
const scheduleDateTimeInput = document.querySelector("[data-schedule-datetime]");
|
|
722
|
-
const scheduleDateTimeShell = document.querySelector("[data-schedule-datetime-shell]");
|
|
723
|
-
const timezoneSelect = document.querySelector("[data-schedule-timezone]");
|
|
724
|
-
const calendarTitle = document.querySelector("[data-schedule-calendar-title]");
|
|
725
|
-
const calendarDays = document.querySelector("[data-schedule-calendar-days]");
|
|
726
|
-
const postPopover = document.querySelector("[data-schedule-post-popover]");
|
|
727
|
-
const scheduleNote = document.querySelector("[data-schedule-note]");
|
|
728
|
-
const scheduleSubmit = document.querySelector("[data-schedule-submit]");
|
|
729
|
-
const scheduleToast = document.querySelector("[data-schedule-toast]");
|
|
730
|
-
const monthFormatter = new Intl.DateTimeFormat(undefined, { month: "long", year: "numeric" });
|
|
731
|
-
const popoverDateFormatter = new Intl.DateTimeFormat(undefined, { month: "short", day: "numeric" });
|
|
732
|
-
const popoverTimeFormatter = new Intl.DateTimeFormat(undefined, { hour: "numeric", minute: "2-digit" });
|
|
733
|
-
const toastDateFormatter = new Intl.DateTimeFormat(undefined, { month: "short", day: "numeric", hour: "numeric", minute: "2-digit" });
|
|
734
|
-
const minScheduleLeadMs = 10 * 60 * 1000;
|
|
735
|
-
const cacheKey = "vidfarm:flockposter-cache:v1_" + (scheduleBoot.userId || "public");
|
|
736
|
-
const isoDate = (date) => {
|
|
737
|
-
const year = date.getFullYear();
|
|
738
|
-
const month = String(date.getMonth() + 1).padStart(2, "0");
|
|
739
|
-
const day = String(date.getDate()).padStart(2, "0");
|
|
740
|
-
return year + "-" + month + "-" + day;
|
|
741
|
-
};
|
|
742
|
-
const pad2 = (value) => String(value).padStart(2, "0");
|
|
743
|
-
const isoDateTimeLocal = (date, time) => isoDate(date) + "T" + time;
|
|
744
|
-
const startOfDay = (date) => new Date(date.getFullYear(), date.getMonth(), date.getDate());
|
|
745
|
-
const today = startOfDay(new Date());
|
|
746
|
-
let selectedDate = today;
|
|
747
|
-
let calendarCursor = new Date(today.getFullYear(), today.getMonth(), 1);
|
|
748
|
-
let selectedTime = (() => {
|
|
749
|
-
const next = new Date();
|
|
750
|
-
next.setMinutes(next.getMinutes() >= 30 ? 0 : 30, 0, 0);
|
|
751
|
-
if (next.getTime() < Date.now() + minScheduleLeadMs) next.setHours(next.getHours() + 1);
|
|
752
|
-
return pad2(next.getHours()) + ":" + pad2(next.getMinutes());
|
|
753
|
-
})();
|
|
754
|
-
let scheduleChannels = Array.isArray(scheduleBoot.channels) ? scheduleBoot.channels : [];
|
|
755
|
-
let selectedChannelId = "";
|
|
756
|
-
let channelSearchQuery = "";
|
|
757
|
-
let isScheduleSubmitting = false;
|
|
758
|
-
let scheduleSubmitMode = "schedule";
|
|
759
|
-
let hasInteractedWithScheduleDateTime = false;
|
|
760
|
-
let scheduledPosts = [];
|
|
761
|
-
let loadedRangeStart = null;
|
|
762
|
-
let loadedRangeEnd = null;
|
|
763
|
-
let scheduleFetchPromise = null;
|
|
764
|
-
let hasLoadedScheduleCalendar = false;
|
|
765
|
-
let activePostPopoverDateKey = "";
|
|
766
|
-
|
|
767
|
-
const createOption = (label, value) => {
|
|
768
|
-
const option = document.createElement("option");
|
|
769
|
-
option.textContent = label;
|
|
770
|
-
option.value = value || label;
|
|
771
|
-
return option;
|
|
772
|
-
};
|
|
773
|
-
|
|
774
|
-
const describeChannel = (channel) => {
|
|
775
|
-
const name = channel?.name || channel?.title || channel?.id || "Untitled channel";
|
|
776
|
-
const handle = channel?.handle ? " @" + channel.handle : "";
|
|
777
|
-
const platform = channel?.platform ? " · " + String(channel.platform).toUpperCase() : "";
|
|
778
|
-
return name + handle + platform;
|
|
779
|
-
};
|
|
780
|
-
|
|
781
|
-
const normalizeChannelsForSchedule = (entries) => (Array.isArray(entries) ? entries : []).map((channel) => ({
|
|
782
|
-
id: String(channel.id || ""),
|
|
783
|
-
name: String(channel.name || channel.title || channel.id || "Channel"),
|
|
784
|
-
title: String(channel.title || channel.name || channel.id || "Channel"),
|
|
785
|
-
handle: channel.handle ? String(channel.handle) : null,
|
|
786
|
-
platform: channel.platform ? String(channel.platform) : null,
|
|
787
|
-
avatarUrl: channel.avatarUrl ? String(channel.avatarUrl) : null,
|
|
788
|
-
platformIconUrl: channel.platformIconUrl ? String(channel.platformIconUrl) : null
|
|
789
|
-
})).filter((channel) => channel.id);
|
|
790
|
-
|
|
791
|
-
const dedupeById = (entries) => [...new Map(entries.map((entry) => [entry.id, entry])).values()];
|
|
792
|
-
|
|
793
|
-
const dedupeSchedulePosts = (entries) => {
|
|
794
|
-
const byId = dedupeById(entries);
|
|
795
|
-
const managedSlots = new Set(byId
|
|
796
|
-
.filter((post) => post.managedBy === "vidfarm")
|
|
797
|
-
.map((post) => post.channelId + "|" + post.scheduledAt));
|
|
798
|
-
return byId.filter((post) => post.managedBy !== "external" || !managedSlots.has(post.channelId + "|" + post.scheduledAt));
|
|
799
|
-
};
|
|
800
|
-
|
|
801
|
-
const normalizePostsForSchedule = (entries) => dedupeSchedulePosts((Array.isArray(entries) ? entries : []).map((post) => {
|
|
802
|
-
const scheduledAt = typeof post?.scheduledAt === "string" ? post.scheduledAt : "";
|
|
803
|
-
return {
|
|
804
|
-
id: String(post?.id || ""),
|
|
805
|
-
scheduleId: String(post?.scheduleId || post?.schedule_id || post?.id || ""),
|
|
806
|
-
postId: String(post?.postId || post?.post_id || ""),
|
|
807
|
-
managedBy: String(post?.managedBy || post?.managed_by || ""),
|
|
808
|
-
channelId: String(post?.channelId || ""),
|
|
809
|
-
scheduledAt,
|
|
810
|
-
status: String(post?.status || "Scheduled"),
|
|
811
|
-
title: String(post?.title || "Scheduled post"),
|
|
812
|
-
summary: String(post?.summary || ""),
|
|
813
|
-
url: typeof post?.url === "string" && post.url ? post.url : null
|
|
814
|
-
};
|
|
815
|
-
}).filter((post) => post.id && post.channelId && !Number.isNaN(Date.parse(post.scheduledAt))));
|
|
816
|
-
|
|
817
|
-
const readScheduleCache = () => {
|
|
818
|
-
try {
|
|
819
|
-
const runtime = window.__vidfarmFlockPosterCache;
|
|
820
|
-
if (runtime && typeof runtime.readSnapshot === "function") {
|
|
821
|
-
return runtime.readSnapshot();
|
|
822
|
-
}
|
|
823
|
-
const raw = window.localStorage.getItem(cacheKey);
|
|
824
|
-
return raw ? JSON.parse(raw) : {};
|
|
825
|
-
} catch {
|
|
826
|
-
return {};
|
|
827
|
-
}
|
|
828
|
-
};
|
|
829
|
-
|
|
830
|
-
const applyScheduleCache = () => {
|
|
831
|
-
const snapshot = readScheduleCache();
|
|
832
|
-
if (Array.isArray(snapshot.channels) && snapshot.channels.length) {
|
|
833
|
-
scheduleChannels = normalizeChannelsForSchedule(dedupeById([...scheduleChannels, ...snapshot.channels]));
|
|
834
|
-
}
|
|
835
|
-
if (Array.isArray(snapshot.posts) && snapshot.posts.length) {
|
|
836
|
-
scheduledPosts = normalizePostsForSchedule([...scheduledPosts, ...snapshot.posts]);
|
|
837
|
-
}
|
|
838
|
-
loadedRangeStart = typeof snapshot.calendarRangeStart === "string" ? snapshot.calendarRangeStart : loadedRangeStart;
|
|
839
|
-
loadedRangeEnd = typeof snapshot.calendarRangeEnd === "string" ? snapshot.calendarRangeEnd : loadedRangeEnd;
|
|
840
|
-
};
|
|
841
|
-
|
|
842
|
-
const writeScheduleCache = (channels, posts, rangeStart, rangeEnd) => {
|
|
843
|
-
const runtime = window.__vidfarmFlockPosterCache;
|
|
844
|
-
if (runtime && typeof runtime.setCalendarData === "function") {
|
|
845
|
-
runtime.setCalendarData({ channels, posts, rangeStart, rangeEnd, replaceRange: true });
|
|
846
|
-
return;
|
|
847
|
-
}
|
|
848
|
-
try {
|
|
849
|
-
const current = readScheduleCache();
|
|
850
|
-
window.localStorage.setItem(cacheKey, JSON.stringify({
|
|
851
|
-
channels: dedupeById([...(Array.isArray(current.channels) ? current.channels : []), ...channels]),
|
|
852
|
-
posts: normalizePostsForSchedule([...(Array.isArray(current.posts) ? current.posts : []), ...posts]),
|
|
853
|
-
channelsUpdatedAt: new Date().toISOString(),
|
|
854
|
-
calendarUpdatedAt: new Date().toISOString(),
|
|
855
|
-
calendarRangeStart: rangeStart,
|
|
856
|
-
calendarRangeEnd: rangeEnd
|
|
857
|
-
}));
|
|
858
|
-
} catch {
|
|
859
|
-
// Ignore storage failures.
|
|
860
|
-
}
|
|
861
|
-
};
|
|
862
|
-
|
|
863
|
-
const clearScheduleNote = () => {
|
|
864
|
-
if (!scheduleNote) return;
|
|
865
|
-
scheduleNote.textContent = "";
|
|
866
|
-
scheduleNote.dataset.visible = "false";
|
|
867
|
-
delete scheduleNote.dataset.tone;
|
|
868
|
-
};
|
|
869
|
-
|
|
870
|
-
const setScheduleNote = (message, options = {}) => {
|
|
871
|
-
if (!scheduleNote) return;
|
|
872
|
-
if (!message) {
|
|
873
|
-
clearScheduleNote();
|
|
874
|
-
return;
|
|
875
|
-
}
|
|
876
|
-
scheduleNote.textContent = message;
|
|
877
|
-
scheduleNote.dataset.visible = "true";
|
|
878
|
-
scheduleNote.dataset.tone = options.tone || "info";
|
|
879
|
-
if (options.link) {
|
|
880
|
-
scheduleNote.append(" ");
|
|
881
|
-
const anchor = document.createElement("a");
|
|
882
|
-
anchor.href = options.link.href;
|
|
883
|
-
anchor.textContent = options.link.label;
|
|
884
|
-
scheduleNote.append(anchor);
|
|
885
|
-
}
|
|
886
|
-
};
|
|
887
|
-
|
|
888
|
-
let scheduleToastTimer = 0;
|
|
889
|
-
const showScheduleToast = (message) => {
|
|
890
|
-
if (!scheduleToast) return;
|
|
891
|
-
window.clearTimeout(scheduleToastTimer);
|
|
892
|
-
scheduleToast.textContent = message;
|
|
893
|
-
scheduleToast.dataset.visible = "true";
|
|
894
|
-
scheduleToastTimer = window.setTimeout(() => {
|
|
895
|
-
scheduleToast.dataset.visible = "false";
|
|
896
|
-
}, 3600);
|
|
897
|
-
};
|
|
898
|
-
|
|
899
|
-
const syncDateTimeInput = () => {
|
|
900
|
-
if (!scheduleDateInput || !scheduleDateTimeInput) return;
|
|
901
|
-
scheduleDateInput.value = isoDate(selectedDate);
|
|
902
|
-
scheduleDateTimeInput.value = isoDateTimeLocal(selectedDate, selectedTime);
|
|
903
|
-
updateScheduleSubmitState();
|
|
904
|
-
};
|
|
905
|
-
|
|
906
|
-
const syncDateFromDateTimeInput = () => {
|
|
907
|
-
hasInteractedWithScheduleDateTime = true;
|
|
908
|
-
if (!scheduleDateTimeInput?.value) {
|
|
909
|
-
updateScheduleSubmitState();
|
|
910
|
-
return;
|
|
911
|
-
}
|
|
912
|
-
const [datePart, timePart] = scheduleDateTimeInput.value.split("T");
|
|
913
|
-
if (datePart) {
|
|
914
|
-
const parsed = new Date(datePart + "T00:00:00");
|
|
915
|
-
if (!Number.isNaN(parsed.getTime())) {
|
|
916
|
-
selectedDate = startOfDay(parsed);
|
|
917
|
-
calendarCursor = new Date(parsed.getFullYear(), parsed.getMonth(), 1);
|
|
918
|
-
}
|
|
919
|
-
}
|
|
920
|
-
if (/^\\d{2}:\\d{2}/.test(timePart || "")) {
|
|
921
|
-
selectedTime = timePart.slice(0, 5);
|
|
922
|
-
}
|
|
923
|
-
renderCalendar();
|
|
924
|
-
updateScheduleSubmitState();
|
|
925
|
-
};
|
|
926
|
-
|
|
927
|
-
const showDateTimePicker = () => {
|
|
928
|
-
if (!scheduleDateTimeInput) return;
|
|
929
|
-
scheduleDateTimeInput.focus();
|
|
930
|
-
if (typeof scheduleDateTimeInput.showPicker === "function") {
|
|
931
|
-
try { scheduleDateTimeInput.showPicker(); } catch {}
|
|
932
|
-
}
|
|
933
|
-
};
|
|
934
|
-
|
|
935
|
-
const rangeContainsDate = (rangeStart, rangeEnd, date) => {
|
|
936
|
-
if (!rangeStart || !rangeEnd) return false;
|
|
937
|
-
const time = startOfDay(date).getTime();
|
|
938
|
-
return time >= startOfDay(new Date(rangeStart)).getTime() && time <= startOfDay(new Date(rangeEnd)).getTime();
|
|
939
|
-
};
|
|
940
|
-
|
|
941
|
-
const calendarFetchWindow = () => {
|
|
942
|
-
const first = new Date(calendarCursor.getFullYear(), calendarCursor.getMonth(), 1);
|
|
943
|
-
const gridStart = new Date(first);
|
|
944
|
-
gridStart.setDate(first.getDate() - first.getDay());
|
|
945
|
-
const gridEnd = new Date(gridStart);
|
|
946
|
-
gridEnd.setDate(gridStart.getDate() + 41);
|
|
947
|
-
gridEnd.setHours(23, 59, 59, 999);
|
|
948
|
-
return { startDate: gridStart.toISOString(), endDate: gridEnd.toISOString() };
|
|
949
|
-
};
|
|
950
|
-
|
|
951
|
-
const postsForDate = (date) => {
|
|
952
|
-
const dateKey = isoDate(date);
|
|
953
|
-
const channelId = selectedChannelId;
|
|
954
|
-
return scheduledPosts
|
|
955
|
-
.filter((post) => isoDate(new Date(post.scheduledAt)) === dateKey)
|
|
956
|
-
.filter((post) => !channelId || post.channelId === channelId)
|
|
957
|
-
.sort((a, b) => Date.parse(a.scheduledAt) - Date.parse(b.scheduledAt));
|
|
958
|
-
};
|
|
959
|
-
|
|
960
|
-
const closePostPopover = () => {
|
|
961
|
-
activePostPopoverDateKey = "";
|
|
962
|
-
if (postPopover) postPopover.hidden = true;
|
|
963
|
-
};
|
|
964
|
-
|
|
965
|
-
const hidePostPopover = () => {
|
|
966
|
-
if (postPopover) postPopover.hidden = true;
|
|
967
|
-
};
|
|
968
|
-
|
|
969
|
-
const openPostPopover = (button, date, posts, options = {}) => {
|
|
970
|
-
if (!postPopover || !posts.length) {
|
|
971
|
-
closePostPopover();
|
|
972
|
-
return;
|
|
973
|
-
}
|
|
974
|
-
if (options.persist) {
|
|
975
|
-
activePostPopoverDateKey = isoDate(date);
|
|
976
|
-
}
|
|
977
|
-
const title = popoverDateFormatter.format(date);
|
|
978
|
-
postPopover.innerHTML = "";
|
|
979
|
-
const closeButton = document.createElement("button");
|
|
980
|
-
closeButton.type = "button";
|
|
981
|
-
closeButton.className = "ready-post-calendar-popover-close";
|
|
982
|
-
closeButton.setAttribute("aria-label", "Close post preview");
|
|
983
|
-
closeButton.dataset.schedulePostPopoverClose = "true";
|
|
984
|
-
closeButton.textContent = "×";
|
|
985
|
-
const heading = document.createElement("div");
|
|
986
|
-
heading.className = "ready-post-calendar-popover-title";
|
|
987
|
-
heading.textContent = title + " · " + posts.length + " post" + (posts.length === 1 ? "" : "s");
|
|
988
|
-
const list = document.createElement("div");
|
|
989
|
-
list.className = "ready-post-calendar-popover-list";
|
|
990
|
-
posts.slice(0, 8).forEach((post) => {
|
|
991
|
-
const channel = scheduleChannels.find((entry) => entry.id === post.channelId) || null;
|
|
992
|
-
const item = document.createElement("div");
|
|
993
|
-
item.className = "ready-post-calendar-popover-item";
|
|
994
|
-
const time = document.createElement("div");
|
|
995
|
-
time.className = "ready-post-calendar-popover-time";
|
|
996
|
-
time.textContent = popoverTimeFormatter.format(new Date(post.scheduledAt));
|
|
997
|
-
const channelNode = document.createElement("div");
|
|
998
|
-
channelNode.className = "ready-post-calendar-popover-channel";
|
|
999
|
-
channelNode.textContent = channel ? describeChannel(channel) : post.channelId;
|
|
1000
|
-
const titleNode = post.url ? document.createElement("a") : document.createElement("span");
|
|
1001
|
-
if (post.url) {
|
|
1002
|
-
titleNode.href = post.url;
|
|
1003
|
-
titleNode.target = "_blank";
|
|
1004
|
-
titleNode.rel = "noreferrer";
|
|
1005
|
-
} else {
|
|
1006
|
-
titleNode.className = "ready-post-calendar-popover-linkless";
|
|
1007
|
-
}
|
|
1008
|
-
titleNode.textContent = post.title || "Scheduled post";
|
|
1009
|
-
item.append(time, titleNode, channelNode);
|
|
1010
|
-
if (post.summary && post.summary !== post.title) {
|
|
1011
|
-
const summary = document.createElement("div");
|
|
1012
|
-
summary.className = "ready-post-calendar-popover-summary";
|
|
1013
|
-
summary.textContent = post.summary;
|
|
1014
|
-
item.append(summary);
|
|
1015
|
-
}
|
|
1016
|
-
list.append(item);
|
|
1017
|
-
});
|
|
1018
|
-
postPopover.append(closeButton, heading, list);
|
|
1019
|
-
const rect = button.getBoundingClientRect();
|
|
1020
|
-
postPopover.hidden = false;
|
|
1021
|
-
const width = postPopover.offsetWidth || 390;
|
|
1022
|
-
const height = postPopover.offsetHeight || 260;
|
|
1023
|
-
const preferRight = rect.right + width + 12 <= window.innerWidth - 16;
|
|
1024
|
-
const left = preferRight
|
|
1025
|
-
? rect.right + 12
|
|
1026
|
-
: Math.max(16, Math.min(window.innerWidth - width - 16, rect.left));
|
|
1027
|
-
const top = Math.max(16, Math.min(window.innerHeight - height - 16, rect.top));
|
|
1028
|
-
postPopover.style.left = left + "px";
|
|
1029
|
-
postPopover.style.top = top + "px";
|
|
1030
|
-
};
|
|
1031
|
-
|
|
1032
|
-
const channelInitials = (channel) => String(channel?.name || channel?.title || channel?.id || "CH")
|
|
1033
|
-
.split(/\s+/)
|
|
1034
|
-
.filter(Boolean)
|
|
1035
|
-
.slice(0, 2)
|
|
1036
|
-
.map((part) => part[0]?.toUpperCase() || "")
|
|
1037
|
-
.join("") || "CH";
|
|
1038
|
-
|
|
1039
|
-
const channelMeta = (channel) => {
|
|
1040
|
-
const handle = channel?.handle ? (String(channel.platform || "").toLowerCase() === "email" ? channel.handle : "@" + channel.handle) : channel?.id || "";
|
|
1041
|
-
const platform = channel?.platform ? String(channel.platform).toUpperCase() : "CHANNEL";
|
|
1042
|
-
return [handle, platform].filter(Boolean).join(" · ");
|
|
1043
|
-
};
|
|
1044
|
-
|
|
1045
|
-
const isEmailScheduleChannel = (channel) => String(channel?.platform || "").toLowerCase() === "email" || String(channel?.id || "").startsWith("email:");
|
|
1046
|
-
|
|
1047
|
-
const updateEmailInstructionsVisibility = () => {
|
|
1048
|
-
if (!emailInstructions) return;
|
|
1049
|
-
const visible = isEmailScheduleChannel(selectedChannel());
|
|
1050
|
-
emailInstructions.hidden = !visible;
|
|
1051
|
-
if (!visible && additionalNotesInput) {
|
|
1052
|
-
additionalNotesInput.value = "";
|
|
1053
|
-
}
|
|
1054
|
-
};
|
|
1055
|
-
|
|
1056
|
-
const renderChannelAvatar = (channel) => {
|
|
1057
|
-
const avatar = document.createElement("span");
|
|
1058
|
-
avatar.className = "ready-post-channel-avatar";
|
|
1059
|
-
if (channel?.avatarUrl) {
|
|
1060
|
-
const image = document.createElement("img");
|
|
1061
|
-
image.src = channel.avatarUrl;
|
|
1062
|
-
image.alt = "";
|
|
1063
|
-
avatar.append(image);
|
|
1064
|
-
} else {
|
|
1065
|
-
avatar.textContent = channelInitials(channel);
|
|
1066
|
-
}
|
|
1067
|
-
return avatar;
|
|
1068
|
-
};
|
|
1069
|
-
|
|
1070
|
-
const selectedChannel = () => scheduleChannels.find((channel) => channel.id === selectedChannelId) || null;
|
|
1071
|
-
|
|
1072
|
-
const setSelectedChannel = (channelId) => {
|
|
1073
|
-
if (!channelId || !scheduleChannels.some((channel) => channel.id === channelId)) {
|
|
1074
|
-
selectedChannelId = "";
|
|
1075
|
-
} else {
|
|
1076
|
-
selectedChannelId = channelId;
|
|
1077
|
-
}
|
|
1078
|
-
if (channelValueInput) channelValueInput.value = selectedChannelId;
|
|
1079
|
-
updateScheduleSubmitState();
|
|
1080
|
-
};
|
|
1081
|
-
|
|
1082
|
-
const renderChannelTrigger = () => {
|
|
1083
|
-
if (!channelTrigger) return;
|
|
1084
|
-
channelTrigger.innerHTML = "";
|
|
1085
|
-
channelTrigger.classList.remove("is-placeholder");
|
|
1086
|
-
const channel = selectedChannel();
|
|
1087
|
-
if (!channel) {
|
|
1088
|
-
updateEmailInstructionsVisibility();
|
|
1089
|
-
channelTrigger.classList.add("is-placeholder");
|
|
1090
|
-
channelTrigger.textContent = scheduleChannels.length ? "Select a channel" : (scheduleBoot.error || "No channels connected");
|
|
1091
|
-
if (scheduleChannels.length) {
|
|
1092
|
-
setScheduleNote("Choose a channel to schedule this post.", { tone: "info" });
|
|
1093
|
-
} else {
|
|
1094
|
-
setScheduleNote("Add an email channel or connect FlockPoster to load channels.", {
|
|
1095
|
-
tone: "info",
|
|
1096
|
-
link: {
|
|
1097
|
-
href: scheduleBoot.connectHref || "/settings?tab=channels",
|
|
1098
|
-
label: "Open Settings"
|
|
1099
|
-
}
|
|
1100
|
-
});
|
|
1101
|
-
}
|
|
1102
|
-
return;
|
|
1103
|
-
}
|
|
1104
|
-
channelTrigger.append(renderChannelAvatar(channel));
|
|
1105
|
-
const copy = document.createElement("span");
|
|
1106
|
-
copy.className = "ready-post-channel-copy";
|
|
1107
|
-
const title = document.createElement("span");
|
|
1108
|
-
title.className = "ready-post-channel-title";
|
|
1109
|
-
title.textContent = channel.name || channel.title || channel.id;
|
|
1110
|
-
const meta = document.createElement("span");
|
|
1111
|
-
meta.className = "ready-post-channel-meta";
|
|
1112
|
-
meta.textContent = channelMeta(channel);
|
|
1113
|
-
copy.append(title, meta);
|
|
1114
|
-
channelTrigger.append(copy);
|
|
1115
|
-
updateEmailInstructionsVisibility();
|
|
1116
|
-
clearScheduleNote();
|
|
1117
|
-
updateScheduleSubmitState();
|
|
1118
|
-
};
|
|
1119
|
-
|
|
1120
|
-
const renderChannelList = () => {
|
|
1121
|
-
if (!channelList) return;
|
|
1122
|
-
channelList.innerHTML = "";
|
|
1123
|
-
const query = channelSearchQuery.trim().toLowerCase();
|
|
1124
|
-
const visible = scheduleChannels.filter((channel) => {
|
|
1125
|
-
const haystack = [channel.name, channel.title, channel.handle, channel.platform, channel.id].filter(Boolean).join(" ").toLowerCase();
|
|
1126
|
-
return !query || haystack.includes(query);
|
|
1127
|
-
});
|
|
1128
|
-
if (!visible.length) {
|
|
1129
|
-
const empty = document.createElement("span");
|
|
1130
|
-
empty.className = "ready-post-channel-empty";
|
|
1131
|
-
empty.textContent = scheduleChannels.length ? "No channels match that search." : "No channels connected yet.";
|
|
1132
|
-
channelList.append(empty);
|
|
1133
|
-
return;
|
|
1134
|
-
}
|
|
1135
|
-
visible.forEach((channel) => {
|
|
1136
|
-
const button = document.createElement("button");
|
|
1137
|
-
button.type = "button";
|
|
1138
|
-
button.className = "ready-post-channel-option" + (channel.id === selectedChannelId ? " is-selected" : "");
|
|
1139
|
-
button.setAttribute("role", "option");
|
|
1140
|
-
button.setAttribute("aria-selected", channel.id === selectedChannelId ? "true" : "false");
|
|
1141
|
-
button.append(renderChannelAvatar(channel));
|
|
1142
|
-
const copy = document.createElement("span");
|
|
1143
|
-
copy.className = "ready-post-channel-copy";
|
|
1144
|
-
const title = document.createElement("span");
|
|
1145
|
-
title.className = "ready-post-channel-title";
|
|
1146
|
-
title.textContent = channel.name || channel.title || channel.id;
|
|
1147
|
-
const meta = document.createElement("span");
|
|
1148
|
-
meta.className = "ready-post-channel-meta";
|
|
1149
|
-
meta.textContent = channelMeta(channel);
|
|
1150
|
-
copy.append(title, meta);
|
|
1151
|
-
button.append(copy);
|
|
1152
|
-
button.addEventListener("click", () => {
|
|
1153
|
-
setSelectedChannel(channel.id);
|
|
1154
|
-
closeChannelMenu();
|
|
1155
|
-
renderChannelPicker();
|
|
1156
|
-
closePostPopover();
|
|
1157
|
-
renderCalendar();
|
|
1158
|
-
});
|
|
1159
|
-
channelList.append(button);
|
|
1160
|
-
});
|
|
1161
|
-
};
|
|
1162
|
-
|
|
1163
|
-
const renderChannelPicker = () => {
|
|
1164
|
-
const previous = selectedChannelId;
|
|
1165
|
-
setSelectedChannel(previous);
|
|
1166
|
-
renderChannelTrigger();
|
|
1167
|
-
renderChannelList();
|
|
1168
|
-
};
|
|
1169
|
-
|
|
1170
|
-
const openChannelMenu = () => {
|
|
1171
|
-
if (!channelMenu || !channelTrigger) return;
|
|
1172
|
-
channelMenu.hidden = false;
|
|
1173
|
-
channelTrigger.setAttribute("aria-expanded", "true");
|
|
1174
|
-
renderChannelList();
|
|
1175
|
-
setTimeout(() => channelSearch?.focus(), 0);
|
|
1176
|
-
};
|
|
1177
|
-
|
|
1178
|
-
const closeChannelMenu = () => {
|
|
1179
|
-
if (!channelMenu || !channelTrigger) return;
|
|
1180
|
-
channelMenu.hidden = true;
|
|
1181
|
-
channelTrigger.setAttribute("aria-expanded", "false");
|
|
1182
|
-
};
|
|
1183
|
-
|
|
1184
|
-
const refreshScheduleCalendar = async (options = {}) => {
|
|
1185
|
-
applyScheduleCache();
|
|
1186
|
-
if (!scheduleBoot.feedEndpoint || !scheduleBoot.hasFlockPosterKey) {
|
|
1187
|
-
renderChannelPicker();
|
|
1188
|
-
renderCalendar();
|
|
1189
|
-
return;
|
|
1190
|
-
}
|
|
1191
|
-
const range = calendarFetchWindow();
|
|
1192
|
-
if (!options.force && hasLoadedScheduleCalendar && rangeContainsDate(loadedRangeStart, loadedRangeEnd, calendarCursor)) {
|
|
1193
|
-
renderChannelPicker();
|
|
1194
|
-
renderCalendar();
|
|
1195
|
-
return;
|
|
1196
|
-
}
|
|
1197
|
-
if (scheduleFetchPromise) {
|
|
1198
|
-
await scheduleFetchPromise;
|
|
1199
|
-
return;
|
|
1200
|
-
}
|
|
1201
|
-
hasLoadedScheduleCalendar = true;
|
|
1202
|
-
scheduleFetchPromise = (async () => {
|
|
1203
|
-
try {
|
|
1204
|
-
const url = new URL(scheduleBoot.feedEndpoint, window.location.origin);
|
|
1205
|
-
url.searchParams.set("start_date", range.startDate);
|
|
1206
|
-
url.searchParams.set("end_date", range.endDate);
|
|
1207
|
-
const response = await fetch(url.pathname + url.search, { credentials: "same-origin", headers: { accept: "application/json" } });
|
|
1208
|
-
const payload = await response.json();
|
|
1209
|
-
if (!response.ok) {
|
|
1210
|
-
throw new Error(typeof payload?.error === "string" ? payload.error : "Unable to load FlockPoster calendar.");
|
|
1211
|
-
}
|
|
1212
|
-
const nextChannels = normalizeChannelsForSchedule(payload.channels);
|
|
1213
|
-
const nextPosts = normalizePostsForSchedule(payload.posts);
|
|
1214
|
-
scheduleChannels = normalizeChannelsForSchedule(dedupeById([...scheduleChannels, ...nextChannels]));
|
|
1215
|
-
scheduledPosts = normalizePostsForSchedule(dedupeById([...scheduledPosts, ...nextPosts]));
|
|
1216
|
-
loadedRangeStart = typeof payload.startDate === "string" ? payload.startDate : range.startDate;
|
|
1217
|
-
loadedRangeEnd = typeof payload.endDate === "string" ? payload.endDate : range.endDate;
|
|
1218
|
-
scheduleBoot.error = typeof payload.error === "string" ? payload.error : "";
|
|
1219
|
-
writeScheduleCache(nextChannels, nextPosts, loadedRangeStart, loadedRangeEnd);
|
|
1220
|
-
} catch (error) {
|
|
1221
|
-
scheduleBoot.error = error instanceof Error ? error.message : "Unable to load FlockPoster calendar.";
|
|
1222
|
-
} finally {
|
|
1223
|
-
scheduleFetchPromise = null;
|
|
1224
|
-
}
|
|
1225
|
-
})();
|
|
1226
|
-
await scheduleFetchPromise;
|
|
1227
|
-
renderChannelPicker();
|
|
1228
|
-
renderCalendar();
|
|
1229
|
-
};
|
|
1230
|
-
|
|
1231
|
-
const hydrateScheduleChannelsOnPageLoad = async () => {
|
|
1232
|
-
const runtime = window.__vidfarmFlockPosterCache;
|
|
1233
|
-
if (runtime && typeof runtime.ensureHydrated === "function") {
|
|
1234
|
-
await runtime.ensureHydrated({ force: true });
|
|
1235
|
-
}
|
|
1236
|
-
await refreshScheduleCalendar({ force: true });
|
|
1237
|
-
};
|
|
1238
|
-
|
|
1239
|
-
const renderCalendar = () => {
|
|
1240
|
-
if (!calendarTitle || !calendarDays || !scheduleDateInput) return;
|
|
1241
|
-
calendarTitle.textContent = monthFormatter.format(calendarCursor);
|
|
1242
|
-
syncDateTimeInput();
|
|
1243
|
-
calendarDays.innerHTML = "";
|
|
1244
|
-
const first = new Date(calendarCursor.getFullYear(), calendarCursor.getMonth(), 1);
|
|
1245
|
-
const gridStart = new Date(first);
|
|
1246
|
-
gridStart.setDate(first.getDate() - first.getDay());
|
|
1247
|
-
for (let index = 0; index < 42; index += 1) {
|
|
1248
|
-
const date = new Date(gridStart);
|
|
1249
|
-
date.setDate(gridStart.getDate() + index);
|
|
1250
|
-
const button = document.createElement("button");
|
|
1251
|
-
button.type = "button";
|
|
1252
|
-
button.className = "ready-post-calendar-day";
|
|
1253
|
-
const number = document.createElement("span");
|
|
1254
|
-
number.className = "ready-post-calendar-day-number";
|
|
1255
|
-
number.textContent = String(date.getDate());
|
|
1256
|
-
button.append(number);
|
|
1257
|
-
button.dataset.scheduleDate = isoDate(date);
|
|
1258
|
-
if (date.getMonth() !== calendarCursor.getMonth()) button.classList.add("is-muted");
|
|
1259
|
-
if (isoDate(date) === isoDate(today)) button.classList.add("is-today");
|
|
1260
|
-
if (isoDate(date) === isoDate(selectedDate)) button.classList.add("is-selected");
|
|
1261
|
-
const dayPosts = postsForDate(date);
|
|
1262
|
-
if (dayPosts.length) {
|
|
1263
|
-
button.classList.add("has-posts");
|
|
1264
|
-
if (dayPosts.length > 2) button.classList.add("has-many-posts");
|
|
1265
|
-
button.setAttribute("aria-label", number.textContent + ", " + dayPosts.length + " scheduled post" + (dayPosts.length === 1 ? "" : "s"));
|
|
1266
|
-
const preview = document.createElement("span");
|
|
1267
|
-
preview.className = "ready-post-calendar-day-preview";
|
|
1268
|
-
preview.textContent = String(dayPosts.length);
|
|
1269
|
-
button.append(preview);
|
|
1270
|
-
button.addEventListener("mouseenter", () => openPostPopover(button, date, dayPosts));
|
|
1271
|
-
button.addEventListener("focus", () => openPostPopover(button, date, dayPosts));
|
|
1272
|
-
if (activePostPopoverDateKey === isoDate(date)) {
|
|
1273
|
-
setTimeout(() => {
|
|
1274
|
-
openPostPopover(button, date, dayPosts, { persist: true });
|
|
1275
|
-
}, 0);
|
|
1276
|
-
}
|
|
1277
|
-
}
|
|
1278
|
-
button.addEventListener("click", () => {
|
|
1279
|
-
selectedDate = startOfDay(date);
|
|
1280
|
-
calendarCursor = new Date(date.getFullYear(), date.getMonth(), 1);
|
|
1281
|
-
activePostPopoverDateKey = dayPosts.length ? isoDate(date) : "";
|
|
1282
|
-
hidePostPopover();
|
|
1283
|
-
renderCalendar();
|
|
1284
|
-
void refreshScheduleCalendar();
|
|
1285
|
-
});
|
|
1286
|
-
calendarDays.append(button);
|
|
1287
|
-
}
|
|
1288
|
-
};
|
|
1289
|
-
|
|
1290
|
-
const selectedScheduleIso = () => {
|
|
1291
|
-
if (!scheduleDateTimeInput?.value) return "";
|
|
1292
|
-
const timezone = timezoneSelect?.value || "";
|
|
1293
|
-
const offset = /^GMT([+-]\\d{2}:\\d{2})$/.exec(timezone)?.[1];
|
|
1294
|
-
const raw = scheduleDateTimeInput.value.length === 16
|
|
1295
|
-
? scheduleDateTimeInput.value + ":00"
|
|
1296
|
-
: scheduleDateTimeInput.value;
|
|
1297
|
-
const parsed = new Date(offset ? raw + offset : raw);
|
|
1298
|
-
return Number.isNaN(parsed.getTime()) ? "" : parsed.toISOString();
|
|
1299
|
-
};
|
|
1300
|
-
|
|
1301
|
-
const canSubmitSchedule = () => {
|
|
1302
|
-
const scheduledAt = selectedScheduleIso();
|
|
1303
|
-
return Boolean(
|
|
1304
|
-
scheduleBoot.scheduleEndpoint
|
|
1305
|
-
&& selectedChannel()
|
|
1306
|
-
&& scheduledAt
|
|
1307
|
-
&& Date.parse(scheduledAt) >= Date.now() + minScheduleLeadMs
|
|
1308
|
-
);
|
|
1309
|
-
};
|
|
1310
|
-
|
|
1311
|
-
const validateScheduleDateTime = () => {
|
|
1312
|
-
if (!hasInteractedWithScheduleDateTime) return;
|
|
1313
|
-
const scheduledAt = selectedScheduleIso();
|
|
1314
|
-
if (!scheduledAt) {
|
|
1315
|
-
setScheduleNote("Choose a valid date and time.", { tone: "error" });
|
|
1316
|
-
return;
|
|
1317
|
-
}
|
|
1318
|
-
if (Date.parse(scheduledAt) < Date.now() + minScheduleLeadMs) {
|
|
1319
|
-
setScheduleNote("Choose a time at least 10 minutes from now.", { tone: "error" });
|
|
1320
|
-
return;
|
|
1321
|
-
}
|
|
1322
|
-
if (selectedChannel()) {
|
|
1323
|
-
clearScheduleNote();
|
|
1324
|
-
}
|
|
1325
|
-
};
|
|
1326
|
-
|
|
1327
|
-
const setScheduleSubmitMode = (mode) => {
|
|
1328
|
-
scheduleSubmitMode = mode;
|
|
1329
|
-
if (!scheduleSubmit) return;
|
|
1330
|
-
scheduleSubmit.textContent = mode === "another" ? "Schedule Another?" : "Schedule";
|
|
1331
|
-
scheduleSubmit.classList.toggle("secondary", mode === "another");
|
|
1332
|
-
};
|
|
1333
|
-
|
|
1334
|
-
const updateScheduleSubmitState = () => {
|
|
1335
|
-
if (!scheduleSubmit) return;
|
|
1336
|
-
if (scheduleSubmitMode === "another") {
|
|
1337
|
-
scheduleSubmit.disabled = false;
|
|
1338
|
-
return;
|
|
1339
|
-
}
|
|
1340
|
-
scheduleSubmit.disabled = isScheduleSubmitting || !canSubmitSchedule();
|
|
1341
|
-
validateScheduleDateTime();
|
|
1342
|
-
};
|
|
1343
|
-
|
|
1344
|
-
const submitSchedule = async () => {
|
|
1345
|
-
if (!scheduleSubmit) return;
|
|
1346
|
-
if (scheduleSubmitMode === "another") {
|
|
1347
|
-
setScheduleSubmitMode("schedule");
|
|
1348
|
-
updateScheduleSubmitState();
|
|
1349
|
-
return;
|
|
1350
|
-
}
|
|
1351
|
-
if (!canSubmitSchedule()) {
|
|
1352
|
-
updateScheduleSubmitState();
|
|
1353
|
-
return;
|
|
1354
|
-
}
|
|
1355
|
-
if (!scheduleBoot.scheduleEndpoint) {
|
|
1356
|
-
setScheduleNote("Sign in as the post owner before scheduling.", { tone: "error" });
|
|
1357
|
-
return;
|
|
1358
|
-
}
|
|
1359
|
-
const channel = selectedChannel();
|
|
1360
|
-
if (!channel) {
|
|
1361
|
-
setScheduleNote("Choose a channel before scheduling.", { tone: "error" });
|
|
1362
|
-
return;
|
|
1363
|
-
}
|
|
1364
|
-
const scheduledAt = selectedScheduleIso();
|
|
1365
|
-
if (!scheduledAt) {
|
|
1366
|
-
setScheduleNote("Choose a valid date and time.", { tone: "error" });
|
|
1367
|
-
return;
|
|
1368
|
-
}
|
|
1369
|
-
if (Date.parse(scheduledAt) < Date.now() + minScheduleLeadMs) {
|
|
1370
|
-
setScheduleNote("Choose a time at least 10 minutes from now.", { tone: "error" });
|
|
1371
|
-
return;
|
|
1372
|
-
}
|
|
1373
|
-
const destinationType = isEmailScheduleChannel(channel) ? "email" : "flockposter";
|
|
1374
|
-
const additionalNotes = destinationType === "email" ? String(additionalNotesInput?.value || "").trim() : "";
|
|
1375
|
-
isScheduleSubmitting = true;
|
|
1376
|
-
updateScheduleSubmitState();
|
|
1377
|
-
scheduleSubmit.textContent = "Scheduling...";
|
|
1378
|
-
try {
|
|
1379
|
-
const response = await fetch(scheduleBoot.scheduleEndpoint, {
|
|
1380
|
-
method: "POST",
|
|
1381
|
-
credentials: "same-origin",
|
|
1382
|
-
headers: {
|
|
1383
|
-
"Content-Type": "application/json",
|
|
1384
|
-
accept: "application/json"
|
|
1385
|
-
},
|
|
1386
|
-
body: JSON.stringify({
|
|
1387
|
-
destination_type: destinationType,
|
|
1388
|
-
destination_id: channel.id,
|
|
1389
|
-
scheduled_at: scheduledAt,
|
|
1390
|
-
timezone: timezoneSelect?.value || null,
|
|
1391
|
-
additional_notes: additionalNotes || undefined
|
|
1392
|
-
})
|
|
1393
|
-
});
|
|
1394
|
-
const payload = await response.json().catch(() => ({}));
|
|
1395
|
-
if (!response.ok) {
|
|
1396
|
-
throw new Error(typeof payload?.error === "string" ? payload.error : "Unable to schedule post.");
|
|
1397
|
-
}
|
|
1398
|
-
const channelName = channel.name || channel.title || channel.id || "channel";
|
|
1399
|
-
showScheduleToast("Scheduled to " + channelName + " · " + toastDateFormatter.format(new Date(scheduledAt)));
|
|
1400
|
-
clearScheduleNote();
|
|
1401
|
-
setScheduleSubmitMode("another");
|
|
1402
|
-
await refreshScheduleCalendar({ force: true });
|
|
1403
|
-
} catch (error) {
|
|
1404
|
-
setScheduleNote(error instanceof Error ? error.message : "Unable to schedule post.", { tone: "error" });
|
|
1405
|
-
} finally {
|
|
1406
|
-
isScheduleSubmitting = false;
|
|
1407
|
-
updateScheduleSubmitState();
|
|
1408
|
-
if (scheduleSubmitMode !== "another") {
|
|
1409
|
-
setScheduleSubmitMode("schedule");
|
|
1410
|
-
}
|
|
1411
|
-
}
|
|
1412
|
-
};
|
|
1413
|
-
|
|
1414
|
-
channelTrigger?.addEventListener("click", (event) => {
|
|
1415
|
-
event.preventDefault();
|
|
1416
|
-
closePostPopover();
|
|
1417
|
-
if (channelMenu?.hidden === false) {
|
|
1418
|
-
closeChannelMenu();
|
|
1419
|
-
} else {
|
|
1420
|
-
openChannelMenu();
|
|
1421
|
-
}
|
|
1422
|
-
});
|
|
1423
|
-
channelSearch?.addEventListener("input", () => {
|
|
1424
|
-
channelSearchQuery = String(channelSearch.value || "");
|
|
1425
|
-
renderChannelList();
|
|
1426
|
-
});
|
|
1427
|
-
scheduleDateTimeShell?.addEventListener("click", showDateTimePicker);
|
|
1428
|
-
scheduleDateTimeInput?.addEventListener("focus", showDateTimePicker);
|
|
1429
|
-
scheduleDateTimeInput?.addEventListener("input", () => {
|
|
1430
|
-
hasInteractedWithScheduleDateTime = true;
|
|
1431
|
-
updateScheduleSubmitState();
|
|
1432
|
-
});
|
|
1433
|
-
scheduleDateTimeInput?.addEventListener("change", syncDateFromDateTimeInput);
|
|
1434
|
-
scheduleSubmit?.addEventListener("click", () => {
|
|
1435
|
-
void submitSchedule();
|
|
1436
|
-
});
|
|
1437
|
-
if (timezoneSelect) {
|
|
1438
|
-
const timezoneCities = {
|
|
1439
|
-
"-12": "Baker Island",
|
|
1440
|
-
"-11": "Pago Pago",
|
|
1441
|
-
"-10": "Honolulu",
|
|
1442
|
-
"-9": "Anchorage",
|
|
1443
|
-
"-8": "Los Angeles",
|
|
1444
|
-
"-7": "Denver",
|
|
1445
|
-
"-6": "Chicago",
|
|
1446
|
-
"-5": "New York",
|
|
1447
|
-
"-4": "Toronto",
|
|
1448
|
-
"-3": "Sao Paulo",
|
|
1449
|
-
"-2": "South Georgia",
|
|
1450
|
-
"-1": "Azores",
|
|
1451
|
-
"0": "London",
|
|
1452
|
-
"1": "Paris",
|
|
1453
|
-
"2": "Cairo",
|
|
1454
|
-
"3": "Istanbul",
|
|
1455
|
-
"4": "Dubai",
|
|
1456
|
-
"5": "Karachi",
|
|
1457
|
-
"6": "Dhaka",
|
|
1458
|
-
"7": "Bangkok",
|
|
1459
|
-
"8": "Singapore",
|
|
1460
|
-
"9": "Tokyo",
|
|
1461
|
-
"10": "Sydney",
|
|
1462
|
-
"11": "Noumea",
|
|
1463
|
-
"12": "Auckland",
|
|
1464
|
-
"13": "Apia",
|
|
1465
|
-
"14": "Kiritimati"
|
|
1466
|
-
};
|
|
1467
|
-
timezoneSelect.innerHTML = "";
|
|
1468
|
-
for (let offset = -12; offset <= 14; offset += 1) {
|
|
1469
|
-
const sign = offset >= 0 ? "+" : "-";
|
|
1470
|
-
const value = "GMT" + sign + String(Math.abs(offset)).padStart(2, "0") + ":00";
|
|
1471
|
-
timezoneSelect.append(createOption(value + " · " + timezoneCities[String(offset)], value));
|
|
1472
|
-
}
|
|
1473
|
-
const localOffset = -new Date().getTimezoneOffset() / 60;
|
|
1474
|
-
const roundedOffset = Math.max(-12, Math.min(14, Math.round(localOffset)));
|
|
1475
|
-
const localSign = roundedOffset >= 0 ? "+" : "-";
|
|
1476
|
-
timezoneSelect.value = "GMT" + localSign + String(Math.abs(roundedOffset)).padStart(2, "0") + ":00";
|
|
1477
|
-
timezoneSelect.addEventListener("change", () => {
|
|
1478
|
-
hasInteractedWithScheduleDateTime = true;
|
|
1479
|
-
updateScheduleSubmitState();
|
|
1480
|
-
});
|
|
1481
|
-
}
|
|
1482
|
-
document.querySelector("[data-schedule-prev-month]")?.addEventListener("click", () => {
|
|
1483
|
-
calendarCursor = new Date(calendarCursor.getFullYear(), calendarCursor.getMonth() - 1, 1);
|
|
1484
|
-
closePostPopover();
|
|
1485
|
-
renderCalendar();
|
|
1486
|
-
void refreshScheduleCalendar();
|
|
1487
|
-
});
|
|
1488
|
-
document.querySelector("[data-schedule-next-month]")?.addEventListener("click", () => {
|
|
1489
|
-
calendarCursor = new Date(calendarCursor.getFullYear(), calendarCursor.getMonth() + 1, 1);
|
|
1490
|
-
closePostPopover();
|
|
1491
|
-
renderCalendar();
|
|
1492
|
-
void refreshScheduleCalendar();
|
|
1493
|
-
});
|
|
1494
|
-
document.addEventListener("pointerdown", (event) => {
|
|
1495
|
-
if (channelPicker && !channelPicker.contains(event.target)) {
|
|
1496
|
-
closeChannelMenu();
|
|
1497
|
-
}
|
|
1498
|
-
if (!event.target.closest("[data-schedule-post-popover]") && !event.target.closest(".ready-post-calendar-day")) {
|
|
1499
|
-
closePostPopover();
|
|
1500
|
-
}
|
|
1501
|
-
});
|
|
1502
|
-
window.addEventListener("resize", closePostPopover);
|
|
1503
|
-
window.addEventListener("vidfarm:flockposter-cache-updated", () => {
|
|
1504
|
-
applyScheduleCache();
|
|
1505
|
-
renderChannelPicker();
|
|
1506
|
-
renderCalendar();
|
|
1507
|
-
});
|
|
1508
|
-
applyScheduleCache();
|
|
1509
|
-
renderChannelPicker();
|
|
1510
|
-
renderCalendar();
|
|
1511
|
-
void hydrateScheduleChannelsOnPageLoad();
|
|
1512
|
-
})();
|
|
1513
|
-
</script>`;
|
|
1514
|
-
}
|
|
1515
|
-
//# sourceMappingURL=ready-post-schedule-component.js.map
|