@tomako/tools-runtime 0.1.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +12 -0
- package/package.json +629 -0
- package/src/assets/icons/brands/social/bluesky-icon.tsx +9 -0
- package/src/assets/icons/brands/social/facebook-icon.tsx +9 -0
- package/src/assets/icons/brands/social/index.ts +8 -0
- package/src/assets/icons/brands/social/instagram-icon.tsx +9 -0
- package/src/assets/icons/brands/social/linkedin-icon.tsx +9 -0
- package/src/assets/icons/brands/social/threads-icon.tsx +9 -0
- package/src/assets/icons/brands/social/tiktok-icon.tsx +10 -0
- package/src/assets/icons/brands/social/x-icon.tsx +9 -0
- package/src/assets/icons/brands/social/youtube-icon.tsx +9 -0
- package/src/assets/icons/social-profile/facebook-icon.tsx +12 -0
- package/src/assets/icons/social-profile/index.ts +29 -0
- package/src/assets/icons/social-profile/instagram-icon.tsx +18 -0
- package/src/assets/icons/social-profile/linkedin-icon.tsx +12 -0
- package/src/assets/icons/social-profile/tiktok-icon.tsx +12 -0
- package/src/assets/icons/social-profile/x-icon.tsx +13 -0
- package/src/assets/icons/social-profile/youtube-icon.tsx +12 -0
- package/src/components/tools/engine/form-builder.tsx +219 -0
- package/src/components/tools/engine/package-widget-loader.tsx +38 -0
- package/src/components/tools/engine/package-widget-runtime.tsx +409 -0
- package/src/components/tools/engine/package-widget.tsx +77 -0
- package/src/components/tools/engine/result-view.tsx +596 -0
- package/src/components/tools/engine/use-legacy-llm-task.ts +64 -0
- package/src/components/tools/engine/use-tool-task.ts +195 -0
- package/src/components/tools/market-forecast-report.tsx +1150 -0
- package/src/components/tools/registry.ts +13 -0
- package/src/components/tools/workspace/index.ts +39 -0
- package/src/components/tools/workspace/tool-action-bar.tsx +99 -0
- package/src/components/tools/workspace/tool-empty-panel.tsx +32 -0
- package/src/components/tools/workspace/tool-error-panel.tsx +40 -0
- package/src/components/tools/workspace/tool-field.tsx +124 -0
- package/src/components/tools/workspace/tool-file-upload.tsx +112 -0
- package/src/components/tools/workspace/tool-form-section.tsx +21 -0
- package/src/components/tools/workspace/tool-form-shell.tsx +36 -0
- package/src/components/tools/workspace/tool-loading-panel.tsx +269 -0
- package/src/components/tools/workspace/tool-option-row.tsx +97 -0
- package/src/components/tools/workspace/tool-preview-panel.tsx +31 -0
- package/src/components/tools/workspace/tool-result-actions.tsx +67 -0
- package/src/components/tools/workspace/tool-result-file-actions.ts +31 -0
- package/src/components/tools/workspace/tool-result-header.tsx +39 -0
- package/src/components/tools/workspace/tool-status.tsx +13 -0
- package/src/components/tools/workspace/tool-workspace-layout.tsx +226 -0
- package/src/constants/LKS.ts +29 -0
- package/src/constants/related-tools.ts +18 -0
- package/src/constants/social-profile-kit.ts +284 -0
- package/src/constants/tool-assets.ts +7 -0
- package/src/env.d.ts +3 -0
- package/src/features/tools/_templates/standard-tool.container.tsx +90 -0
- package/src/features/tools/app-icon-resizer/app-icon-resizer.container.tsx +11 -0
- package/src/features/tools/app-icon-resizer/app-icon-resizer.spec.ts +15 -0
- package/src/features/tools/app-icon-resizer/widget/app-icon-resizer.tsx +444 -0
- package/src/features/tools/app-icon-resizer/widget/constants.ts +19 -0
- package/src/features/tools/app-icon-resizer/widget/helpers.ts +314 -0
- package/src/features/tools/app-icon-resizer/widget/index.ts +7 -0
- package/src/features/tools/app-icon-resizer/widget/platform-icons.tsx +59 -0
- package/src/features/tools/app-icon-resizer/widget/preview-dialogs.tsx +139 -0
- package/src/features/tools/app-icon-resizer/widget/result-shell.tsx +165 -0
- package/src/features/tools/app-icon-resizer/widget/types.ts +36 -0
- package/src/features/tools/app-store-screenshot-generator/app-store-screenshot-generator.container.tsx +108 -0
- package/src/features/tools/app-store-screenshot-generator/app-store-screenshot-generator.spec.ts +14 -0
- package/src/features/tools/app-store-screenshot-generator/config.ts +3 -0
- package/src/features/tools/app-store-screenshot-generator/widget/app-store-screenshot-generator.tsx +1250 -0
- package/src/features/tools/app-store-screenshot-generator/widget/asset-slots.ts +76 -0
- package/src/features/tools/app-store-screenshot-generator/widget/constants.ts +43 -0
- package/src/features/tools/app-store-screenshot-generator/widget/form-controls.tsx +214 -0
- package/src/features/tools/app-store-screenshot-generator/widget/generation.ts +528 -0
- package/src/features/tools/app-store-screenshot-generator/widget/index.ts +7 -0
- package/src/features/tools/app-store-screenshot-generator/widget/input-media.ts +175 -0
- package/src/features/tools/app-store-screenshot-generator/widget/types.ts +60 -0
- package/src/features/tools/app-store-screenshot-generator/widget/zip.ts +119 -0
- package/src/features/tools/build-in-public-story-generator/build-in-public-story-generator.container.tsx +135 -0
- package/src/features/tools/build-in-public-story-generator/build-in-public-story-generator.spec.ts +15 -0
- package/src/features/tools/build-in-public-story-generator/widget/build-in-public-story-generator.tsx +314 -0
- package/src/features/tools/build-in-public-story-generator/widget/constants.ts +3 -0
- package/src/features/tools/build-in-public-story-generator/widget/helpers.ts +25 -0
- package/src/features/tools/build-in-public-story-generator/widget/index.ts +7 -0
- package/src/features/tools/build-in-public-story-generator/widget/preview-panels.tsx +58 -0
- package/src/features/tools/build-in-public-story-generator/widget/result-shell.tsx +164 -0
- package/src/features/tools/build-in-public-story-generator/widget/types.ts +6 -0
- package/src/features/tools/cold-start-channel-selector/cold-start-channel-selector.container.tsx +30 -0
- package/src/features/tools/cold-start-channel-selector/cold-start-channel-selector.spec.ts +15 -0
- package/src/features/tools/cold-start-channel-selector/widget/cold-start-channel-selector.tsx +417 -0
- package/src/features/tools/cold-start-channel-selector/widget/constants.ts +46 -0
- package/src/features/tools/cold-start-channel-selector/widget/form-controls.tsx +41 -0
- package/src/features/tools/cold-start-channel-selector/widget/helpers.ts +75 -0
- package/src/features/tools/cold-start-channel-selector/widget/index.ts +7 -0
- package/src/features/tools/cold-start-channel-selector/widget/preview-panels.tsx +250 -0
- package/src/features/tools/cold-start-channel-selector/widget/result-shell.tsx +199 -0
- package/src/features/tools/cold-start-channel-selector/widget/types.ts +21 -0
- package/src/features/tools/commercial-bp-generator/commercial-bp-generator.container.tsx +102 -0
- package/src/features/tools/commercial-bp-generator/commercial-bp-generator.spec.ts +14 -0
- package/src/features/tools/commercial-bp-generator/widget/commercial-bp-generator.tsx +676 -0
- package/src/features/tools/commercial-bp-generator/widget/constants.ts +32 -0
- package/src/features/tools/commercial-bp-generator/widget/helpers.ts +147 -0
- package/src/features/tools/commercial-bp-generator/widget/index.ts +7 -0
- package/src/features/tools/commercial-bp-generator/widget/result-shell.tsx +271 -0
- package/src/features/tools/commercial-bp-generator/widget/style-option.tsx +54 -0
- package/src/features/tools/commercial-bp-generator/widget/types.ts +33 -0
- package/src/features/tools/community-feedback-inbox/community-feedback-inbox.container.tsx +126 -0
- package/src/features/tools/community-feedback-inbox/community-feedback-inbox.spec.ts +15 -0
- package/src/features/tools/community-feedback-inbox/widget/community-feedback-inbox.tsx +271 -0
- package/src/features/tools/community-feedback-inbox/widget/constants.ts +3 -0
- package/src/features/tools/community-feedback-inbox/widget/helpers.ts +28 -0
- package/src/features/tools/community-feedback-inbox/widget/index.ts +7 -0
- package/src/features/tools/community-feedback-inbox/widget/preview-panels.tsx +92 -0
- package/src/features/tools/community-feedback-inbox/widget/result-shell.tsx +266 -0
- package/src/features/tools/community-feedback-inbox/widget/types.ts +6 -0
- package/src/features/tools/community-pain-point-extractor/community-pain-point-extractor.container.tsx +124 -0
- package/src/features/tools/community-pain-point-extractor/community-pain-point-extractor.spec.ts +15 -0
- package/src/features/tools/community-pain-point-extractor/widget/community-pain-point-extractor.tsx +404 -0
- package/src/features/tools/community-pain-point-extractor/widget/constants.ts +41 -0
- package/src/features/tools/community-pain-point-extractor/widget/helpers.ts +76 -0
- package/src/features/tools/community-pain-point-extractor/widget/index.ts +8 -0
- package/src/features/tools/community-pain-point-extractor/widget/progress-panels.tsx +251 -0
- package/src/features/tools/community-pain-point-extractor/widget/result-shell.tsx +478 -0
- package/src/features/tools/community-pain-point-extractor/widget/types.ts +33 -0
- package/src/features/tools/community-post-risk-checker/community-post-risk-checker.package.ts +792 -0
- package/src/features/tools/competitor-analysis/competitor-analysis.container.tsx +136 -0
- package/src/features/tools/competitor-analysis/competitor-analysis.spec.ts +15 -0
- package/src/features/tools/competitor-analysis/widget/competitor-analysis.tsx +241 -0
- package/src/features/tools/competitor-analysis/widget/constants.ts +9 -0
- package/src/features/tools/competitor-analysis/widget/index.ts +7 -0
- package/src/features/tools/competitor-analysis/widget/preview-panels.tsx +60 -0
- package/src/features/tools/competitor-analysis/widget/result-shell.tsx +418 -0
- package/src/features/tools/competitor-analysis/widget/types.ts +13 -0
- package/src/features/tools/disclaimer-generator/disclaimer-generator.package.ts +339 -0
- package/src/features/tools/email-template-generator/email-template-generator.container.tsx +224 -0
- package/src/features/tools/email-template-generator/email-template-generator.spec.ts +14 -0
- package/src/features/tools/email-template-generator/widget/email-template-generator.tsx +358 -0
- package/src/features/tools/email-template-generator/widget/helpers.ts +39 -0
- package/src/features/tools/email-template-generator/widget/index.ts +7 -0
- package/src/features/tools/email-template-generator/widget/preview-panel.tsx +311 -0
- package/src/features/tools/email-template-generator/widget/result-text-block.tsx +7 -0
- package/src/features/tools/email-template-generator/widget/types.ts +24 -0
- package/src/features/tools/gtm-readiness-checklist/gtm-readiness-checklist.container.tsx +75 -0
- package/src/features/tools/gtm-readiness-checklist/gtm-readiness-checklist.spec.ts +15 -0
- package/src/features/tools/gtm-readiness-checklist/widget/gtm-readiness-checklist.tsx +122 -0
- package/src/features/tools/gtm-readiness-checklist/widget/index.ts +7 -0
- package/src/features/tools/investor-matching-planner/investor-matching-planner.package.ts +869 -0
- package/src/features/tools/koko-codex-assistant/koko-codex-assistant.container.tsx +151 -0
- package/src/features/tools/koko-codex-assistant/koko-codex-assistant.spec.ts +14 -0
- package/src/features/tools/koko-codex-assistant/widget/index.ts +7 -0
- package/src/features/tools/koko-codex-assistant/widget/koko-codex-assistant-download.tsx +192 -0
- package/src/features/tools/logo-generator/logo-generator.container.tsx +112 -0
- package/src/features/tools/logo-generator/logo-generator.spec.ts +15 -0
- package/src/features/tools/logo-generator/widget/index.ts +7 -0
- package/src/features/tools/logo-generator/widget/logo-generator.tsx +1244 -0
- package/src/features/tools/market-forecast-report/market-forecast-report.container.tsx +73 -0
- package/src/features/tools/market-forecast-report/market-forecast-report.spec.ts +15 -0
- package/src/features/tools/million-user-growth-test/million-user-growth-test.container.tsx +123 -0
- package/src/features/tools/million-user-growth-test/million-user-growth-test.spec.ts +14 -0
- package/src/features/tools/million-user-growth-test/widget/index.ts +7 -0
- package/src/features/tools/million-user-growth-test/widget/million-user-growth-test.tsx +433 -0
- package/src/features/tools/module-loader.ts +107 -0
- package/src/features/tools/og-image-generator/og-image-generator.container.tsx +86 -0
- package/src/features/tools/og-image-generator/og-image-generator.spec.ts +14 -0
- package/src/features/tools/og-image-generator/widget/constants.ts +38 -0
- package/src/features/tools/og-image-generator/widget/form-fields.tsx +240 -0
- package/src/features/tools/og-image-generator/widget/index.ts +7 -0
- package/src/features/tools/og-image-generator/widget/og-image-generator.tsx +742 -0
- package/src/features/tools/og-image-generator/widget/preview-panel.tsx +305 -0
- package/src/features/tools/og-image-generator/widget/types.ts +1 -0
- package/src/features/tools/package/direct-models.ts +20 -0
- package/src/features/tools/package/form.ts +38 -0
- package/src/features/tools/package/l10n.ts +22 -0
- package/src/features/tools/package/package-container.tsx +285 -0
- package/src/features/tools/package/package-loaders.ts +22 -0
- package/src/features/tools/package/package-registry.ts +36 -0
- package/src/features/tools/package/result-markdown.ts +142 -0
- package/src/features/tools/package/schema.ts +379 -0
- package/src/features/tools/package/to-tool-module.ts +20 -0
- package/src/features/tools/package/to-tool-spec.ts +52 -0
- package/src/features/tools/package/types.ts +381 -0
- package/src/features/tools/pitch-deck-generator/pitch-deck-generator.container.tsx +175 -0
- package/src/features/tools/pitch-deck-generator/pitch-deck-generator.spec.ts +14 -0
- package/src/features/tools/pitch-deck-generator/pitch-deck-library-data.ts +476 -0
- package/src/features/tools/pitch-deck-generator/pitch-deck-library.tsx +159 -0
- package/src/features/tools/pitch-deck-generator/widget/ceremony-line.tsx +27 -0
- package/src/features/tools/pitch-deck-generator/widget/constants.ts +27 -0
- package/src/features/tools/pitch-deck-generator/widget/index.ts +7 -0
- package/src/features/tools/pitch-deck-generator/widget/pitch-deck-generator.tsx +763 -0
- package/src/features/tools/pitch-deck-generator/widget/result-helpers.ts +102 -0
- package/src/features/tools/pitch-deck-generator/widget/result-shell.tsx +263 -0
- package/src/features/tools/pitch-deck-generator/widget/slide-frame.tsx +106 -0
- package/src/features/tools/pitch-deck-generator/widget/slide-lightbox.tsx +149 -0
- package/src/features/tools/pitch-deck-generator/widget/style-option.tsx +54 -0
- package/src/features/tools/pitch-deck-generator/widget/types.ts +44 -0
- package/src/features/tools/product-agreement-generator/product-agreement-generator.container.tsx +137 -0
- package/src/features/tools/product-agreement-generator/product-agreement-generator.spec.ts +14 -0
- package/src/features/tools/product-agreement-generator/widget/constants.ts +27 -0
- package/src/features/tools/product-agreement-generator/widget/form-controls.tsx +218 -0
- package/src/features/tools/product-agreement-generator/widget/helpers.ts +68 -0
- package/src/features/tools/product-agreement-generator/widget/index.ts +7 -0
- package/src/features/tools/product-agreement-generator/widget/product-agreement-generator.tsx +671 -0
- package/src/features/tools/product-agreement-generator/widget/result-shell.tsx +473 -0
- package/src/features/tools/product-agreement-generator/widget/types.ts +89 -0
- package/src/features/tools/product-hunt-launch-planner/product-hunt-launch-planner.container.tsx +122 -0
- package/src/features/tools/product-hunt-launch-planner/product-hunt-launch-planner.spec.ts +15 -0
- package/src/features/tools/product-hunt-launch-planner/widget/constants.ts +5 -0
- package/src/features/tools/product-hunt-launch-planner/widget/helpers.ts +44 -0
- package/src/features/tools/product-hunt-launch-planner/widget/index.ts +7 -0
- package/src/features/tools/product-hunt-launch-planner/widget/preview-panel.tsx +143 -0
- package/src/features/tools/product-hunt-launch-planner/widget/product-hunt-launch-planner.tsx +504 -0
- package/src/features/tools/product-hunt-launch-planner/widget/result-shell.tsx +176 -0
- package/src/features/tools/product-hunt-launch-planner/widget/types.ts +20 -0
- package/src/features/tools/product-name-generator/product-name-generator.container.tsx +14 -0
- package/src/features/tools/product-name-generator/product-name-generator.spec.ts +15 -0
- package/src/features/tools/product-name-generator/widget/candidate-card.tsx +273 -0
- package/src/features/tools/product-name-generator/widget/constants.ts +21 -0
- package/src/features/tools/product-name-generator/widget/form-controls.tsx +136 -0
- package/src/features/tools/product-name-generator/widget/helpers.ts +41 -0
- package/src/features/tools/product-name-generator/widget/index.ts +7 -0
- package/src/features/tools/product-name-generator/widget/product-name-generator.tsx +776 -0
- package/src/features/tools/product-name-generator/widget/types.ts +36 -0
- package/src/features/tools/product-positioning-analyzer/product-positioning-analyzer.package.ts +801 -0
- package/src/features/tools/product-poster-generator/product-poster-generator.container.tsx +14 -0
- package/src/features/tools/product-poster-generator/product-poster-generator.spec.ts +15 -0
- package/src/features/tools/product-poster-generator/widget/constants.ts +125 -0
- package/src/features/tools/product-poster-generator/widget/form-controls.tsx +204 -0
- package/src/features/tools/product-poster-generator/widget/helpers.ts +155 -0
- package/src/features/tools/product-poster-generator/widget/index.ts +7 -0
- package/src/features/tools/product-poster-generator/widget/product-poster-generator.tsx +663 -0
- package/src/features/tools/product-poster-generator/widget/result-shell.tsx +12 -0
- package/src/features/tools/product-poster-generator/widget/types.ts +83 -0
- package/src/features/tools/product-ui-generator/product-ui-generator.container.tsx +116 -0
- package/src/features/tools/product-ui-generator/product-ui-generator.spec.ts +14 -0
- package/src/features/tools/product-ui-generator/widget/constants.ts +18 -0
- package/src/features/tools/product-ui-generator/widget/helpers.ts +11 -0
- package/src/features/tools/product-ui-generator/widget/index.ts +7 -0
- package/src/features/tools/product-ui-generator/widget/preview-panels.tsx +73 -0
- package/src/features/tools/product-ui-generator/widget/product-ui-generator.tsx +304 -0
- package/src/features/tools/product-ui-generator/widget/result-shell.tsx +118 -0
- package/src/features/tools/product-ui-generator/widget/types.ts +9 -0
- package/src/features/tools/reddit-pain-point-finder/reddit-pain-point-finder.container.tsx +113 -0
- package/src/features/tools/reddit-pain-point-finder/reddit-pain-point-finder.spec.ts +15 -0
- package/src/features/tools/reddit-pain-point-finder/widget/constants.ts +5 -0
- package/src/features/tools/reddit-pain-point-finder/widget/index.ts +7 -0
- package/src/features/tools/reddit-pain-point-finder/widget/preview-panels.tsx +73 -0
- package/src/features/tools/reddit-pain-point-finder/widget/reddit-pain-point-finder.tsx +281 -0
- package/src/features/tools/reddit-pain-point-finder/widget/result-shell.tsx +203 -0
- package/src/features/tools/reddit-pain-point-finder/widget/types.ts +15 -0
- package/src/features/tools/registry.ts +288 -0
- package/src/features/tools/runtime-registry.ts +186 -0
- package/src/features/tools/shared/create-guide-stack-container.tsx +176 -0
- package/src/features/tools/shared/create-standard-landing-container.tsx +163 -0
- package/src/features/tools/shared/tool-content-sections.tsx +659 -0
- package/src/features/tools/shared/tool-cta.tsx +66 -0
- package/src/features/tools/shared/tool-draft-view.tsx +53 -0
- package/src/features/tools/shared/tool-guide-section.tsx +191 -0
- package/src/features/tools/shared/tool-handoff.tsx +38 -0
- package/src/features/tools/shared/tool-mcp-badge.tsx +23 -0
- package/src/features/tools/shared/tool-message-translator.ts +37 -0
- package/src/features/tools/shared/tool-page-shell.tsx +348 -0
- package/src/features/tools/shared/tool-standard-generation-steps.tsx +52 -0
- package/src/features/tools/shared/tool-standard-landing-sections.tsx +447 -0
- package/src/features/tools/shared/tool-ui-registry.ts +237 -0
- package/src/features/tools/shared/tool-widget-slot.tsx +29 -0
- package/src/features/tools/slogan-generator/slogan-generator.package.ts +641 -0
- package/src/features/tools/social-listening-research-report/social-listening-research-report.container.tsx +124 -0
- package/src/features/tools/social-listening-research-report/social-listening-research-report.spec.ts +15 -0
- package/src/features/tools/social-listening-research-report/widget/constants.ts +4 -0
- package/src/features/tools/social-listening-research-report/widget/index.ts +7 -0
- package/src/features/tools/social-listening-research-report/widget/preview-panels.tsx +73 -0
- package/src/features/tools/social-listening-research-report/widget/result-shell.tsx +216 -0
- package/src/features/tools/social-listening-research-report/widget/social-listening-research-report.tsx +303 -0
- package/src/features/tools/social-listening-research-report/widget/types.ts +15 -0
- package/src/features/tools/social-platform-asset-adapter/social-platform-asset-adapter.container.tsx +123 -0
- package/src/features/tools/social-platform-asset-adapter/social-platform-asset-adapter.spec.ts +15 -0
- package/src/features/tools/social-platform-asset-adapter/widget/constants.ts +43 -0
- package/src/features/tools/social-platform-asset-adapter/widget/helpers.ts +249 -0
- package/src/features/tools/social-platform-asset-adapter/widget/index.ts +7 -0
- package/src/features/tools/social-platform-asset-adapter/widget/result-shell.tsx +350 -0
- package/src/features/tools/social-platform-asset-adapter/widget/section-heading.tsx +18 -0
- package/src/features/tools/social-platform-asset-adapter/widget/social-platform-asset-adapter.tsx +641 -0
- package/src/features/tools/social-platform-asset-adapter/widget/types.ts +40 -0
- package/src/features/tools/social-profile-kit/social-profile-kit.container.tsx +177 -0
- package/src/features/tools/social-profile-kit/social-profile-kit.spec.ts +15 -0
- package/src/features/tools/social-profile-kit/widget/context-editor.tsx +171 -0
- package/src/features/tools/social-profile-kit/widget/generation-runtime.ts +281 -0
- package/src/features/tools/social-profile-kit/widget/index.ts +7 -0
- package/src/features/tools/social-profile-kit/widget/input-panel.tsx +294 -0
- package/src/features/tools/social-profile-kit/widget/platform-dock.tsx +115 -0
- package/src/features/tools/social-profile-kit/widget/profile-canvas.tsx +318 -0
- package/src/features/tools/social-profile-kit/widget/profile-preview/bluesky-preview.tsx +188 -0
- package/src/features/tools/social-profile-kit/widget/profile-preview/facebook-preview.tsx +168 -0
- package/src/features/tools/social-profile-kit/widget/profile-preview/index.ts +1 -0
- package/src/features/tools/social-profile-kit/widget/profile-preview/instagram-preview.tsx +278 -0
- package/src/features/tools/social-profile-kit/widget/profile-preview/linkedin-preview.tsx +358 -0
- package/src/features/tools/social-profile-kit/widget/profile-preview/profile-preview.tsx +348 -0
- package/src/features/tools/social-profile-kit/widget/profile-preview/shared.tsx +391 -0
- package/src/features/tools/social-profile-kit/widget/profile-preview/threads-preview.tsx +148 -0
- package/src/features/tools/social-profile-kit/widget/profile-preview/tiktok-preview.tsx +319 -0
- package/src/features/tools/social-profile-kit/widget/profile-preview/x-preview.tsx +341 -0
- package/src/features/tools/social-profile-kit/widget/profile-preview/youtube-preview.tsx +297 -0
- package/src/features/tools/social-profile-kit/widget/social-profile-kit-generator.tsx +1059 -0
- package/src/features/tools/social-profile-kit/widget/types.ts +104 -0
- package/src/features/tools/spec-registry.ts +158 -0
- package/src/features/tools/startup-idea-research/startup-idea-research.container.tsx +111 -0
- package/src/features/tools/startup-idea-research/startup-idea-research.spec.ts +15 -0
- package/src/features/tools/startup-idea-research/widget/constants.ts +11 -0
- package/src/features/tools/startup-idea-research/widget/index.ts +7 -0
- package/src/features/tools/startup-idea-research/widget/preview-panels.tsx +67 -0
- package/src/features/tools/startup-idea-research/widget/result-shell.tsx +323 -0
- package/src/features/tools/startup-idea-research/widget/startup-idea-research.tsx +272 -0
- package/src/features/tools/startup-idea-research/widget/types.ts +21 -0
- package/src/features/tools/tarot-reading/tarot-reading.container.tsx +412 -0
- package/src/features/tools/tarot-reading/tarot-reading.spec.ts +15 -0
- package/src/features/tools/tarot-reading/widget/cards.tsx +152 -0
- package/src/features/tools/tarot-reading/widget/constants.ts +69 -0
- package/src/features/tools/tarot-reading/widget/deck-view.tsx +86 -0
- package/src/features/tools/tarot-reading/widget/deck.ts +86 -0
- package/src/features/tools/tarot-reading/widget/index.ts +7 -0
- package/src/features/tools/tarot-reading/widget/landing-view.tsx +209 -0
- package/src/features/tools/tarot-reading/widget/reading-copy.tsx +138 -0
- package/src/features/tools/tarot-reading/widget/reading-view.tsx +189 -0
- package/src/features/tools/tarot-reading/widget/reveal-view.tsx +50 -0
- package/src/features/tools/tarot-reading/widget/ritual-view.tsx +276 -0
- package/src/features/tools/tarot-reading/widget/tarot-reading.tsx +262 -0
- package/src/features/tools/tarot-reading/widget/types.ts +22 -0
- package/src/features/tools/twitter-gif-downloader/twitter-gif-downloader.container.tsx +114 -0
- package/src/features/tools/twitter-gif-downloader/twitter-gif-downloader.spec.ts +14 -0
- package/src/features/tools/twitter-gif-downloader/widget/index.ts +7 -0
- package/src/features/tools/twitter-gif-downloader/widget/twitter-gif-downloader.tsx +351 -0
- package/src/features/tools/types.ts +68 -0
- package/src/features/tools/user-interview-guide-generator/user-interview-guide-generator.package.ts +774 -0
- package/src/features/tools/user-interview-insight-report-generator/user-interview-insight-report-generator.container.tsx +23 -0
- package/src/features/tools/user-interview-insight-report-generator/user-interview-insight-report-generator.spec.ts +14 -0
- package/src/features/tools/user-interview-insight-report-generator/widget/constants.ts +8 -0
- package/src/features/tools/user-interview-insight-report-generator/widget/helpers.ts +4 -0
- package/src/features/tools/user-interview-insight-report-generator/widget/index.ts +7 -0
- package/src/features/tools/user-interview-insight-report-generator/widget/preview-panels.tsx +55 -0
- package/src/features/tools/user-interview-insight-report-generator/widget/result-shell.tsx +122 -0
- package/src/features/tools/user-interview-insight-report-generator/widget/types.ts +16 -0
- package/src/features/tools/user-interview-insight-report-generator/widget/user-interview-insight-report-generator.tsx +293 -0
- package/src/features/tools/user-interview-record-generator/user-interview-record-generator.container.tsx +18 -0
- package/src/features/tools/user-interview-record-generator/user-interview-record-generator.spec.ts +14 -0
- package/src/features/tools/user-interview-record-generator/widget/constants.ts +9 -0
- package/src/features/tools/user-interview-record-generator/widget/helpers.ts +4 -0
- package/src/features/tools/user-interview-record-generator/widget/index.ts +7 -0
- package/src/features/tools/user-interview-record-generator/widget/preview-panels.tsx +48 -0
- package/src/features/tools/user-interview-record-generator/widget/result-shell.tsx +128 -0
- package/src/features/tools/user-interview-record-generator/widget/types.ts +16 -0
- package/src/features/tools/user-interview-record-generator/widget/user-interview-record-generator.tsx +305 -0
- package/src/features/tools/utm-builder/utm-builder.package.ts +846 -0
- package/src/features/tools/widget-registry.ts +73 -0
- package/src/generated/mcp-tools-registry.json +17 -0
- package/src/host/client-proxy.test.ts +33 -0
- package/src/host/client.ts +678 -0
- package/src/host/server.ts +119 -0
- package/src/i18n/client.ts +11 -0
- package/src/i18n/locale-fallback.ts +38 -0
- package/src/i18n/locale.ts +18 -0
- package/src/i18n/messages/en/page/tools.ts +124 -0
- package/src/i18n/messages/en/tools/app-icon-resizer.ts +244 -0
- package/src/i18n/messages/en/tools/app-store-screenshot-generator.ts +145 -0
- package/src/i18n/messages/en/tools/build-in-public-story-generator.ts +229 -0
- package/src/i18n/messages/en/tools/cold-start-channel-selector.ts +423 -0
- package/src/i18n/messages/en/tools/commercial-bp-generator.ts +304 -0
- package/src/i18n/messages/en/tools/community-feedback-inbox.ts +218 -0
- package/src/i18n/messages/en/tools/community-pain-point-extractor.ts +230 -0
- package/src/i18n/messages/en/tools/community-post-risk-checker.ts +209 -0
- package/src/i18n/messages/en/tools/competitor-analysis.ts +197 -0
- package/src/i18n/messages/en/tools/email-template-generator.ts +302 -0
- package/src/i18n/messages/en/tools/engine.ts +69 -0
- package/src/i18n/messages/en/tools/gtm-readiness-checklist.ts +166 -0
- package/src/i18n/messages/en/tools/index.ts +73 -0
- package/src/i18n/messages/en/tools/koko-codex-assistant.ts +171 -0
- package/src/i18n/messages/en/tools/logo-generator.ts +173 -0
- package/src/i18n/messages/en/tools/market-forecast-report.ts +228 -0
- package/src/i18n/messages/en/tools/million-user-growth-test.ts +386 -0
- package/src/i18n/messages/en/tools/og-image-generator.ts +172 -0
- package/src/i18n/messages/en/tools/pitch-deck-generator.ts +358 -0
- package/src/i18n/messages/en/tools/product-agreement-generator.ts +411 -0
- package/src/i18n/messages/en/tools/product-hunt-launch-planner.ts +272 -0
- package/src/i18n/messages/en/tools/product-name-generator.ts +383 -0
- package/src/i18n/messages/en/tools/product-poster-generator.ts +294 -0
- package/src/i18n/messages/en/tools/product-ui-generator.ts +234 -0
- package/src/i18n/messages/en/tools/reddit-pain-point-finder.ts +163 -0
- package/src/i18n/messages/en/tools/shared.ts +24 -0
- package/src/i18n/messages/en/tools/social-listening-research-report.ts +185 -0
- package/src/i18n/messages/en/tools/social-media-profile-generator.ts +22 -0
- package/src/i18n/messages/en/tools/social-platform-asset-adapter.ts +287 -0
- package/src/i18n/messages/en/tools/social-profile-kit.ts +150 -0
- package/src/i18n/messages/en/tools/startup-idea-research.ts +170 -0
- package/src/i18n/messages/en/tools/tarot-reading.ts +230 -0
- package/src/i18n/messages/en/tools/twitter-gif-downloader.ts +145 -0
- package/src/i18n/messages/en/tools/user-interview-insight-report-generator.ts +242 -0
- package/src/i18n/messages/en/tools/user-interview-record-generator.ts +244 -0
- package/src/i18n/messages/en/tools-ui.ts +704 -0
- package/src/i18n/messages/zh/page/tools.ts +124 -0
- package/src/i18n/messages/zh/tools/app-icon-resizer.ts +242 -0
- package/src/i18n/messages/zh/tools/app-store-screenshot-generator.ts +145 -0
- package/src/i18n/messages/zh/tools/build-in-public-story-generator.ts +230 -0
- package/src/i18n/messages/zh/tools/cold-start-channel-selector.ts +422 -0
- package/src/i18n/messages/zh/tools/commercial-bp-generator.ts +302 -0
- package/src/i18n/messages/zh/tools/community-feedback-inbox.ts +217 -0
- package/src/i18n/messages/zh/tools/community-pain-point-extractor.ts +230 -0
- package/src/i18n/messages/zh/tools/community-post-risk-checker.ts +200 -0
- package/src/i18n/messages/zh/tools/competitor-analysis.ts +192 -0
- package/src/i18n/messages/zh/tools/email-template-generator.ts +302 -0
- package/src/i18n/messages/zh/tools/engine.ts +68 -0
- package/src/i18n/messages/zh/tools/gtm-readiness-checklist.ts +166 -0
- package/src/i18n/messages/zh/tools/index.ts +73 -0
- package/src/i18n/messages/zh/tools/koko-codex-assistant.ts +170 -0
- package/src/i18n/messages/zh/tools/logo-generator.ts +172 -0
- package/src/i18n/messages/zh/tools/market-forecast-report.ts +228 -0
- package/src/i18n/messages/zh/tools/million-user-growth-test.ts +385 -0
- package/src/i18n/messages/zh/tools/og-image-generator.ts +173 -0
- package/src/i18n/messages/zh/tools/pitch-deck-generator.ts +358 -0
- package/src/i18n/messages/zh/tools/product-agreement-generator.ts +401 -0
- package/src/i18n/messages/zh/tools/product-hunt-launch-planner.ts +267 -0
- package/src/i18n/messages/zh/tools/product-name-generator.ts +383 -0
- package/src/i18n/messages/zh/tools/product-poster-generator.ts +282 -0
- package/src/i18n/messages/zh/tools/product-ui-generator.ts +234 -0
- package/src/i18n/messages/zh/tools/reddit-pain-point-finder.ts +162 -0
- package/src/i18n/messages/zh/tools/shared.ts +24 -0
- package/src/i18n/messages/zh/tools/social-listening-research-report.ts +181 -0
- package/src/i18n/messages/zh/tools/social-media-profile-generator.ts +22 -0
- package/src/i18n/messages/zh/tools/social-platform-asset-adapter.ts +284 -0
- package/src/i18n/messages/zh/tools/social-profile-kit.ts +150 -0
- package/src/i18n/messages/zh/tools/startup-idea-research.ts +165 -0
- package/src/i18n/messages/zh/tools/tarot-reading.ts +228 -0
- package/src/i18n/messages/zh/tools/twitter-gif-downloader.ts +138 -0
- package/src/i18n/messages/zh/tools/user-interview-insight-report-generator.ts +224 -0
- package/src/i18n/messages/zh/tools/user-interview-record-generator.ts +226 -0
- package/src/i18n/messages/zh/tools-ui.ts +684 -0
- package/src/i18n/messages/zh-tw/page/tools.ts +115 -0
- package/src/i18n/messages/zh-tw/tools/app-icon-resizer.ts +242 -0
- package/src/i18n/messages/zh-tw/tools/app-store-screenshot-generator.ts +145 -0
- package/src/i18n/messages/zh-tw/tools/build-in-public-story-generator.ts +230 -0
- package/src/i18n/messages/zh-tw/tools/cold-start-channel-selector.ts +440 -0
- package/src/i18n/messages/zh-tw/tools/commercial-bp-generator.ts +302 -0
- package/src/i18n/messages/zh-tw/tools/community-feedback-inbox.ts +217 -0
- package/src/i18n/messages/zh-tw/tools/community-pain-point-extractor.ts +230 -0
- package/src/i18n/messages/zh-tw/tools/community-post-risk-checker.ts +200 -0
- package/src/i18n/messages/zh-tw/tools/competitor-analysis.ts +192 -0
- package/src/i18n/messages/zh-tw/tools/email-template-generator.ts +302 -0
- package/src/i18n/messages/zh-tw/tools/engine.ts +68 -0
- package/src/i18n/messages/zh-tw/tools/gtm-readiness-checklist.ts +166 -0
- package/src/i18n/messages/zh-tw/tools/index.ts +73 -0
- package/src/i18n/messages/zh-tw/tools/koko-codex-assistant.ts +170 -0
- package/src/i18n/messages/zh-tw/tools/logo-generator.ts +71 -0
- package/src/i18n/messages/zh-tw/tools/market-forecast-report.ts +228 -0
- package/src/i18n/messages/zh-tw/tools/million-user-growth-test.ts +385 -0
- package/src/i18n/messages/zh-tw/tools/og-image-generator.ts +173 -0
- package/src/i18n/messages/zh-tw/tools/pitch-deck-generator.ts +358 -0
- package/src/i18n/messages/zh-tw/tools/product-agreement-generator.ts +401 -0
- package/src/i18n/messages/zh-tw/tools/product-hunt-launch-planner.ts +267 -0
- package/src/i18n/messages/zh-tw/tools/product-name-generator.ts +383 -0
- package/src/i18n/messages/zh-tw/tools/product-poster-generator.ts +282 -0
- package/src/i18n/messages/zh-tw/tools/product-ui-generator.ts +234 -0
- package/src/i18n/messages/zh-tw/tools/reddit-pain-point-finder.ts +162 -0
- package/src/i18n/messages/zh-tw/tools/shared.ts +24 -0
- package/src/i18n/messages/zh-tw/tools/social-listening-research-report.ts +181 -0
- package/src/i18n/messages/zh-tw/tools/social-media-profile-generator.ts +22 -0
- package/src/i18n/messages/zh-tw/tools/social-platform-asset-adapter.ts +284 -0
- package/src/i18n/messages/zh-tw/tools/social-profile-kit.ts +150 -0
- package/src/i18n/messages/zh-tw/tools/startup-idea-research.ts +165 -0
- package/src/i18n/messages/zh-tw/tools/tarot-reading.ts +228 -0
- package/src/i18n/messages/zh-tw/tools/twitter-gif-downloader.ts +138 -0
- package/src/i18n/messages/zh-tw/tools/user-interview-insight-report-generator.ts +224 -0
- package/src/i18n/messages/zh-tw/tools/user-interview-record-generator.ts +226 -0
- package/src/i18n/messages/zh-tw/tools-ui.ts +525 -0
- package/src/index.ts +15 -0
- package/src/lib/activity-task-handoff.ts +404 -0
- package/src/lib/api/errors.ts +39 -0
- package/src/lib/app-origin.ts +30 -0
- package/src/lib/fact-claim-contract.ts +68 -0
- package/src/lib/fake-delay.ts +3 -0
- package/src/lib/file/download.ts +10 -0
- package/src/lib/routing/locale-paths.ts +27 -0
- package/src/lib/seo-meta.ts +3 -0
- package/src/lib/tools/app-icon-resizer-schema.ts +191 -0
- package/src/lib/tools/app-store-screenshot-generator-schema.ts +185 -0
- package/src/lib/tools/build-in-public-story-generator-schema.ts +67 -0
- package/src/lib/tools/build-in-public-story-generator.format.ts +507 -0
- package/src/lib/tools/cold-start-channel-selector-schema.ts +147 -0
- package/src/lib/tools/commercial-bp-generator-schema.ts +222 -0
- package/src/lib/tools/community-feedback-inbox-schema.ts +125 -0
- package/src/lib/tools/community-feedback-inbox.format.ts +764 -0
- package/src/lib/tools/community-pain-point-extractor-schema.ts +166 -0
- package/src/lib/tools/community-post-risk-checker-schema.ts +99 -0
- package/src/lib/tools/community-post-risk-checker.format.ts +557 -0
- package/src/lib/tools/competitor-analysis-schema.ts +144 -0
- package/src/lib/tools/draft-preview-access.ts +3 -0
- package/src/lib/tools/draft-store.ts +69 -0
- package/src/lib/tools/email-template-generator-schema.ts +124 -0
- package/src/lib/tools/gtm-checklist-copy.ts +57 -0
- package/src/lib/tools/gtm-checklist-structure.ts +37 -0
- package/src/lib/tools/image-download.ts +68 -0
- package/src/lib/tools/input-quality.ts +97 -0
- package/src/lib/tools/logo-generator-schema.ts +224 -0
- package/src/lib/tools/market-forecast-report-schema.ts +299 -0
- package/src/lib/tools/mcp-registry.ts +16 -0
- package/src/lib/tools/mcp-types.ts +18 -0
- package/src/lib/tools/million-user-growth-test-schema.ts +49 -0
- package/src/lib/tools/million-user-growth-test.ts +181 -0
- package/src/lib/tools/og-image-generator-render.ts +448 -0
- package/src/lib/tools/og-image-generator-schema.ts +140 -0
- package/src/lib/tools/ops-catalog.ts +102 -0
- package/src/lib/tools/pitch-deck-generator-schema.ts +182 -0
- package/src/lib/tools/pitch-deck-package.ts +0 -0
- package/src/lib/tools/product-agreement-generator-schema.ts +168 -0
- package/src/lib/tools/product-hunt-launch-planner-schema.ts +136 -0
- package/src/lib/tools/product-hunt-launch-planner.format.ts +72 -0
- package/src/lib/tools/product-name-generator-schema.ts +563 -0
- package/src/lib/tools/product-poster-generator-schema.ts +215 -0
- package/src/lib/tools/product-ui-generator-schema.ts +157 -0
- package/src/lib/tools/reddit-pain-point-finder-schema.ts +88 -0
- package/src/lib/tools/resolve-tool-locale-copy.ts +75 -0
- package/src/lib/tools/slug.ts +60 -0
- package/src/lib/tools/social-listening-research-report-schema.ts +105 -0
- package/src/lib/tools/social-platform-asset-adapter-schema.ts +152 -0
- package/src/lib/tools/social-profile-kit.constants.ts +12 -0
- package/src/lib/tools/social-profile-kit.generation.ts +257 -0
- package/src/lib/tools/social-profile-kit.input.ts +290 -0
- package/src/lib/tools/social-profile-kit.manual.ts +481 -0
- package/src/lib/tools/social-profile-kit.package.ts +220 -0
- package/src/lib/tools/social-profile-kit.schema.ts +328 -0
- package/src/lib/tools/startup-idea-research-schema.ts +107 -0
- package/src/lib/tools/tarot-imagery.ts +89 -0
- package/src/lib/tools/tarot-reading.ts +1044 -0
- package/src/lib/tools/tool-message-keys.ts +18 -0
- package/src/lib/tools/types.ts +32 -0
- package/src/lib/tools/user-interview.format.ts +147 -0
- package/src/lib/tools/user-interview.generation.ts +670 -0
- package/src/lib/tools/user-interview.schema.ts +192 -0
- package/src/lib/zip.ts +106 -0
- package/src/services/tools/handlers/gtm-readiness-checklist.ts +71 -0
- package/src/services/tools/handlers/types.ts +7 -0
|
@@ -0,0 +1,1244 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
|
|
3
|
+
import { Field, Input, Textarea } from "@tomako/ui/input";
|
|
4
|
+
import { useLocale, useTranslations } from "../../../../i18n/client";
|
|
5
|
+
import { ApiError } from "../../../../lib/api/errors";
|
|
6
|
+
import {
|
|
7
|
+
LOGO_GENERATOR_FORMS,
|
|
8
|
+
LOGO_GENERATOR_SCHEME_COUNTS,
|
|
9
|
+
logoGeneratorInputSchema,
|
|
10
|
+
type LogoCandidate,
|
|
11
|
+
type LogoForm,
|
|
12
|
+
type LogoGeneratorAgentResult,
|
|
13
|
+
type LogoGeneratorInput,
|
|
14
|
+
type LogoSvgConversionResult,
|
|
15
|
+
} from "../../../../lib/tools/logo-generator-schema";
|
|
16
|
+
import {
|
|
17
|
+
fetchLogoGenerationTask,
|
|
18
|
+
fetchLogoSvgConversionTask,
|
|
19
|
+
streamTaskEvents,
|
|
20
|
+
submitLogoGeneration,
|
|
21
|
+
submitLogoSvgConversion,
|
|
22
|
+
type LogoGenerationErrorCode,
|
|
23
|
+
type LogoSvgConversionErrorCode,
|
|
24
|
+
} from "../../../../host/client";
|
|
25
|
+
import {
|
|
26
|
+
AlertTriangle,
|
|
27
|
+
ChevronLeft,
|
|
28
|
+
ChevronRight,
|
|
29
|
+
Download,
|
|
30
|
+
FileCode2,
|
|
31
|
+
FileImage,
|
|
32
|
+
Loader2,
|
|
33
|
+
Plus,
|
|
34
|
+
RefreshCcw,
|
|
35
|
+
Upload,
|
|
36
|
+
X,
|
|
37
|
+
} from "lucide-react";
|
|
38
|
+
import type { MutableRefObject } from "react";
|
|
39
|
+
import { useEffect, useMemo, useRef, useState } from "react";
|
|
40
|
+
|
|
41
|
+
type GenerationState =
|
|
42
|
+
| { phase: "idle" }
|
|
43
|
+
| { phase: "loading"; status: string; taskId?: string; awaitingResult?: boolean }
|
|
44
|
+
| { phase: "partial"; status: string; taskId: string; data: LogoGeneratorAgentResult }
|
|
45
|
+
| { phase: "done"; data: LogoGeneratorAgentResult }
|
|
46
|
+
| { phase: "error"; message: string };
|
|
47
|
+
|
|
48
|
+
type LogoGeneratorForm = LogoGeneratorInput & {
|
|
49
|
+
referenceImageDataUrl?: string;
|
|
50
|
+
};
|
|
51
|
+
|
|
52
|
+
type SvgConversionState =
|
|
53
|
+
| { phase: "idle" }
|
|
54
|
+
| { phase: "loading"; status: string; taskId?: string; candidateId: string }
|
|
55
|
+
| { phase: "done"; candidateId: string; data: LogoSvgConversionResult }
|
|
56
|
+
| { phase: "error"; candidateId?: string; message: string };
|
|
57
|
+
|
|
58
|
+
type FormCopy = {
|
|
59
|
+
customPaletteSlots: Record<CustomPaletteKey, string>;
|
|
60
|
+
forms: Record<LogoForm, string>;
|
|
61
|
+
directions: Record<LogoCandidate["direction"], string>;
|
|
62
|
+
};
|
|
63
|
+
|
|
64
|
+
type ResolveOptions = {
|
|
65
|
+
final?: boolean;
|
|
66
|
+
retries?: number;
|
|
67
|
+
};
|
|
68
|
+
|
|
69
|
+
type StoredLogoTask = {
|
|
70
|
+
taskId: string;
|
|
71
|
+
form: LogoGeneratorInput;
|
|
72
|
+
createdAt: number;
|
|
73
|
+
};
|
|
74
|
+
|
|
75
|
+
const taskStorageKey = "tomako.logo-generator.task.v1";
|
|
76
|
+
const taskStorageTtlMs = 1000 * 60 * 60 * 2;
|
|
77
|
+
|
|
78
|
+
const defaultForm: LogoGeneratorForm = {
|
|
79
|
+
productUrl: "",
|
|
80
|
+
productName: "",
|
|
81
|
+
productContext: "",
|
|
82
|
+
industry: "",
|
|
83
|
+
audience: "",
|
|
84
|
+
schemeCount: 1,
|
|
85
|
+
customPalette: {
|
|
86
|
+
primary: "",
|
|
87
|
+
secondary: "",
|
|
88
|
+
accent: "",
|
|
89
|
+
},
|
|
90
|
+
form: "combination",
|
|
91
|
+
referenceImageName: "",
|
|
92
|
+
referenceImageUrl: "",
|
|
93
|
+
referenceImageDataUrl: undefined,
|
|
94
|
+
};
|
|
95
|
+
|
|
96
|
+
const customPaletteKeys = ["primary", "secondary", "accent"] as const;
|
|
97
|
+
const customPaletteFallbacks: Record<CustomPaletteKey, string> = {
|
|
98
|
+
primary: "#111111",
|
|
99
|
+
secondary: "#D8D4CA",
|
|
100
|
+
accent: "#7C3AED",
|
|
101
|
+
};
|
|
102
|
+
type CustomPaletteKey = (typeof customPaletteKeys)[number];
|
|
103
|
+
|
|
104
|
+
function wait(ms: number): Promise<void> {
|
|
105
|
+
return new Promise((resolve) => window.setTimeout(resolve, ms));
|
|
106
|
+
}
|
|
107
|
+
|
|
108
|
+
function fileBase(value: string) {
|
|
109
|
+
return (
|
|
110
|
+
value
|
|
111
|
+
.trim()
|
|
112
|
+
.toLowerCase()
|
|
113
|
+
.replace(/[^a-z0-9]+/gi, "-")
|
|
114
|
+
.replace(/^-+|-+$/g, "") || "logo"
|
|
115
|
+
);
|
|
116
|
+
}
|
|
117
|
+
|
|
118
|
+
function readImageAsDataUrl(file: File): Promise<string> {
|
|
119
|
+
return new Promise((resolve, reject) => {
|
|
120
|
+
if (!file.type.startsWith("image/")) {
|
|
121
|
+
reject(new Error("Unsupported image file"));
|
|
122
|
+
return;
|
|
123
|
+
}
|
|
124
|
+
const reader = new FileReader();
|
|
125
|
+
reader.onload = () => resolve(String(reader.result || ""));
|
|
126
|
+
reader.onerror = () => reject(reader.error || new Error("Failed to read image"));
|
|
127
|
+
reader.readAsDataURL(file);
|
|
128
|
+
});
|
|
129
|
+
}
|
|
130
|
+
|
|
131
|
+
function downloadRemoteImage(url: string, filename: string) {
|
|
132
|
+
const link = document.createElement("a");
|
|
133
|
+
link.href = url;
|
|
134
|
+
link.download = filename;
|
|
135
|
+
link.target = "_blank";
|
|
136
|
+
link.rel = "noopener noreferrer";
|
|
137
|
+
link.click();
|
|
138
|
+
}
|
|
139
|
+
|
|
140
|
+
function downloadTextFile(content: string, filename: string, mimeType: string) {
|
|
141
|
+
const blob = new Blob([content], { type: mimeType });
|
|
142
|
+
const url = URL.createObjectURL(blob);
|
|
143
|
+
const link = document.createElement("a");
|
|
144
|
+
link.href = url;
|
|
145
|
+
link.download = filename;
|
|
146
|
+
link.click();
|
|
147
|
+
window.setTimeout(() => URL.revokeObjectURL(url), 1000);
|
|
148
|
+
}
|
|
149
|
+
|
|
150
|
+
function persistLogoTask(taskId: string, form: LogoGeneratorForm) {
|
|
151
|
+
if (typeof window === "undefined") return;
|
|
152
|
+
const schemaForm = logoGeneratorInputSchema.parse(form);
|
|
153
|
+
const payload: StoredLogoTask = {
|
|
154
|
+
taskId,
|
|
155
|
+
form: schemaForm,
|
|
156
|
+
createdAt: Date.now(),
|
|
157
|
+
};
|
|
158
|
+
window.sessionStorage.setItem(taskStorageKey, JSON.stringify(payload));
|
|
159
|
+
}
|
|
160
|
+
|
|
161
|
+
function readStoredLogoTask(): StoredLogoTask | null {
|
|
162
|
+
if (typeof window === "undefined") return null;
|
|
163
|
+
try {
|
|
164
|
+
const raw = window.sessionStorage.getItem(taskStorageKey);
|
|
165
|
+
if (!raw) return null;
|
|
166
|
+
const parsed = JSON.parse(raw) as Partial<StoredLogoTask>;
|
|
167
|
+
if (!parsed.taskId || !parsed.form || !parsed.createdAt) return null;
|
|
168
|
+
if (Date.now() - parsed.createdAt > taskStorageTtlMs) {
|
|
169
|
+
window.sessionStorage.removeItem(taskStorageKey);
|
|
170
|
+
return null;
|
|
171
|
+
}
|
|
172
|
+
const form = logoGeneratorInputSchema.safeParse(parsed.form);
|
|
173
|
+
if (!form.success) {
|
|
174
|
+
window.sessionStorage.removeItem(taskStorageKey);
|
|
175
|
+
return null;
|
|
176
|
+
}
|
|
177
|
+
return {
|
|
178
|
+
taskId: parsed.taskId,
|
|
179
|
+
form: form.data,
|
|
180
|
+
createdAt: parsed.createdAt,
|
|
181
|
+
};
|
|
182
|
+
} catch {
|
|
183
|
+
window.sessionStorage.removeItem(taskStorageKey);
|
|
184
|
+
return null;
|
|
185
|
+
}
|
|
186
|
+
}
|
|
187
|
+
|
|
188
|
+
function clearStoredLogoTask() {
|
|
189
|
+
if (typeof window === "undefined") return;
|
|
190
|
+
window.sessionStorage.removeItem(taskStorageKey);
|
|
191
|
+
}
|
|
192
|
+
|
|
193
|
+
function isPartialLogoResult(result: LogoGeneratorAgentResult): boolean {
|
|
194
|
+
const totalCount = result.totalCount ?? result.source?.schemeCount ?? result.candidates.length;
|
|
195
|
+
return result.generationStatus === "partial" || result.candidates.length < totalCount;
|
|
196
|
+
}
|
|
197
|
+
|
|
198
|
+
export function LogoGenerator() {
|
|
199
|
+
const locale = useLocale();
|
|
200
|
+
const t = useTranslations("toolsUi.logoGenerator");
|
|
201
|
+
const [form, setForm] = useState<LogoGeneratorForm>(defaultForm);
|
|
202
|
+
const [state, setState] = useState<GenerationState>({ phase: "idle" });
|
|
203
|
+
const [svgState, setSvgState] = useState<SvgConversionState>({ phase: "idle" });
|
|
204
|
+
const [selectedId, setSelectedId] = useState<string | null>(null);
|
|
205
|
+
const [lightboxIndex, setLightboxIndex] = useState<number | null>(null);
|
|
206
|
+
const [error, setError] = useState<string | null>(null);
|
|
207
|
+
const [downloadError, setDownloadError] = useState<string | null>(null);
|
|
208
|
+
const eventSourceRef = useRef<EventSource | null>(null);
|
|
209
|
+
const svgEventSourceRef = useRef<EventSource | null>(null);
|
|
210
|
+
const activeTaskIdRef = useRef<string | null>(null);
|
|
211
|
+
const activeSvgTaskIdRef = useRef<string | null>(null);
|
|
212
|
+
const resultLookupVersionRef = useRef(0);
|
|
213
|
+
const svgLookupVersionRef = useRef(0);
|
|
214
|
+
const customColorInputRefs = useRef<Record<CustomPaletteKey, HTMLInputElement | null>>({
|
|
215
|
+
primary: null,
|
|
216
|
+
secondary: null,
|
|
217
|
+
accent: null,
|
|
218
|
+
});
|
|
219
|
+
|
|
220
|
+
useEffect(() => {
|
|
221
|
+
return () => {
|
|
222
|
+
eventSourceRef.current?.close();
|
|
223
|
+
svgEventSourceRef.current?.close();
|
|
224
|
+
activeTaskIdRef.current = null;
|
|
225
|
+
activeSvgTaskIdRef.current = null;
|
|
226
|
+
resultLookupVersionRef.current += 1;
|
|
227
|
+
svgLookupVersionRef.current += 1;
|
|
228
|
+
};
|
|
229
|
+
}, []);
|
|
230
|
+
|
|
231
|
+
useEffect(() => {
|
|
232
|
+
const stored = readStoredLogoTask();
|
|
233
|
+
if (!stored) return;
|
|
234
|
+
const restoredForm: LogoGeneratorForm = {
|
|
235
|
+
...defaultForm,
|
|
236
|
+
...stored.form,
|
|
237
|
+
referenceImageDataUrl: undefined,
|
|
238
|
+
};
|
|
239
|
+
let cancelled = false;
|
|
240
|
+
activeTaskIdRef.current = stored.taskId;
|
|
241
|
+
queueMicrotask(() => {
|
|
242
|
+
if (cancelled) return;
|
|
243
|
+
setForm(restoredForm);
|
|
244
|
+
setState({
|
|
245
|
+
phase: "loading",
|
|
246
|
+
status: "RESTORING",
|
|
247
|
+
taskId: stored.taskId,
|
|
248
|
+
awaitingResult: true,
|
|
249
|
+
});
|
|
250
|
+
void resolveAgentTask(stored.taskId, {
|
|
251
|
+
retries: Math.max(160, restoredForm.schemeCount * 100),
|
|
252
|
+
});
|
|
253
|
+
});
|
|
254
|
+
return () => {
|
|
255
|
+
cancelled = true;
|
|
256
|
+
};
|
|
257
|
+
// Restore only once on mount. resolveAgentTask is a function declaration in this component.
|
|
258
|
+
// eslint-disable-next-line react-hooks/exhaustive-deps
|
|
259
|
+
}, []);
|
|
260
|
+
|
|
261
|
+
const copy = useMemo(
|
|
262
|
+
() =>
|
|
263
|
+
({
|
|
264
|
+
customPaletteSlots: t.raw("customPaletteSlots"),
|
|
265
|
+
forms: t.raw("forms"),
|
|
266
|
+
directions: t.raw("directions"),
|
|
267
|
+
}) as FormCopy,
|
|
268
|
+
[t],
|
|
269
|
+
);
|
|
270
|
+
|
|
271
|
+
const result = state.phase === "done" || state.phase === "partial" ? state.data : null;
|
|
272
|
+
const isPartialResult = state.phase === "partial";
|
|
273
|
+
const completedCount = result?.completedCount ?? result?.candidates.length ?? 0;
|
|
274
|
+
const totalCount = result?.totalCount ?? result?.source?.schemeCount ?? result?.candidates.length ?? 0;
|
|
275
|
+
const selectedCandidate = useMemo(
|
|
276
|
+
() => result?.candidates.find((candidate) => candidate.id === selectedId) ?? null,
|
|
277
|
+
[result, selectedId],
|
|
278
|
+
);
|
|
279
|
+
const lightboxCandidate = lightboxIndex === null ? null : result?.candidates[lightboxIndex] ?? null;
|
|
280
|
+
const canSubmit = state.phase !== "loading" && state.phase !== "partial";
|
|
281
|
+
const currentSvgResult =
|
|
282
|
+
selectedCandidate && svgState.phase === "done" && svgState.candidateId === selectedCandidate.id
|
|
283
|
+
? svgState.data
|
|
284
|
+
: null;
|
|
285
|
+
const isConvertingSelectedSvg =
|
|
286
|
+
selectedCandidate &&
|
|
287
|
+
svgState.phase === "loading" &&
|
|
288
|
+
svgState.candidateId === selectedCandidate.id;
|
|
289
|
+
|
|
290
|
+
function update<K extends keyof LogoGeneratorForm>(key: K, value: LogoGeneratorForm[K]) {
|
|
291
|
+
setForm((current) => ({ ...current, [key]: value }));
|
|
292
|
+
}
|
|
293
|
+
|
|
294
|
+
function validateForm(): boolean {
|
|
295
|
+
const parsed = logoGeneratorInputSchema.safeParse(form);
|
|
296
|
+
if (!parsed.success) {
|
|
297
|
+
const customPaletteIssue = parsed.error.issues.some(
|
|
298
|
+
(issue) => issue.path[0] === "customPalette",
|
|
299
|
+
);
|
|
300
|
+
setError(customPaletteIssue ? t("errors.customPalette") : t("errors.required"));
|
|
301
|
+
return false;
|
|
302
|
+
}
|
|
303
|
+
setError(null);
|
|
304
|
+
return true;
|
|
305
|
+
}
|
|
306
|
+
|
|
307
|
+
function formatAgentError(err: unknown): string {
|
|
308
|
+
if (err instanceof ApiError) {
|
|
309
|
+
if (err.status === 502 || err.status === 503 || err.status === 504) {
|
|
310
|
+
return t("errors.gateway");
|
|
311
|
+
}
|
|
312
|
+
return t("errors.agent");
|
|
313
|
+
}
|
|
314
|
+
return err instanceof Error ? err.message : t("errors.agent");
|
|
315
|
+
}
|
|
316
|
+
|
|
317
|
+
function mapTaskError(code?: LogoGenerationErrorCode, message?: string): string {
|
|
318
|
+
if (code === "result_schema_invalid") return t("errors.schema");
|
|
319
|
+
if (code === "result_type_invalid") return t("errors.resultType");
|
|
320
|
+
if (code === "task_failed") return message || t("errors.taskFailed");
|
|
321
|
+
return message || t("errors.agent");
|
|
322
|
+
}
|
|
323
|
+
|
|
324
|
+
function mapSvgTaskError(code?: LogoSvgConversionErrorCode, message?: string): string {
|
|
325
|
+
if (code === "result_schema_invalid") return t("errors.svgSchema");
|
|
326
|
+
if (code === "result_type_invalid") return t("errors.svgResultType");
|
|
327
|
+
if (code === "task_failed") return message || t("errors.svgTaskFailed");
|
|
328
|
+
return message || t("errors.svgAgent");
|
|
329
|
+
}
|
|
330
|
+
|
|
331
|
+
function isActiveLookup(taskId: string, version: number): boolean {
|
|
332
|
+
return activeTaskIdRef.current === taskId && resultLookupVersionRef.current === version;
|
|
333
|
+
}
|
|
334
|
+
|
|
335
|
+
function isActiveSvgLookup(taskId: string, version: number): boolean {
|
|
336
|
+
return activeSvgTaskIdRef.current === taskId && svgLookupVersionRef.current === version;
|
|
337
|
+
}
|
|
338
|
+
|
|
339
|
+
function isAwaitingResultStatus(status: string): boolean {
|
|
340
|
+
return status === "AWAITING_INPUT" || status === "SUCCEEDED" || status === "RECONNECTING";
|
|
341
|
+
}
|
|
342
|
+
|
|
343
|
+
async function handleReferenceImage(file?: File) {
|
|
344
|
+
if (!file) return;
|
|
345
|
+
try {
|
|
346
|
+
const dataUrl = await readImageAsDataUrl(file);
|
|
347
|
+
setForm((current) => ({
|
|
348
|
+
...current,
|
|
349
|
+
referenceImageName: file.name,
|
|
350
|
+
referenceImageDataUrl: dataUrl,
|
|
351
|
+
referenceImageUrl: "",
|
|
352
|
+
}));
|
|
353
|
+
} catch {
|
|
354
|
+
setError(t("errors.referenceImage"));
|
|
355
|
+
}
|
|
356
|
+
}
|
|
357
|
+
|
|
358
|
+
function clearReferenceImage() {
|
|
359
|
+
setForm((current) => ({
|
|
360
|
+
...current,
|
|
361
|
+
referenceImageName: "",
|
|
362
|
+
referenceImageUrl: "",
|
|
363
|
+
referenceImageDataUrl: undefined,
|
|
364
|
+
}));
|
|
365
|
+
}
|
|
366
|
+
|
|
367
|
+
function openCustomColorPicker(key: CustomPaletteKey) {
|
|
368
|
+
customColorInputRefs.current[key]?.click();
|
|
369
|
+
}
|
|
370
|
+
|
|
371
|
+
function updateCustomColor(key: CustomPaletteKey, color: string) {
|
|
372
|
+
setForm((current) => ({
|
|
373
|
+
...current,
|
|
374
|
+
customPalette: {
|
|
375
|
+
...current.customPalette,
|
|
376
|
+
[key]: color.toUpperCase(),
|
|
377
|
+
},
|
|
378
|
+
}));
|
|
379
|
+
}
|
|
380
|
+
|
|
381
|
+
function removeCustomColor(key: CustomPaletteKey) {
|
|
382
|
+
setForm((current) => ({
|
|
383
|
+
...current,
|
|
384
|
+
customPalette: {
|
|
385
|
+
...current.customPalette,
|
|
386
|
+
[key]: "",
|
|
387
|
+
},
|
|
388
|
+
}));
|
|
389
|
+
}
|
|
390
|
+
|
|
391
|
+
async function resolveAgentTask(taskId: string, options: ResolveOptions = {}) {
|
|
392
|
+
const { final = false, retries = final ? 20 : 0 } = options;
|
|
393
|
+
const lookupVersion = ++resultLookupVersionRef.current;
|
|
394
|
+
let sawPartialResult = false;
|
|
395
|
+
|
|
396
|
+
for (let attempt = 0; attempt <= retries; attempt += 1) {
|
|
397
|
+
const task = await fetchLogoGenerationTask(taskId);
|
|
398
|
+
if (!isActiveLookup(taskId, lookupVersion)) return;
|
|
399
|
+
|
|
400
|
+
if (task.data && task.data.candidates.length > 0) {
|
|
401
|
+
const data = task.data;
|
|
402
|
+
const partial = isPartialLogoResult(data);
|
|
403
|
+
setSelectedId((current) =>
|
|
404
|
+
data.candidates.some((candidate: LogoCandidate) => candidate.id === current)
|
|
405
|
+
? current
|
|
406
|
+
: data.candidates[0]?.id ?? null,
|
|
407
|
+
);
|
|
408
|
+
if (partial) {
|
|
409
|
+
sawPartialResult = true;
|
|
410
|
+
setState({ phase: "partial", status: task.status, taskId, data });
|
|
411
|
+
if (attempt < retries) {
|
|
412
|
+
await wait(1500);
|
|
413
|
+
continue;
|
|
414
|
+
}
|
|
415
|
+
return;
|
|
416
|
+
}
|
|
417
|
+
setState({ phase: "done", data });
|
|
418
|
+
return;
|
|
419
|
+
}
|
|
420
|
+
|
|
421
|
+
if (task.errorCode || task.status === "FAILED") {
|
|
422
|
+
setState({ phase: "error", message: mapTaskError(task.errorCode, task.error) });
|
|
423
|
+
return;
|
|
424
|
+
}
|
|
425
|
+
|
|
426
|
+
if (attempt < retries) {
|
|
427
|
+
setState((current) =>
|
|
428
|
+
current.phase === "partial" || current.phase === "done"
|
|
429
|
+
? current
|
|
430
|
+
: {
|
|
431
|
+
phase: "loading",
|
|
432
|
+
status: task.status,
|
|
433
|
+
taskId,
|
|
434
|
+
awaitingResult: isAwaitingResultStatus(task.status),
|
|
435
|
+
},
|
|
436
|
+
);
|
|
437
|
+
await wait(1500);
|
|
438
|
+
}
|
|
439
|
+
}
|
|
440
|
+
|
|
441
|
+
if (isActiveLookup(taskId, lookupVersion) && final && !sawPartialResult) {
|
|
442
|
+
setState({ phase: "error", message: t("errors.noResult") });
|
|
443
|
+
}
|
|
444
|
+
}
|
|
445
|
+
|
|
446
|
+
async function resolveSvgTask(
|
|
447
|
+
taskId: string,
|
|
448
|
+
candidateId: string,
|
|
449
|
+
options: ResolveOptions = {},
|
|
450
|
+
) {
|
|
451
|
+
const { final = false, retries = final ? 20 : 0 } = options;
|
|
452
|
+
const lookupVersion = ++svgLookupVersionRef.current;
|
|
453
|
+
|
|
454
|
+
for (let attempt = 0; attempt <= retries; attempt += 1) {
|
|
455
|
+
const task = await fetchLogoSvgConversionTask(taskId);
|
|
456
|
+
if (!isActiveSvgLookup(taskId, lookupVersion)) return;
|
|
457
|
+
|
|
458
|
+
if (task.data) {
|
|
459
|
+
setSvgState({ phase: "done", candidateId, data: task.data });
|
|
460
|
+
return;
|
|
461
|
+
}
|
|
462
|
+
|
|
463
|
+
if (task.errorCode || task.status === "FAILED") {
|
|
464
|
+
setSvgState({
|
|
465
|
+
phase: "error",
|
|
466
|
+
candidateId,
|
|
467
|
+
message: mapSvgTaskError(task.errorCode, task.error),
|
|
468
|
+
});
|
|
469
|
+
return;
|
|
470
|
+
}
|
|
471
|
+
|
|
472
|
+
if (attempt < retries) {
|
|
473
|
+
setSvgState({ phase: "loading", status: task.status, taskId, candidateId });
|
|
474
|
+
await wait(1500);
|
|
475
|
+
}
|
|
476
|
+
}
|
|
477
|
+
|
|
478
|
+
if (isActiveSvgLookup(taskId, lookupVersion) && final) {
|
|
479
|
+
setSvgState({ phase: "error", candidateId, message: t("errors.svgNoResult") });
|
|
480
|
+
}
|
|
481
|
+
}
|
|
482
|
+
|
|
483
|
+
async function generateWithAgent() {
|
|
484
|
+
if (!validateForm() || !canSubmit) return;
|
|
485
|
+
const resultPollingRetries = Math.max(160, form.schemeCount * 100);
|
|
486
|
+
eventSourceRef.current?.close();
|
|
487
|
+
activeTaskIdRef.current = null;
|
|
488
|
+
resultLookupVersionRef.current += 1;
|
|
489
|
+
setSelectedId(null);
|
|
490
|
+
setLightboxIndex(null);
|
|
491
|
+
setDownloadError(null);
|
|
492
|
+
setState({ phase: "loading", status: "PENDING" });
|
|
493
|
+
|
|
494
|
+
try {
|
|
495
|
+
const { taskId, status } = await submitLogoGeneration(form, locale);
|
|
496
|
+
activeTaskIdRef.current = taskId;
|
|
497
|
+
persistLogoTask(taskId, form);
|
|
498
|
+
setState({
|
|
499
|
+
phase: "loading",
|
|
500
|
+
status,
|
|
501
|
+
taskId,
|
|
502
|
+
awaitingResult: isAwaitingResultStatus(status),
|
|
503
|
+
});
|
|
504
|
+
eventSourceRef.current = streamTaskEvents(taskId, {
|
|
505
|
+
onStatus: (nextStatus: string) => {
|
|
506
|
+
setState((current) =>
|
|
507
|
+
current.phase === "partial" || current.phase === "done"
|
|
508
|
+
? current
|
|
509
|
+
: {
|
|
510
|
+
phase: "loading",
|
|
511
|
+
status: nextStatus,
|
|
512
|
+
taskId,
|
|
513
|
+
awaitingResult: isAwaitingResultStatus(nextStatus),
|
|
514
|
+
},
|
|
515
|
+
);
|
|
516
|
+
if (
|
|
517
|
+
nextStatus === "AWAITING_INPUT" ||
|
|
518
|
+
nextStatus === "SUCCEEDED" ||
|
|
519
|
+
nextStatus === "FAILED"
|
|
520
|
+
) {
|
|
521
|
+
void resolveAgentTask(taskId, {
|
|
522
|
+
final: nextStatus === "SUCCEEDED" || nextStatus === "FAILED",
|
|
523
|
+
retries: nextStatus === "AWAITING_INPUT" ? resultPollingRetries : 20,
|
|
524
|
+
});
|
|
525
|
+
}
|
|
526
|
+
},
|
|
527
|
+
onResult: async () => {
|
|
528
|
+
await resolveAgentTask(taskId, { retries: resultPollingRetries });
|
|
529
|
+
},
|
|
530
|
+
onError: () => {
|
|
531
|
+
if (activeTaskIdRef.current === taskId) {
|
|
532
|
+
setState((current) =>
|
|
533
|
+
current.phase === "partial" || current.phase === "done"
|
|
534
|
+
? current
|
|
535
|
+
: { phase: "loading", status: "RECONNECTING", taskId, awaitingResult: true },
|
|
536
|
+
);
|
|
537
|
+
}
|
|
538
|
+
},
|
|
539
|
+
onDone: () => {
|
|
540
|
+
eventSourceRef.current = null;
|
|
541
|
+
void resolveAgentTask(taskId, { final: true, retries: 80 });
|
|
542
|
+
},
|
|
543
|
+
});
|
|
544
|
+
void resolveAgentTask(taskId, { retries: resultPollingRetries });
|
|
545
|
+
} catch (err) {
|
|
546
|
+
setState({ phase: "error", message: formatAgentError(err) });
|
|
547
|
+
}
|
|
548
|
+
}
|
|
549
|
+
|
|
550
|
+
function reset() {
|
|
551
|
+
eventSourceRef.current?.close();
|
|
552
|
+
svgEventSourceRef.current?.close();
|
|
553
|
+
eventSourceRef.current = null;
|
|
554
|
+
svgEventSourceRef.current = null;
|
|
555
|
+
activeTaskIdRef.current = null;
|
|
556
|
+
activeSvgTaskIdRef.current = null;
|
|
557
|
+
resultLookupVersionRef.current += 1;
|
|
558
|
+
svgLookupVersionRef.current += 1;
|
|
559
|
+
setSelectedId(null);
|
|
560
|
+
setLightboxIndex(null);
|
|
561
|
+
setSvgState({ phase: "idle" });
|
|
562
|
+
setError(null);
|
|
563
|
+
setDownloadError(null);
|
|
564
|
+
clearStoredLogoTask();
|
|
565
|
+
setState({ phase: "idle" });
|
|
566
|
+
}
|
|
567
|
+
|
|
568
|
+
function downloadGeneratedImage() {
|
|
569
|
+
if (!selectedCandidate) return;
|
|
570
|
+
downloadRemoteImage(selectedCandidate.imageUrl, `${fileBase(selectedCandidate.exportName)}.png`);
|
|
571
|
+
}
|
|
572
|
+
|
|
573
|
+
function downloadConvertedSvg() {
|
|
574
|
+
if (!currentSvgResult) return;
|
|
575
|
+
downloadTextFile(
|
|
576
|
+
currentSvgResult.svgText,
|
|
577
|
+
`${fileBase(currentSvgResult.exportName)}.svg`,
|
|
578
|
+
"image/svg+xml;charset=utf-8",
|
|
579
|
+
);
|
|
580
|
+
}
|
|
581
|
+
|
|
582
|
+
async function convertSelectedToSvg() {
|
|
583
|
+
if (!selectedCandidate || !result) {
|
|
584
|
+
setDownloadError(t("selectedEmpty"));
|
|
585
|
+
return;
|
|
586
|
+
}
|
|
587
|
+
svgEventSourceRef.current?.close();
|
|
588
|
+
activeSvgTaskIdRef.current = null;
|
|
589
|
+
svgLookupVersionRef.current += 1;
|
|
590
|
+
setDownloadError(null);
|
|
591
|
+
setSvgState({ phase: "loading", status: "PENDING", candidateId: selectedCandidate.id });
|
|
592
|
+
|
|
593
|
+
try {
|
|
594
|
+
const { taskId, status } = await submitLogoSvgConversion(
|
|
595
|
+
{
|
|
596
|
+
productName: form.productName || selectedCandidate.name,
|
|
597
|
+
productUrl: form.productUrl,
|
|
598
|
+
productContext: form.productContext,
|
|
599
|
+
form: form.form,
|
|
600
|
+
candidate: selectedCandidate,
|
|
601
|
+
},
|
|
602
|
+
locale,
|
|
603
|
+
);
|
|
604
|
+
activeSvgTaskIdRef.current = taskId;
|
|
605
|
+
setSvgState({ phase: "loading", status, taskId, candidateId: selectedCandidate.id });
|
|
606
|
+
svgEventSourceRef.current = streamTaskEvents(taskId, {
|
|
607
|
+
onStatus: (nextStatus: string) => {
|
|
608
|
+
setSvgState((current) =>
|
|
609
|
+
current.phase === "done"
|
|
610
|
+
? current
|
|
611
|
+
: { phase: "loading", status: nextStatus, taskId, candidateId: selectedCandidate.id },
|
|
612
|
+
);
|
|
613
|
+
if (
|
|
614
|
+
nextStatus === "AWAITING_INPUT" ||
|
|
615
|
+
nextStatus === "SUCCEEDED" ||
|
|
616
|
+
nextStatus === "FAILED"
|
|
617
|
+
) {
|
|
618
|
+
void resolveSvgTask(taskId, selectedCandidate.id, {
|
|
619
|
+
final: nextStatus === "SUCCEEDED" || nextStatus === "FAILED",
|
|
620
|
+
retries: nextStatus === "AWAITING_INPUT" ? 80 : 20,
|
|
621
|
+
});
|
|
622
|
+
}
|
|
623
|
+
},
|
|
624
|
+
onResult: async () => {
|
|
625
|
+
await resolveSvgTask(taskId, selectedCandidate.id, { retries: 80 });
|
|
626
|
+
},
|
|
627
|
+
onError: () => {
|
|
628
|
+
if (activeSvgTaskIdRef.current === taskId) {
|
|
629
|
+
setSvgState((current) =>
|
|
630
|
+
current.phase === "done"
|
|
631
|
+
? current
|
|
632
|
+
: {
|
|
633
|
+
phase: "loading",
|
|
634
|
+
status: "RECONNECTING",
|
|
635
|
+
taskId,
|
|
636
|
+
candidateId: selectedCandidate.id,
|
|
637
|
+
},
|
|
638
|
+
);
|
|
639
|
+
}
|
|
640
|
+
},
|
|
641
|
+
onDone: () => {
|
|
642
|
+
svgEventSourceRef.current = null;
|
|
643
|
+
void resolveSvgTask(taskId, selectedCandidate.id, { final: true, retries: 30 });
|
|
644
|
+
},
|
|
645
|
+
});
|
|
646
|
+
void resolveSvgTask(taskId, selectedCandidate.id, { retries: 80 });
|
|
647
|
+
} catch (err) {
|
|
648
|
+
setSvgState({
|
|
649
|
+
phase: "error",
|
|
650
|
+
candidateId: selectedCandidate.id,
|
|
651
|
+
message: formatAgentError(err),
|
|
652
|
+
});
|
|
653
|
+
}
|
|
654
|
+
}
|
|
655
|
+
|
|
656
|
+
function downloadAllGeneratedImages() {
|
|
657
|
+
if (!result?.candidates.length) return;
|
|
658
|
+
result.candidates.forEach((candidate, index) => {
|
|
659
|
+
window.setTimeout(() => {
|
|
660
|
+
downloadRemoteImage(candidate.imageUrl, `${fileBase(candidate.exportName)}.png`);
|
|
661
|
+
}, index * 120);
|
|
662
|
+
});
|
|
663
|
+
}
|
|
664
|
+
|
|
665
|
+
function openLightbox(candidate: LogoCandidate, index: number) {
|
|
666
|
+
setSelectedId(candidate.id);
|
|
667
|
+
setLightboxIndex(index);
|
|
668
|
+
setDownloadError(null);
|
|
669
|
+
}
|
|
670
|
+
|
|
671
|
+
function showAdjacentLightboxCandidate(direction: -1 | 1) {
|
|
672
|
+
if (!result?.candidates.length) return;
|
|
673
|
+
setLightboxIndex((current) => {
|
|
674
|
+
const currentIndex =
|
|
675
|
+
current ?? Math.max(result.candidates.findIndex((candidate) => candidate.id === selectedId), 0);
|
|
676
|
+
const nextIndex = (currentIndex + direction + result.candidates.length) % result.candidates.length;
|
|
677
|
+
setSelectedId(result.candidates[nextIndex]?.id ?? null);
|
|
678
|
+
return nextIndex;
|
|
679
|
+
});
|
|
680
|
+
}
|
|
681
|
+
|
|
682
|
+
return (
|
|
683
|
+
<section className="overflow-hidden rounded-[1.75rem] border border-[#CFC9BC] bg-white shadow-[0_22px_60px_rgba(17,17,17,0.08)]">
|
|
684
|
+
<div className="grid xl:grid-cols-[0.42fr_0.58fr]">
|
|
685
|
+
<div className="bg-white p-5 md:p-7">
|
|
686
|
+
<div className="mb-6 flex items-start justify-between gap-4 border-b border-[#D8D4CA] pb-5">
|
|
687
|
+
<div>
|
|
688
|
+
<p className="text-base font-semibold text-[#111111]">{t("formTitle")}</p>
|
|
689
|
+
<p className="mt-1 text-sm leading-6 text-[#555555]">{t("formHint")}</p>
|
|
690
|
+
</div>
|
|
691
|
+
</div>
|
|
692
|
+
|
|
693
|
+
<div className="grid gap-5">
|
|
694
|
+
<Field label={t("productUrlLabel")} hint={t("optional")}>
|
|
695
|
+
<Input
|
|
696
|
+
className="h-12 rounded-2xl border-[#CFC9BC] bg-white text-[15px] shadow-none focus-visible:border-[#111111] focus-visible:ring-[#111111]/15"
|
|
697
|
+
placeholder={t("productUrlPlaceholder")}
|
|
698
|
+
value={form.productUrl}
|
|
699
|
+
onChange={(event) => update("productUrl", event.target.value)}
|
|
700
|
+
/>
|
|
701
|
+
</Field>
|
|
702
|
+
|
|
703
|
+
<Field label={t("productNameLabel")}>
|
|
704
|
+
<Input
|
|
705
|
+
aria-invalid={Boolean(error)}
|
|
706
|
+
className="h-12 rounded-2xl border-[#CFC9BC] bg-white text-[15px] shadow-none focus-visible:border-[#111111] focus-visible:ring-[#111111]/15"
|
|
707
|
+
placeholder={t("productNamePlaceholder")}
|
|
708
|
+
value={form.productName}
|
|
709
|
+
onChange={(event) => update("productName", event.target.value)}
|
|
710
|
+
/>
|
|
711
|
+
</Field>
|
|
712
|
+
|
|
713
|
+
<Field label={t("contextLabel")} hint={t("optional")}>
|
|
714
|
+
<Textarea
|
|
715
|
+
className="min-h-24 rounded-2xl border-[#CFC9BC] bg-white text-[15px] shadow-none focus-visible:border-[#111111] focus-visible:ring-[#111111]/15"
|
|
716
|
+
placeholder={t("contextPlaceholder")}
|
|
717
|
+
value={form.productContext}
|
|
718
|
+
onChange={(event) => update("productContext", event.target.value)}
|
|
719
|
+
/>
|
|
720
|
+
</Field>
|
|
721
|
+
|
|
722
|
+
<Field label={t("referenceImageLabel")} hint={t("optional")}>
|
|
723
|
+
<div className="grid gap-3">
|
|
724
|
+
<label className="flex min-h-12 cursor-pointer items-center justify-center gap-2 rounded-2xl border border-dashed border-[#CFC9BC] bg-white px-4 text-sm font-semibold text-[#111111] transition hover:border-[#111111]">
|
|
725
|
+
<Upload aria-hidden className="size-4" />
|
|
726
|
+
{form.referenceImageName || t("referenceImageUpload")}
|
|
727
|
+
<input
|
|
728
|
+
className="sr-only"
|
|
729
|
+
type="file"
|
|
730
|
+
accept="image/png,image/jpeg,image/webp"
|
|
731
|
+
onChange={(event) => {
|
|
732
|
+
void handleReferenceImage(event.target.files?.[0]);
|
|
733
|
+
event.currentTarget.value = "";
|
|
734
|
+
}}
|
|
735
|
+
/>
|
|
736
|
+
</label>
|
|
737
|
+
{form.referenceImageDataUrl ? (
|
|
738
|
+
<div className="flex items-center gap-3 rounded-2xl border border-[#E1DDD3] bg-white p-3">
|
|
739
|
+
{/* eslint-disable-next-line @next/next/no-img-element */}
|
|
740
|
+
<img
|
|
741
|
+
alt={form.referenceImageName || t("referenceImagePreviewAlt")}
|
|
742
|
+
className="size-14 rounded-xl object-cover"
|
|
743
|
+
src={form.referenceImageDataUrl}
|
|
744
|
+
/>
|
|
745
|
+
<p className="min-w-0 flex-1 truncate text-sm font-semibold text-[#555555]">
|
|
746
|
+
{form.referenceImageName}
|
|
747
|
+
</p>
|
|
748
|
+
<button
|
|
749
|
+
type="button"
|
|
750
|
+
onClick={clearReferenceImage}
|
|
751
|
+
className="flex size-9 shrink-0 items-center justify-center rounded-full border border-[#D8D4CA] text-[#111111]"
|
|
752
|
+
aria-label={t("referenceImageRemove")}
|
|
753
|
+
>
|
|
754
|
+
<X aria-hidden className="size-4" />
|
|
755
|
+
</button>
|
|
756
|
+
</div>
|
|
757
|
+
) : null}
|
|
758
|
+
<p className="text-xs leading-5 text-[#777777]">{t("referenceImageHint")}</p>
|
|
759
|
+
</div>
|
|
760
|
+
</Field>
|
|
761
|
+
|
|
762
|
+
<CustomPaletteControl
|
|
763
|
+
fallbackColors={customPaletteFallbacks}
|
|
764
|
+
hint={t("customPaletteHint")}
|
|
765
|
+
inputRefs={customColorInputRefs}
|
|
766
|
+
label={t("customPaletteLabel")}
|
|
767
|
+
onChange={updateCustomColor}
|
|
768
|
+
onOpen={openCustomColorPicker}
|
|
769
|
+
onRemove={removeCustomColor}
|
|
770
|
+
removeLabel={t("removeCustomColor")}
|
|
771
|
+
slots={copy.customPaletteSlots}
|
|
772
|
+
values={form.customPalette}
|
|
773
|
+
/>
|
|
774
|
+
|
|
775
|
+
<SchemeCountGroup
|
|
776
|
+
label={t("schemeCountLabel")}
|
|
777
|
+
options={LOGO_GENERATOR_SCHEME_COUNTS}
|
|
778
|
+
selected={form.schemeCount}
|
|
779
|
+
labelFor={(count) => t(`schemeCountOptions.${count}`)}
|
|
780
|
+
onSelect={(schemeCount) => update("schemeCount", schemeCount)}
|
|
781
|
+
/>
|
|
782
|
+
|
|
783
|
+
<details className="rounded-[1.25rem] border border-[#E1DDD3] bg-[#F7F6F2] p-4">
|
|
784
|
+
<summary className="cursor-pointer text-sm font-semibold text-[#111111]">
|
|
785
|
+
{t("advancedSettings")}
|
|
786
|
+
</summary>
|
|
787
|
+
<div className="mt-5 grid gap-5">
|
|
788
|
+
<div className="grid gap-4 md:grid-cols-2">
|
|
789
|
+
<Field label={t("industryLabel")} hint={t("optional")}>
|
|
790
|
+
<Input
|
|
791
|
+
className="h-12 rounded-2xl border-[#CFC9BC] bg-white text-[15px] shadow-none focus-visible:border-[#111111] focus-visible:ring-[#111111]/15"
|
|
792
|
+
placeholder={t("industryPlaceholder")}
|
|
793
|
+
value={form.industry}
|
|
794
|
+
onChange={(event) => update("industry", event.target.value)}
|
|
795
|
+
/>
|
|
796
|
+
</Field>
|
|
797
|
+
<Field label={t("audienceLabel")} hint={t("optional")}>
|
|
798
|
+
<Input
|
|
799
|
+
className="h-12 rounded-2xl border-[#CFC9BC] bg-white text-[15px] shadow-none focus-visible:border-[#111111] focus-visible:ring-[#111111]/15"
|
|
800
|
+
placeholder={t("audiencePlaceholder")}
|
|
801
|
+
value={form.audience}
|
|
802
|
+
onChange={(event) => update("audience", event.target.value)}
|
|
803
|
+
/>
|
|
804
|
+
</Field>
|
|
805
|
+
</div>
|
|
806
|
+
|
|
807
|
+
<OptionGroup
|
|
808
|
+
label={t("formLabel")}
|
|
809
|
+
options={LOGO_GENERATOR_FORMS}
|
|
810
|
+
selected={form.form}
|
|
811
|
+
labelFor={(key) => copy.forms[key]}
|
|
812
|
+
onSelect={(nextForm) => update("form", nextForm)}
|
|
813
|
+
/>
|
|
814
|
+
</div>
|
|
815
|
+
</details>
|
|
816
|
+
|
|
817
|
+
{error ? (
|
|
818
|
+
<p className="rounded-2xl border border-[#FFD2C2] bg-[#FFF4EC] px-4 py-3 text-sm font-semibold leading-6 text-[#8A260F]">
|
|
819
|
+
{error}
|
|
820
|
+
</p>
|
|
821
|
+
) : null}
|
|
822
|
+
|
|
823
|
+
<div className="grid gap-3">
|
|
824
|
+
<button
|
|
825
|
+
type="button"
|
|
826
|
+
onClick={() => void generateWithAgent()}
|
|
827
|
+
disabled={!canSubmit}
|
|
828
|
+
className="inline-flex min-h-12 w-full items-center justify-center rounded-full bg-[#111111] px-5 text-sm font-semibold text-white transition hover:-translate-y-0.5 disabled:pointer-events-none disabled:opacity-55"
|
|
829
|
+
>
|
|
830
|
+
{state.phase === "loading" || state.phase === "partial"
|
|
831
|
+
? t("generatingAgent")
|
|
832
|
+
: t("generateAgent")}
|
|
833
|
+
</button>
|
|
834
|
+
<button
|
|
835
|
+
type="button"
|
|
836
|
+
onClick={reset}
|
|
837
|
+
className="inline-flex min-h-11 items-center justify-center gap-2 rounded-full border border-[#CFC9BC] bg-white px-5 text-sm font-semibold text-[#111111] transition hover:-translate-y-0.5"
|
|
838
|
+
>
|
|
839
|
+
<RefreshCcw aria-hidden className="size-4" />
|
|
840
|
+
{t("reset")}
|
|
841
|
+
</button>
|
|
842
|
+
</div>
|
|
843
|
+
</div>
|
|
844
|
+
</div>
|
|
845
|
+
|
|
846
|
+
<div className="bg-white p-5 md:p-7">
|
|
847
|
+
<div className="flex min-h-[760px] flex-col overflow-hidden rounded-[1.5rem] border border-[#E8E4DB] bg-[#FAFAFA] p-4 md:p-5">
|
|
848
|
+
<div className="flex flex-col justify-between gap-3 border-b border-[#E8E4DB] pb-4 md:flex-row md:items-start">
|
|
849
|
+
<div>
|
|
850
|
+
<p className="text-base font-semibold text-[#111111]">{t("conversationTitle")}</p>
|
|
851
|
+
<p className="mt-1 text-sm leading-6 text-[#666666]">{t("conversationHint")}</p>
|
|
852
|
+
</div>
|
|
853
|
+
{result ? (
|
|
854
|
+
<div className="flex shrink-0 flex-wrap gap-2 md:justify-end">
|
|
855
|
+
<button
|
|
856
|
+
type="button"
|
|
857
|
+
onClick={downloadGeneratedImage}
|
|
858
|
+
disabled={!selectedCandidate}
|
|
859
|
+
className="inline-flex min-h-10 items-center gap-2 rounded-lg bg-[#111111] px-4 text-xs font-semibold text-white transition hover:bg-[#2A2A2A] disabled:pointer-events-none disabled:opacity-45"
|
|
860
|
+
>
|
|
861
|
+
<Download aria-hidden className="size-4" />
|
|
862
|
+
{t("downloadPng")}
|
|
863
|
+
</button>
|
|
864
|
+
<button
|
|
865
|
+
type="button"
|
|
866
|
+
onClick={() =>
|
|
867
|
+
currentSvgResult ? downloadConvertedSvg() : void convertSelectedToSvg()
|
|
868
|
+
}
|
|
869
|
+
disabled={!selectedCandidate || Boolean(isConvertingSelectedSvg)}
|
|
870
|
+
className="inline-flex min-h-10 items-center gap-2 rounded-lg border border-[#D8D4CA] bg-white px-4 text-xs font-semibold text-[#111111] transition hover:bg-[#F4F4F4] disabled:pointer-events-none disabled:opacity-45"
|
|
871
|
+
>
|
|
872
|
+
{isConvertingSelectedSvg ? (
|
|
873
|
+
<Loader2 aria-hidden className="size-4 animate-spin" />
|
|
874
|
+
) : currentSvgResult ? (
|
|
875
|
+
<Download aria-hidden className="size-4" />
|
|
876
|
+
) : (
|
|
877
|
+
<FileCode2 aria-hidden className="size-4" />
|
|
878
|
+
)}
|
|
879
|
+
{isConvertingSelectedSvg
|
|
880
|
+
? t("convertingSvg")
|
|
881
|
+
: currentSvgResult
|
|
882
|
+
? t("downloadSvg")
|
|
883
|
+
: t("convertToSvg")}
|
|
884
|
+
</button>
|
|
885
|
+
{result.candidates.length > 1 ? (
|
|
886
|
+
<button
|
|
887
|
+
type="button"
|
|
888
|
+
onClick={downloadAllGeneratedImages}
|
|
889
|
+
className="inline-flex min-h-10 items-center gap-2 rounded-lg border border-[#D8D4CA] bg-white px-4 text-xs font-semibold text-[#111111] transition hover:bg-[#F4F4F4]"
|
|
890
|
+
>
|
|
891
|
+
<Download aria-hidden className="size-4" />
|
|
892
|
+
{t("downloadAllPng")}
|
|
893
|
+
</button>
|
|
894
|
+
) : null}
|
|
895
|
+
</div>
|
|
896
|
+
) : null}
|
|
897
|
+
</div>
|
|
898
|
+
|
|
899
|
+
{downloadError ? (
|
|
900
|
+
<p className="mt-3 text-xs font-semibold leading-5 text-[#8E2A17]">
|
|
901
|
+
{downloadError}
|
|
902
|
+
</p>
|
|
903
|
+
) : null}
|
|
904
|
+
{selectedCandidate &&
|
|
905
|
+
svgState.phase === "loading" &&
|
|
906
|
+
svgState.candidateId === selectedCandidate.id ? (
|
|
907
|
+
<p className="mt-3 text-xs font-semibold leading-5 text-[#555555]">
|
|
908
|
+
{t("svgLoadingHint")}
|
|
909
|
+
</p>
|
|
910
|
+
) : null}
|
|
911
|
+
{selectedCandidate &&
|
|
912
|
+
svgState.phase === "done" &&
|
|
913
|
+
svgState.candidateId === selectedCandidate.id ? (
|
|
914
|
+
<p className="mt-3 text-xs font-semibold leading-5 text-[#2F5B40]">
|
|
915
|
+
{t("svgReadyHint", { count: svgState.data.conversion.pathCount })}
|
|
916
|
+
</p>
|
|
917
|
+
) : null}
|
|
918
|
+
{selectedCandidate &&
|
|
919
|
+
svgState.phase === "error" &&
|
|
920
|
+
svgState.candidateId === selectedCandidate.id ? (
|
|
921
|
+
<p className="mt-3 text-xs font-semibold leading-5 text-[#8E2A17]">
|
|
922
|
+
{svgState.message}
|
|
923
|
+
</p>
|
|
924
|
+
) : null}
|
|
925
|
+
|
|
926
|
+
{state.phase === "idle" ? (
|
|
927
|
+
<ResultPlaceholder title={t("emptyTitle")} hint={t("emptyHint")} />
|
|
928
|
+
) : null}
|
|
929
|
+
|
|
930
|
+
{state.phase === "loading" ? (
|
|
931
|
+
<div className="mt-5 flex min-h-0 flex-1 flex-col items-center justify-center rounded-lg border border-[#E5E5E5] bg-white p-8 text-center">
|
|
932
|
+
<span className="flex size-12 items-center justify-center rounded-lg bg-[#F4F4F4] text-[#111111]">
|
|
933
|
+
<Loader2 aria-hidden className="size-5 animate-spin" />
|
|
934
|
+
</span>
|
|
935
|
+
<h3 className="mt-4 text-lg font-semibold text-[#111111]">
|
|
936
|
+
{state.awaitingResult ? t("awaitingResultTitle") : t("loadingTitle")}
|
|
937
|
+
</h3>
|
|
938
|
+
<p className="mx-auto mt-2 max-w-sm text-sm leading-6 text-[#555555]">
|
|
939
|
+
{state.awaitingResult ? t("awaitingResultHint") : t("loadingHint")}
|
|
940
|
+
</p>
|
|
941
|
+
</div>
|
|
942
|
+
) : null}
|
|
943
|
+
|
|
944
|
+
{state.phase === "error" ? (
|
|
945
|
+
<div className="mt-5 flex min-h-0 flex-1 items-center justify-center rounded-lg border border-[#FFD2C2] bg-[#FFF4EC] p-8 text-center">
|
|
946
|
+
<div className="max-w-md">
|
|
947
|
+
<span className="mx-auto flex size-12 items-center justify-center rounded-lg bg-[#FF5A2E] text-white">
|
|
948
|
+
<AlertTriangle aria-hidden className="size-5" />
|
|
949
|
+
</span>
|
|
950
|
+
<h3 className="mt-4 text-lg font-semibold text-[#111111]">{t("errorTitle")}</h3>
|
|
951
|
+
<p className="mt-2 text-sm leading-6 text-[#6A382A]">
|
|
952
|
+
{state.message || t("errors.agent")}
|
|
953
|
+
</p>
|
|
954
|
+
<button
|
|
955
|
+
type="button"
|
|
956
|
+
onClick={() => void generateWithAgent()}
|
|
957
|
+
className="mt-5 inline-flex min-h-10 items-center justify-center rounded-lg bg-[#111111] px-4 text-sm font-semibold text-white"
|
|
958
|
+
>
|
|
959
|
+
{t("retryAgent")}
|
|
960
|
+
</button>
|
|
961
|
+
</div>
|
|
962
|
+
</div>
|
|
963
|
+
) : null}
|
|
964
|
+
|
|
965
|
+
{result ? (
|
|
966
|
+
<div className="mt-5 min-h-0 flex-1 overflow-y-auto pr-1">
|
|
967
|
+
<div className="mb-4">
|
|
968
|
+
<div className="flex items-center gap-2">
|
|
969
|
+
<h3 className="text-xl font-semibold leading-tight text-[#111111]">
|
|
970
|
+
{isPartialResult
|
|
971
|
+
? t("partialResultTitle", { completed: completedCount, total: totalCount })
|
|
972
|
+
: t("resultTitle", { count: result.candidates.length })}
|
|
973
|
+
</h3>
|
|
974
|
+
{isPartialResult ? (
|
|
975
|
+
<Loader2 aria-hidden className="size-4 animate-spin text-[#555555]" />
|
|
976
|
+
) : null}
|
|
977
|
+
</div>
|
|
978
|
+
<p className="mt-2 text-sm leading-6 text-[#666666]">
|
|
979
|
+
{isPartialResult ? t("partialResultHint") : t("resultHint")}
|
|
980
|
+
</p>
|
|
981
|
+
</div>
|
|
982
|
+
<div className="flex flex-wrap items-start gap-4">
|
|
983
|
+
{result.candidates.map((candidate, index) => {
|
|
984
|
+
const selected = selectedId === candidate.id;
|
|
985
|
+
return (
|
|
986
|
+
<button
|
|
987
|
+
key={candidate.id}
|
|
988
|
+
type="button"
|
|
989
|
+
aria-label={candidate.name}
|
|
990
|
+
aria-pressed={selected}
|
|
991
|
+
onClick={() => openLightbox(candidate, index)}
|
|
992
|
+
style={{
|
|
993
|
+
borderColor: selected ? "#111111" : "#E1DDD3",
|
|
994
|
+
borderWidth: selected ? 2 : 1,
|
|
995
|
+
width: "min(100%, 280px)",
|
|
996
|
+
}}
|
|
997
|
+
className={`block overflow-hidden rounded-lg border-solid bg-white p-0 transition hover:border-[#111111] focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-[#111111]/20 ${
|
|
998
|
+
selected
|
|
999
|
+
? "shadow-[0_14px_34px_rgba(17,17,17,0.12)]"
|
|
1000
|
+
: "shadow-[0_8px_22px_rgba(17,17,17,0.05)]"
|
|
1001
|
+
}`}
|
|
1002
|
+
>
|
|
1003
|
+
<span className="block aspect-[3/2] w-full bg-white">
|
|
1004
|
+
{/* eslint-disable-next-line @next/next/no-img-element */}
|
|
1005
|
+
<img
|
|
1006
|
+
alt={candidate.name}
|
|
1007
|
+
className="h-full w-full object-contain"
|
|
1008
|
+
src={candidate.imageUrl}
|
|
1009
|
+
/>
|
|
1010
|
+
</span>
|
|
1011
|
+
</button>
|
|
1012
|
+
);
|
|
1013
|
+
})}
|
|
1014
|
+
</div>
|
|
1015
|
+
</div>
|
|
1016
|
+
) : null}
|
|
1017
|
+
</div>
|
|
1018
|
+
</div>
|
|
1019
|
+
</div>
|
|
1020
|
+
{lightboxCandidate ? (
|
|
1021
|
+
<div
|
|
1022
|
+
className="fixed inset-0 z-[80] flex items-center justify-center bg-black/85 p-4 backdrop-blur-sm md:p-8"
|
|
1023
|
+
role="dialog"
|
|
1024
|
+
aria-modal="true"
|
|
1025
|
+
aria-label={lightboxCandidate.name}
|
|
1026
|
+
>
|
|
1027
|
+
<button
|
|
1028
|
+
type="button"
|
|
1029
|
+
aria-label={t("closePreview")}
|
|
1030
|
+
onClick={() => setLightboxIndex(null)}
|
|
1031
|
+
className="absolute right-4 top-4 z-10 flex size-11 items-center justify-center rounded-lg bg-white/10 p-0 text-white transition hover:bg-white/20"
|
|
1032
|
+
>
|
|
1033
|
+
<X aria-hidden className="size-5" />
|
|
1034
|
+
</button>
|
|
1035
|
+
{result && result.candidates.length > 1 ? (
|
|
1036
|
+
<>
|
|
1037
|
+
<button
|
|
1038
|
+
type="button"
|
|
1039
|
+
aria-label={t("previousPreview")}
|
|
1040
|
+
onClick={() => showAdjacentLightboxCandidate(-1)}
|
|
1041
|
+
className="absolute left-4 top-1/2 z-10 flex size-11 -translate-y-1/2 items-center justify-center rounded-lg bg-white/10 p-0 text-white transition hover:bg-white/20"
|
|
1042
|
+
>
|
|
1043
|
+
<ChevronLeft aria-hidden className="size-6" />
|
|
1044
|
+
</button>
|
|
1045
|
+
<button
|
|
1046
|
+
type="button"
|
|
1047
|
+
aria-label={t("nextPreview")}
|
|
1048
|
+
onClick={() => showAdjacentLightboxCandidate(1)}
|
|
1049
|
+
className="absolute right-4 top-1/2 z-10 flex size-11 -translate-y-1/2 items-center justify-center rounded-lg bg-white/10 p-0 text-white transition hover:bg-white/20"
|
|
1050
|
+
>
|
|
1051
|
+
<ChevronRight aria-hidden className="size-6" />
|
|
1052
|
+
</button>
|
|
1053
|
+
</>
|
|
1054
|
+
) : null}
|
|
1055
|
+
<div className="flex h-full w-full items-center justify-center px-10 py-12 md:px-16">
|
|
1056
|
+
{/* eslint-disable-next-line @next/next/no-img-element */}
|
|
1057
|
+
<img
|
|
1058
|
+
alt={lightboxCandidate.name}
|
|
1059
|
+
className="block max-h-full max-w-full rounded-lg bg-white object-contain shadow-[0_28px_80px_rgba(0,0,0,0.45)]"
|
|
1060
|
+
src={lightboxCandidate.imageUrl}
|
|
1061
|
+
/>
|
|
1062
|
+
</div>
|
|
1063
|
+
</div>
|
|
1064
|
+
) : null}
|
|
1065
|
+
</section>
|
|
1066
|
+
);
|
|
1067
|
+
}
|
|
1068
|
+
|
|
1069
|
+
function CustomPaletteControl({
|
|
1070
|
+
fallbackColors,
|
|
1071
|
+
hint,
|
|
1072
|
+
inputRefs,
|
|
1073
|
+
label,
|
|
1074
|
+
onChange,
|
|
1075
|
+
onOpen,
|
|
1076
|
+
onRemove,
|
|
1077
|
+
removeLabel,
|
|
1078
|
+
slots,
|
|
1079
|
+
values,
|
|
1080
|
+
}: {
|
|
1081
|
+
fallbackColors: Record<CustomPaletteKey, string>;
|
|
1082
|
+
hint: string;
|
|
1083
|
+
inputRefs: MutableRefObject<Record<CustomPaletteKey, HTMLInputElement | null>>;
|
|
1084
|
+
label: string;
|
|
1085
|
+
onChange: (key: CustomPaletteKey, color: string) => void;
|
|
1086
|
+
onOpen: (key: CustomPaletteKey) => void;
|
|
1087
|
+
onRemove: (key: CustomPaletteKey) => void;
|
|
1088
|
+
removeLabel: string;
|
|
1089
|
+
slots: Record<CustomPaletteKey, string>;
|
|
1090
|
+
values: Record<CustomPaletteKey, string>;
|
|
1091
|
+
}) {
|
|
1092
|
+
const hasAnyColor = Object.values(values).some(Boolean);
|
|
1093
|
+
|
|
1094
|
+
return (
|
|
1095
|
+
<div className="grid gap-2">
|
|
1096
|
+
<div
|
|
1097
|
+
className={`flex min-h-14 items-center justify-between gap-4 rounded-2xl border-2 px-4 text-sm font-semibold transition ${
|
|
1098
|
+
hasAnyColor
|
|
1099
|
+
? "border-[#111111] bg-[#F2F1EC] text-[#111111] shadow-[0_8px_18px_rgba(17,17,17,0.08)]"
|
|
1100
|
+
: "border-[#E1DDD3] bg-white text-[#555555]"
|
|
1101
|
+
}`}
|
|
1102
|
+
>
|
|
1103
|
+
<span className="min-w-0 text-[#111111]">{label}</span>
|
|
1104
|
+
<span className="flex shrink-0 gap-2">
|
|
1105
|
+
{customPaletteKeys.map((key) => {
|
|
1106
|
+
const color = values[key];
|
|
1107
|
+
return (
|
|
1108
|
+
<span key={key} className="group relative flex size-9 items-center justify-center">
|
|
1109
|
+
<button
|
|
1110
|
+
type="button"
|
|
1111
|
+
aria-label={slots[key]}
|
|
1112
|
+
className={`flex size-8 items-center justify-center rounded-full border transition focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-[#111111]/20 ${
|
|
1113
|
+
color ? "border-white/60" : "border-[#CFC9BC] bg-white text-[#777777]"
|
|
1114
|
+
}`}
|
|
1115
|
+
style={color ? { backgroundColor: color } : undefined}
|
|
1116
|
+
onClick={() => onOpen(key)}
|
|
1117
|
+
>
|
|
1118
|
+
{color ? null : <Plus aria-hidden className="size-4" />}
|
|
1119
|
+
</button>
|
|
1120
|
+
{color ? (
|
|
1121
|
+
<button
|
|
1122
|
+
type="button"
|
|
1123
|
+
aria-label={`${removeLabel} ${slots[key]}`}
|
|
1124
|
+
className="absolute -right-1 -top-1 flex size-4 items-center justify-center rounded-full border border-white bg-[#111111] text-white opacity-0 shadow-[0_2px_8px_rgba(17,17,17,0.2)] transition group-hover:opacity-100 group-focus-within:opacity-100"
|
|
1125
|
+
onClick={(event) => {
|
|
1126
|
+
event.stopPropagation();
|
|
1127
|
+
onRemove(key);
|
|
1128
|
+
}}
|
|
1129
|
+
>
|
|
1130
|
+
<X aria-hidden className="size-2.5" />
|
|
1131
|
+
</button>
|
|
1132
|
+
) : null}
|
|
1133
|
+
<input
|
|
1134
|
+
ref={(node) => {
|
|
1135
|
+
inputRefs.current[key] = node;
|
|
1136
|
+
}}
|
|
1137
|
+
aria-label={slots[key]}
|
|
1138
|
+
className="sr-only"
|
|
1139
|
+
type="color"
|
|
1140
|
+
value={color || fallbackColors[key]}
|
|
1141
|
+
onChange={(event) => onChange(key, event.target.value)}
|
|
1142
|
+
/>
|
|
1143
|
+
</span>
|
|
1144
|
+
);
|
|
1145
|
+
})}
|
|
1146
|
+
</span>
|
|
1147
|
+
</div>
|
|
1148
|
+
<p className="text-xs leading-5 text-[#777777]">{hint}</p>
|
|
1149
|
+
</div>
|
|
1150
|
+
);
|
|
1151
|
+
}
|
|
1152
|
+
|
|
1153
|
+
function OptionGroup<T extends string>({
|
|
1154
|
+
label,
|
|
1155
|
+
options,
|
|
1156
|
+
selected,
|
|
1157
|
+
labelFor,
|
|
1158
|
+
onSelect,
|
|
1159
|
+
}: {
|
|
1160
|
+
label: string;
|
|
1161
|
+
options: readonly T[];
|
|
1162
|
+
selected: T;
|
|
1163
|
+
labelFor: (key: T) => string;
|
|
1164
|
+
onSelect: (key: T) => void;
|
|
1165
|
+
}) {
|
|
1166
|
+
return (
|
|
1167
|
+
<div>
|
|
1168
|
+
<p className="mb-3 text-[13px] font-semibold text-[#111111]">{label}</p>
|
|
1169
|
+
<div className="flex flex-wrap gap-2">
|
|
1170
|
+
{options.map((option) => {
|
|
1171
|
+
const active = selected === option;
|
|
1172
|
+
return (
|
|
1173
|
+
<button
|
|
1174
|
+
key={option}
|
|
1175
|
+
type="button"
|
|
1176
|
+
aria-pressed={active}
|
|
1177
|
+
onClick={() => onSelect(option)}
|
|
1178
|
+
style={active ? { borderColor: "#111111" } : undefined}
|
|
1179
|
+
className={`min-h-10 rounded-full border-2 px-4 text-sm font-semibold transition focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-[#111111]/20 ${
|
|
1180
|
+
active
|
|
1181
|
+
? "border-[#111111] bg-[#F2F1EC] text-[#111111] shadow-[0_8px_18px_rgba(17,17,17,0.08)]"
|
|
1182
|
+
: "border-[#E1DDD3] bg-white text-[#555555] hover:border-[#8A857A] hover:text-[#111111]"
|
|
1183
|
+
}`}
|
|
1184
|
+
>
|
|
1185
|
+
{labelFor(option)}
|
|
1186
|
+
</button>
|
|
1187
|
+
);
|
|
1188
|
+
})}
|
|
1189
|
+
</div>
|
|
1190
|
+
</div>
|
|
1191
|
+
);
|
|
1192
|
+
}
|
|
1193
|
+
|
|
1194
|
+
function SchemeCountGroup({
|
|
1195
|
+
label,
|
|
1196
|
+
options,
|
|
1197
|
+
selected,
|
|
1198
|
+
labelFor,
|
|
1199
|
+
onSelect,
|
|
1200
|
+
}: {
|
|
1201
|
+
label: string;
|
|
1202
|
+
options: readonly number[];
|
|
1203
|
+
selected: number;
|
|
1204
|
+
labelFor: (count: number) => string;
|
|
1205
|
+
onSelect: (count: number) => void;
|
|
1206
|
+
}) {
|
|
1207
|
+
return (
|
|
1208
|
+
<div>
|
|
1209
|
+
<p className="mb-3 text-[13px] font-semibold text-[#111111]">{label}</p>
|
|
1210
|
+
<div className="grid grid-cols-5 gap-2">
|
|
1211
|
+
{options.map((option) => {
|
|
1212
|
+
const active = selected === option;
|
|
1213
|
+
return (
|
|
1214
|
+
<button
|
|
1215
|
+
key={option}
|
|
1216
|
+
type="button"
|
|
1217
|
+
aria-pressed={active}
|
|
1218
|
+
onClick={() => onSelect(option)}
|
|
1219
|
+
className={`flex min-h-11 items-center justify-center rounded-full border-2 text-sm font-semibold transition focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-[#111111]/20 ${
|
|
1220
|
+
active
|
|
1221
|
+
? "border-[#111111] bg-[#F2F1EC] text-[#111111] shadow-[0_8px_18px_rgba(17,17,17,0.08)]"
|
|
1222
|
+
: "border-[#E1DDD3] bg-white text-[#555555] hover:border-[#8A857A] hover:text-[#111111]"
|
|
1223
|
+
}`}
|
|
1224
|
+
>
|
|
1225
|
+
{labelFor(option)}
|
|
1226
|
+
</button>
|
|
1227
|
+
);
|
|
1228
|
+
})}
|
|
1229
|
+
</div>
|
|
1230
|
+
</div>
|
|
1231
|
+
);
|
|
1232
|
+
}
|
|
1233
|
+
|
|
1234
|
+
function ResultPlaceholder({ title, hint }: { title: string; hint: string }) {
|
|
1235
|
+
return (
|
|
1236
|
+
<div className="mt-5 flex min-h-0 flex-1 flex-col items-center justify-center rounded-lg border border-[#E5E5E5] bg-white p-8 text-center">
|
|
1237
|
+
<span className="mx-auto flex size-12 items-center justify-center rounded-lg bg-[#F4F4F4] text-[#111111]">
|
|
1238
|
+
<FileImage aria-hidden className="size-5" />
|
|
1239
|
+
</span>
|
|
1240
|
+
<h3 className="mt-5 text-lg font-semibold leading-tight text-[#111111]">{title}</h3>
|
|
1241
|
+
<p className="mx-auto mt-3 max-w-sm text-sm leading-6 text-[#555555]">{hint}</p>
|
|
1242
|
+
</div>
|
|
1243
|
+
);
|
|
1244
|
+
}
|