Unrestricted Open-source alternative to AI video platforms — Free AI image & video generation studio with 600+ models (Flux, Midjourney, Kling, Sora, Veo). No content filters. Self-hosted, MIT licensed.
JavaScript ai-art-generatorai-image-generationai-video-generationfal-ai-alternativegenerative-aiimage-to-videoinvideo-alternativekling-ailipsynclitellm-alternativemidjourney-alternativemuapiopen-sourceopenrouter-alternativeseedance2sora-alternativetext-to-imagetext-to-videouncensoredwan-video
Restore complete Studio sources
WhiteRaven116aa3372b94d0
diff --git a/components/StandaloneShell.js b/components/StandaloneShell.jsindex 6bbf230d..1158a906 100644--- a/components/StandaloneShell.js+++ b/components/StandaloneShell.js@@ -423,4 +423,726 @@ export default function StandaloneShell() {}, [pushNotification]);const makeGenerationStartCallback = useCallback((tabId) => () => {- setGenerationCounts((previous��w����k�w��@�����(�����������������������������(��������������������������(������������������������(����������������������(��������������������(�������������������(����������������((���������������aA1=I}AAM}Q�����(����������������������9����д́�д́��ɑ�ȵЁ��ɑ�ȵݡ�є�l����t��(�������������������(���������������������ɕ��퀽��Ց�����aA1=I}AAM}Q������(���������������������� �����졕ٕ�Ф����������9�٥��ѥ��%ѕ� ������ٕ�а�aA1=I}AAM}Q�����(���������������������ɥ�����ɕ���텍ѥٕQ������aA1=I}AAM}Q��������������չ��������(���������������������ɥ���������aA1=I}AAM}Q�������(��������������������ѥѱ�����M������ �����͕��������5�����=������aA1=I}AAM}Q��������չ��������(�������������������������9�����(�����������������������ɽ���ɕ��ѥٔ�������ѕ�̵���ѕȁɽչ����ᰁ�Ʌ�ͥѥ���������Ʌѥ�������ѕ�еl����t����е͕������(��������������������������M������ �����͕��������5�����=����������āܴ�ā���ѥ�䵍��ѕȁ��Ѽ��耝��́��ȸԁܵ�ձ������̝�(�����������������������텍ѥٕQ������aA1=I}AAM}Q���(�������������������������������Ʌ����еѼ�ȁ�ɽ��l��ɐ͕�t��ԁѼ���������������ѕ�еl��ɐ͕�t���ɑ�ȁ��ɑ�ȵl��ɐ͕�t����(������������������������耝ѕ�еݡ�є������ٕ��ѕ�еݡ�є���ٕ�鉜�ݡ�є�l����t���ɑ�ȁ��ɑ�ȵ�Ʌ����ɕ�М(�����������������������(����������������������(�������������������(��������������������텍ѥٕQ������aA1=I}AAM}Q��������(���������������������������������9���ͽ��є����д��ѽ��ȁ���ѽ��ȁܴā����Ʌ����еѼ����ɽ��l��ɐ͕�t�Ѽ�l�����t�ɽչ����ȵ�ձ�����(����������������������(�������������������������������9����큙���͡ɥ������텍ѥٕQ������aA1=I}AAM}Q�������ѕ�еl��ɐ͕�t��耝ѕ�еݡ�є�����ɽ�����ٕ��ѕ�еݡ�є�����(�����������������������aA1=I}AAM}Q������(��������������������������(��������������������젅��M������ �����͕�������5�����=���������(���������������������������������9������չ��є���aA1=I}AAM}Q�������������(����������������������(��������������������(������������������(����������������(��������������(�����������ͥ���(����������((��������켨�M�Ց��� ��ѕ�Ѐ���(��������������9�����ā�����������ձ��ɕ��ѥٔ��ٕə��ܵ����������l�������t��(��������������9����텍ѥٕQ�����������������ձ��ܵ�ձ���耉���������(�����������%����M�Ց������-������-���ɽ����������ɽ������������!������������������!���������Ʌѥ��Mх�����������Ʌѥ��Mх�� �������������������Ʌѥ�������������Ʌѥ���� �������������������Ʌѥ�� �����є������MՍ���� �������������������Ʌѥ���ɽ��������ɽ� ������������������(����������(��������������9����텍ѥٕQ������٥�����������ձ��ܵ�ձ���耉���������(�����������Y����M�Ց������-������-���ɽ����������ɽ������������!������������������!���������Ʌѥ��Mх�����������Ʌѥ��Mх�� ���������٥��������Ʌѥ�������������Ʌѥ���� ���������٥��������Ʌѥ�� �����є������MՍ���� ���������٥��������Ʌѥ���ɽ��������ɽ� ���������٥�������(����������(��������������9����텍ѥٕQ��������������������ձ��ܵ�ձ���耉���������(����������� �������M�Ց������-������-���ɽ����������ɽ������������!������������������!���������Ʌѥ��Mх�����������Ʌѥ��Mх�� ����������������������Ʌѥ�������������Ʌѥ���� ����������������������Ʌѥ�� �����є������MՍ���� ����������������������Ʌѥ���ɽ��������ɽ� ���������������������(����������(��������������9����텍ѥٕQ������٥�����ѥ����������ձ��ܵ�ձ���耉���������(�����������Y���5�ѥ��M�Ց������-������-�����Ʌѥ��Mх�����������Ʌѥ��Mх�� ���������٥�����ѥ�������Ʌѥ�������������Ʌѥ���� ���������٥�����ѥ�������Ʌѥ�� �����є������MՍ���� ���������٥�����ѥ�������Ʌѥ���ɽ��������ɽ� ���������٥�����ѥ������(����������(��������������9����텍ѥٕQ��������幌��������ձ��ܵ�ձ���耉���������(�����������1��M幍M�Ց������-������-���ɽ����������ɽ������������!������������������!���������Ʌѥ��Mх�����������Ʌѥ��Mх�� �������������幌�����Ʌѥ�������������Ʌѥ���� �������������幌�����Ʌѥ�� �����є������MՍ���� �������������幌�����Ʌѥ���ɽ��������ɽ� �������������幌����(����������(��������������9����텍ѥٕQ���������݅���������ձ��ܵ�ձ���耉���������(�����������I�����M�Ց������-������-���ɽ����������ɽ������������!������������������!���������Ʌѥ��Mх�����������Ʌѥ��Mх�� ��������������݅������Ʌѥ�������������Ʌѥ���� ��������������݅������Ʌѥ�� �����є������MՍ���� ��������������݅������Ʌѥ���ɽ��������ɽ� ��������������݅�����(����������(��������������9����텍ѥٕQ������������������ձ��ܵ�ձ���耉���������(����������� �����M�Ց������-������-�����Ʌѥ��Mх�����������Ʌѥ��Mх�� ��������������������Ʌѥ�������������Ʌѥ���� ��������������������Ʌѥ�� �����є������MՍ���� ��������������������Ʌѥ���ɽ��������ɽ� �������������������(����������(��������������9����텍ѥٕQ�����Ց����������ձ��ܵ�ձ���耉���������(�����������Ց��M�Ց������-������-���ɽ����������ɽ������������!������������������!���������Ʌѥ��Mх�����������Ʌѥ��Mх�� ����������Ց�������Ʌѥ�������������Ʌѥ���� ����������Ց�������Ʌѥ�� �����є������MՍ���� ����������Ց�������Ʌѥ���ɽ��������ɽ� ����������Ց������(����������(��������������9����텍ѥٕQ������ɭ�ѥ����������ձ��ܵ�ձ���耉���������(�����������5�ɭ�ѥ��M�Ց������-������-���ɽ����������ɽ������������!������������������!���������Ʌѥ��Mх�����������Ʌѥ��Mх�� �����������ɭ�ѥ�������Ʌѥ�������������Ʌѥ���� �����������ɭ�ѥ�������Ʌѥ�� �����є������MՍ���� �����������ɭ�ѥ�������Ʌѥ���ɽ��������ɽ� �����������ɭ�ѥ������(����������(��������������9����텍ѥٕQ������ݽɭ����̜�������ձ��ܵ�ձ���耉���������(�����������]�ɭ����M�Ց��(���������������-������-���(��������������!�����Y�ͥ�������!�����Y�ͥ����(��������������Q�����!�������͕�%�!�����Y�ͥ����(�����������������Ʌѥ��Mх�����������Ʌѥ��Mх�� ���������ݽɭ����̜��(�����������������Ʌѥ�������������Ʌѥ���� ���������ݽɭ����̜��(�����������������Ʌѥ�� �����є������MՍ���� ���������ݽɭ����̜��(�����������������Ʌѥ���ɽ��������ɽ� ���������ݽɭ����̜��(������������(����������(��������������9����텍ѥٕQ���������̜�������ձ��ܵ�ձ���耉���������(���������������M�Ց������-������-����!�����Y�ͥ�������!�����Y�ͥ���Q�����!�������͕�%�!�����Y�ͥ�����(����������(��������������9����텍ѥٕQ������ͥ�������М�������ձ��ܵ�ձ���耉���������(����������텍ѥٕQ������ͥ�������М�����(��������������ͥ������M�Ց��(�����������������-������-���(����������������!�����Y�ͥ�������!�����Y�ͥ����(����������������Q�����!�������͕�%�!�����Y�ͥ����(�������������������Ʌѥ��Mх�����������Ʌѥ��Mх�� �����������ͥ�������М��(�������������������Ʌѥ�������������Ʌѥ���� �����������ͥ�������М��(�������������������Ʌѥ�� �����є������MՍ���� �����������ͥ�������М��(�������������������Ʌѥ���ɽ��������ɽ� �����������ͥ�������М��(��������������(������������(����������(��������������9����텍ѥٕQ�������̜�������ձ��ܵ�ձ���耉���������(��������������M�Ց������-������-����(����������(��������������9����텍ѥٕQ�����������Օ���Ȝ�������ձ��ܵ�ձ���耉���������(������������%���Օ����M�Ց��(���������������-������-���(�����������������Ʌѥ��Mх�����������Ʌѥ��Mх�� ����������������Օ���Ȝ��(�����������������Ʌѥ�������������Ʌѥ���� ����������������Օ���Ȝ��(�����������������Ʌѥ�� �����є������MՍ���� ����������������Օ���Ȝ��(�����������������Ʌѥ���ɽ��������ɽ� ����������������Օ���Ȝ��(������������(����������(��������(������((������켨�����������Ʌѥ�����ѥ٥�䁅�����ѥ����ѥ����х������(������졅�ѥٕ���Ʌѥ��̹����Ѡ����������ѥ����ѥ��̹����Ѡ����������(����������(�����������ɥ����ٔ�����є�(�����������ɥ�����������Ʌѥ�����ѥ٥�䁅�����ѥ����ѥ��̈(���������������9���ᕐ����ѽ��ԁɥ��дԁ�l���t��������ൠ�m��������٠�����t�ܵl�����t����ܵm���������ܴ����t����്�������ȁ�ٕə��ܵ䵅�Ѽ�����ѕȵ�ٕ��̵�����(������������ф�ѕ�ѥ��������ѥ����ѥ����х���(���������(����������텍ѥٕ���Ʌѥ��̹���������Ʌѥ��������(��������������(������������������흕��Ʌѥ���х�%��(��������������ɽ����х��̈(����������������ф�����Ʌѥ���х��흕��Ʌѥ���х�%��(�������������������9��������ѕȵ�ٕ��̵��Ѽ�������ѕ�̵���ѕȁ����́ɽչ����ᰁ��ɑ�ȁ��ɑ�ȵ�典�����������l�������t���̸ԁ��́ѕ�еl����t�ѕ�е饹������͡���ܵl�|����|����}ɝ������������ԥt�(����������������ф�ѕ�ѥ���Ʌѥ�����ѥ٥��(�������������(�������������������������9����������ܴ��͡ɥ������ѕ�̵���ѕȁ���ѥ�䵍��ѕȁɽչ���������ɑ�ȁ��ɑ�ȵ�典������ԁ����典���������(���������������������(�����������������������9���̸ԁ̸ܴԁ�����є������ɽչ�����ձ����ɑ�ȴȁ��ɑ�ȵ�典������ԁ��ɑ�ȵе�典�����(�������������������ɥ�����������Ք�(������������������(��������������������(����������������������9�����ܴ������ā���е͕���������������ԁѕ�е饹�������(����������������흕��Ʌѥ���������́����Ʌѥ��(����������������흕��Ʌѥ�����չЀ��Ā������흕��Ʌѥ�����չ�����耜��(�����������������(��������������(�������������((�������������ѥ����ѥ��̹�������ѥ�������(��������������(���������������������ѥ�����(��������������ɽ������ѥ����������ɽȜ��������М�耝�х��̝�(����������������ф���ѥ����ѥ�����������ѥ�������(����������������ф���ѥ����ѥ���х�����ѥ��х�%��(�������������������9��������ѕȵ�ٕ��̵��Ѽ�������ѕ�̵�х�Ё����́ɽչ����ᰁ��ɑ�ȁ���l�������t���̸ԁ��́ѕ�еl����t�ѕ�е饹������͡���ܵl�|����|����}ɝ������������ԥt�(����������������屔���(������������������ɑ�� ����聹�ѥ�����������Ս���̜����ɝ����а��İ������Ԥ��耝ɝ�������������Ԥ��(���������������������ѥ��耝ͱ���%�I���Ѐ����́�Չ�����饕Ƞ���ذİ��̰Ĥ����݅ɑ̜�(����������������(�������������(�������������������(���������������������9����큵д��ԁ���������ܴ��͡ɥ������ѕ�̵���ѕȁ���ѥ�䵍��ѕȁɽչ���������ɑ�Ȁ��(��������������������ѥ�����������Ս���̜(�������������������������ɑ�ȵ�典������ԁ����典��������ѕ�е�典�����(��������������������耝��ɑ�ȵɕ�������ԁ���ɕ���������ѕ�еɕ������(�������������������(���������������(�������������������ѥ�����������Ս���̜����(��������������������ٜ�ݥ�Ѡ��܈���������܈�٥�� ��������Ѐ�Ј�����������ɽ�����ɕ�� ���Ȉ���ɽ��]��Ѡ�ȸԈ���ɽ��1�������ɽչ�����ɽ��1��������ɽչ����ɥ�����������Ք��(�����������������������Ѡ���Ԁ�ȀЀ�0��؈���(��������������������ٜ�(������������������耠(��������������������ٜ�ݥ�Ѡ��܈���������܈�٥�� ��������Ѐ�Ј�����������ɽ�����ɕ�� ���Ȉ���ɽ��]��Ѡ�Ȉ���ɽ��1�������ɽչ�����ɽ��1��������ɽչ����ɥ�����������Ք��(���������������������ɍ�������Ȉ�����Ȉ���䈀��(�����������������������Ѡ���4�Ȁ��؈���(�����������������������Ѡ���4�Ȁ�ݠ��Ĉ���(��������������������ٜ�(������������������(��������������������((��������������������9�����ܴ������Ĉ�(������������������������9����е͕���������������ԁѕ�е饹�������(���������������������ѥ��������(�����������������������������9����е��ɵ���ѕ�е饹�������(�����������������������ѥ�����������Ս���̜����������Ʌѥ���������є��耜������Ʌѥ�����������(������������������������(�������������������(�������������������ѥ����������ɽȜ������ѥ�����ͅ�������(��������������������������9����д��ԁ�����������ȁѕ�еl����t����е����մ���������Ёѕ�еɕ�������Ԉ�ѥѱ�����ѥ�����ͅ����(�����������������������ѥ�����ͅ���(���������������������(������������������(�������������������ѥ�����������Ս���̜�����(��������������������������9����д��ԁѕ�еl����t���������Ёѕ�е饹�������(��������������������e��ȁɕ�ձЁ�́ɕ���(���������������������(������������������(�������������������ѥ�����������Ս���̜�����(���������������������ѽ�(���������������������������ѽ��(���������������������� �����젤����������=���9�ѥ����ѥ�����ѥ���(�������������������������9����дĸԁѕ�еl����t����е�����ѕ�е�典������Ʌ�ͥѥ��������́��ٕ��ѕ�е�典�����(���������������������ɥ���������=��������ѥ��������ɕ�ձс�(�������������������(��������������������=���(���������������������ѽ��(������������������(����������������((�����������������ѽ�(�����������������������ѽ��(������������������ �����젤������͵���9�ѥ����ѥ�����ѥ������(���������������������9����д��ԁ�������܁ܴ܁͡ɥ������ѕ�̵���ѕȁ���ѥ�䵍��ѕȁɽչ�������ѕ�е饹�������Ʌ�ͥѥ��������́��ٕ�鉜�ݡ�є�ԁ��ٕ��ѕ�е饹�������������ѱ���������������ɥ���ā������ɥ���ݡ�є����(�����������������ɥ���������͵��́��ѥ����ѥ���(���������������(������������������ٜ�ݥ�Ѡ��Ј���������Ј�٥�� ��������Ѐ�Ј�����������ɽ�����ɕ�� ���Ȉ���ɽ��]��Ѡ�Ȉ���ɽ��1�������ɽչ����ɥ�����������Ք��(���������������������Ѡ���4�����4ٰ�Ȁ�Ȉ���(������������������ٜ�(�����������������ѽ��(��������������(�������������(����������(��������((������켨�-��Ʌ�����ȁѽ��Ёͱ����������(���������屔��(�����������Ʌ��́ͱ���%�I���Ё�(�����������ɽ����Ʌ�͙�ɴ��Ʌ�ͱ�ѕ`������쁽����������(����������Ѽ�����Ʌ�͙�ɴ��Ʌ�ͱ�ѕ`���쀀�������������(���������(�����������屔�((������켨�M��ѥ��́5��������(�������͡��M��ѥ��̀����(��������������9���ᕐ���͕д�������������������ɽ�����ȵʹ�������ѕ�̵���ѕȁ���ѥ�䵍��ѕȁ���������є�������������(����������������9����l�������t���ɑ�ȁ��ɑ�ȵݡ�є����ɽչ����ᰁ����ܵ�ձ�����ܵʹ�͡���ܴ�ᰈ�(�������������ȁ�����9����ѕ�еݡ�є����е�����ѕ�е������Ȉ�M��ѥ������(��������������������9����ѕ�еݡ�є����ѕ�еl����t�������(��������������5��������ȁ$���Ց����ɕ��ɕ���́������ѡ��ѥ��ѥ���(���������������(������������(������������������9�����������Ё������(��������������������9����ݡ�є�ԁ��ɑ�ȁ��ɑ�ȵݡ�є�l����t�ɽչ���������Ј�(������������������������9�������ѕ�е�́���е�����ѕ�еݡ�є�������Ȉ�(��������������������ѥٔ�A$�-��(��������������������(����������������������9����ѕ�еl����t����е�����ѕ�еݡ�є�����(���������������������-��ͱ�����������������������������������������(������������������(����������������(��������������((������������������9����������̈�(�����������������ѽ�(������������������ ������������-�� ������(���������������������9�����ā�����ɽչ����������ɕ���������ѕ�еɕ��������ٕ�鉜�ɕ���������ѕ�е�́���е͕��������Ʌ�ͥѥ�������(���������������(���������������� ������-��(�����������������ѽ��(�����������������ѽ�(������������������ �����젤����͕�M���M��ѥ��̡���͔��(���������������������9�����ā�����ɽչ����������ݡ�є�ԁѕ�еݡ�є������ٕ�鉜�ݡ�є����ѕ�е�́���е͕��������Ʌ�ͥѥ���������ɑ�ȁ��ɑ�ȵݡ�є�Ԉ(���������������(���������������� ��͔(�����������������ѽ��(��������������(������������(����������(��������(������(����)�(\ No newline at end of file+ setGenerationCounts((previous) => ({+ ...previous,+ [tabId]: (previous[tabId] || 0) + 1,+ }));+ }, []);++ const makeGenerationEndCallback = useCallback((tabId) => () => {+ setGenerationCounts((previous) => {+ const currentCount = previous[tabId] || 0;+ if (currentCount <= 1) {+ const next = { ...previous };+ delete next[tabId];+ return next;+ }++ return {+ ...previous,+ [tabId]: currentCount - 1,+ };+ });+ }, []);++ const activeGenerations = TABS+ .filter((tab) => generationCounts[tab.id] > 0)+ .map((tab) => ({+ tabId: tab.id,+ label: tab.label,+ count: generationCounts[tab.id],+ }));++ // Popstate event listener to sync tab state with URL on back/forward navigation+ useEffect(() => {+ const handlePopState = () => {+ const path = window.location.pathname;+ const segments = path.split('/').filter(Boolean);+ const tabId = segments[1] || 'image';+ if (TABS.find(t => t.id === tabId)) {+ setActiveTab(tabId);+ }+ };+ window.addEventListener('popstate', handlePopState);+ return () => window.removeEventListener('popstate', handlePopState);+ }, []);++ const handleTabChange = useCallback((tabId) => {+ window.history.pushState(null, '', `/studio/${tabId}`);+ setActiveTab(tabId);+ }, []);++ const handleOpenNotification = useCallback((notification) => {+ handleTabChange(notification.tabId);+ dismissNotification(notification.id);+ }, [dismissNotification, handleTabChange]);++ const handleTabClick = (e, tabId) => {+ if (e.button === 0 && !e.ctrlKey && !e.metaKey && !e.shiftKey && !e.altKey) {+ e.preventDefault();+ handleTabChange(tabId);+ return true;+ }+ return false;+ };++ const handleNavigationItemClick = (event, tabId) => {+ if (handleTabClick(event, tabId)) {+ setIsMobileOpen(false);+ }+ };++ // Auto-hide header when inside a specific workflow view or design agent+ useEffect(() => {+ const isEditingWorkflow = (activeTab === 'workflows' || !!idFromParams) && urlWorkflowId;+ const isDesignAgent = activeTab === 'design-agent';++ if (isEditingWorkflow || isDesignAgent) {+ setIsHeaderVisible(false);+ } else {+ setIsHeaderVisible(true);+ }+ }, [activeTab, urlWorkflowId, idFromParams]);++ // Global builder CSS cleanup when switching away from Workflows or Design Agent tabs+ useEffect(() => {+ const fromBuilder = sessionStorage.getItem("fromWorkflowBuilder");+ const fromDesignAgent = sessionStorage.getItem("fromDesignAgent");++ if ((fromBuilder && activeTab !== 'workflows') || (fromDesignAgent && activeTab !== 'design-agent')) {+ sessionStorage.removeItem("fromWorkflowBuilder");+ sessionStorage.removeItem("fromDesignAgent");+ window.location.reload();+ }+ }, [activeTab]);++ const fetchBalance = useCallback(async (key) => {+ try {+ const data = await getUserBalance(key);+ setBalance(data.balance);+ } catch (err) {+ console.error('Balance fetch failed:', err);+ }+ }, []);++ useEffect(() => {+ setHasMounted(true);+ const stored = localStorage.getItem(STORAGE_KEY);+ if (stored) {+ setApiKey(stored);+ fetchBalance(stored);+ // Sync cookie immediately on mount to establish identity for background requests+ document.cookie = `muapi_key=${stored}; path=/; max-age=31536000; SameSite=Lax`;+ }+ }, [fetchBalance]);++ const handleKeySave = useCallback((key) => {+ localStorage.setItem(STORAGE_KEY, key);+ setApiKey(key);+ fetchBalance(key);+ document.cookie = `muapi_key=${key}; path=/; max-age=31536000; SameSite=Lax`;+ }, [fetchBalance]);++ const handleKeyChange = useCallback(() => {+ localStorage.removeItem(STORAGE_KEY);+ setApiKey(null);+ setBalance(null);+ document.cookie = "muapi_key=; path=/; expires=Thu, 01 Jan 1970 00:00:00 GMT";+ }, []);++ // Inject API key into all outgoing Axios requests (prop-based approach)+ // We use an interceptor to be selective and NOT send the key to external domains like S3+ useEffect(() => {+ // Safety: Clear any global defaults that might have been set previously+ delete axios.defaults.headers.common['x-api-key'];++ if (!apiKey) return;++ const interceptorId = axios.interceptors.request.use((config) => {+ // Check if URL is local/proxied+ const isRelative = config.url.startsWith('/') || !config.url.startsWith('http');+ const isInternalProxy = config.url.includes('/api/app') || config.url.includes('/api/workflow') || config.url.includes('/api/agents') || config.url.includes('/api/api') || config.url.includes('/api/v1');++ if (isRelative || isInternalProxy) {+ config.headers['x-api-key'] = apiKey;+ }++ return config;+ });++ return () => {+ axios.interceptors.request.eject(interceptorId);+ };+ }, [apiKey]);++ // Poll for balance every 30 seconds if key is present+ useEffect(() => {+ if (!apiKey) return;+ const interval = setInterval(() => fetchBalance(apiKey), 30000);+ return () => clearInterval(interval);+ }, [apiKey, fetchBalance]);++ // Drag and Drop Handlers+ const handleDragOver = useCallback((e) => {+ e.preventDefault();+ e.stopPropagation();+ }, []);++ const handleDragEnter = useCallback((e) => {+ e.preventDefault();+ e.stopPropagation();+ if (e.dataTransfer.items && e.dataTransfer.items.length > 0) {+ setIsDragging(true);+ }+ }, []);++ const handleDragLeave = useCallback((e) => {+ e.preventDefault();+ e.stopPropagation();+ // Only set to false if we're leaving the container itself, not moving between children+ if (e.currentTarget.contains(e.relatedTarget)) return;+ setIsDragging(false);+ }, []);++ const handleDrop = useCallback((e) => {+ e.preventDefault();+ e.stopPropagation();+ setIsDragging(false);++ const files = Array.from(e.dataTransfer.files);+ if (files.length > 0) {+ setDroppedFiles(files);+ }+ }, []);++ const handleFilesHandled = useCallback(() => {+ setDroppedFiles(null);+ }, []);++ if (!hasMounted) return (+ <div className="min-h-screen bg-[#050505] flex items-center justify-center">+ <div className="animate-spin text-[#22d3ee] text-3xl">◌</div>+ </div>+ );++ if (!apiKey) {+ return <ApiKeyModal onSave={handleKeySave} />;+ }++ return (+ <div+ className="h-screen bg-[#030303] flex flex-col overflow-hidden text-white relative"+ onDragOver={handleDragOver}+ onDragEnter={handleDragEnter}+ onDragLeave={handleDragLeave}+ onDrop={handleDrop}+ >+ {/* Drag Overlay */}+ {isDragging && (+ <div className="fixed inset-0 z-[100] bg-[#22d3ee]/10 backdrop-blur-md border-4 border-dashed border-[#22d3ee]/50 flex items-center justify-center pointer-events-none transition-all duration-300">+ <div className="bg-[#0a0a0a] p-8 rounded-3xl border border-white/10 shadow-2xl flex flex-col items-center gap-4 scale-110 animate-pulse">+ <div className="w-20 h-20 bg-[#22d3ee] rounded-2xl flex items-center justify-center">+ <svg width="40" height="40" viewBox="0 0 24 24" fill="none" stroke="black" strokeWidth="2.5">+ <path d="M21 15v4a2 2 0 01-2 2H5a2 2 0 01-2-2v-4M17 8l-5-5-5 5M12 3v12"/>+ </svg>+ </div>+ <div className="flex flex-col items-center">+ <span className="text-xl font-bold text-white">Drop your media here</span>+ <span className="text-sm text-white/40">Images, videos, or audio files</span>+ </div>+ </div>+ </div>+ )}++ {/* Vadoo promo banner */}+ {showVadooBanner && (+ <div className="flex-shrink-0 w-full bg-indigo-600 flex items-center justify-center px-4 py-2 gap-3 relative z-50">+ <a+ href="https://vadoo.tv"+ target="_blank"+ rel="noopener noreferrer"+ className="text-[13px] font-bold text-white hover:opacity-80 transition-opacity text-center"+ >+ Unrestricted AI Images & Videos → Auto-Publish as YouTube Shorts & TikToks, Earn ↗+ </a>+ <button+ onClick={() => {+ setShowVadooBanner(false);+ localStorage.setItem('vadoo_banner_dismissed', '1');+ }}+ className="absolute right-3 text-white/60 hover:text-white transition-colors text-lg leading-none"+ aria-label="Dismiss"+ >+ ✕+ </button>+ </div>+ )}++ {/* Header */}+ {isHeaderVisible && (+ <header className="flex-shrink-0 h-14 border-b border-white/[0.05] flex items-center justify-between px-4 bg-[#0a0a0b]/80 backdrop-blur-md z-50 gap-4">+ {/* Left: Mobile menu toggle + Logo + Desktop Sidebar Toggle */}+ <div className="flex items-center gap-3">+ {/* Mobile drawer toggle */}+ <button+ onClick={() => setIsMobileOpen(!isMobileOpen)}+ className="md:hidden p-2 rounded-lg bg-white/5 hover:bg-white/10 text-white/70 hover:text-white transition-colors"+ aria-label="Toggle Navigation Menu"+ >+ <svg width="20" height="20" viewBox="0 0 24 24" fill="none" stroke="currentColor" strokeWidth="2">+ <line x1="3" y1="12" x2="21" y2="12" />+ <line x1="3" y1="6" x2="21" y2="6" />+ <line x1="3" y1="18" x2="21" y2="18" />+ </svg>+ </button>++ {/* Desktop Sidebar Toggle Button (Single Toggle Button) */}+ <div className="hidden md:block relative group">+ <button+ onClick={toggleSidebar}+ className="flex items-center justify-center w-8 h-8 rounded-lg bg-white/5 hover:bg-white/10 text-white/60 hover:text-white transition-colors border border-white/5"+ aria-label={isSidebarCollapsed ? "Expand sidebar" : "Collapse sidebar"}+ >+ <svg+ width="18"+ height="18"+ viewBox="0 0 24 24"+ fill="none"+ stroke="currentColor"+ strokeWidth="2"+ className={`transition-transform duration-300 ${isSidebarCollapsed ? 'rotate-180' : ''}`}+ >+ <rect x="3" y="3" width="18" height="18" rx="2" />+ <path d="M9 3v18" />+ <path d="M14 9l-3 3 3 3" />+ </svg>+ </button>+ {/* Custom Tooltip */}+ <div className="absolute left-0 top-full mt-2 px-2.5 py-1 bg-[#121215]/95 backdrop-blur-md text-white text-[11px] font-medium rounded-md shadow-2xl border border-white/15 opacity-0 group-hover:opacity-100 pointer-events-none transition-all duration-200 z-50 whitespace-nowrap">+ {isSidebarCollapsed ? "Expand sidebar" : "Collapse sidebar"}+ </div>+ </div>++ {/* Logo & Title */}+ <div className="flex items-center gap-2.5">+ <div className="w-8 h-8 bg-[#22d3ee] rounded-lg flex items-center justify-center shadow-lg shadow-[#22d3ee]/20">+ <svg width="20" height="20" viewBox="0 0 24 24" fill="none" stroke="black" strokeWidth="2.5" strokeLinecap="round" strokeLinejoin="round">+ <path d="M12 2L2 7l10 5 10-5-10-5zM2 17l10 5 10-5M2 12l10 5 10-5"/>+ </svg>+ </div>+ <span className="text-sm font-bold tracking-tight hidden sm:block text-white">+ OpenGenerativeAI+ </span>+ </div>+ </div>++ {/* Active Tab Breadcrumb Badge */}+ <div className="hidden lg:flex items-center gap-2 px-3 py-1 rounded-full bg-white/[0.03] border border-white/[0.05] text-xs text-white/60">+ <span className="w-1.5 h-1.5 rounded-full bg-[#22d3ee]" />+ <span className="font-medium text-white/80">+ {TABS.find(t => t.id === activeTab)?.label || 'Studio'}+ </span>+ </div>++ {/* Right: Actions */}+ <div className="flex-shrink-0 flex items-center gap-3">+ <div className="flex items-center gap-2.5 bg-white/5 px-3 py-1.5 rounded-full border border-white/5 transition-colors">+ <div className="w-2 h-2 rounded-full bg-green-500 animate-pulse" />+ <span className="text-xs font-bold text-white/90">+ ${balance !== null ? `${balance}` : '---'}+ </span>+ </div>++ <button+ onClick={() => setShowSettings(true)}+ className="flex items-center gap-2 px-3 py-1.5 rounded-md border border-white/10 bg-white/5 text-[13px] font-bold text-white/80 hover:text-white hover:bg-white/10 hover:border-white/20 transition-colors"+ aria-label="Settings"+ >+ <svg width="16" height="16" viewBox="0 0 24 24" fill="none" stroke="currentColor" strokeWidth="2" strokeLinecap="round" strokeLinejoin="round">+ <circle cx="12" cy="12" r="3" />+ <path d="M19.4 15a1.65 1.65 0 0 0 .33 1.82l.06.06a2 2 0 0 1 0 2.83 2 2 0 0 1-2.83 0l-.06-.06a1.65 1.65 0 0 0-1.82-.33 1.65 1.65 0 0 0-1 1.51V21a2 2 0 0 1-2 2 2 2 0 0 1-2-2v-.09A1.65 1.65 0 0 0 9 19.4a1.65 1.65 0 0 0-1.82.33l-.06.06a2 2 0 0 1-2.83 0 2 2 0 0 1 0-2.83l.06-.06a1.65 1.65 0 0 0 .33-1.82 1.65 1.65 0 0 0-1.51-1H3a2 2 0 0 1-2-2 2 2 0 0 1 2-2h.09A1.65 1.65 0 0 0 4.6 9a1.65 1.65 0 0 0-.33-1.82l-.06-.06a2 2 0 0 1 0-2.83 2 2 0 0 1 2.83 0l.06.06a1.65 1.65 0 0 0 1.82.33H9a1.65 1.65 0 0 0 1-1.51V3a2 2 0 0 1 2-2 2 2 0 0 1 2 2v.09a1.65 1.65 0 0 0 1 1.51 1.65 1.65 0 0 0 1.82-.33l.06-.06a2 2 0 0 1 2.83 0 2 2 0 0 1 0 2.83l-.06.06a1.65 1.65 0 0 0-.33 1.82V9a1.65 1.65 0 0 0 1.51 1H21a2 2 0 0 1 2 2 2 2 0 0 1-2 2h-.09a1.65 1.65 0 0 0-1.51 1z" />+ </svg>+ <span className="hidden sm:inline">Settings</span>+ </button>+ </div>+ </header>+ )}++ {/* Main Body Layout: Left Sidebar + Studio Content Area */}+ <div className="flex-1 min-h-0 flex relative overflow-hidden">+ {/* Mobile Backdrop Overlay */}+ {isMobileOpen && (+ <div+ className="fixed inset-0 bg-black/70 backdrop-blur-sm z-40 md:hidden animate-fade-in"+ onClick={() => setIsMobileOpen(false)}+ />+ )}++ {/* Left Sidebar Navigation */}+ {isHeaderVisible && (+ <aside+ className={`+ fixed top-14 bottom-0 left-0 md:static md:h-full z-30 bg-[#0a0a0b]/95 backdrop-blur-md border-r border-white/[0.06] flex flex-col transition-all duration-300 ease-in-out flex-shrink-0 select-none+ ${isMobileOpen ? 'translate-x-0 w-60 z-50' : '-translate-x-full md:translate-x-0'}+ ${isSidebarCollapsed ? 'md:w-16' : 'md:w-52'}+ `}+ >+ <nav aria-label="Studio navigation" className="flex-1 overflow-y-auto overflow-x-hidden scrollbar-none py-2 px-2">+ <div className="space-y-1">+ {NAVIGATION_CATEGORIES.map((category) => {+ const isCategoryActive = activeCategory?.id === category.id;+ const isCollapsed = isSidebarCollapsed && !isMobileOpen;+ const isCategoryOpen = !isCollapsed && expandedCategoryId === category.id;+ const categoryPanelId = `navigation-category-${category.id}`;++ return (+ <div key={category.id} className="relative">+ <button+ type="button"+ onClick={() => handleCategoryToggle(category.id)}+ aria-label={category.label}+ aria-expanded={isCategoryOpen}+ aria-controls={isCollapsed ? undefined : categoryPanelId}+ title={isCollapsed ? category.label : undefined}+ className={`+ group relative flex items-center rounded-xl transition-all duration-150 font-semibold+ ${isCollapsed ? 'h-11 w-11 justify-center mx-auto' : 'px-3 py-2.5 w-full gap-3 text-left'}+ ${isCategoryActive+ ? 'bg-gradient-to-r from-[#22d3ee]/15 to-purple-500/10 text-[#22d3ee] border border-[#22d3ee]/20 shadow-[0_0_15px_rgba(34,211,238,0.08)]'+ : isCategoryOpen+ ? 'bg-white/[0.06] text-white border border-white/[0.08]'+ : 'text-white/60 hover:text-white hover:bg-white/[0.04] border border-transparent'+ }+ `}+ >+ {isCategoryActive && (+ <span className="absolute left-0 top-2 bottom-2 w-1 bg-gradient-to-b from-[#22d3ee] to-[#a855f7] rounded-r-full shadow-[0_0_8px_rgba(34,211,238,0.6)]" />+ )}++ <span className={`flex-shrink-0 transition-colors ${isCategoryActive ? 'text-[#22d3ee]' : 'text-white/55 group-hover:text-white'}`}>+ {category.icon}+ </span>++ {!isCollapsed && (+ <>+ <span className="flex-1 min-w-0 text-[12px] leading-4 tracking-tight">+ {category.label}+ </span>+ <svg+ width="15"+ height="15"+ viewBox="0 0 24 24"+ fill="none"+ stroke="currentColor"+ strokeWidth="2"+ strokeLinecap="round"+ strokeLinejoin="round"+ className={`flex-shrink-0 transition-transform duration-200 ${isCategoryOpen ? 'rotate-180' : ''}`}+ aria-hidden="true"+ >+ <path d="M6 9l6 6 6-6"/>+ </svg>+ </>+ )}+ </button>++ {!isCollapsed && isCategoryOpen && (+ <div+ id={categoryPanelId}+ role="group"+ aria-label={`${category.label} tools`}+ className="mt-1 ml-2 pl-2 border-l border-white/[0.08] space-y-1 max-h-64 overflow-y-auto scrollbar-none"+ >+ {category.tabIds.map((tabId) => {+ const tab = TABS.find((item) => item.id === tabId);+ if (!tab) return null;+ const isActive = activeTab === tab.id;++ return (+ <a+ key={tab.id}+ href={`/studio/${tab.id}`}+ onClick={(event) => handleNavigationItemClick(event, tab.id)}+ aria-current={isActive ? 'page' : undefined}+ className={`+ group relative flex items-center gap-2.5 rounded-lg px-2.5 py-2 text-[12px] font-medium transition-all duration-150+ ${isActive+ ? 'bg-[#22d3ee]/12 text-[#22d3ee] border border-[#22d3ee]/20'+ : 'text-white/55 hover:text-white hover:bg-white/[0.04] border border-transparent'+ }+ `}+ >+ {isActive && (+ <span className="absolute -left-[11px] top-2 bottom-2 w-0.5 rounded-full bg-[#22d3ee] shadow-[0_0_7px_rgba(34,211,238,0.7)]" />+ )}+ <span className={`flex-shrink-0 ${isActive ? 'text-[#22d3ee]' : 'text-white/45 group-hover:text-white/80'}`}>+ {tab.icon}+ </span>+ <span className="truncate">{tab.label}</span>+ </a>+ );+ })}+ </div>+ )}+ </div>+ );+ })}+ </div>++ {EXPLORE_APPS_TAB && (+ <div className="mt-3 pt-3 border-t border-white/[0.07]">+ <a+ href={`/studio/${EXPLORE_APPS_TAB.id}`}+ onClick={(event) => handleNavigationItemClick(event, EXPLORE_APPS_TAB.id)}+ aria-current={activeTab === EXPLORE_APPS_TAB.id ? 'page' : undefined}+ aria-label={EXPLORE_APPS_TAB.label}+ title={isSidebarCollapsed && !isMobileOpen ? EXPLORE_APPS_TAB.label : undefined}+ className={`+ group relative flex items-center rounded-xl transition-all duration-150 text-[13px] font-semibold+ ${isSidebarCollapsed && !isMobileOpen ? 'h-11 w-11 justify-center mx-auto' : 'px-3 py-2.5 w-full gap-3'}+ ${activeTab === EXPLORE_APPS_TAB.id+ ? 'bg-gradient-to-r from-[#22d3ee]/15 to-purple-500/10 text-[#22d3ee] border border-[#22d3ee]/20'+ : 'text-white/60 hover:text-white hover:bg-white/[0.04] border border-transparent'+ }+ `}+ >+ {activeTab === EXPLORE_APPS_TAB.id && (+ <span className="absolute left-0 top-2 bottom-2 w-1 bg-gradient-to-b from-[#22d3ee] to-[#a855f7] rounded-r-full" />+ )}+ <span className={`flex-shrink-0 ${activeTab === EXPLORE_APPS_TAB.id ? 'text-[#22d3ee]' : 'text-white/50 group-hover:text-white'}`}>+ {EXPLORE_APPS_TAB.icon}+ </span>+ {(!isSidebarCollapsed || isMobileOpen) && (+ <span className="truncate">{EXPLORE_APPS_TAB.label}</span>+ )}+ </a>+ </div>+ )}+ </nav>+ </aside>+ )}++ {/* Studio Content */}+ <div className="flex-1 min-h-0 h-full relative overflow-hidden bg-[#030303]">+ <div className={activeTab === 'image' ? "h-full w-full" : "hidden"}>+ <ImageStudio apiKey={apiKey} droppedFiles={droppedFiles} onFilesHandled={handleFilesHandled} onGenerationStart={makeGenerationStartCallback('image')} onGenerationEnd={makeGenerationEndCallback('image')} onGenerationComplete={makeSuccessCallback('image')} onGenerationError={makeErrorCallback('image')} />+ </div>+ <div className={activeTab === 'video' ? "h-full w-full" : "hidden"}>+ <VideoStudio apiKey={apiKey} droppedFiles={droppedFiles} onFilesHandled={handleFilesHandled} onGenerationStart={makeGenerationStartCallback('video')} onGenerationEnd={makeGenerationEndCallback('video')} onGenerationComplete={makeSuccessCallback('video')} onGenerationError={makeErrorCallback('video')} />+ </div>+ <div className={activeTab === 'clipping' ? "h-full w-full" : "hidden"}>+ <ClippingStudio apiKey={apiKey} droppedFiles={droppedFiles} onFilesHandled={handleFilesHandled} onGenerationStart={makeGenerationStartCallback('clipping')} onGenerationEnd={makeGenerationEndCallback('clipping')} onGenerationComplete={makeSuccessCallback('clipping')} onGenerationError={makeErrorCallback('clipping')} />+ </div>+ <div className={activeTab === 'vibe-motion' ? "h-full w-full" : "hidden"}>+ <VibeMotionStudio apiKey={apiKey} onGenerationStart={makeGenerationStartCallback('vibe-motion')} onGenerationEnd={makeGenerationEndCallback('vibe-motion')} onGenerationComplete={makeSuccessCallback('vibe-motion')} onGenerationError={makeErrorCallback('vibe-motion')} />+ </div>+ <div className={activeTab === 'lipsync' ? "h-full w-full" : "hidden"}>+ <LipSyncStudio apiKey={apiKey} droppedFiles={droppedFiles} onFilesHandled={handleFilesHandled} onGenerationStart={makeGenerationStartCallback('lipsync')} onGenerationEnd={makeGenerationEndCallback('lipsync')} onGenerationComplete={makeSuccessCallback('lipsync')} onGenerationError={makeErrorCallback('lipsync')} />+ </div>+ <div className={activeTab === 'body-swap' ? "h-full w-full" : "hidden"}>+ <RecastStudio apiKey={apiKey} droppedFiles={droppedFiles} onFilesHandled={handleFilesHandled} onGenerationStart={makeGenerationStartCallback('body-swap')} onGenerationEnd={makeGenerationEndCallback('body-swap')} onGenerationComplete={makeSuccessCallback('body-swap')} onGenerationError={makeErrorCallback('body-swap')} />+ </div>+ <div className={activeTab === 'cinema' ? "h-full w-full" : "hidden"}>+ <CinemaStudio apiKey={apiKey} onGenerationStart={makeGenerationStartCallback('cinema')} onGenerationEnd={makeGenerationEndCallback('cinema')} onGenerationComplete={makeSuccessCallback('cinema')} onGenerationError={makeErrorCallback('cinema')} />+ </div>+ <div className={activeTab === 'audio' ? "h-full w-full" : "hidden"}>+ <AudioStudio apiKey={apiKey} droppedFiles={droppedFiles} onFilesHandled={handleFilesHandled} onGenerationStart={makeGenerationStartCallback('audio')} onGenerationEnd={makeGenerationEndCallback('audio')} onGenerationComplete={makeSuccessCallback('audio')} onGenerationError={makeErrorCallback('audio')} />+ </div>+ <div className={activeTab === 'marketing' ? "h-full w-full" : "hidden"}>+ <MarketingStudio apiKey={apiKey} droppedFiles={droppedFiles} onFilesHandled={handleFilesHandled} onGenerationStart={makeGenerationStartCallback('marketing')} onGenerationEnd={makeGenerationEndCallback('marketing')} onGenerationComplete={makeSuccessCallback('marketing')} onGenerationError={makeErrorCallback('marketing')} />+ </div>+ <div className={activeTab === 'workflows' ? "h-full w-full" : "hidden"}>+ <WorkflowStudio+ apiKey={apiKey}+ isHeaderVisible={isHeaderVisible}+ onToggleHeader={setIsHeaderVisible}+ onGenerationStart={makeGenerationStartCallback('workflows')}+ onGenerationEnd={makeGenerationEndCallback('workflows')}+ onGenerationComplete={makeSuccessCallback('workflows')}+ onGenerationError={makeErrorCallback('workflows')}+ />+ </div>+ <div className={activeTab === 'agents' ? "h-full w-full" : "hidden"}>+ <AgentStudio apiKey={apiKey} isHeaderVisible={isHeaderVisible} onToggleHeader={setIsHeaderVisible} />+ </div>+ <div className={activeTab === 'design-agent' ? "h-full w-full" : "hidden"}>+ {activeTab === 'design-agent' && (+ <DesignAgentStudio+ apiKey={apiKey}+ isHeaderVisible={isHeaderVisible}+ onToggleHeader={setIsHeaderVisible}+ onGenerationStart={makeGenerationStartCallback('design-agent')}+ onGenerationEnd={makeGenerationEndCallback('design-agent')}+ onGenerationComplete={makeSuccessCallback('design-agent')}+ onGenerationError={makeErrorCallback('design-agent')}+ />+ )}+ </div>+ <div className={activeTab === 'apps' ? "h-full w-full" : "hidden"}>+ <AppsStudio apiKey={apiKey} />+ </div>+ <div className={activeTab === 'ai-influencer' ? "h-full w-full" : "hidden"}>+ <AiInfluencerStudio+ apiKey={apiKey}+ onGenerationStart={makeGenerationStartCallback('ai-influencer')}+ onGenerationEnd={makeGenerationEndCallback('ai-influencer')}+ onGenerationComplete={makeSuccessCallback('ai-influencer')}+ onGenerationError={makeErrorCallback('ai-influencer')}+ />+ </div>+ </div>+ </div>++ {/* Global generation activity and notification stack */}+ {(activeGenerations.length > 0 || notifications.length > 0) && (+ <div+ aria-live="polite"+ aria-label="Generation activity and notifications"+ className="fixed bottom-5 right-5 z-[200] flex max-h-[calc(100vh-32px)] w-[340px] max-w-[calc(100vw-32px)] flex-col gap-2 overflow-y-auto pointer-events-none"+ data-testid="global-notification-stack"+ >+ {activeGenerations.map((generation) => (+ <div+ key={generation.tabId}+ role="status"+ data-generation-tab={generation.tabId}+ className="pointer-events-auto flex items-center gap-3 rounded-xl border border-cyan-400/30 bg-[#0d0d0f] px-3.5 py-3 text-[13px] text-zinc-100 shadow-[0_16px_48px_rgba(0,0,0,0.65)]"+ data-testid="generation-activity"+ >+ <span className="flex h-8 w-8 shrink-0 items-center justify-center rounded-lg border border-cyan-400/35 bg-cyan-400/10">+ <span+ className="h-3.5 w-3.5 animate-spin rounded-full border-2 border-cyan-300/25 border-t-cyan-300"+ aria-hidden="true"+ />+ </span>+ <p className="min-w-0 flex-1 font-semibold leading-5 text-zinc-100">+ {generation.label} is generating+ {generation.count > 1 ? ` (${generation.count})` : ''}+ </p>+ </div>+ ))}++ {notifications.map((notif) => (+ <div+ key={notif.id}+ role={notif.type === 'error' ? 'alert' : 'status'}+ data-notification-type={notif.type}+ data-notification-tab={notif.tabId}+ className="pointer-events-auto flex items-start gap-3 rounded-xl border bg-[#0d0d0f] px-3.5 py-3 text-[13px] text-zinc-100 shadow-[0_16px_48px_rgba(0,0,0,0.65)]"+ style={{+ borderColor: notif.type === 'success' ? 'rgba(34,211,238,0.35)' : 'rgba(239,68,68,0.35)',+ animation: 'slideInRight 280ms cubic-bezier(0.16,1,0.3,1) forwards',+ }}+ >+ <span+ className={`mt-0.5 flex h-8 w-8 shrink-0 items-center justify-center rounded-lg border ${+ notif.type === 'success'+ ? 'border-cyan-400/35 bg-cyan-400/10 text-cyan-300'+ : 'border-red-500/35 bg-red-500/10 text-red-400'+ }`}+ >+ {notif.type === 'success' ? (+ <svg width="17" height="17" viewBox="0 0 24 24" fill="none" stroke="currentColor" strokeWidth="2.5" strokeLinecap="round" strokeLinejoin="round" aria-hidden="true">+ <path d="m5 12 4 4L19 6" />+ </svg>+ ) : (+ <svg width="17" height="17" viewBox="0 0 24 24" fill="none" stroke="currentColor" strokeWidth="2" strokeLinecap="round" strokeLinejoin="round" aria-hidden="true">+ <circle cx="12" cy="12" r="9" />+ <path d="M12 7v6" />+ <path d="M12 17h.01" />+ </svg>+ )}+ </span>++ <div className="min-w-0 flex-1">+ <p className="font-semibold leading-5 text-zinc-100">+ {notif.label}+ <span className="font-normal text-zinc-400">+ {notif.type === 'success' ? ' - Generation complete' : ' - Generation failed'}+ </span>+ </p>+ {notif.type === 'error' && notif.message && (+ <p className="mt-0.5 line-clamp-2 text-[12px] font-medium leading-4 text-red-300/85" title={notif.message}>+ {notif.message}+ </p>+ )}+ {notif.type === 'success' && (+ <p className="mt-0.5 text-[12px] leading-4 text-zinc-400">+ Your result is ready.+ </p>+ )}+ {notif.type === 'success' && (+ <button+ type="button"+ onClick={() => handleOpenNotification(notif)}+ className="mt-1.5 text-[11px] font-bold text-cyan-300 transition-colors hover:text-cyan-100"+ aria-label={`Open ${notif.label} result`}+ >+ Open+ </button>+ )}+ </div>++ <button+ type="button"+ onClick={() => dismissNotification(notif.id)}+ className="mt-0.5 flex h-7 w-7 shrink-0 items-center justify-center rounded-md text-zinc-500 transition-colors hover:bg-white/5 hover:text-zinc-200 focus:outline-none focus:ring-1 focus:ring-white/20"+ aria-label="Dismiss notification"+ >+ <svg width="14" height="14" viewBox="0 0 24 24" fill="none" stroke="currentColor" strokeWidth="2" strokeLinecap="round" aria-hidden="true">+ <path d="M18 6 6 18M6 6l12 12" />+ </svg>+ </button>+ </div>+ ))}+ </div>+ )}++ {/* Keyframe for toast slide-in */}+ <style>{`+ @keyframes slideInRight {+ from { transform: translateX(110%); opacity: 0; }+ to { transform: translateX(0); opacity: 1; }+ }+ `}</style>++ {/* Settings Modal */}+ {showSettings && (+ <div className="fixed inset-0 bg-black/60 backdrop-blur-sm flex items-center justify-center z-50 animate-fade-in-up">+ <div className="bg-[#0a0a0a] border border-white/10 rounded-xl p-8 w-full max-w-sm shadow-2xl">+ <h2 className="text-white font-bold text-lg mb-2">Settings</h2>+ <p className="text-white/40 text-[13px] mb-8">+ Manage your AI studio preferences and authentication.+ </p>++ <div className="space-y-4 mb-8">+ <div className="bg-white/5 border border-white/[0.03] rounded-md p-4">+ <label className="block text-xs font-bold text-white/30 mb-2">+ Active API Key+ </label>+ <div className="text-[13px] font-mono text-white/80">+ {apiKey.slice(0, 8)}••••••••••••••••+ </div>+ </div>+ </div>++ <div className="flex gap-3">+ <button+ onClick={handleKeyChange}+ className="flex-1 h-10 rounded-md bg-red-500/10 text-red-400 hover:bg-red-500/20 text-xs font-semibold transition-all"+ >+ Change Key+ </button>+ <button+ onClick={() => setShowSettings(false)}+ className="flex-1 h-10 rounded-md bg-white/5 text-white/80 hover:bg-white/10 text-xs font-semibold transition-all border border-white/5"+ >+ Close+ </button>+ </div>+ </div>+ </div>+ )}+ </div>+ );+}diff --git a/packages/Open-AI-Design-Agent b/packages/Open-AI-Design-Agentindex 80ff449a..ebc0ce76 160000--- a/packages/Open-AI-Design-Agent+++ b/packages/Open-AI-Design-Agent@@ -1 +1 @@-Subproject commit 80ff449ac99d178032dcaa3ba935fa96d05fb716+Subproject commit ebc0ce7650baad0d13797ccd471c883e78be3161diff --git a/packages/Vibe-Workflow b/packages/Vibe-Workflowindex b96ad671..c65ce897 160000--- a/packages/Vibe-Workflow+++ b/packages/Vibe-Workflow@@ -1 +1 @@-Subproject commit b96ad67168958fdd48559a84d99072bbd83a8d73+Subproject commit c65ce897e82bf73659c2725528c8492cd609d831diff --git a/packages/studio/src/components/AiInfluencerStudio.jsx b/packages/studio/src/components/AiInfluencerStudio.jsxindex e93f8fc4..4a7000ad 100644--- a/packages/studio/src/components/AiInfluencerStudio.jsx+++ b/packages/studio/src/components/AiInfluencerStudio.jsx@@ -188,4 +188,579 @@ const TABS_CONFIG = {label: "Left Arm",options: [{ id: "left_arm_normal", label: "Normal", img: `${CDN}/left_arm_left_arm_normal.webp`, promptVal: "normal left arm" },- { id: "left_arm_cute", label: "Cute Prosthetic",img: `${CDN}/left_arm_make_lef�^�����k�w��C�VC�VC�VC�VC�VC�VC�VC�VC�VC�VC�VC�VC�VC�VC�VC�VC�VC�VC�VC�VC�VC�VC�VC�VC�VC�VC�VC�VC�VC�VC�VC�VC�VC�VC�VC�VC�VC�VC�V@(����������1P��P� ե���Ȁ��=�ѥ��́A����(�������VC�VC�VC�VC�VC�VC�VC�VC�VC�VC�VC�VC�VC�VC�VC�VC�VC�VC�VC�VC�VC�VC�VC�VC�VC�VC�VC�VC�VC�VC�VC�VC�VC�VC�VC�VC�VC�VC�VC�VC�VC�VC�VC�VC�VC�VC�VC�VC�VC�VC�VC�VC�VC�VC�VC�VC�VC�VC�VC�V@����(������������9���������്���ܵl�����t�͡ɥ�������ɑ�ȵȁ��ɑ�ȵݡ�є�l����t����l�������t��ٕə��ܵ��������((��������켨� ե���ȁ�����Ȁ���(��������������9�������ѕ�̵���ѕȁ���ѥ�䵉��ݕ�����Ё��́��ɑ�ȵ����ɑ�ȵݡ�є�l����t�͡ɥ������(���������������������9����ѕ�еl����t����е�����ѕ�еݡ�є��Ʌ������ѥ��Ј� ե����������(�������������ѽ�(�������������� �����젤����͕�M����ѕ�=�ѥ��̠��������(������������������Ё���Ѐ����(��������������=����йم�Օ̡Q M} =9%����������х�����(����������������х���Չ��ѕ��ɥ�̹���������Ո������(�����������������������Ո���ѥ���������Ѡ����������m�Ո���t���Ո���ѥ���l�t����(������������������(����������������(��������������ɕ��ɸ������(������������������(�����������������9����ѕ�еl����t�ѕ�е�Ʌ�������ٕ��ѕ�еݡ�є��Ʌ�ͥѥ��������́���е����մ�(�����������(������������I�͕�(�������������ѽ��(����������((��������켨�Q�������̀���(��������������9����������ā��́��ȁ��ɑ�ȵ����ɑ�ȵݡ�є�l����t�͡ɥ������(�����������=����й���̡Q M} =9%���������䤀����(���������������ѽ�(�����������������������(���������������� �����젤����͕��ѥٕQ�������(�������������������9����큙���ā��ĸԁɽչ�������ѕ�еl����t����е͕��������Ʌ�ͥѥ���������(������������������ѥٕQ������(������������������������ݡ�є�ѕ�е������͡���܈(������������������耉ѕ�е�Ʌ�������ٕ��ѕ�еݡ�є���ٕ�鉜�ݡ�є�l����t�(�����������������(�������������(���������������Q M} =9%m���t�������(���������������ѽ��(�������������(����������((��������켨�MՉ��ѕ���䁽�ѥ��͍́ɽ����ɕ�����(��������������9�����ā�ٕə��ܵ䵅�Ѽ���́�������Ԉ�(�����������Q M} =9%m��ѥٕQ��t���Չ��ѕ��ɥ����������Չ��Ф�����(�������������������Չ��й����(����������������������9����ѕ�еl����t����е�����ѕ�е�Ʌ���������ɍ�͔��Ʌ������ݥ���Ё���ȁ����Ԉ�(������������������Չ��й������(�����������������(��������������������9����ɥ���ɥ�����̴́����ĸԈ�(������������������Չ��й��ѥ������������Ф�����(����������������������Ё͕���͕���ѕ�=�ѥ���m�Չ��й��t�����й���(������������������ɕ��ɸ��(�����������������������ѽ�(�����������������������������й���(������������������������ �����젤����������=�ѥ��M����С�Չ��й������й����(���������������������������9����큝ɽ���ɕ��ѥٔ������е��Յɔ�ɽչ����ᰁ�ٕə��ܵ���������ɑ�ȁ�Ʌ�ͥѥ���������(������������������������͕�(�������������������������������ɑ�ȵݡ�є����ɥ���āɥ���ݡ�є����͡���ܵ���(��������������������������耉��ɑ�ȵݡ�є�l����t���ٕ�鉽ɑ�ȵݡ�є��Ԉ(�������������������������(���������������������(����������������������(�������������������������Ɍ����й����(�������������������������������й������(���������������������������������(�����������������������������9����ܵ�ձ�����ձ�������е��ٕȈ(���������������������������ɽ��졔�����쁔�хɝ�й����ɽȀ�ձ�쁔�хɝ�й�Ɍ�� 9�����Ʌ�ѕ�}����}�յ���ݕ������(������������������������(����������������������켨�1������ٕɱ�䀨��(����������������������������9���ͽ��є���͕е������ѽ��������Ʌ����еѼ�Ё�ɽ�����������٥�����������Ѽ��Ʌ����ɕ�Ё�дЁ���ā��Ĉ�(�����������������������������������9����ѕ�еl���t����е͕�������ѕ�еݡ�є������������������й������������(������������������������(����������������������켨�M����ѕ�����������������(�����������������������͕������(������������������������������9���ͽ��є�ѽ��āɥ��дāܴЁ��Ёɽչ�����ձ�����ݡ�є�ѕ�е������������ѕ�̵���ѕȁ���ѥ�䵍��ѕȈ�(��������������������������� ����%������(��������������������������(������������������������(�����������������������ѽ��(��������������������(�������������������(����������������(��������������(�������������(����������(��������((������켨��VC�VC�VC�VC�VC�VC�VC�VC�VC�VC�VC�VC�VC�VC�VC�VC�VC�VC�VC�VC�VC�VC�VC�VC�VC�VC�VC�VC�VC�VC�VC�VC�VC�VC�VC�VC�VC�VC�VC�VC�VC�VC�VC�VC�VC�VC�VC�VC�VC�VC�VC�VC�VC�VC�VC�VC�VC�VC�VC�V@(���������� 9QH��P� ��ɕ�Ё ��Ʌ�ѕȁAɕ٥��(�������VC�VC�VC�VC�VC�VC�VC�VC�VC�VC�VC�VC�VC�VC�VC�VC�VC�VC�VC�VC�VC�VC�VC�VC�VC�VC�VC�VC�VC�VC�VC�VC�VC�VC�VC�VC�VC�VC�VC�VC�VC�VC�VC�VC�VC�VC�VC�VC�VC�VC�VC�VC�VC�VC�VC�VC�VC�VC�VC�V@����(������������9���������്�������ā����ܴ���ٕə��ܵ����������l�������t��((��������켨� ��ѕȁѽ�����聅����ЁɅѥ��������Ʌє����(��������������9�������ѕ�̵���ѕȁ���ѥ�䵉��ݕ�������́��ɑ�ȵ����ɑ�ȵݡ�є�l����t�͡ɥ������(����������켨�����ЁɅѥ�����(����������������9������������ԁ���ݡ�є�l����t���ɑ�ȁ��ɑ�ȵݡ�є�l����t�ɽչ����ᰁ��Ĉ�(�������������l���Ј�����Ĉ������؈�������t������Ȥ�����(�����������������ѽ�(�����������������������(������������������ �����젤����͕������I�ѥ��ȥ�(���������������������9�������́��ĸԁɽչ�������ѕ�еl����t����е������Ʌ�ͥѥ���������(������������������������I�ѥ������(��������������������������٥���д����ѕ�еݡ�є�͡���ܵ���͡���ܵ٥���д�������(��������������������耉ѕ�е�Ʌ�������ٕ��ѕ�еݡ�є�(�������������������(���������������(�������������������(�����������������ѽ��(���������������(������������((����������������9�������ѕ�̵���ѕȁ����Ȉ�(������������켨�M�ՙ�������(���������������ѽ�(���������������� ������������M�ՙ����(�������������������9�������ѕ�̵���ѕȁ����ĸԁ��́��ȁɽչ����ᰁ���ݡ�є�l����t���ɑ�ȁ��ɑ�ȵݡ�є�l����t�ѕ�е�Ʌ�������ٕ��ѕ�еݡ�є���ٕ�鉜�ݡ�є����ѕ�еl����t����е͕��������Ʌ�ͥѥ�������(�������������(���������������M�ՙ���%������(��������������M�ՙ���(���������������ѽ��((������������켨����Ʌє����(���������������ѽ�(���������������� ���������������Ʌѕ�(����������������ͅ�����������Ʌѥ���(�������������������9����큙�����ѕ�̵���ѕȁ����ȁ��ԁ��ȁɽչ����ᰁѕ�еl����t����е������Ʌ�ͥѥ�������͡���ܵ�����(���������������������Ʌѥ��(������������������������٥���д�������ѕ�еݡ�є�������ͽȵ��е����ݕ��(������������������耉����Ʌ����еѼ�ȁ�ɽ��٥���д����Ѽ��������������ٕ��ɽ��٥���д������ٕ��Ѽ������������ѕ�еݡ�є�͡���ܵ٥���д���������ٕ��͡���ܵ٥���д�������(�����������������(�������������(��������������������Ʌѥ������(������������������(��������������������ٜ������9������є�������ݥ�Ѡ��Ј���������Ј�٥�� ��������Ѐ�Ј�����������ɽ�����ɕ�� ���Ȉ���ɽ��]��Ѡ�ȸԈ�(�����������������������Ѡ���4�Ā�Ʉ�����Ĵ���������������舁��ɽ��=���������̈���(�����������������������Ѡ���4�Ā�Ʉ��������䈀��(��������������������ٜ�(���������������������Ʌѥ����(������������������(����������������耠(������������������� ���%���������Ʌє� ��Ʌ�ѕ���(����������������(���������������ѽ��(������������(����������((��������켨�Aɕ٥�܁�ɕ�����(��������������9�����ā������ѕ�̵���ѕȁ���ѥ�䵍��ѕȁ���ٕə��ܵ��������(������������(�����������������9����ɕ��ѥٔ�ɽչ�����ᰁ�ٕə��ܵ����������l�������t���ɑ�ȁ��ɑ�ȵݡ�є�l����t�͡���ܴ�ᰁ������ѕ�̵���ѕȁ���ѥ�䵍��ѕȈ(��������������屔��쁅�����I�ѥ�聅�5��m������I�ѥ�t�����̼Ј�����!�����耈����������]��Ѡ耈��������(�����������(������������������Ʌѥ������(��������������������9���������്����ѕ�̵���ѕȁ����Ёѕ�е���ѕȁ�������Ȉ�(����������������������9����ܴ�ȁ���ȁ��ɑ�ȵl���t���ɑ�ȵ٥���д���������ɑ�ȵе٥���д����ɽչ�����ձ�������є���������(������������������������9����ѕ�еʹ�ѕ�е�Ʌ��������е����մ�����Ʌѥ�����ȁ$�����Օ���ˊ����(����������������(����������������ɕ٥��Uɰ����(����������������(������������������Ɍ���ɕ٥��Uɱ�����Ʌѕ��$� ��Ʌ�ѕȈ������9����ܵ�ձ�����ձ�������е��ٕȈ���(����������������켨��ݹ������ٕɱ�䁉��ѽ�����(�������������������ѽ�(�������������������� �����젤������ݹ����%����ɕ٥��Uɰ��(�����������������������9���ͽ��є����ѽ��́ɥ��д́������ѕ�̵���ѕȁ����ĸԁ��́��ĸԁɽչ������������������������ɽ�����ȵʹ���ɑ�ȁ��ɑ�ȵݡ�є����ѕ�еݡ�є�ѕ�еl����t����е͕���������ٕ�鉜�����������Ʌ�ͥѥ�������(�����������������(��������������������ݹ����%������(������������������M�ٔ(�������������������ѽ��(����������������(��������������耠(��������������������9���������്����ѕ�̵���ѕȁ����́ѕ�е���ѕȁ�������Ȉ�(������������������ٜ�ݥ�Ѡ����������������٥�� ��������Ѐ�Ј�����������ɽ�����ɕ�� ���Ȉ���ɽ��]��Ѡ�����������9����ѕ�е�Ʌ������(���������������������Ѡ���4�����شɄЀЀ�����д� �ЀЀ�����Ѐ��Ȉ����ɍ�������Ȉ����܈���Ј���(������������������ٜ�(������������������������9����ѕ�еʹ�ѕ�е�Ʌ��������е����մ��e��ȁ$�����Օ���ȁ��ٕ́��ɔ����(������������������������9����ѕ�е�́ѕ�е�Ʌ�������ͥ��������ե�����ȁ$�����Օ�����Ȁ���ɽ��͍Ʌэ����(����������������(��������������(������������(����������((��������켨��R�R �M����ѕ����ѥ�������̃�R�R�R�R�R�R�R�R�R�R�R�R�R�R�R�R�R�R�R�R�R�R�R�R�R�R�R�R�R�R�R�R�R�R�R�R ����(���������͕���ѕ�Q��̹����Ѡ���������(����������������9���������́͡ɥ������(������������������9�����������Ʌ������ĸԁ�ѕ�̵���ѕȈ�(���������������͡����Q��̀��͕���ѕ�Q��̀�͕���ѕ�Q��̹ͱ�������QM}Y%M% 1��������х�������(�����������������!�ٕ�A���(�����������������������х���Չ���%��(�������������������������х��������(�����������������������х������(�������������������� �����젤�����(�����������������������)յ���ե���ȁ������Ѽ�ѡ��х��ѡ�Ё�ݹ́ѡ�́�Չ��ѕ����(������������������������Ё�ݹ��Q����=����й���̡Q M} =9%��������Ѭ����(����������������������Q M} =9%mѭt��Չ��ѕ��ɥ�̹ͽ����̤����̹������х���Չ���%��(����������������������(�������������������������ݹ��Q����͕��ѥٕQ����ݹ��Q����(��������������������(������������������(�����������������(���������������͕���ѕ�Q��̹����Ѡ���QM}Y%M% 1�����(�������������������ѽ�(�������������������������ѽ��(�������������������� �����젤����͕�M�����Q��̠�ؤ�����إ�(�����������������������9���l����t���ȁɽչ����������ݡ�є�l����t���ٕ�鉜�ݡ�є�l����t���ɑ�ȁ��ɑ�ȵݡ�є�l����t�ѕ�еl����t�ѕ�е�Ʌ�������ٕ��ѕ�е�Ʌ�����ݡ�ѕ���������Ʌ���Ʌ�ͥѥ�������(�����������������(�������������������͡����Q��̀���������聁͡�܁��ɕ��(�������������������ѽ��(����������������(��������������(������������(����������((��������켨��ɽȀ���(����������ɽ�5͜�����(����������������9��������Ё��Ё��́ɽչ����ᰁ���ɕ�����������ɑ�ȁ��ɑ�ȵɕ���������ѕ�еɕ������ѕ�еl����t�͡ɥ������(��������������ɽ�5͝�(������������(����������((��������켨� ��ѽ���ɽ��Ё��ȁ�Ё���ѽ�����(��������������9���������Ё͡ɥ������(��������������(�����������������ѕ�Ј(������������م�Ք����ѽ�Aɽ����(�������������� ������졔�����͕� ��ѽ�Aɽ��С��хɝ�йم�Ք��(������������������������������Ʉ���х��ϊ�������������剕��չ������ѥ�����Ʌ��ѥ��͡����̈(�����������������9����ܵ�ձ����䁉��l�������t���ɑ�ȁ��ɑ�ȵݡ�є�l����t�ɽչ����ᰁ��́ѕ�еl����t�ѕ�е�Ʌ���������������ȵ�Ʌ�������ѱ��������������鉽ɑ�ȵ٥���д��������Ʌ�ͥѥ��������̈(������������(����������(��������((������켨��VC�VC�VC�VC�VC�VC�VC�VC�VC�VC�VC�VC�VC�VC�VC�VC�VC�VC�VC�VC�VC�VC�VC�VC�VC�VC�VC�VC�VC�VC�VC�VC�VC�VC�VC�VC�VC�VC�VC�VC�VC�VC�VC�VC�VC�VC�VC�VC�VC�VC�VC�VC�VC�VC�VC�VC�VC�VC�VC�V@(����������I%!P��P����Ʌѕ�� ��Ʌ�ѕ�́!��ѽ��������(�������VC�VC�VC�VC�VC�VC�VC�VC�VC�VC�VC�VC�VC�VC�VC�VC�VC�VC�VC�VC�VC�VC�VC�VC�VC�VC�VC�VC�VC�VC�VC�VC�VC�VC�VC�VC�VC�VC�VC�VC�VC�VC�VC�VC�VC�VC�VC�VC�VC�VC�VC�VC�VC�VC�VC�VC�VC�VC�VC�V@����(������������9���������്���ܵl�����t�͡ɥ�������ɑ�ȵ����ɑ�ȵݡ�є�l����t����l�������t��ٕə��ܵ��������((��������켨������䁡����Ȁ���(��������������9������́��́��ɑ�ȵ����ɑ�ȵݡ�є�l����t�͡ɥ������(������������������9����ѕ�еl����t����е�����ѕ�еݡ�є��Ʌ������ѥ��Ј����Ʌѕ����(������������������9����ѕ�еl���t�ѕ�е�Ʌ������д��Ԉ�����ѽ�乱���ѡ�Ʌ�ѕ�����(����������((��������켨�������͍ɽ������(��������������9�����ā�ٕə��ܵ䵅�Ѽ���ȁ�������Ȉ�(��������������ѽ�乱���Ѡ���������(������������������9���������്����ѕ�̵���ѕȁ���ѥ�䵍��ѕȁ���ȁѕ�е���ѕȁ��Ȉ�(����������������ٜ�ݥ�Ѡ����������������٥�� ��������Ѐ�Ј�����������ɽ�����ɕ�� ���Ȉ���ɽ��]��Ѡ�Ĉ������9����ѕ�е�Ʌ��������Ȉ�(�����������������ɕ�Ё��̈���̈�ݥ�Ѡ�������������������Ȉ����Ȉ����ɍ�������Ԉ�����Ԉ���ĸԈ�������履�����������Ā�Ԁ����Ԁ�Ĉ���(����������������ٜ�(����������������������9����ѕ�еl���t�ѕ�е�Ʌ�������������ɕ��ᕐ�����Ʌѕ�����Ʌ�ѕ���Ȁ�������ȁ��ɔ���(��������������(������������耠(���������������ѽ�乵�����ѕ�����ऀ����(����������������(����������������������ѕ�����(����������������ɽ�����ѽ��(����������������х�%��������(������������������ �����젤����͕�M����ѕ�!��ѽ��%�ࡥ���(������������������-���ݸ�졔��������������ѕȈ����͕�M����ѕ�!��ѽ��%�ࡥ���(���������������������9����큝ɽ���ɕ��ѥٔ�ܵ�ձ�������еl̼�t�ɽչ����ᰁ�ٕə��ܵ���������ɑ�ȁ�Ʌ�ͥѥ����������ͽȵ����ѕȀ��(������������������͕���ѕ�!��ѽ��%������(�������������������������ɑ�ȵ٥���д����ɥ���āɥ���٥���д�������(��������������������耉��ɑ�ȵݡ�є�l����t���ٕ�鉽ɑ�ȵݡ�є����(�������������������(���������������(������������������Ɍ���ѕ���ɱ��� ��Ʌ�ѕȀ��������������9����ܵ�ձ�����ձ�������е��ٕȈ���(����������������켨��ݹ����������ٕȀ���(����������������������9���ͽ��є���͕д������������������������ɽ�����ٕ�������������Ʌ�ͥѥ���������䁙�����ѕ�̵�������ѥ�䵍��ѕȁ���Ȉ�(��������������������(��������������������ɽ�����ѽ��(��������������������х�%��������(���������������������� �����졔�����쁔��ѽ�Aɽ����ѥ����쁑�ݹ����%����ѕ���ɰ����(����������������������-���ݸ�졔�����쁥������������ѕȈ��쁔��ѽ�Aɽ����ѥ����쁑�ݹ����%����ѕ���ɰ�����(�������������������������9������ĸԁɽչ����������ݡ�є���������ɽ�����ȵʹ���ɑ�ȁ��ɑ�ȵݡ�є����ѕ�еݡ�є���ٕ�鉜�ݡ�є�����Ʌ�ͥѥ����������ͽȵ����ѕȈ(�������������������(����������������������ݹ����%������(��������������������(������������������(����������������켨�%��������������(����������������������9���ͽ��є�ѽ��ā���дā��ĸԁ����ԁɽչ������������������������ɽ�����ȵʹ�ѕ�еl���t�ѕ�е�Ʌ��������е������(�����������������������ѽ�乱���Ѡ�������(������������������(����������������(��������������(������������(����������(��������(�������Q���ѕȁ��ͥѥ���ѽ��ɥ��Ј����х����M�屔����%������������ѽ���=�ѥ�����쁑�Ʌѥ�����������屔�쁉����ɽչ�耜�����ň��������耜������������ɑ��耜����ͽ����ɝ������������Ԥ�������M��耜���������ɑ��I�����耜����������M�����耜������������ɝ�����������ؤ������]��Ѡ耜��������ݽɑ ɕ��耝�ɕ���ݽɐ���ݡ�ѕM����耝�ɔ��Ʌ�����������耜���������������(������(����)�\ No newline at end of file+ { id: "left_arm_cute", label: "Cute Prosthetic",img: `${CDN}/left_arm_make_left_arm_stylish_pink_prosthetic_wi.webp`, promptVal: "stylish pink prosthetic left arm with cute stickers" },+ { id: "left_arm_robotic", label: "Robotic", img: `${CDN}/left_arm_left_arm_robotic.webp`, promptVal: "robotic left arm" },+ { id: "left_arm_prosthetic", label: "Prosthetic", img: `${CDN}/left_arm_left_arm_prosthetic.webp`, promptVal: "prosthetic left arm" },+ { id: "left_arm_mechanical", label: "Mechanical", img: `${CDN}/left_arm_left_arm_mechanical.webp`, promptVal: "mechanical left arm" },+ { id: "left_arm_none", label: "None", img: `${CDN}/left_arm_left_arm_none.webp`, promptVal: "no left arm" },+ ],+ },+ {+ id: "right_arm",+ label: "Right Arm",+ options: [+ { id: "right_arm_normal", label: "Normal", img: `${CDN}/right_arm_right_arm_normal.webp`, promptVal: "normal right arm" },+ { id: "right_arm_cute", label: "Cute Prosthetic",img: `${CDN}/right_arm_make_right_arm_stylish_pink_prosthetic_w.webp`, promptVal: "stylish pink prosthetic right arm with cute stickers" },+ { id: "right_arm_robotic", label: "Robotic", img: `${CDN}/right_arm_right_arm_robotic.webp`, promptVal: "robotic right arm" },+ { id: "right_arm_prosthetic", label: "Prosthetic", img: `${CDN}/right_arm_right_arm_prosthetic.webp`, promptVal: "prosthetic right arm" },+ { id: "right_arm_mechanical", label: "Mechanical", img: `${CDN}/right_arm_right_arm_mechanical.webp`, promptVal: "mechanical right arm" },+ { id: "right_arm_none", label: "None", img: `${CDN}/right_arm_right_arm_none.webp`, promptVal: "no right arm" },+ ],+ },+ {+ id: "left_leg",+ label: "Left Leg",+ options: [+ { id: "left_leg_normal", label: "Normal", img: `${CDN}/left_leg_left_leg_normal.webp`, promptVal: "normal left leg" },+ { id: "left_leg_cute", label: "Cute Prosthetic",img: `${CDN}/left_leg_make_left_leg_stylish_pink_prosthetic_wi.webp`, promptVal: "stylish pink prosthetic left leg with cute stickers" },+ { id: "left_leg_robotic", label: "Robotic", img: `${CDN}/left_leg_left_leg_robotic.webp`, promptVal: "robotic left leg" },+ { id: "left_leg_prosthetic", label: "Prosthetic", img: `${CDN}/left_leg_left_leg_prosthetic.webp`, promptVal: "prosthetic left leg" },+ { id: "left_leg_mechanical", label: "Mechanical", img: `${CDN}/left_leg_left_leg_mechanical.webp`, promptVal: "mechanical left leg" },+ { id: "left_leg_none", label: "None", img: `${CDN}/left_leg_left_leg_none.webp`, promptVal: "no left leg" },+ ],+ },+ {+ id: "right_leg",+ label: "Right Leg",+ options: [+ { id: "right_leg_normal", label: "Normal", img: `${CDN}/right_leg_right_leg_normal.webp`, promptVal: "normal right leg" },+ { id: "right_leg_cute", label: "Cute Prosthetic",img: `${CDN}/right_leg_make_right_leg_stylish_pink_prosthetic_w.webp`, promptVal: "stylish pink prosthetic right leg with cute stickers" },+ { id: "right_leg_robotic", label: "Robotic", img: `${CDN}/right_leg_right_leg_robotic.webp`, promptVal: "robotic right leg" },+ { id: "right_leg_prosthetic", label: "Prosthetic", img: `${CDN}/right_leg_right_leg_prosthetic.webp`, promptVal: "prosthetic right leg" },+ { id: "right_leg_mechanical", label: "Mechanical", img: `${CDN}/right_leg_right_leg_mechanical.webp`, promptVal: "mechanical right leg" },+ { id: "right_leg_none", label: "None", img: `${CDN}/right_leg_right_leg_none.webp`, promptVal: "no right leg" },+ ],+ },+ ],+ },+ style: {+ label: "Style",+ subcategories: [+ {+ id: "hair",+ label: "Hair / Head Growth",+ options: [+ { id: "hair_bald", label: "Bald", img: `${CDN}/hair_hair_bald.webp`, promptVal: "bald head" },+ { id: "hair_short", label: "Short Hair", img: `${CDN}/hair_hair_short.webp`, promptVal: "short hair" },+ { id: "hair_long", label: "Long Hair", img: `${CDN}/hair_hair_long.webp`, promptVal: "long flowing hair" },+ { id: "hair_afro", label: "Afro", img: `${CDN}/hair_hair_afro.webp`, promptVal: "afro hairstyle" },+ { id: "hair_punk", label: "Punk", img: `${CDN}/hair_hair_punk.webp`, promptVal: "punk mohawk hairstyle" },+ { id: "hair_fur", label: "Fur / Mane", img: `${CDN}/hair_hair_fur.webp`, promptVal: "fur mane on head" },+ { id: "hair_tentacles", label: "Tentacles", img: `${CDN}/hair_hair_tentacles.webp`, promptVal: "tentacles as hair" },+ { id: "hair_spines", label: "Spines", img: `${CDN}/hair_hair_spines.webp`, promptVal: "spines as hair" },+ ],+ },+ {+ id: "accessories",+ label: "Accessories & Markings",+ options: [+ { id: "accessory_tattoos", label: "Tattoos", img: `${CDN}/accessories_accessory_tattoos.webp`, promptVal: "covered in tattoos" },+ { id: "accessory_piercing", label: "Piercings", img: `${CDN}/accessories_accessory_piercing.webp`, promptVal: "multiple piercings" },+ { id: "accessory_scarification", label: "Scarification", img: `${CDN}/accessories_accessory_scarification.webp`, promptVal: "ritual scarification marks" },+ { id: "accessory_symbols", label: "Symbols / Markings", img: `${CDN}/accessories_accessory_symbols.webp`, promptVal: "symbolic tribal markings" },+ { id: "accessory_cyber", label: "Cyber Markings", img: `${CDN}/accessories_accessory_cyber.webp`, promptVal: "cyberpunk circuit markings" },+ ],+ },+ {+ id: "rendering_style",+ label: "Rendering Style",+ options: [+ { id: "style_hyper_realistic", label: "Hyper-Realistic", img: `${CDN}/character_type_human.webp`, promptVal: "hyper-realistic 8k photograph" },+ { id: "style_anime", label: "Anime", img: `${CDN}/character_type_elf.webp`, promptVal: "anime art style" },+ { id: "style_cartoon", label: "Cartoon", img: `${CDN}/character_type_mantis.webp`, promptVal: "cartoon illustration style" },+ { id: "style_2d", label: "2D Illustration", img: `${CDN}/character_type_alien.webp`, promptVal: "2D flat illustration style" },+ ],+ },+ ],+ },+};++// ─── SVG Icon Components ────────────────────────────────────────────────────+const ShuffleIcon = () => (+ <svg width="15" height="15" viewBox="0 0 24 24" fill="none" stroke="currentColor" strokeWidth="2.2" strokeLinecap="round" strokeLinejoin="round">+ <polyline points="16 3 21 3 21 8" /><line x1="4" y1="20" x2="21" y2="3" />+ <polyline points="21 16 21 21 16 21" /><line x1="15" y1="15" x2="21" y2="21" />+ </svg>+);+const BoltIcon = () => (+ <svg width="15" height="15" viewBox="0 0 24 24" fill="none" stroke="currentColor" strokeWidth="2.2" strokeLinecap="round" strokeLinejoin="round">+ <path d="M13 10V3L4 14h7v7l9-11h-7z" />+ </svg>+);+const CheckIcon = () => (+ <svg width="9" height="9" viewBox="0 0 24 24" fill="none" stroke="currentColor" strokeWidth="3.5" strokeLinecap="round" strokeLinejoin="round">+ <polyline points="20 6 9 17 4 12" />+ </svg>+);+const DownloadIcon = () => (+ <svg width="13" height="13" viewBox="0 0 24 24" fill="none" stroke="currentColor" strokeWidth="2.2" strokeLinecap="round" strokeLinejoin="round">+ <path d="M21 15v4a2 2 0 01-2 2H5a2 2 0 01-2-2v-4" /><polyline points="7 10 12 15 17 10" /><line x1="12" y1="15" x2="12" y2="3" />+ </svg>+);++// ─── Hover Pill — shows label, reveals image on hover ───────────────────────+function HoverPill({ label, img, onClick }) {+ const [hovered, setHovered] = useState(false);+ return (+ <div+ className="relative shrink-0"+ onMouseEnter={() => setHovered(true)}+ onMouseLeave={() => setHovered(false)}+ >+ {/* Image tooltip */}+ {hovered && img && (+ <div+ className="absolute bottom-full left-1/2 -translate-x-1/2 mb-2 z-50 pointer-events-none"+ style={{ filter: "drop-shadow(0 4px 16px rgba(0,0,0,0.6))" }}+ >+ <div className="w-[72px] h-[72px] rounded-xl overflow-hidden border border-white/20 bg-[#1a1a1a]"+ style={{ transform: "rotate(-3deg)" }}>+ <img src={img} alt={label} className="w-full h-full object-cover" />+ </div>+ </div>+ )}+ {/* Pill */}+ <button+ type="button"+ onClick={onClick}+ className="h-[22px] px-2 rounded-md bg-white/[0.07] hover:bg-white/[0.13] border border-white/[0.10] text-[11px] font-medium text-gray-200 whitespace-nowrap transition-all cursor-pointer"+ >+ {label}+ </button>+ </div>+ );+}++// ─── Main Component ─────────────────────────────────────────────────────────+export default function AiInfluencerStudio({+ apiKey,+ onGenerate,+ onGenerationStart,+ onGenerationEnd,+ onGenerationComplete,+ onGenerationError,+ isGenerating: externalIsGenerating,+}) {+ const [activeTab, setActiveTab] = useState("face");++ const [selectedOptions, setSelectedOptions] = useState(() => {+ const init = {};+ Object.values(TABS_CONFIG).forEach((tab) =>+ tab.subcategories.forEach((sub) => {+ if (sub.options?.length > 0) init[sub.id] = sub.options[0].id;+ })+ );+ return init;+ });++ const [aspectRatio, setAspectRatio] = useState("3:4");+ const [customPrompt, setCustomPrompt] = useState("");+ const [isGeneratingInternal, setIsGeneratingInternal] = useState(false);+ const [currentResult, setCurrentResult] = useState(null); // latest generated image+ const [history, setHistory] = useState([]); // all generated images+ const [selectedHistoryIdx, setSelectedHistoryIdx] = useState(null);+ const [errorMsg, setErrorMsg] = useState("");++ const isGenerating = externalIsGenerating || isGeneratingInternal;++ // ── Build prompt from selections ──────────────────────────────────────────+ const buildPrompt = useCallback(() => {+ const parts = [];+ Object.values(TABS_CONFIG).forEach((tab) =>+ tab.subcategories.forEach((sub) => {+ const opt = sub.options.find((o) => o.id === selectedOptions[sub.id]);+ if (opt?.promptVal) parts.push(opt.promptVal);+ })+ );+ let prompt = "Ultra-realistic professional portrait photograph of an AI influencer character, 8k resolution, cinematic lighting, sharp detail";+ if (parts.length) prompt += ", " + parts.join(", ");+ if (customPrompt.trim()) prompt += ", " + customPrompt.trim();+ return prompt;+ }, [selectedOptions, customPrompt]);++ // ── Option selection ───────────────────────────────────────────────────────+ const handleOptionSelect = (subcatId, optId) =>+ setSelectedOptions((p) => ({ ...p, [subcatId]: optId }));++ // ── Shuffle all options randomly ───────────────────────────────────────────+ const handleShuffle = () => {+ const next = {};+ Object.values(TABS_CONFIG).forEach((tab) =>+ tab.subcategories.forEach((sub) => {+ if (sub.options?.length > 0)+ next[sub.id] = sub.options[Math.floor(Math.random() * sub.options.length)].id;+ })+ );+ setSelectedOptions(next);+ };++ // ── Generate ──────────────────────────────────────────────────────────────+ const handleGenerate = async () => {+ if (isGenerating) return;+ onGenerationStart?.();+ setIsGeneratingInternal(true);+ setErrorMsg("");++ const prompt = buildPrompt();+ try {+ let res;+ if (onGenerate) {+ res = await onGenerate({ prompt, aspectRatio, selections: selectedOptions });+ } else {+ res = await generateImage(apiKey, {+ model: INFLUENCER_MODEL,+ prompt,+ aspect_ratio: aspectRatio,+ });+ }+ if (res?.url) {+ setCurrentResult(res.url);+ setHistory((prev) => [{ url: res.url, ts: Date.now() }, ...prev]);+ setSelectedHistoryIdx(0);+ onGenerationComplete?.({+ url: res.url,+ model: INFLUENCER_MODEL,+ prompt,+ type: "image",+ });+ }+ } catch (err) {+ const message = formatErrorMessage(err, "Generation failed. Please try again.");+ if (onGenerationError) onGenerationError(message);+ else toast.error(message);+ } finally {+ setIsGeneratingInternal(false);+ onGenerationEnd?.();+ }+ };++ // ── Download helper ───────────────────────────────────────────────────────+ const downloadImg = async (url) => {+ try {+ const res = await fetch(url);+ const blob = await res.blob();+ const a = document.createElement("a");+ a.href = URL.createObjectURL(blob);+ a.download = `ai-influencer-${Date.now()}.webp`;+ a.click();+ URL.revokeObjectURL(a.href);+ } catch {+ window.open(url, "_blank");+ }+ };++ // Preview image = selected history or current result+ const previewUrl =+ selectedHistoryIdx !== null && history[selectedHistoryIdx]+ ? history[selectedHistoryIdx].url+ : currentResult;++ const arMap = { "3:4": "3/4", "1:1": "1/1", "9:16": "9/16", "16:9": "16/9" };++ // ── Collect all selected options as flat list for the pill tags bar ─────────+ const selectedTags = [];+ Object.keys(TABS_CONFIG).forEach((tabKey) => {+ TABS_CONFIG[tabKey].subcategories.forEach((sub) => {+ const selId = selectedOptions[sub.id];+ const opt = sub.options.find((o) => o.id === selId);+ if (opt) selectedTags.push({ subcatId: sub.id, label: opt.label, img: opt.img });+ });+ });++ const [showAllTags, setShowAllTags] = useState(false);+ const TAGS_VISIBLE = 7; // how many pills to show before "show more"++ return (+ <div className="flex h-full bg-[#0a0a0a] text-white overflow-hidden select-none font-sans">++ {/* ════════════════════════════════════════════════════════════+ LEFT — Builder / Options Panel+ ════════════════════════════════════════════════════════════ */}+ <div className="flex flex-col w-[320px] shrink-0 border-r border-white/[0.07] bg-[#111111] overflow-hidden">++ {/* Builder header */}+ <div className="flex items-center justify-between px-4 py-3 border-b border-white/[0.07] shrink-0">+ <span className="text-[13px] font-bold text-white tracking-tight">Builder</span>+ <button+ onClick={() => setSelectedOptions((() => {+ const init = {};+ Object.values(TABS_CONFIG).forEach((tab) =>+ tab.subcategories.forEach((sub) => {+ if (sub.options?.length > 0) init[sub.id] = sub.options[0].id;+ })+ );+ return init;+ })())}+ className="text-[11px] text-gray-500 hover:text-white transition-colors font-medium"+ >+ Reset+ </button>+ </div>++ {/* Tab pills */}+ <div className="flex gap-1 px-3 py-2 border-b border-white/[0.07] shrink-0">+ {Object.keys(TABS_CONFIG).map((key) => (+ <button+ key={key}+ onClick={() => setActiveTab(key)}+ className={`flex-1 py-1.5 rounded-lg text-[12px] font-semibold transition-all ${+ activeTab === key+ ? "bg-white text-black shadow"+ : "text-gray-500 hover:text-white hover:bg-white/[0.06]"+ }`}+ >+ {TABS_CONFIG[key].label}+ </button>+ ))}+ </div>++ {/* Subcategory options scroll area */}+ <div className="flex-1 overflow-y-auto p-3 space-y-5">+ {TABS_CONFIG[activeTab]?.subcategories?.map((subcat) => (+ <div key={subcat.id}>+ <p className="text-[10px] font-bold text-gray-500 uppercase tracking-widest mb-2 px-0.5">+ {subcat.label}+ </p>+ <div className="grid grid-cols-3 gap-1.5">+ {subcat.options?.map((opt) => {+ const sel = selectedOptions[subcat.id] === opt.id;+ return (+ <button+ key={opt.id}+ onClick={() => handleOptionSelect(subcat.id, opt.id)}+ className={`group relative aspect-square rounded-xl overflow-hidden border transition-all ${+ sel+ ? "border-white/80 ring-1 ring-white/30 shadow-lg"+ : "border-white/[0.08] hover:border-white/25"+ }`}+ >+ <img+ src={opt.img}+ alt={opt.label}+ loading="lazy"+ className="w-full h-full object-cover"+ onError={(e) => { e.target.onerror = null; e.target.src = `${CDN}/character_type_human.webp`; }}+ />+ {/* Label overlay */}+ <div className="absolute inset-x-0 bottom-0 bg-gradient-to-t from-black/80 via-black/40 to-transparent pt-4 pb-1 px-1">+ <span className="text-[9px] font-semibold text-white leading-none">{opt.label}</span>+ </div>+ {/* Selected check badge */}+ {sel && (+ <div className="absolute top-1 right-1 w-4 h-4 rounded-full bg-white text-black flex items-center justify-center">+ <CheckIcon />+ </div>+ )}+ </button>+ );+ })}+ </div>+ </div>+ ))}+ </div>+ </div>++ {/* ════════════════════════════════════════════════════════════+ CENTER — Current Character Preview+ ════════════════════════════════════════════════════════════ */}+ <div className="flex flex-col flex-1 min-w-0 overflow-hidden bg-[#0a0a0a]">++ {/* Center top bar: aspect ratio + generate */}+ <div className="flex items-center justify-between px-6 py-3 border-b border-white/[0.07] shrink-0">+ {/* Aspect ratio */}+ <div className="flex gap-0.5 bg-white/[0.05] border border-white/[0.08] rounded-xl p-1">+ {["3:4", "1:1", "9:16", "16:9"].map((r) => (+ <button+ key={r}+ onClick={() => setAspectRatio(r)}+ className={`px-3 py-1.5 rounded-lg text-[11px] font-bold transition-all ${+ aspectRatio === r+ ? "bg-violet-600 text-white shadow-md shadow-violet-600/40"+ : "text-gray-500 hover:text-white"+ }`}+ >+ {r}+ </button>+ ))}+ </div>++ <div className="flex items-center gap-2">+ {/* Shuffle */}+ <button+ onClick={handleShuffle}+ className="flex items-center gap-1.5 px-3 py-2 rounded-xl bg-white/[0.05] border border-white/[0.08] text-gray-400 hover:text-white hover:bg-white/10 text-[12px] font-semibold transition-all"+ >+ <ShuffleIcon />+ Shuffle+ </button>++ {/* Generate */}+ <button+ onClick={handleGenerate}+ disabled={isGenerating}+ className={`flex items-center gap-2 px-5 py-2 rounded-xl text-[13px] font-bold transition-all shadow-lg ${+ isGenerating+ ? "bg-violet-600/40 text-white/60 cursor-not-allowed"+ : "bg-gradient-to-r from-violet-600 to-indigo-600 hover:from-violet-500 hover:to-indigo-500 text-white shadow-violet-600/30 hover:shadow-violet-500/40"+ }`}+ >+ {isGenerating ? (+ <>+ <svg className="animate-spin" width="14" height="14" viewBox="0 0 24 24" fill="none" stroke="currentColor" strokeWidth="2.5">+ <path d="M21 12a9 9 0 11-18 0 9 9 0 0118 0z" strokeOpacity="0.3" />+ <path d="M21 12a9 9 0 00-9-9" />+ </svg>+ Generating…+ </>+ ) : (+ <><BoltIcon />Generate Character</>+ )}+ </button>+ </div>+ </div>++ {/* Preview area */}+ <div className="flex-1 flex items-center justify-center p-6 overflow-hidden">+ <div+ className="relative rounded-2xl overflow-hidden bg-[#141414] border border-white/[0.07] shadow-2xl flex items-center justify-center"+ style={{ aspectRatio: arMap[aspectRatio] ?? "3/4", maxHeight: "100%", maxWidth: "100%" }}+ >+ {isGenerating ? (+ <div className="flex flex-col items-center gap-4 text-center px-8 py-12">+ <div className="w-12 h-12 border-[3px] border-violet-500/20 border-t-violet-500 rounded-full animate-spin" />+ <p className="text-sm text-gray-400 font-medium">Generating your AI influencer…</p>+ </div>+ ) : previewUrl ? (+ <>+ <img src={previewUrl} alt="Generated AI Character" className="w-full h-full object-cover" />+ {/* Download overlay button */}+ <button+ onClick={() => downloadImg(previewUrl)}+ className="absolute bottom-3 right-3 flex items-center gap-1.5 px-3 py-1.5 rounded-lg bg-black/60 backdrop-blur-sm border border-white/10 text-white text-[11px] font-semibold hover:bg-black/80 transition-all"+ >+ <DownloadIcon />+ Save+ </button>+ </>+ ) : (+ <div className="flex flex-col items-center gap-3 text-center px-8 py-12">+ <svg width="48" height="48" viewBox="0 0 24 24" fill="none" stroke="currentColor" strokeWidth="0.8" className="text-gray-700">+ <path d="M20 21v-2a4 4 0 00-4-4H8a4 4 0 00-4 4v2" /><circle cx="12" cy="7" r="4" />+ </svg>+ <p className="text-sm text-gray-600 font-medium">Your AI influencer lives here.</p>+ <p className="text-xs text-gray-700">Design and build your AI influencer<br />from scratch</p>+ </div>+ )}+ </div>+ </div>++ {/* ── Selected option pills ──────────────────────────────────── */}+ {selectedTags.length > 0 && (+ <div className="px-6 pb-3 shrink-0">+ <div className="flex flex-wrap gap-1.5 items-center">+ {(showAllTags ? selectedTags : selectedTags.slice(0, TAGS_VISIBLE)).map((tag) => (+ <HoverPill+ key={tag.subcatId}+ label={tag.label}+ img={tag.img}+ onClick={() => {+ // Jump builder panel to the tab that owns this subcategory+ const ownerTab = Object.keys(TABS_CONFIG).find((tk) =>+ TABS_CONFIG[tk].subcategories.some((s) => s.id === tag.subcatId)+ );+ if (ownerTab) setActiveTab(ownerTab);+ }}+ />+ ))}+ {selectedTags.length > TAGS_VISIBLE && (+ <button+ type="button"+ onClick={() => setShowAllTags((v) => !v)}+ className="h-[22px] px-2 rounded-md bg-white/[0.04] hover:bg-white/[0.09] border border-white/[0.08] text-[11px] text-gray-500 hover:text-gray-300 whitespace-nowrap transition-all"+ >+ {showAllTags ? "hide" : `show more`}+ </button>+ )}+ </div>+ </div>+ )}++ {/* Error */}+ {errorMsg && (+ <div className="mx-6 mb-4 px-4 py-3 rounded-xl bg-red-500/10 border border-red-500/20 text-red-400 text-[12px] shrink-0">+ {errorMsg}+ </div>+ )}++ {/* Custom prompt bar at bottom */}+ <div className="px-6 pb-4 shrink-0">+ <input+ type="text"+ value={customPrompt}+ onChange={(e) => setCustomPrompt(e.target.value)}+ placeholder="Add extra details… e.g. neon cyberpunk lighting, dramatic shadows"+ className="w-full h-9 bg-[#161616] border border-white/[0.07] rounded-xl px-3 text-[12px] text-gray-200 placeholder-gray-600 outline-none focus:border-violet-500/40 transition-colors"+ />+ </div>+ </div>++ {/* ════════════════════════════════════════════════════════════+ RIGHT — Generated Characters History Gallery+ ════════════════════════════════════════════════════════════ */}+ <div className="flex flex-col w-[160px] shrink-0 border-l border-white/[0.07] bg-[#111111] overflow-hidden">++ {/* Gallery header */}+ <div className="px-3 py-3 border-b border-white/[0.07] shrink-0">+ <p className="text-[11px] font-bold text-white tracking-tight">Generated</p>+ <p className="text-[9px] text-gray-600 mt-0.5">{history.length} characters</p>+ </div>++ {/* Gallery scroll */}+ <div className="flex-1 overflow-y-auto p-2 space-y-2">+ {history.length === 0 ? (+ <div className="flex flex-col items-center justify-center h-32 text-center px-2">+ <svg width="28" height="28" viewBox="0 0 24 24" fill="none" stroke="currentColor" strokeWidth="1" className="text-gray-700 mb-2">+ <rect x="3" y="3" width="18" height="18" rx="2" ry="2" /><circle cx="8.5" cy="8.5" r="1.5" /><polyline points="21 15 16 10 5 21" />+ </svg>+ <p className="text-[9px] text-gray-700 leading-relaxed">Generated characters<br />appear here</p>+ </div>+ ) : (+ history.map((item, idx) => (+ <div+ key={item.ts}+ role="button"+ tabIndex={0}+ onClick={() => setSelectedHistoryIdx(idx)}+ onKeyDown={(e) => e.key === "Enter" && setSelectedHistoryIdx(idx)}+ className={`group relative w-full aspect-[3/4] rounded-xl overflow-hidden border transition-all cursor-pointer ${+ selectedHistoryIdx === idx+ ? "border-violet-500 ring-1 ring-violet-500/40"+ : "border-white/[0.08] hover:border-white/20"+ }`}+ >+ <img src={item.url} alt={`Character ${idx + 1}`} className="w-full h-full object-cover" />+ {/* Download on hover */}+ <div className="absolute inset-0 bg-black/50 opacity-0 group-hover:opacity-100 transition-opacity flex items-end justify-center pb-2">+ <div+ role="button"+ tabIndex={0}+ onClick={(e) => { e.stopPropagation(); downloadImg(item.url); }}+ onKeyDown={(e) => { if (e.key === "Enter") { e.stopPropagation(); downloadImg(item.url); } }}+ className="p-1.5 rounded-lg bg-white/10 backdrop-blur-sm border border-white/20 text-white hover:bg-white/20 transition-all cursor-pointer"+ >+ <DownloadIcon />+ </div>+ </div>+ {/* Index badge */}+ <div className="absolute top-1 left-1 px-1.5 py-0.5 rounded-md bg-black/60 backdrop-blur-sm text-[8px] text-gray-300 font-bold">+ #{history.length - idx}+ </div>+ </div>+ ))+ )}+ </div>+ </div>+ <Toaster position="top-right" containerStyle={{ zIndex: 99999 }} toastOptions={{ duration: 5000, style: { background: '#18181b', color: '#ffffff', border: '1px solid rgba(255,255,255,0.15)', fontSize: '13px', borderRadius: '12px', boxShadow: '0 10px 30px rgba(0,0,0,0.6)', maxWidth: '440px', wordBreak: 'break-word', whiteSpace: 'pre-wrap', padding: '12px 16px' } }} />+ </div>+ );+}diff --git a/packages/studio/src/components/AudioStudio.jsx b/packages/studio/src/components/AudioStudio.jsxindex 5ff33702..aa6bf7c6 100644--- a/packages/studio/src/components/AudioStudio.jsx+++ b/packages/studio/src/components/AudioStudio.jsx@@ -431,4 +431,693 @@ function PremiumAudioPlayer({ url, title }) {title="Mute/Unmute"type="button">- {isMuted�]�����k�w��|���(��������������������������������耉ѕ�е饹��������ɑ�ȵ�Ʌ����ɕ�Ё��ٕ�鉜�饹��������ٕ��ѕ�еݡ�є�(�������������������������������(���������������������������(���������������������������������(�����������������������������ѽ��(���������������������������(������������������������(����������������������(���������������������͍�������͍ɥ�ѥ�������(���������������������������������9�������ѕ�еl����t�ѕ�е饹����������������ɵ����(�������������������������͍�������͍ɥ�ѥ���(����������������������������(����������������������(��������������������(������������������(���������������((�����������������9յ��ȁM�����̀��I�����(������������������Ё��9յ��Ȁ�͍�������������Ј����͍�������������ѕ��Ȉ����͍���������������Ј����͍������������յ��Ȉ�(������������������Ё���5��5����͍��������Y��Ք����չ�����������͍��������Y��Ք����չ��������(��������������������9յ��Ȁ������5��5�ँ�(��������������������Ё�ѕ���͍������ѕ������͍���������������Ј������Ԁ�Ĥ�(����������������ɕ��ɸ��(������������������������������9�����������́���饹��������ɑ�ȁ��ɑ�ȵ饹���������ɽչ������Ё�Ʌ�ͥѥ���������ٕ�鉽ɑ�ȵ饹�������(��������������������������9�������ѕ�̵���ѕȁ���ѥ�䵉��ݕ���ѕ�е�́���е������(���������������������������������9����ѕ�еݡ�є��Ʌ������ѥ��Ј��͍�����ѥѱ���������������(���������������������������������9����ѕ�е�ɥ���䁙��е���������ɥ���������ȁ����ԁɽչ������ɑ�ȁ��ɑ�ȵ�ɥ�����������Ʌ��m���t����չ������������Ʌ��m���t��͍���������ձ��������(����������������������(��������������������������9�������ѕ�̵���ѕȁ����Ȉ�(���������������������������������9����ѕ�еl����t�ѕ�е饹���������е����մ�ܴѕ�еɥ��Ј��͍��������Y��Օ�������(��������������������������(�����������������������������Ʌ����(�����������������������������͍��������Y��Օ�(�����������������������������͍��������Y��Օ�(�������������������������ѕ����ѕ��(������������������������م�Ք����Ʌ��m���t����չ������������Ʌ��m���t�耡͍���������ձЁ������(�������������������������� ������졔�����͕�A�Ʌ�̡�ɕ����쀸���ɕذ�m���t����͕���С��хɝ�йم�Ք������(�����������������������������9�����ā��ĸԁ���饹������ɽչ�����ձ�������Ʌ������������ͽȵ����ѕȁ�����е�ɥ���䁡�ٕ�鉜�饹�������Ʌ�ͥѥ�������(������������������������(���������������������������������9����ѕ�еl����t�ѕ�е饹���������е����մ�ܴѕ�е���Ј��͍��������Y��Օ�������(����������������������(���������������������͍�������͍ɥ�ѥ�������(���������������������������������9�������ѕ�еl����t�ѕ�е饹����������������ɵ����(�������������������������͍�������͍ɥ�ѥ���(����������������������������(����������������������(��������������������(������������������(���������������((�����������������Aɽ��Ѐ��Q��хɕ��%����(�������������������������ɽ��Ј���(����������������ɕ��ɸ��(������������������������������9�����������Ȉ�(����������������������������9�������ѕ�е�́���е�����ѕ�е饹����������ɍ�͔��Ʌ������ݥ��Ȉ�(�����������������������͍�����ѥѱ������1�ɥ�̀��Aɽ��Љ�(������������������������(���������������������ѕ�хɕ�(����������������������م�Ք����Ʌ��m���t�������(������������������������ ������졔�����͕�A�Ʌ�̡�ɕ����쀸���ɕذ�m���t联�хɝ�йم�Ք�����(���������������������������9����ܵ�ձ�����饹��������ɑ�ȁ��ɑ�ȵ饹�����������鉽ɑ�ȵ�ɥ�����ԁɽչ������́ѕ�е�́ѕ�еݡ�є�������������ѕ�е饹�������������ѱ����������Ʌ�ͥѥ�������������l�����t�ɕͥ锵�������������ɕ��ᕐ�͡���ܵ����Ȉ(�����������������������������������͍�������͍ɥ�ѥ��������ѕȁݡ�Ё�ԁ݅�Ё����Ʌѕ������(����������������������(���������������������͍������ᅵ���̀����Ʌ乥��Ʌ�͍������ᅵ���̤�����(����������������������������9�����������Ʌ������ĸԁ�дȈ�(�������������������������͍������ᅵ���̹������ఁ��ऀ����(�����������������������������ѽ�(�������������������������������������(�����������������������������������ѽ��(������������������������������ �����젤����͕�A�Ʌ�̡�ɕ����쀸���ɕذ�m���t聕������(���������������������������������9����ѕ�еl����t���́��ā���饹�����������ɑ�ȁ��ɑ�ȵ饹��������ٕ�鉜��ɥ���������ٕ�鉽ɑ�ȵ�ɥ�����ԁ��ٕ��ѕ�еݡ�є�ɽչ�����ձ���Ʌ�ͥѥ����������е͕�������ѕ�е饹������(���������������������������(�������������������������������ͱ��������ԥ�����(�����������������������������ѽ��(���������������������������(������������������������(����������������������(��������������������(������������������(���������������((�����������������Mх���ɐ�Q��Ѐ��%���Ё������(��������������ɕ��ɸ��(����������������������������9�����������Ȉ�(��������������������������9�������ѕ�е�́���е�����ѕ�е饹����������ɍ�͔��Ʌ������ݥ��Ȉ�(���������������������͍�����ѥѱ���������(����������������������(����������������������(����������������������������9յ��Ȁ����յ��Ȉ�耉ѕ�Љ�(��������������������م�Ք����Ʌ��m���t����չ������������Ʌ��m���t�耈��(���������������������������������͍���������������ȁ���͍�������͍ɥ�ѥ��������ѕȀ�����������(���������������������� ������졔������(��������������������������Ёم����9յ��Ȁ�����хɝ�йم�Ք�������������͕���С��хɝ�йم�Ք���联�хɝ�йم�Ք�(����������������������͕�A�Ʌ�̡�ɕ����쀸���ɕذ�m���t�م������(����������������������(�������������������������9����ܵ�ձ�����饹��������ɑ�ȁ��ɑ�ȵ饹��������ٕ�鉽ɑ�ȵ饹�����������鉽ɑ�ȵ�ɥ�������ɽչ������Ё��̸ԁѕ�е�́ѕ�еݡ�є�������������ѕ�е饹�������������ѱ����������Ʌ�ͥѥ�������͡���ܵ����Ȉ(��������������������(�������������������͍�������͍ɥ�ѥ�������(�������������������������������9�������ѕ�еl����t�ѕ�е饹����������������ɵ����(�����������������������͍�������͍ɥ�ѥ���(��������������������������(��������������������(������������������(����������������(���������������(������������((����������((��������켨�幅���� ��Ѐ�����Ʌє�M��ѥ������(��������������9������Ё��ɑ�ȵЁ��ɑ�ȵ饹���������饹��������������ɽ�����ȵᰁ��ͽ��є����ѽ�������д��ܵ�ձ�����ܵl�����t������(�������������ѽ�(�������������������ѽ��(�������������� ���������������Ʌѕ�(��������������ͅ�����������Ʌѥ�������͕���ѕ�5�����(�����������������9����ܵ�ձ����Ё����ɥ����ѕ�е������ѕ�е��͔����е�����ɽչ������ٕ�鉜�ݡ�є��Ʌ�ͥѥ��������Ʌ�͙�ɴ���ٕ��͍����lĸ��t���ѥٔ�͍�����ԁ��ͅ����������������ͅ�����Ʌ�͍����͡���ܵ���܁������ѕ�̵���ѕȁ���ѥ�䵍��ѕȁ����̈(�����������(������������������Ʌѥ������(����������������(����������������������9����ܴЁ��Ё��ɑ�ȴȁ��ɑ�ȵ�����������ɑ�ȵе������ɽչ�����ձ�������є���������(�������������������������Ʌѥ���Ց�����������(����������������(��������������耠(����������������(������������������ٜ�ݥ�Ѡ��Ј���������Ј�٥�� ��������Ѐ�Ј�����������ɽ�����ɕ�� ���Ȉ���ɽ��]��Ѡ�̈�(���������������������Ѡ���4ԀͰ�Ѐ��Ѐ�X�舀��(������������������ٜ�(�������������������������Ʌє�QɅ��������(����������������(��������������(�������������ѽ��(����������(��������(������켨��R�R�R �I%!P� =9Q9P�I��R�R�R ����(������������9�����ā��������്�������ܴ�����ձ��ɕ��ѥٔ������(��������(��������켨�5�������������������(��������������9�����ā�ٕə��ܵ䵅�Ѽ����ѽ��͍ɽ����ȁ������������������്������ѥ�䵉��ݕ����(����������(����������������9�����ā������ѕ�̵���ѕȁ���ѥ�䵍��ѕȁ������l�����t�������(������������(������������켨�ĸ��ɽȁ�����䀨��(������������흕��Ʌѕ�ɽȀ����(��������������������9����ܵ�ձ�����ܵ��������ɕ�����������ɑ�ȁ��ɑ�ȵɕ���������ɽչ������������്����ѕ�̵���ѕȁ����Ё�����є�͡�����(����������������������9����ܴ�ȁ���ȁ���ɕ���������ɽչ�����ձ��������ѕ�̵���ѕȁ���ѥ�䵍��ѕȁѕ�еɕ��������ɑ�ȁ��ɑ�ȵɕ���������͡���ܵ����(��������������������ٜ�ݥ�Ѡ��Ј���������Ј�٥�� ��������Ѐ�Ј�����������ɽ�����ɕ�� ���Ȉ���ɽ��]��Ѡ�ȸԈ�(���������������������ɍ�������Ȉ�����Ȉ���������(��������������������������Ȉ�����������Ȉ�����Ȉ���(��������������������������Ȉ�����؈�����ȸ�Ĉ�����؈���(��������������������ٜ�(������������������(����������������������9����ѕ�е���ѕȈ�(�����������������������������9����ѕ�е�́���е������ѕ�еɕ����������ɍ�͔��Ʌ������ݥ���Ё���������Ĉ�(�����������������������Ʌѥ����ɽ�(������������������������(��������������������������9����ѕ�еݡ�є����е����մ�ѕ�еʹ���������ɕ��ᕐ��(��������������������흕��Ʌѕ�ɽ��(���������������������(������������������(����������������(��������������((������������켨�ȸ����Ʌѥ�����1�������Y��܀���(������������������Ʌѥ�����������Ʌѕ�ɽȀ����(��������������������9���������്����ѕ�̵���ѕȁ���������є����������(����������������������9����ɕ��ѥٔ��(������������������������9����ܴ�Ё���Ё��ɑ�ȵl���t���ɑ�ȵ饹��������ɑ�ȵе�ɥ����ɽչ�����ձ�������є������͡���ܵ���܈���(������������������������9���ͽ��є���͕д��������ѕ�̵���ѕȁ���ѥ�䵍��ѕȁѕ�е�ɥ�����(���������������������5�ͥ�%���������9������є��ձ͔�ѕ�е�ɥ���䈀��(��������������������(������������������(����������������������9����ѕ�е���ѕȁ�������Ȉ�(������������������������9����ѕ�е�́���е������ѕ�е�ɥ��������ɍ�͔��Ʌ������l��͕�t������є��ձ͔��(�����������������������Ʌѥ���M�չ��Ʌ��(��������������������(������������������������9����ѕ�еʹ�ѕ�е饹���������е������(��������������������I����ɥ����Ց���ٕ݅��ɵ́����ٽ���̸��(��������������������(������������������(����������������(��������������((������������켨�̸�����Mхє������Ց������Ё��������������ɽȤ����(�������������٥�܀�����Ј����������Ʌѥ�����������Ʌѕ�ɽȀ����(��������������������9���������്����ѕ�̵���ѕȁ�������ܵ���ѕ�е���ѕȁ�������饹�����������ɑ�ȁ��ɑ�ȵ饹������ɽչ���������ɽ�����ȵʹ�ɕ��ѥٔ��ɽ��������є�������������(����������������켨���܁�������ѡ����������(����������������������9���ͽ��є���͕д������ɥ����ԁ���ȴ�ᰁɽչ�����ձ����������ԁ�ɽ�����ٕ������������Ʌ�ͥѥ���������䁑�Ʌѥ������������ѕȵ�ٕ��̵��������(����������������������9����ܴ�����������饹��������ɑ�ȁ��ɑ�ȵ饹����ԁɽչ����������ѕ�̵���ѕȁ���ѥ�䵍��ѕȁ͡���ܵ����ȁɕ��ѥٔ������Ʌ�ͥѥ����Ʌ�͙�ɴ���Ʌѥ��������ɽ�����ٕ��͍������Ԉ�(�������������������5�ͥ�%���������9����ѕ�е�ɥ����ܴ���������ѕȁ�ɽ��͡���ܵl�|�|���}ɝ����а��İ�����̥t����(������������������(����������������������9����ɕ��ѥٔ������(�������������������́�����9����ѕ�еݡ�є����е������ѕ�еᰁ���́�Ʌ������ѥ��Ј�Ց���M�Ց�����(��������������������������9����ѕ�еʹ�ѕ�е饹���������е����մ���������ɕ��ᕐ���Ј�(�������������������� ���͔����$���ͥ���������ٽ���������Ȱ��ȁͽչ������Ʌѽȸ�5�����مɥ����́���ѡ�����Ё�����Ʌ�Ё��ȁ���Ё��������������Ʌ���(���������������������(������������������(����������������(��������������((������������켨�и��ѥٔ�I��ձЁA���ȁ�����䀨��(�������������٥�܀���ɕ�ձЈ������ѥٕI��ձ�Uɰ����������Ʌѥ�����������Ʌѕ�ɽȀ����(��������������������9����ܵ�ձ�����ܴ�ᰁ�����є�������������������Ј�(����������������������9�������ѕ�̵���ѕȁ���ѥ�䵉��ݕ�����Ĉ�(���������������������ѽ�(���������������������� ������������9���(�������������������������9����ѕ�е�́���е�����ѕ�е饹��������ٕ��ѕ�е�ɥ���䁙�����ѕ�̵���ѕȁ����ȁ�Ʌ�ͥѥ����������饹����ԁ��ɑ�ȁ��ɑ�ȵ饹��������ٕ�鉽ɑ�ȵ�ɥ���������Ё��ȁɽչ�����ձ��(���������������������������ѽ��(�������������������(����������������������ٜ�ݥ�Ѡ��Ȉ���������Ȉ�٥�� ��������Ѐ�Ј�����������ɽ�����ɕ�� ���Ȉ���ɽ��]��Ѡ�ȸԈ�(����������������������������䈁����Ȉ����Ԉ�����Ȉ���(��������������������������履�����������Ȁ��Ԁ�Ȁ�ȀԈ���(����������������������ٜ�(��������������������������9�܁���Ʌѥ��������(���������������������ѽ��(�����������������������������9����ѕ�еl����t����е�����ѕ�е�ɕ���������̸ԁ��ĸԁ����ɕ������������ɑ�ȁ��ɑ�ȵ�ɕ����������ɽչ�����ձ��������ѕ�̵���ѕȁ����Ȉ�(��������������������������9����ܴĸԁ��ĸԁ����ɕ�������ɽչ�����ձ�������є��ձ͔�����MՍ����(������������������������(������������������(�����������������Aɕ��յՑ��A���ȁ�ɰ�텍ѥٕI��ձ�Uɱ�ѥѱ��텍ѥٕI��ձ�Q�ѱ���(����������������(��������������((������������((����������켨��R�R�R � =QQ=4�!%MQ=Id�==QH��R�R�R ����(��������������ѽ�乱���Ѡ���������(������������������9���ɑ�ȵЁ��ɑ�ȵ饹�������дܵ�ձ�������є�������������(���������������Ё�����9����ѕ�е�́���е�����ѕ�е饹����������ɍ�͔��Ʌ������ݥ��ȁ���Ё��Ĉ�(�������������������Ʌѥ���!��ѽ�䀡����ѽ�乱���ѡ��(�����������������(��������������������9����ɥ���ɥ�����̴ȁʹ�ɥ�����̴́���ɥ�����̴Ё���ɥ�����̴ԁ��ɥ�����̴����Ј�(��������������������ѽ�乵��������䰁��ऀ����(��������������������(������������������������핹��乥���������(���������������������� �����젤����������M�����!��ѽ�䡕���䰁����(�������������������������9�������̸ԁ���饹��������ɑ�ȁɽչ�������ͽȵ����ѕȁ�Ʌ�ͥѥ���������������്������ѥ�䵉��ݕ����������ɑ�ȵ饹�����������ٕ�鉜�饹��������ٕ�鉽ɑ�ȵ饹��������(������������������������ѥٕI��ձ�Uɰ�������ɰ����٥�܀���ɕ�ձЈ(�����������������������������ɑ�ȵ�ɥ���䁉���ɥ����ԁ͡���ܵ���܈(������������������������耈�(�����������������������(�������������������(��������������������������9�������ѕ�̵���ѕȁ����Ȉ�(����������������������������9�����ܴ������ɽչ����������ѕ�̵���ѕȁ���ѥ�䵍��ѕȁ����͡ɥ�������(��������������������������ѥٕI��ձ�Uɰ�������ɰ����٥�܀���ɕ�ձЈ��������ɥ�������ѕ�е�ɥ���䈀耉���饹������ѕ�е饹������(��������������������������(��������������������������ٜ�ݥ�Ѡ��Ј���������Ј�٥�� ��������Ѐ�Ј�����������ɽ�����ɕ�� ���Ȉ���ɽ��]��Ѡ�ȸԈ�(������������������������������坽����������ĀԀ�Ȁ�Ȁ�Ԁ�Ԁ�Ā���ĀԈ���(��������������������������ٜ�(������������������������(���������������������������������9����ѕ�еl����t����е�����ѕ�е�ɥ��������ɍ�͔��Ʌ������ݥ��ȁ��չ��є��(������������������������핹��乵�����������乵���������Р�����ͱ�������Ȥ�����������耝Ց����(����������������������������(����������������������(����������������������������9����ѕ�еl����t����е͕�������ѕ�еݡ�є������������ȁ��������ѥ��Ј�(����������������������핹���ѥѱ�����������ɽ��Ё����U�ѥѱ���Ց����(�����������������������(��������������������(�������������������(����������������(��������������(������������((����������((��������(�������Q���ѕȁ��ͥѥ���ѽ��ɥ��Ј����х����M�屔����%������������ѽ���=�ѥ�����쁑�Ʌѥ�����������屔�쁉����ɽչ�耜�����ň��������耜������������ɑ��耜����ͽ����ɝ������������Ԥ�������M��耜���������ɑ��I�����耜����������M�����耜������������ɝ�����������ؤ������]��Ѡ耜��������ݽɑ ɕ��耝�ɕ���ݽɐ���ݡ�ѕM����耝�ɔ��Ʌ�����������耜���������������(������(����)�(\ No newline at end of file+ {isMuted ? <VolumeMuteIcon /> : <VolumeIcon />}+ </button>+ <input+ type="range"+ min="0"+ max="1"+ step="0.05"+ value={isMuted ? 0 : volume}+ onChange={handleVolumeChange}+ className="w-16 h-1 bg-zinc-700 rounded appearance-none cursor-pointer accent-primary hover:bg-zinc-600 transition-all opacity-0 group-hover/volume:opacity-100"+ />+ </div>++ {/* Main Play/Pause Button */}+ <button+ onClick={togglePlay}+ className="w-12 h-12 bg-primary hover:bg-white text-black rounded-full flex items-center justify-center hover:scale-105 active:scale-95 transition-all shadow-glow"+ title={isPlaying ? "Pause" : "Play"}+ type="button"+ >+ {isPlaying ? <PauseIcon /> : <PlayIcon />}+ </button>++ {/* Download Button */}+ <button+ onClick={downloadAudio}+ className="px-4 py-2 bg-zinc-800/80 hover:bg-zinc-700 border border-zinc-700 rounded text-xs font-bold text-white flex items-center gap-2 hover:border-primary/45 transition-all"+ title="Download Audio"+ type="button"+ >+ <svg width="12" height="12" viewBox="0 0 24 24" fill="none" stroke="currentColor" strokeWidth="2.5">+ <path d="M21 15v4a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2v-4M7 10l5 5 5-5M12 15V3" />+ </svg>+ <span>Save</span>+ </button>+ </div>+ </div>+ </div>+ );+}++// ---------------------------------------------------------------------------+// Main Audio Studio Component+// ---------------------------------------------------------------------------+export default function AudioStudio({+ apiKey,+ onGenerationStart,+ onGenerationEnd,+ onGenerationComplete,+ onGenerationError,+ historyItems,+ droppedFiles,+ onFilesHandled,+}) {+ const LEGACY_PERSIST_KEY = "hg_audio_studio_persistent";+ const PERSIST_KEY = scopedPersistKey(LEGACY_PERSIST_KEY, apiKey);+ useEffect(() => {+ migrateLegacyPersistKey(LEGACY_PERSIST_KEY, PERSIST_KEY);+ }, [PERSIST_KEY]);++ // ── Mode & model state ──────────────────────────────────────────────────+ const [selectedModelId, setSelectedModelId] = useState(audioModels[0]?.id ?? "");+ const [params, setParams] = useState({});+ const [openDropdown, setOpenDropdown] = useState(false);+ const [openParamDropdown, setOpenParamDropdown] = useState(null);+ const modelBtnRef = useRef(null);+ const sidebarRef = useRef(null);++ // Close dropdowns on outside click+ useEffect(() => {+ const handler = (e) => {+ if (sidebarRef.current && !sidebarRef.current.contains(e.target)) {+ setOpenDropdown(false);+ setOpenParamDropdown(null);+ }+ };+ window.addEventListener("click", handler);+ return () => window.removeEventListener("click", handler);+ }, []);++ // ── Generation state ──────────────────────────────────────────────────+ const [isGenerating, setIsGenerating] = useState(false);+ const [generateError, setGenerateError] = useState(null);+ const [activeResultUrl, setActiveResultUrl] = useState(null);+ const [activeResultTitle, setActiveResultTitle] = useState("");+ const [view, setView] = useState("input"); // 'input' | 'result'++ // ── History state ────────────────────────────────────────────────────+ const [internalHistory, setInternalHistory] = useState([]);+ const history = historyItems ?? internalHistory;+ const [activeHistoryIdx, setActiveHistoryIdx] = useState(0);++ const selectedModel = getAudioModelById(selectedModelId);++ // ── Initialize params when model changes ──────────────────────────────+ useEffect(() => {+ if (!selectedModel) return;+ const initial = {};+ Object.entries(selectedModel.inputs || {}).forEach(([key, schema]) => {+ // Don't overwrite parameters like vocal upload, list etc. if they are already in state+ if (params[key] !== undefined) {+ initial[key] = params[key];+ } else {+ initial[key] = schema.default !== undefined ? schema.default : "";+ }+ });+ setParams(initial);+ }, [selectedModelId]); // Only reset when model ID changes++ // ── Persistence: Load ────────────────────────────────────────────────────+ useEffect(() => {+ try {+ const stored = localStorage.getItem(PERSIST_KEY);+ if (stored) {+ const data = JSON.parse(stored);+ if (data.selectedModelId) setSelectedModelId(data.selectedModelId);+ if (data.params) setParams(data.params);+ if (data.internalHistory) setInternalHistory(data.internalHistory);+ if (data.activeResultUrl) setActiveResultUrl(data.activeResultUrl);+ if (data.activeResultTitle) setActiveResultTitle(data.activeResultTitle);+ if (data.view) setView(data.view);+ }+ } catch (err) {+ console.warn("Failed to load AudioStudio persistence:", err);+ }+ }, []);++ // ── Persistence: Save ────────────────────────────────────────────────────+ useEffect(() => {+ const timer = setTimeout(() => {+ try {+ const state = {+ selectedModelId,+ params,+ internalHistory,+ activeResultUrl,+ activeResultTitle,+ view,+ };+ localStorage.setItem(PERSIST_KEY, JSON.stringify(state));+ } catch (err) {+ console.warn("Failed to save AudioStudio persistence:", err);+ }+ }, 500);+ return () => clearTimeout(timer);+ }, [selectedModelId, params, internalHistory, activeResultUrl, activeResultTitle, view]);++ // ── Handle Dropped Files ────────────────────────────────────────────────+ useEffect(() => {+ if (droppedFiles && droppedFiles.length > 0) {+ const audioFiles = droppedFiles.filter(f => f.type.startsWith('audio/'));+ if (audioFiles.length > 0 && selectedModel) {+ // Find the first audio input field in the current model+ const firstAudioField = Object.entries(selectedModel.inputs || {}).find(+ ([_, schema]) => schema.field === 'audio'+ );+ const firstAudioListField = Object.entries(selectedModel.inputs || {}).find(+ ([_, schema]) => schema.field === 'audios_list'+ );++ if (firstAudioField) {+ const [key] = firstAudioField;+ // Trigger file upload helper+ uploadFile(apiKey, audioFiles[0], () => {})+ .then(url => {+ setParams(prev => ({ ...prev, [key]: url }));+ })+ .catch(err => alert(`Failed to upload dropped file: ${err.message}`));+ } else if (firstAudioListField) {+ const [key] = firstAudioListField;+ uploadFile(apiKey, audioFiles[0], () => {})+ .then(url => {+ setParams(prev => {+ const currentList = Array.isArray(prev[key]) ? [...prev[key]] : [];+ if (currentList.length < 2) currentList.push(url);+ return { ...prev, [key]: currentList };+ });+ })+ .catch(err => alert(`Failed to upload dropped file: ${err.message}`));+ }+ }+ onFilesHandled?.();+ }+ }, [droppedFiles, onFilesHandled, selectedModel, apiKey]);++ // ── History helpers ─────────────────────────────────────────────────────+ const addToInternalHistory = useCallback((entry) => {+ setInternalHistory((prev) => [entry, ...prev].slice(0, 30));+ }, []);++ const handleSelectHistory = (entry, index) => {+ setActiveResultUrl(entry.url);+ setActiveResultTitle(entry.title || entry.prompt || "Generated Track");+ setActiveHistoryIdx(index);+ setView("result");+ };++ const handleGenerate = async () => {+ if (!selectedModel) return;++ // Check required fields+ if (selectedModel.required) {+ for (const field of selectedModel.required) {+ if (!params[field] || (Array.isArray(params[field]) && params[field].length === 0)) {+ alert(`Please complete the required field: ${selectedModel.inputs?.[field]?.title || field}`);+ return;+ }+ }+ }++ onGenerationStart?.();+ setIsGenerating(true);+ setGenerateError(null);++ try {+ const audioParams = {+ ...params,+ _modelId: selectedModelId,+ };++ // Call generateAudio+ const res = await generateAudio(apiKey, audioParams);++ if (!res?.url) {+ throw new Error("No audio URL returned by the API.");+ }++ const title = params.title || params.prompt || `Generated ${selectedModel.name}`;+ const entry = {+ id: res.id || Date.now().toString(),+ url: res.url,+ title,+ prompt: params.prompt || "",+ model: selectedModelId,+ timestamp: new Date().toISOString(),+ };++ if (!historyItems) addToInternalHistory(entry);++ setActiveResultUrl(res.url);+ setActiveResultTitle(title);+ setView("result");+ setActiveHistoryIdx(0);++ if (onGenerationComplete) {+ onGenerationComplete({+ url: res.url,+ model: selectedModelId,+ prompt: params.prompt,+ type: "audio",+ });+ }+ } catch (e) {+ console.error("[AudioStudio]", e);+ const errMsg = formatErrorMessage(e, "Audio generation failed");+ if (onGenerationError) onGenerationError(errMsg);+ else toast.error(errMsg);+ } finally {+ setIsGenerating(false);+ onGenerationEnd?.();+ }+ };++ const handleNew = () => {+ setView("input");+ setActiveResultUrl(null);+ setActiveResultTitle("");+ // Keep parameters to avoid having to reupload files if they wish to adjust details+ };++ return (+ <div className="w-full h-full flex bg-app-bg text-white overflow-hidden relative">++ {/* ─── LEFT CONFIGURATION SIDEBAR ─── */}+ <div ref={sidebarRef} className="w-full lg:w-[400px] border-r border-zinc-900 flex flex-col bg-zinc-950/40 backdrop-blur-lg flex-shrink-0 z-30">+ <div className="p-6 overflow-y-auto flex-1 custom-scrollbar space-y-6 pb-24">++ {/* Model Selector */}+ <div className="space-y-2 relative">+ <label className="text-xs font-bold text-zinc-300 uppercase tracking-wider block">+ Audio Model+ </label>+ <button+ ref={modelBtnRef}+ type="button"+ onClick={() => setOpenDropdown(!openDropdown)}+ className="w-full bg-zinc-900 border border-zinc-700 rounded px-4 py-3.5 text-sm text-left font-bold text-white flex items-center justify-between hover:bg-zinc-850 hover:border-primary/50 transition-all"+ >+ <span>{selectedModel?.name ?? "Select Model"}</span>+ <svg width="14" height="14" viewBox="0 0 24 24" fill="none" stroke="currentColor" strokeWidth="2.5" className={`transition-transform duration-200 ${openDropdown ? 'rotate-180' : ''}`}>+ <polyline points="6 9 12 15 18 9" />+ </svg>+ </button>++ {openDropdown && (+ <div className="absolute left-0 right-0 mt-2 z-50 bg-[#161618] border border-zinc-700 rounded shadow-3xl max-h-60 overflow-y-auto custom-scrollbar p-1.5">+ {audioModels.map((model) => (+ <button+ key={model.id}+ type="button"+ onClick={() => {+ setSelectedModelId(model.id);+ setOpenDropdown(false);+ }}+ className={`w-full text-left px-4 py-2.5 rounded text-xs font-bold transition-all flex flex-col gap-1.5 border ${+ model.id === selectedModelId ? "text-primary bg-primary/10 border-primary/20" : "text-zinc-200 border-transparent hover:bg-zinc-900 hover:text-white"+ }`}+ >+ <span>{model.name}</span>+ {model.description && (+ <span className="text-[10px] text-zinc-300 truncate max-w-[320px] font-normal">+ {model.description}+ </span>+ )}+ </button>+ ))}+ </div>+ )}+ </div>++ {/* Model Description */}+ {selectedModel?.description && (+ <div className="">+ <span className="text-[10px] font-bold text-primary uppercase tracking-wider block mb-1.5">Description</span>+ <p className="text-zinc-400 text-xs leading-relaxed font-semibold">{selectedModel.description}</p>+ </div>+ )}++ {/* Dynamic Configuration Form */}+ <div className="space-y-5">+ {selectedModel && Object.entries(selectedModel.inputs || {}).map(([key, schema]) => {+ // Skip model switcher itself (if it's in schemas)+ if (key === 'model') return null;+ // Audio URL file upload (single)+ if (schema.type === "string" && schema.field === "audio") {+ return (+ <AudioFileUploader+ key={key}+ label={schema.title || key}+ value={params[key] || ""}+ onChange={(url) => setParams(prev => ({ ...prev, [key]: url }))}+ apiKey={apiKey}+ />+ );+ }+ // Audio URLs list file upload (multiple)+ if (schema.type === "array" && schema.field === "audios_list") {+ return (+ <AudioListUploader+ key={key}+ label={schema.title || key}+ value={params[key] || []}+ onChange={(urls) => setParams(prev => ({ ...prev, [key]: urls }))}+ apiKey={apiKey}+ maxItems={schema.maxItems || 2}+ />+ );+ }+ // Boolean Toggles+ if (schema.type === "boolean") {+ return (+ <div key={key} className="flex items-center justify-between bg-zinc-900 border border-zinc-700/80 rounded p-4 transition-all hover:border-zinc-600">+ <div className="flex-1 pr-4">+ <span className="block text-xs font-bold text-white tracking-tight">+ {schema.title || key}+ </span>+ {schema.description && (+ <span className="block text-[11px] text-zinc-300 leading-normal mt-1">+ {schema.description}+ </span>+ )}+ </div>+ <button+ type="button"+ onClick={() => setParams(prev => ({ ...prev, [key]: !prev[key] }))}+ className={`w-11 h-6 rounded-full p-1 transition-all duration-300 relative shrink-0 ${+ params[key] ? "bg-primary" : "bg-zinc-800"+ }`}+ >+ <div className={`w-4 h-4 rounded-full bg-black shadow-md transform transition-all duration-300 ${+ params[key] ? "translate-x-5 bg-white" : "translate-x-0"+ }`} />+ </button>+ </div>+ );+ }+ // Enum Dropdowns+ if (schema.enum) {+ const isOpen = openParamDropdown === key;+ return (+ <div key={key} className="space-y-2 relative">+ <label className="block text-xs font-bold text-zinc-300 uppercase tracking-wider">+ {schema.title || key}+ </label>+ <button+ type="button"+ onClick={() => {+ setOpenDropdown(false);+ setOpenParamDropdown(isOpen ? null : key);+ }}+ className="w-full bg-zinc-900 border border-zinc-700 hover:border-zinc-600 rounded px-4 py-3.5 text-xs text-left font-bold text-white flex items-center justify-between transition-all cursor-pointer"+ >+ <span>{params[key] || "Select option"}</span>+ <svg width="12" height="12" viewBox="0 0 24 24" fill="none" stroke="currentColor" strokeWidth="2.5" className={`transition-transform duration-200 ${isOpen ? 'rotate-185' : ''}`}>+ <polyline points="6 9 12 15 18 9" />+ </svg>+ </button>++ {isOpen && (+ <div className="absolute left-0 right-0 mt-1 z-50 bg-[#161618] border border-zinc-700 rounded shadow-3xl max-h-60 overflow-y-auto custom-scrollbar p-1">+ {schema.enum.map((opt) => (+ <button+ key={opt}+ type="button"+ onClick={() => {+ setParams(prev => ({ ...prev, [key]: opt }));+ setOpenParamDropdown(null);+ }}+ className={`w-full text-left px-4 py-2.5 rounded text-xs font-bold transition-all border ${+ params[key] === opt+ ? "text-primary bg-primary/10 border-primary/20"+ : "text-zinc-200 border-transparent hover:bg-zinc-900 hover:text-white"+ }`}+ >+ {opt}+ </button>+ ))}+ </div>+ )}+ {schema.description && (+ <span className="block text-[11px] text-zinc-300 leading-normal">+ {schema.description}+ </span>+ )}+ </div>+ );+ }++ // Number Sliders & Ranges+ const isNumber = schema.type === "int" || schema.type === "integer" || schema.type === "float" || schema.type === "number";+ const hasMinMax = schema.minValue !== undefined && schema.maxValue !== undefined;+ if (isNumber && hasMinMax) {+ const step = schema.step || (schema.type === "float" ? 0.05 : 1);+ return (+ <div key={key} className="space-y-3 bg-zinc-900 border border-zinc-700/80 rounded p-4 transition-all hover:border-zinc-600">+ <div className="flex items-center justify-between text-xs font-bold">+ <span className="text-white tracking-tight">{schema.title || key}</span>+ <span className="text-primary font-mono bg-primary/10 px-2 py-0.5 rounded border border-primary/20">{params[key] !== undefined ? params[key] : schema.default}</span>+ </div>+ <div className="flex items-center gap-2">+ <span className="text-[10px] text-zinc-300 font-medium w-6 text-right">{schema.minValue}</span>+ <input+ type="range"+ min={schema.minValue}+ max={schema.maxValue}+ step={step}+ value={params[key] !== undefined ? params[key] : (schema.default || 0)}+ onChange={(e) => setParams(prev => ({ ...prev, [key]: parseFloat(e.target.value) }))}+ className="flex-1 h-1.5 bg-zinc-800 rounded-full appearance-none cursor-pointer accent-primary hover:bg-zinc-700 transition-all"+ />+ <span className="text-[10px] text-zinc-300 font-medium w-6 text-left">{schema.maxValue}</span>+ </div>+ {schema.description && (+ <span className="block text-[11px] text-zinc-300 leading-normal">+ {schema.description}+ </span>+ )}+ </div>+ );+ }++ // Prompt / Textarea Input+ if (key === "prompt") {+ return (+ <div key={key} className="space-y-2">+ <label className="block text-xs font-bold text-zinc-200 uppercase tracking-wider">+ {schema.title || "Lyrics / Prompt"}+ </label>+ <textarea+ value={params[key] || ""}+ onChange={(e) => setParams(prev => ({ ...prev, [key]: e.target.value }))}+ className="w-full bg-zinc-900 border border-zinc-700 focus:border-primary/85 rounded p-3 text-xs text-white placeholder:text-zinc-400 focus:outline-none transition-all min-h-[100px] resize-none leading-relaxed shadow-inner"+ placeholder={schema.description || "Enter what you want generated..."}+ />+ {schema.examples && Array.isArray(schema.examples) && (+ <div className="flex flex-wrap gap-1.5 mt-2">+ {schema.examples.map((ex, idx) => (+ <button+ key={idx}+ type="button"+ onClick={() => setParams(prev => ({ ...prev, [key]: ex }))}+ className="text-[11px] px-3 py-1 bg-zinc-800/80 border border-zinc-700 hover:bg-primary/20 hover:border-primary/45 hover:text-white rounded-full transition-all font-semibold text-zinc-100"+ >+ "{ex.slice(0, 35)}..."+ </button>+ ))}+ </div>+ )}+ </div>+ );+ }++ // Standard Text / Input fields+ return (+ <div key={key} className="space-y-2">+ <label className="block text-xs font-bold text-zinc-200 uppercase tracking-wider">+ {schema.title || key}+ </label>+ <input+ type={isNumber ? "number" : "text"}+ value={params[key] !== undefined ? params[key] : ""}+ placeholder={schema.placeholder || schema.description || `Enter ${key}...`}+ onChange={(e) => {+ const val = isNumber ? (e.target.value === "" ? "" : parseFloat(e.target.value)) : e.target.value;+ setParams(prev => ({ ...prev, [key]: val }));+ }}+ className="w-full bg-zinc-900 border border-zinc-700 hover:border-zinc-600 focus:border-primary/80 rounded px-4 py-3.5 text-xs text-white placeholder:text-zinc-400 focus:outline-none transition-all shadow-inner"+ />+ {schema.description && (+ <span className="block text-[11px] text-zinc-300 leading-normal">+ {schema.description}+ </span>+ )}+ </div>+ );+ })}+ </div>++ </div>++ {/* Dynamic Cost & Generate Section */}+ <div className="p-4 border-t border-zinc-900 bg-zinc-950/80 backdrop-blur-xl absolute bottom-0 left-0 w-full lg:w-[400px] z-40">+ <button+ type="button"+ onClick={handleGenerate}+ disabled={isGenerating || !selectedModel}+ className="w-full py-4 bg-primary text-black text-base font-bold rounded hover:bg-white transition-all transform hover:scale-[1.01] active:scale-95 disabled:opacity-50 disabled:grayscale shadow-glow flex items-center justify-center gap-3"+ >+ {isGenerating ? (+ <>+ <div className="w-4 h-4 border-2 border-black/20 border-t-black rounded-full animate-spin" />+ <span>Generating Audio...</span>+ </>+ ) : (+ <>+ <svg width="14" height="14" viewBox="0 0 24 24" fill="none" stroke="currentColor" strokeWidth="3">+ <path d="M5 3l14 9-14 9V3z" />+ </svg>+ <span>Generate Track</span>+ </>+ )}+ </button>+ </div>+ </div>+ {/* ─── RIGHT CONTENT AREA ─── */}+ <div className="flex-1 flex flex-col min-w-0 h-full relative z-20">++ {/* Main Display panel */}+ <div className="flex-1 overflow-y-auto custom-scrollbar p-6 lg:p-10 flex flex-col justify-between">++ <div className="flex-1 flex items-center justify-center min-h-[400px] mb-8">++ {/* 1. Error Display */}+ {generateError && (+ <div className="w-full max-w-md p-6 bg-red-500/10 border border-red-500/20 rounded flex flex-col items-center gap-4 animate-shake">+ <div className="w-12 h-12 bg-red-500/20 rounded-full flex items-center justify-center text-red-500 border border-red-500/30 shadow-lg">+ <svg width="24" height="24" viewBox="0 0 24 24" fill="none" stroke="currentColor" strokeWidth="2.5">+ <circle cx="12" cy="12" r="10" />+ <line x1="12" y1="8" x2="12" y2="12" />+ <line x1="12" y1="16" x2="12.01" y2="16" />+ </svg>+ </div>+ <div className="text-center">+ <span className="text-xs font-black text-red-500 uppercase tracking-widest block mb-1">+ Generation Error+ </span>+ <p className="text-white font-medium text-sm leading-relaxed">+ {generateError}+ </p>+ </div>+ </div>+ )}++ {/* 2. Generating / Loading View */}+ {isGenerating && !generateError && (+ <div className="flex flex-col items-center gap-6 animate-fade-in">+ <div className="relative">+ <div className="w-24 h-24 border-[3px] border-zinc-800 border-t-primary rounded-full animate-spin shadow-glow" />+ <div className="absolute inset-0 flex items-center justify-center text-primary">+ <MusicIcon className="animate-pulse text-primary" />+ </div>+ </div>+ <div className="text-center space-y-2">+ <div className="text-xs font-black text-primary uppercase tracking-[0.3em] animate-pulse">+ Generating Soundtrack+ </div>+ <div className="text-sm text-zinc-200 font-bold">+ Rendering audio waveforms and vocals...+ </div>+ </div>+ </div>+ )}++ {/* 3. Empty State (no audio, not loading, no error) */}+ {view === "input" && !isGenerating && !generateError && (+ <div className="flex flex-col items-center gap-6 max-w-md text-center p-8 bg-zinc-900/40 border border-zinc-800 rounded backdrop-blur-sm relative group animate-fade-in-up">+ {/* Glow behind the icon */}+ <div className="absolute inset-0 bg-primary/5 blur-3xl rounded-full opacity-25 group-hover:opacity-40 transition-opacity duration-1000 pointer-events-none" />+ <div className="w-20 h-20 bg-zinc-900 border border-zinc-705 rounded flex items-center justify-center shadow-inner relative z-10 transition-transform duration-500 group-hover:scale-105">+ <MusicIcon className="text-primary w-8 h-8 filter drop-shadow-[0_0_8px_rgba(34,211,238,0.3)]" />+ </div>+ <div className="relative z-10">+ <h3 className="text-white font-black text-xl mb-3 tracking-tight">Audio Studio</h3>+ <p className="text-sm text-zinc-200 font-medium leading-relaxed px-4">+ Choose an AI music model, voice cloner, or sound generator. Modify variables on the left and craft your next high-fidelity track.+ </p>+ </div>+ </div>+ )}++ {/* 4. Active Result Player Display */}+ {view === "result" && activeResultUrl && !isGenerating && !generateError && (+ <div className="w-full max-w-2xl animate-fade-in-up space-y-4">+ <div className="flex items-center justify-between px-1">+ <button+ onClick={handleNew}+ className="text-xs font-bold text-zinc-200 hover:text-primary flex items-center gap-2 transition-all bg-zinc-905 border border-zinc-700 hover:border-primary/30 px-4 py-2 rounded-full"+ type="button"+ >+ <svg width="12" height="12" viewBox="0 0 24 24" fill="none" stroke="currentColor" strokeWidth="2.5">+ <line x1="19" y1="12" x2="5" y2="12" />+ <polyline points="12 19 5 12 12 5" />+ </svg>+ <span>New Generation</span>+ </button>+ <span className="text-[11px] font-bold text-green-400 px-3.5 py-1.5 bg-green-500/10 border border-green-500/20 rounded-full flex items-center gap-2">+ <div className="w-1.5 h-1.5 bg-green-400 rounded-full animate-pulse" /> Success+ </span>+ </div>+ <PremiumAudioPlayer url={activeResultUrl} title={activeResultTitle} />+ </div>+ )}++ </div>++ {/* ─── BOTTOM HISTORY FOOTER ─── */}+ {history.length > 0 && (+ <div className="border-t border-zinc-900 pt-6 w-full animate-fade-in-up">+ <h4 className="text-xs font-bold text-zinc-300 uppercase tracking-wider mb-4 px-1">+ Generation History ({history.length})+ </h4>+ <div className="grid grid-cols-2 sm:grid-cols-3 md:grid-cols-4 lg:grid-cols-5 xl:grid-cols-6 gap-4">+ {history.map((entry, idx) => (+ <div+ key={entry.id || idx}+ onClick={() => handleSelectHistory(entry, idx)}+ className={`p-3.5 bg-zinc-900 border rounded cursor-pointer transition-all flex flex-col justify-between h-28 border-zinc-700/80 hover:bg-zinc-850 hover:border-zinc-500 ${+ activeResultUrl === entry.url && view === "result"+ ? "border-primary bg-primary/5 shadow-glow"+ : ""+ }`}+ >+ <div className="flex items-center gap-2">+ <div className={`w-8 h-8 rounded flex items-center justify-center flex-shrink-0 ${+ activeResultUrl === entry.url && view === "result" ? "bg-primary/20 text-primary" : "bg-zinc-800 text-zinc-200"+ }`}>+ <svg width="14" height="14" viewBox="0 0 24 24" fill="none" stroke="currentColor" strokeWidth="2.5">+ <polygon points="11 5 6 9 2 9 2 15 6 15 11 19 11 5" />+ </svg>+ </div>+ <span className="text-[10px] font-bold text-primary uppercase tracking-wider truncate">+ {entry.model ? entry.model.split('-').slice(0, 2).join(' ') : 'Audio'}+ </span>+ </div>+ <p className="text-[11px] font-semibold text-white line-clamp-2 leading-tight">+ {entry.title || entry.prompt || "Untitled Audio"}+ </p>+ </div>+ ))}+ </div>+ </div>+ )}++ </div>++ </div>+ <Toaster position="top-right" containerStyle={{ zIndex: 99999 }} toastOptions={{ duration: 5000, style: { background: '#18181b', color: '#ffffff', border: '1px solid rgba(255,255,255,0.15)', fontSize: '13px', borderRadius: '12px', boxShadow: '0 10px 30px rgba(0,0,0,0.6)', maxWidth: '440px', wordBreak: 'break-word', whiteSpace: 'pre-wrap', padding: '12px 16px' } }} />+ </div>+ );+}diff --git a/packages/studio/src/components/CinemaStudio.jsx b/packages/studio/src/components/CinemaStudio.jsxindex 3f05114f..c8720180 100644--- a/packages/studio/src/components/CinemaStudio.jsx+++ b/packages/studio/src/components/CinemaStudio.jsx@@ -426,5 +426,717 @@ function CameraControlsOverlay({type="button"onClick={onClose}aria-label="Close camera settings"- titl������k�w��Q��(���������������������������ѽ��(��������������������ѥѱ�����є�(���������������������� �����졔������(�������������������������ѽ�Aɽ����ѥ�����(�������������������������������ɴ��ɔ��ԁ��ɔ��ԁ݅�ЁѼ�����є�ѡ�́����Ʌѕ���ѕ�������(������������������������͕�%�ѕɹ��!��ѽ���ɕ����ɕع���ѕȠ�|������������त�(�����������������������(����������������������(�������������������������9������ȁ�����������������ɽ�����ȵ���ɽչ�����ձ��ѕ�еɕ��������ٕ�鉜�ɕ��������ٕ��ѕ�еݡ�є��Ʌ�ͥѥ���������ɑ�ȁ��ɑ�ȵݡ�є����(�������������������(����������������������ٜ�ݥ�Ѡ��Ј���������Ј�٥�� ��������Ѐ�Ј�����������ɽ�����ɕ�� ���Ȉ���ɽ��]��Ѡ�ȸԈ�(��������������������������履����������̀Ԁ�Ā؈���(�������������������������Ѡ���4�����фȀȀ���ĴȀ� ݄ȀȀ���Ĵȴ�Xٴ̀�XфȀȀ����ȴɠфȀȀ����Ȁ��Ȉ���(�����������������������������������Ĉ������������܈���(����������������������������Ј�����Ĉ�����Ј�����܈���(����������������������ٜ�(���������������������ѽ��(������������������((����������������켨��х��̀���(����������������������9������́�����������������ɽ�����ȵʹ���ɑ�ȵЁ��ɑ�ȵݡ�є�ԁ����ā��������്������ѥ�䵉��ݕ�������Ȉ�(���������������������ѽ�(���������������������������ѽ��(���������������������� �����졔������(�������������������������ѽ�Aɽ����ѥ�����(���������������������������� ���Aɽ��С�����͕�ѥ������ɽ��а�����(����������������������(�������������������������9�����ܵ�ձ��ѕ�е���Ёѕ�е�́�����������́��������ɕ��ᕐ��Ʌ�ͥѥ��������́���ͽȵ���䀑�(����������������������������Aɽ���%��������(���������������������������ѕ�еl��ɐ͕�t�(������������������������耉ѕ�еݡ�є������ٕ��ѕ�еݡ�є�(�����������������������(��������������������ѥѱ���(����������������������������Aɽ���%��������(���������������������������Aɽ��Ё�������(������������������������耉 ��䁙ձ���ɽ��Ј(���������������������(���������������������ɥ���������(����������������������������Aɽ���%��������(���������������������������Aɽ��Ё�������(������������������������耉 ��䁙ձ���ɽ��Ј(���������������������(�������������������(��������������������핹���͕�ѥ������ɽ��Ё����9���ɽ��Љ�(���������������������ѽ��(�����������������������������9�����ȵ���䈁�ɥ����ٔ�����є��(��������������������퍽����Aɽ���%������������Aɽ��Ё��������耈��(������������������������(������������������������9�������ѕ�̵���ѕȁ�дā�����Ʌ������Ĉ�(��������������������������9�������ѕ�̵���ѕȁ����Ȉ�(���������������������������������9����ѕ�еl����t����е�����ѕ�еl��ɐ͕�t���ȁ����ԁ���l��ɐ͕�t����ɽչ������ɑ�ȁ��ɑ�ȵl��ɐ͕�t�����(������������������������ ������M�Ց��(����������������������������(����������������������핹���͕�ѥ���������Ʉ�����(�����������������������������������9����ѕ�еl����t�ѕ�еݡ�є�����핹���͕�ѥ��̹����Ʌ�������(������������������������(����������������������(��������������������(������������������(����������������(���������������(������������(����������耠(����������������9���������്����ѕ�̵���ѕȁ���ѥ�䵍��ѕȁ���ձ��ѕ�е���ѕȁ��Ё�����є�������������Ʌ�ͥѥ���������Ʌѥ�������������l��١t��(������������켨�=ٕɱ�����������ѥ�����ɑ̀���(������������������9�������ѕ�̵���ѕȁ���ѥ�䵍��ѕȁ����ĸԁ��靅��́������͕���е�����͍�������ʹ�͍���������(��������������������9����ܴ������ȁʹ�ܴ�Ёʹ頴���ɽչ�����ᰁ��ɑ�ȁ��ɑ�ȵݡ�є����͡���ܴ�ᰀ�ɽхє�l�ɑ��t��Ʌ�͙�ɴ���ٕ��ɽхє�����ٕ��͍����������ٕ�������Ʌ�ͥѥ���������Ʌѥ��������ٕə��ܵ����������ݡ�є�l����t�����͡ɥ������(����������������(�������������������Ɍ�����輽�ͅ�ݭ������Ĺ���Ց�ɽ�й��нݕ���͕�̽٥��������̽͑ᰵ�������٥��(���������������������� ɕ�ѥٔ���͕ЀĈ(�����������������������9����ܵ�ձ�����ձ�������е��ٕȈ(������������������(����������������(��������������������9����ܴ������ȁʹ�ܴ�Ёʹ頴���ɽչ�����ᰁ��ɑ�ȁ��ɑ�ȵݡ�є����͡���ܴ�ᰀ�ɽхє�lё��t��Ʌ�͙�ɴ���ٕ��ɽхє�����ٕ��͍����������ٕ�������Ʌ�ͥѥ���������Ʌѥ��������ٕə��ܵ����������ݡ�є�l����t�����́ʹ赵��Ё����͡ɥ������(����������������(�������������������Ɍ�����輽�ͅ�ݭ������Ĺ���Ց�ɽ�й��нݕ���͕�̽٥��������̽��ɽ����������٥��(���������������������� ɕ�ѥٔ���͕ЀȈ(�����������������������9����ܵ�ձ�����ձ�������е��ٕȈ(������������������(����������������(��������������������9����ܴ��������ʹ�ܴ�Ёʹ頴�Ёɽչ�����ձ����ɑ�ȁ��ɑ�ȵݡ�є����͡���ܴ�ᰁɽхє�lّ��t��Ʌ�͙�ɴ���ٕ��ɽхє�����ٕ��͍����������ٕ�������Ʌ�ͥѥ���������Ʌѥ��������ٕə��ܵ����������ݡ�є�l����t�����́ʹ赵��Ё����͡ɥ������(����������������(�������������������Ɍ�����輽�ͅ�ݭ������Ĺ���Ց�ɽ�й��нݕ���͕�̽٥��������̽��ф��յ�����٥��(���������������������� ɕ�ѥٔ���͕Ѐ̈(�����������������������9����ܵ�ձ�����ձ�������е��ٕȈ(������������������(����������������(��������������������9����ܴ������ȁʹ�ܴ�Ёʹ頴���ɽչ�����ᰁ��ɑ�ȁ��ɑ�ȵݡ�є����͡���ܴ�ᰁɽхє�l�ɑ��t��Ʌ�͙�ɴ���ٕ��ɽхє�����ٕ��͍����������ٕ�������Ʌ�ͥѥ���������Ʌѥ��������ٕə��ܵ����������ݡ�є�l����t�����́ʹ赵��Ё����͡ɥ������(����������������(�������������������Ɍ�����輽�ͅ�ݭ������Ĺ���Ց�ɽ�й��нݕ���͕�̽٥��������̽��ə��е�����٥��(���������������������� ɕ�ѥٔ���͕ЀЈ(�����������������������9����ܵ�ձ�����ձ�������е��ٕȈ(������������������(����������������(��������������((�������������ā�����9����ѕ�д�ᰁʹ�ѕ�д�ᰁ���ѕ�д�ᰁ���е���Ʌ������Ʌ������ѥ��Ё���Ёѕ�е���ѕȁ��Ё��������്����ѕ�̵���ѕȈ�(�������������������������9����ѕ�еݡ�є����е����������ɍ�͔�ѕ�еᰁʹ�ѕ�д�ᰁ�Ʌ������ݥ������ā�����������MQIP� IQ%9�]%Q ������(�������������������������9����ѕ�еl��ɐ͕�t����е����������ɍ�͔�ѕ�д�ᰁʹ�ѕ�д�ᰁʹ�дā�Ʌ������ѥ��Ј�(���������������� %95�MQU%<(��������������������(���������������(��������������������9����ѕ�еݡ�є����ѕ�е�́ʹ�ѕ�еʹ����е����մ��Ʌ������ݥ���ѕ�е���ѕȁ���ܵ�����������ɕ��ᕐ���Ј�(��������������]��Ёݽձ���ԁ͡��ЁݥѠ�������є��Ց����� ���ɽ������Ʌ̰�����ѥ�������͕̰������ɽ��Ё���������������ѥ��͍���̸(���������������(������������(����������(��������((������켨��R�R � =QQ=4�AI=5AP� H��R�R ����(�������Aɽ��� ����͕�(����������ͥѥ�� ����9���ͽ��є����ѽ��Ё���дЁɥ��дЁ��鱕�д�����ɥ��д������Ѽ���鵅�ܵl�ԕt���鵅�ܴ�ᰁ�����Ʌ�ͥѥ���������Ʌѥ������������є������������(����������屔���ձ��(�������(����������켨�U���ȁI���%�����U��������Q��хɕ�����(����������������9�������ѕ�̵�х�Ё����Ёܵ�ձ����Ĉ�(������������켨�%�����U������ ��ѽ�����(������������������9����ɕ��ѥٔ��д��Ԉ�(������������������(�����������������������(����������������ɕ��������%����I���(���������������������9��������(����������������������������(������������������ �������������%����U������(����������������(��������������(�����������������ѽ�(������������������ �����젤���(��������������������������%����(����������������������ɕ��ٕ%������(��������������������聥����%����I������ɕ�����������(�����������������(������������������ͅ��������U��������%�����(���������������������9������ɽ���5���� ��ѽ� ����9�����(��������������������ѥٔ� ���������������%������(�������������������(���������������(�������������������U��������%��������(������������������������9���������്����ѕ�̵���ѕȁ���ѥ�䵍��ѕȁܵ�ձ�����ձ����ͽ��є���͕д�����������������������ɽ�����ȵl���t��(����������������������ٜ������9����ܴ�������ɽхє�����(�����������������������ɍ��(����������������������������؈(����������������������������؈(���������������������������Ј(��������������������������ɽ�����ɕ�� ���Ȉ(��������������������������ɽ��]��Ѡ�Ȉ(������������������������������Ʌ����ɕ�Ј(�����������������������������9����ѕ�еݡ�є����(������������������������(�����������������������ɍ��(����������������������������؈(����������������������������؈(���������������������������Ј(��������������������������ɽ�����ɕ�� ���Ȉ(��������������������������ɽ��]��Ѡ�Ȉ(������������������������������Ʌ����ɕ�Ј(��������������������������ɽ���͡��Ʌ������(��������������������������ɽ���͡���͕�������������������U�����Aɽ�ɕ�̤�������(�����������������������������9����ѕ�е�ɥ�����Ʌ�ͥѥ���������Ʌѥ�������(������������������������(����������������������ٜ�(�������������������������������9���ͽ��є�ѕ�еl���t����е�����ѕ�еݡ�є��(����������������������������U�����Aɽ�ɕ����(��������������������������(��������������������(���������������������������%��������(������������������������9����ɕ��ѥٔ�ܵ�ձ�����ձ���ɽ����(��������������������(�����������������������Ɍ����������%�����(��������������������������I���ɕ����(���������������������������9����ܵ�ձ�����ձ�������е��ٕȁ�����������ɽ�����ٕ������������Ʌ�ͥѥ����������(����������������������(��������������������������9���ͽ��є���͕д��������ѕ�̵���ѕȁ���ѥ�䵍��ѕȁ����������ɽ�����ٕ�������������Ʌ�ͥѥ�����������(������������������������ٜ�ݥ�Ѡ��Ј���������Ј�٥�� ��������Ѐ�Ј�����������ɽ�����ɕ�� ���Ȉ���ɽ��]��Ѡ�̈������9����ѕ�еݡ�є��(���������������������������Ѡ���4����0��4ٰ�Ȁ�Ȉ���(������������������������ٜ�(����������������������(��������������������(������������������耠(��������������������ٜ�ݥ�Ѡ��؈���������؈�٥�� ��������Ѐ�Ј�����������ɽ�����ɕ�� ���Ȉ���ɽ��]��Ѡ�ȸԈ������9����ѕ�еݡ�є�����ɽ�����ٕ��ѕ�еl��ɐ͕�t��Ʌ�ͥѥ��������̈�(���������������������ɕ�Ё��̈���̈�ݥ�Ѡ�������������������Ȉ����Ȉ���(���������������������ɍ�������Ԉ�����Ԉ���ĸԈ���(������������������������履�����������Ā�Ԁ����Ԁ�Ĉ���(��������������������ٜ�(������������������(�����������������ѽ��(��������������((�������������Aɽ���Q��хɕ�(��������������ɕ���ѕ�хɕ�I���(��������������م�Ք��͕�ѥ��̹�ɽ����(���������������� ������졔����(����������������͕�M��ѥ��̠��ɕؤ�����쀸���ɕذ��ɽ���联�хɝ�йم�Ք����(���������������(���������������������������͍ɥ�����ȁ�������͍�������(��������������(������������((����������켨� ��ѽ��I��� ���ɽ�̀�����Ʌє����(�����������Aɽ�����ѕ��(�������������Aɽ��� ���ɽ���(��������������켨�����ЁI�ѥ�� ��ѽ�����(��������������������9����ɕ��ѥٔ��(�������������������ѽ�(������������������ɕ���� ѹI���(�����������������������9������ɽ��� ���ɽ� ����9�����(����������������������ѥٔ聽���ɽ���ݸ���Ȉ�(�������������������������9���耉ѕ�е�́���е͕��������(���������������������(�������������������� �����젤���(��������������������͕�=���ɽ���ݸ�������������Ȉ����ձ��耉�Ȉ��(�������������������(�����������������(�������������������Aɽ��������I�ѥ�%������(�������������������͕�ѥ��̹������}Ʌѥ��(�������������������ѽ��(���������������������ɽ���ݸ���Ȉ�����(�������������������ɽ���ݸ(��������������������ѥѱ������ЁI�ѥ��(���������������������ѕ����MA Q}IQ%=M�(��������������������͕���ѕ���͕�ѥ��̹������}Ʌѥ��(����������������������M�������م�����(����������������������͕�M��ѥ��̠��ɕؤ�����쀸���ɕذ�������}Ʌѥ��م�����(���������������������(���������������������ɥ����I����� ѹI���(���������������������� ��͔�젤����͕�=���ɽ���ݸ��ձ���(��������������������(������������������(����������������((��������������켨�I�ͽ��ѥ��� ��ѽ�����(��������������������9����ɕ��ѥٔ��(�������������������ѽ�(������������������ɕ���ɕ� ѹI���(�����������������������9������ɽ��� ���ɽ� ����9�����(����������������������ѥٔ聽���ɽ���ݸ����ɕ̈�(�������������������������9���耉ѕ�е�́���е͕��������(���������������������(�������������������� �����젤���(��������������������͕�=���ɽ���ݸ��������������ɕ̈����ձ��耉ɕ̈��(�������������������(�����������������(�������������������Aɽ���EՅ����%������(�������������������ɕͽ��ѥ���(�������������������ѽ��(���������������������ɽ���ݸ����ɕ̈�����(�������������������ɽ���ݸ(��������������������ѥѱ��I�ͽ��ѥ���(���������������������ѕ����IM=1UQ%=9M�(��������������������͕���ѕ���ɕͽ��ѥ���(����������������������M�������͕�I�ͽ��ѥ���(���������������������ɥ����I����ɕ� ѹI���(���������������������� ��͔�젤����͕�=���ɽ���ݸ��ձ���(��������������������(������������������(����������������((��������������켨�Mյ���� �ɐ���ɥ����́�ٕɱ�䤀���(�����������������ѽ�(���������������������9������ɽ��� ���ɽ� ����9�����(�����������������������9���耉ѕ�е���Ё�ٕə��ܵ�������ѕ�е�́���е͕�������ѕ�еݡ�є������ٕ��ѕ�еݡ�є��(�������������������(������������������ �����젤����͕�%�=ٕɱ��=������Ք��(���������������(����������������������9����ܴĸԁ��ĸԁ���l��ɐ͕�t�ɽչ�����ձ��͡���ܵ���͡���ܵl��ɐ͕�t����͡ɥ��������(���������������������������9����ܵl�����t���չ��є�ѕ�е�́���е͕�������ѕ�еݡ�є�����ɽ�����ٕ��ѕ�еl��ɐ͕�t��Ʌ�ͥѥ��������̈�(�������������������͕�ѥ��̹����Ʌ�-܁홽ɵ��Mյ����Y��Ք���(����������������������(�����������������ѽ��(�������������Aɽ��� ���ɽ���((������������켨����Ʌє� ��ѽ�����(�������������Aɽ����ѥ��(����������������ͅ�����������Ʌѥ�������͕�ѥ��̹�ɽ��й�ɥ����(���������������� ���������������Ʌѕ�(�������������(��������������������Ʌѥ������(������������������(�����������������������������9������є�������������������ѕ�е��������^0������(���������������������������Ʌѥ�����������(������������������(����������������耠(������������������(������������������������M���Ѓ�r����������(������������������(����������������(�������������Aɽ����ѥ���(�����������Aɽ�����ѕ��(�������Aɽ��� ����͕��(�������ձ�͍ɕ��Uɰ�����(���������(���������������9���ᕐ���͕д���l���t�������ѕ�̵���ѕȁ���ѥ�䵍��ѕȁ����������ԁ�����ɽ�����ȵʹ������є���������(������������ �����젤����͕�ձ�͍ɕ��Uɰ��ձ���(���������(�������������ѽ�(�������������������ѽ��(�����������������9���ͽ��є�ѽ��ɥ��д��́���ݡ�є������ٕ�鉜�ݡ�є����ɽչ�����ձ��ѕ�еݡ�є��Ʌ�ͥѥ��������́��ɑ�ȁ��ɑ�ȵݡ�є����(�������������� �����졔������(�����������������ѽ�Aɽ����ѥ�����(��������������͕�ձ�͍ɕ��Uɰ��ձ���(��������������(�����������(��������������ٜ�ݥ�Ѡ��Ј���������Ј�٥�� ��������Ѐ�Ј�����������ɽ�����ɕ�� ���Ȉ���ɽ��]��Ѡ�ȸԈ���ɽ��1�������ɽչ�����ɽ��1��������ɽչ���(��������������������������؈����؈����������(�������������������؈����؈�����������������(��������������ٜ�(�������������ѽ��(�����������(�������������Ɍ��ձ�͍ɕ��Uɱ�(����������������ձ�͍ɕ���Aɕ٥�܈�(�����������������9����ܵl����t���ൠ�l��١t�ɽչ�����ᰁ͡���ܴ�ᰁ�����е���х��������є�͍��������(�������������� �����졔��������ѽ�Aɽ����ѥ�����(������������(����������(��������(������켨��R�R � ���Ʉ� ���ɽ�́=ٕɱ�䃊R�R ����(������� ���Ʌ ���ɽ��=ٕɱ��(����������=�������=ٕɱ��=����(���������� ��͔�젤����͕�%�=ٕɱ��=�������͔��(��������͕�ѥ�����͕�ѥ����(����������M��ѥ��� �������͕�M��ѥ����(��������(������(����)�(\ No newline at end of file+ title="Close"+ className="ml-4 flex h-9 w-9 shrink-0 items-center justify-center rounded-full border border-white/[0.06] bg-white/[0.03] text-white/40 transition-all hover:border-white/15 hover:bg-white/[0.07] hover:text-white"+ >+ <svg+ width="16"+ height="16"+ viewBox="0 0 24 24"+ fill="none"+ stroke="currentColor"+ strokeWidth="2"+ >+ <path d="M18 6L6 18M6 6l12 12" />+ </svg>+ </button>+ </div>++ <div className="overflow-x-auto px-5 py-6 no-scrollbar md:px-7 md:py-7">+ <div className="mx-auto flex w-max min-w-full justify-start gap-3 sm:justify-center md:gap-5">+ <ScrollColumn+ title="Camera"+ items={CAMERAS}+ columnKey="camera"+ value={settings.camera}+ onChange={updateSetting("camera")}+ />+ <ScrollColumn+ title="Lens"+ items={LENSES}+ columnKey="lens"+ value={settings.lens}+ onChange={updateSetting("lens")}+ />+ <ScrollColumn+ title="Focal length"+ items={FOCAL_LENGTHS}+ columnKey="focal"+ value={settings.focal}+ onChange={updateSetting("focal")}+ />+ <ScrollColumn+ title="Aperture"+ items={APERTURES}+ columnKey="aperture"+ value={settings.aperture}+ onChange={updateSetting("aperture")}+ />+ </div>+ </div>+ </div>+ </div>+ );+}++// ─── Main Component ───────────────────────────────────────────────────────────++export default function CinemaStudio({+ apiKey,+ onGenerationStart,+ onGenerationEnd,+ onGenerationComplete,+ onGenerationError,+ historyItems,+}) {+ const LEGACY_PERSIST_KEY = "hg_cinema_studio_persistent";+ const PERSIST_KEY = scopedPersistKey(LEGACY_PERSIST_KEY, apiKey);+ useEffect(() => {+ migrateLegacyPersistKey(LEGACY_PERSIST_KEY, PERSIST_KEY);+ }, [PERSIST_KEY]);++ // ── Settings state ──+ const [settings, setSettings] = useState({+ prompt: "",+ aspect_ratio: "16:9",+ camera: CAMERAS[0],+ lens: LENSES[0],+ focal: 35,+ aperture: "f/1.4",+ });+ const [resolution, setResolution] = useState("2K");++ // ── UI state ──+ const [isOverlayOpen, setIsOverlayOpen] = useState(false);+ const [isGenerating, setIsGenerating] = useState(false);+ const [canvasUrl, setCanvasUrl] = useState(null); // null = prompt view+ const [fullscreenUrl, setFullscreenUrl] = useState(null);+ const [uploadedImage, setUploadedImage] = useState(null);+ const [isUploadingImage, setIsUploadingImage] = useState(false);+ const [imageUploadProgress, setImageUploadProgress] = useState(0);+ const imageInputRef = useRef(null);+ const [activeHistoryIndex, setactiveHistoryIndex] = useState(null);+ const [copiedPromptIndex, setCopiedPromptIndex] = useState(null);++ // ── Internal history state (used when historyItems prop is not provided) ──+ const [internalHistory, setInternalHistory] = useState([]);++ // ── Dropdown state ──+ const [openDropdown, setOpenDropdown] = useState(null); // 'ar' | 'res' | null+ const arBtnRef = useRef(null);+ const resBtnRef = useRef(null);++ // ── Textarea auto-grow ──+ const textareaRef = useRef(null);+ const resultImgRef = useRef(null);++ const handleImageUpload = async (e) => {+ const file = e.target.files?.[0];+ if (!file) return;++ setIsUploadingImage(true);+ setImageUploadProgress(0);++ try {+ const url = await uploadFile(apiKey, file, (progress) => {+ setImageUploadProgress(progress);+ });+ if (url) setUploadedImage(url);+ } catch (err) {+ console.error("Image upload failed:", err);+ } finally {+ setIsUploadingImage(false);+ setImageUploadProgress(0);+ if (imageInputRef.current) imageInputRef.current.value = "";+ }+ };++ const removeImage = () => {+ setUploadedImage(null);+ };++ // ── Persistence: Load ────────────────────────────────────────────────────+ useEffect(() => {+ try {+ const stored = localStorage.getItem(PERSIST_KEY);+ if (stored) {+ const data = JSON.parse(stored);+ if (data.settings) setSettings(data.settings);+ if (data.resolution) setResolution(data.resolution);+ if (data.internalHistory) setInternalHistory(data.internalHistory);+ if (data.uploadedImage) setUploadedImage(data.uploadedImage);+ }+ } catch (err) {+ console.warn("Failed to load CinemaStudio persistence:", err);+ }+ }, []);++ // ── Adjust height on load ────────────────────────────────────────────────+ // ── Persistence: Save ────────────────────────────────────────────────────+ useEffect(() => {+ const timer = setTimeout(() => {+ try {+ const state = {+ settings,+ resolution,+ internalHistory,+ uploadedImage,+ };+ localStorage.setItem(PERSIST_KEY, JSON.stringify(state));+ } catch (err) {+ console.warn("Failed to save CinemaStudio persistence:", err);+ }+ }, 500); // 500ms debounce+ return () => clearTimeout(timer);+ }, [settings, resolution, internalHistory, uploadedImage]);++ // Derive effective history (prop wins over internal)+ const history = historyItems != null ? historyItems : internalHistory;++ useEffect(() => {+ setCanvasUrl(history[0]?.url || null);+ // eslint-disable-next-line react-hooks/exhaustive-deps+ }, [historyItems]);++ const formatSummaryValue = () =>+ `${settings.lens}, ${settings.focal}mm, ${settings.aperture}`;++ // ── Textarea auto-height ──+ // ── Generate ──+ const handleGenerate = useCallback(async () => {+ const basePrompt = settings.prompt.trim();+ if (!basePrompt || isGenerating) return;++ onGenerationStart?.();+ setIsGenerating(true);++ const finalPrompt = buildNanoBananaPrompt(+ basePrompt,+ settings.camera,+ settings.lens,+ settings.focal,+ settings.aperture,+ );++ try {+ const res = await generateImage(apiKey, {+ model: uploadedImage ? "nano-banana-pro-edit" : "nano-banana-pro",+ prompt: finalPrompt,+ aspect_ratio: settings.aspect_ratio,+ resolution: resolution.toLowerCase(),+ negative_prompt: "blurry, low quality, distortion, bad composition",+ images_list: uploadedImage ? [uploadedImage] : [],+ });++ if (res && res.url) {+ const entry = {+ url: res.url,+ timestamp: Date.now(),+ settings: {+ prompt: basePrompt,+ camera: settings.camera,+ lens: settings.lens,+ focal: settings.focal,+ aperture: settings.aperture,+ aspect_ratio: settings.aspect_ratio,+ resolution,+ },+ };++ // Only update internal history if not using prop-driven history+ if (historyItems == null) {+ setInternalHistory((prev) => [entry, ...prev].slice(0, 50));+ }++ setCanvasUrl(res.url);++ if (onGenerationComplete) {+ onGenerationComplete({+ url: res.url,+ model: "nano-banana-pro",+ prompt: basePrompt,+ type: "cinema",+ });+ }+ } else {+ throw new Error("No data returned");+ }+ } catch (e) {+ console.error(e);+ onGenerationError?.(e.message?.slice(0, 120) || "Cinema generation failed");+ } finally {+ setIsGenerating(false);+ onGenerationEnd?.();+ }+ }, [+ settings,+ resolution,+ apiKey,+ isGenerating,+ onGenerationComplete,+ onGenerationEnd,+ onGenerationError,+ onGenerationStart,+ historyItems,+ ]);++ // ── Regenerate ──+ const handleRegenerate = useCallback(() => {+ setCanvasUrl(null);+ // Small delay then generate+ setTimeout(() => handleGenerate(), 300);+ }, [handleGenerate]);++ // ── Download ──+ const handleDownload = useCallback(async () => {+ if (!canvasUrl) return;+ try {+ const response = await fetch(canvasUrl);+ const blob = await response.blob();+ const blobUrl = URL.createObjectURL(blob);+ const a = document.createElement("a");+ a.href = blobUrl;+ a.download = `cinema-shot-${Date.now()}.jpg`;+ document.body.appendChild(a);+ a.click();+ document.body.removeChild(a);+ URL.revokeObjectURL(blobUrl);+ } catch {+ window.open(canvasUrl, "_blank");+ }+ }, [canvasUrl]);++ const handleCopyPrompt = useCallback(+ async (prompt, index) => {+ if (!prompt) return;++ try {+ await navigator.clipboard.writeText(prompt);+ setCopiedPromptIndex(index);+ window.setTimeout(() => {+ setCopiedPromptIndex((current) => (current === index ? null : current));+ }, 1600);+ } catch (error) {+ console.error("Failed to copy the prompt:", error);+ onGenerationError?.("Could not copy the prompt to the clipboard.");+ }+ },+ [onGenerationError],+ );++ // ── Load history item ──+ const loadHistoryItem = (entry, idx) => {+ if (entry.settings) {+ setSettings((prev) => ({+ ...prev,+ camera: entry.settings.camera ?? prev.camera,+ lens: entry.settings.lens ?? prev.lens,+ focal: entry.settings.focal ?? prev.focal,+ aperture: entry.settings.aperture ?? prev.aperture,+ aspect_ratio: entry.settings.aspect_ratio ?? prev.aspect_ratio,+ prompt: entry.settings.prompt ?? prev.prompt,+ }));+ if (entry.settings.resolution) setResolution(entry.settings.resolution);++ }+ setCanvasUrl(entry.url);+ };++ const resetToPrompt = () => {+ setCanvasUrl(null);+ setSettings((prev) => ({ ...prev, prompt: "" }));+ if (textareaRef.current) {+ setTimeout(() => textareaRef.current?.focus(), 50);+ }+ };++ // ── Render ───────────────────────────────────────────────────────────────+ return (+ <div className="w-full h-full flex flex-col items-center justify-center bg-black relative overflow-hidden">++ {/* ── CENTRAL GALLERY AREA ── */}+ <div className="flex-1 w-full max-w-7xl mx-auto overflow-y-auto custom-scrollbar pb-40 lg:pb-32 px-2">+ {history.length > 0 ? (+ <div className="grid grid-cols-1 md:grid-cols-2 lg:grid-cols-3 gap-6 w-full pt-4 animate-fade-in-up">+ {history.map((entry, idx) => (+ <div+ key={entry.timestamp ?? idx}+ className="relative group rounded-lg overflow-hidden border border-white/10 bg-[#0a0a0a] shadow-xl hover:border-[#22d3ee]/50 transition-all duration-300 flex flex-col cursor-pointer"+ onClick={() => loadHistoryItem(entry, idx)}+ >+ <img+ src={entry.url}+ alt={`History item ${idx + 1}`}+ className="w-full aspect-[4/3] object-cover bg-black/40"+ />++ {/* Overlay actions */}+ <div className="absolute top-2 right-2 flex flex-col gap-2 opacity-0 group-hover:opacity-100 transition-opacity">+ <button+ type="button"+ title="Fullscreen"+ onClick={(e) => {+ e.stopPropagation();+ setFullscreenUrl(entry.url);+ }}+ className="p-2 bg-black/60 backdrop-blur-md rounded-full text-white hover:bg-[#22d3ee] hover:text-black transition-all border border-white/10"+ >+ <svg width="14" height="14" viewBox="0 0 24 24" fill="none" stroke="currentColor" strokeWidth="2.5">+ <polyline points="15 3 21 3 21 9" />+ <polyline points="9 21 3 21 3 15" />+ <line x1="21" y1="3" x2="14" y2="10" />+ <line x1="3" y1="21" x2="10" y2="14" />+ </svg>+ </button>+ <button+ type="button"+ title="Download"+ onClick={async (e) => {+ e.stopPropagation();+ try {+ const response = await fetch(entry.url);+ const blob = await response.blob();+ const blobUrl = URL.createObjectURL(blob);+ const a = document.createElement("a");+ a.href = blobUrl;+ a.download = `cinema-shot-${entry.id || idx}.jpg`;+ document.body.appendChild(a);+ a.click();+ document.body.removeChild(a);+ URL.revokeObjectURL(blobUrl);+ } catch {+ window.open(entry.url, "_blank");+ }+ }}+ className="p-2 bg-black/60 backdrop-blur-md rounded-full text-white hover:bg-[#22d3ee] hover:text-black transition-all border border-white/10"+ >+ <svg width="14" height="14" viewBox="0 0 24 24" fill="none" stroke="currentColor" strokeWidth="2.5">+ <path d="M21 15v4a2 2 0 01-2 2H5a2 2 0 01-2-2v-4M7 10l5 5 5-5M12 15V3" />+ </svg>+ </button>+ <button+ type="button"+ title="Delete"+ onClick={(e) => {+ e.stopPropagation();+ if (confirm("Are you sure you want to delete this generated item?")) {+ setInternalHistory(prev => prev.filter((_, i) => i !== idx));+ }+ }}+ className="p-2 bg-black/60 backdrop-blur-md rounded-full text-red-400 hover:bg-red-500 hover:text-white transition-all border border-white/10"+ >+ <svg width="14" height="14" viewBox="0 0 24 24" fill="none" stroke="currentColor" strokeWidth="2.5">+ <polyline points="3 6 5 6 21 6" />+ <path d="M19 6v14a2 2 0 01-2 2H7a2 2 0 01-2-2V6m3 0V4a2 2 0 012-2h4a2 2 0 012 2v2" />+ <line x1="10" y1="11" x2="10" y2="17" />+ <line x1="14" y1="11" x2="14" y2="17" />+ </svg>+ </button>+ </div>++ {/* Details */}+ <div className="p-3 bg-black/80 backdrop-blur-sm border-t border-white/5 flex-1 flex flex-col justify-between gap-2">+ <button+ type="button"+ onClick={(e) => {+ e.stopPropagation();+ handleCopyPrompt(entry.settings?.prompt, idx);+ }}+ className={`w-full text-left text-xs line-clamp-3 leading-relaxed transition-colors cursor-copy ${+ copiedPromptIndex === idx+ ? "text-[#22d3ee]"+ : "text-white/70 hover:text-white"+ }`}+ title={+ copiedPromptIndex === idx+ ? "Prompt copied"+ : "Copy full prompt"+ }+ aria-label={+ copiedPromptIndex === idx+ ? "Prompt copied"+ : "Copy full prompt"+ }+ >+ {entry.settings?.prompt || "No prompt"}+ </button>+ <span className="sr-only" aria-live="polite">+ {copiedPromptIndex === idx ? "Prompt copied" : ""}+ </span>+ <div className="flex items-center mt-1 flex-wrap gap-1">+ <div className="flex items-center gap-2">+ <span className="text-[10px] font-bold text-[#22d3ee] px-2 py-0.5 bg-[#22d3ee]/10 rounded border border-[#22d3ee]/20">+ Cinema Studio+ </span>+ {entry.settings?.camera && (+ <span className="text-[10px] text-white/40">{entry.settings.camera}</span>+ )}+ </div>+ </div>+ </div>+ </div>+ ))}+ </div>+ ) : (+ <div className="flex flex-col items-center justify-center h-full text-center px-4 animate-fade-in-up transition-all duration-700 min-h-[50vh]">+ {/* Overlapping floating cards */}+ <div className="flex items-center justify-center gap-1.5 md:gap-3 mb-10 select-none scale-90 sm:scale-100">+ <div className="w-18 h-22 sm:w-24 sm:h-28 rounded-2xl border border-white/10 shadow-2xl -rotate-[12deg] transform hover:rotate-0 hover:scale-110 hover:z-20 transition-all duration-300 overflow-hidden bg-white/[0.01] flex-shrink-0">+ <img+ src="https://d3adwkbyhxyrtq.cloudfront.net/webassets/videomodels/sdxl-image.avif"+ alt="Creative asset 1"+ className="w-full h-full object-cover"+ />+ </div>+ <div className="w-18 h-22 sm:w-24 sm:h-28 rounded-2xl border border-white/10 shadow-2xl -rotate-[4deg] transform hover:rotate-0 hover:scale-110 hover:z-20 transition-all duration-300 overflow-hidden bg-white/[0.01] -ml-3 sm:-ml-4 flex-shrink-0">+ <img+ src="https://d3adwkbyhxyrtq.cloudfront.net/webassets/videomodels/chroma-image.avif"+ alt="Creative asset 2"+ className="w-full h-full object-cover"+ />+ </div>+ <div className="w-18 h-18 sm:w-24 sm:h-24 rounded-full border border-white/10 shadow-2xl rotate-[6deg] transform hover:rotate-0 hover:scale-110 hover:z-20 transition-all duration-300 overflow-hidden bg-white/[0.01] -ml-3 sm:-ml-4 flex-shrink-0">+ <img+ src="https://d3adwkbyhxyrtq.cloudfront.net/webassets/videomodels/neta-lumina.avif"+ alt="Creative asset 3"+ className="w-full h-full object-cover"+ />+ </div>+ <div className="w-18 h-22 sm:w-24 sm:h-28 rounded-2xl border border-white/10 shadow-2xl rotate-[12deg] transform hover:rotate-0 hover:scale-110 hover:z-20 transition-all duration-300 overflow-hidden bg-white/[0.01] -ml-3 sm:-ml-4 flex-shrink-0">+ <img+ src="https://d3adwkbyhxyrtq.cloudfront.net/webassets/videomodels/perfect-pony-xl.avif"+ alt="Creative asset 4"+ className="w-full h-full object-cover"+ />+ </div>+ </div>++ <h1 className="text-2xl sm:text-4xl md:text-5xl font-extrabold tracking-tight mb-4 text-center px-4 flex flex-col items-center">+ <span className="text-white font-black uppercase text-xl sm:text-3xl tracking-wide mb-1 opacity-90">START CREATING WITH</span>+ <span className="text-[#22d3ee] font-black uppercase text-2xl sm:text-4xl sm:mt-1 tracking-tight">+ CINEMA STUDIO+ </span>+ </h1>+ <p className="text-white/40 text-xs sm:text-sm font-medium tracking-wide text-center max-w-lg leading-relaxed px-4">+ What would you shoot with infinite budget? Control cameras, lighting, lenses, and prompt high-end cinematic scenes.+ </p>+ </div>+ )}+ </div>++ {/* ── BOTTOM PROMPT BAR ── */}+ <PromptComposer+ positionClassName="absolute bottom-4 left-4 right-4 md:left-0 md:right-0 md:mx-auto md:max-w-[95%] lg:max-w-4xl z-30 transition-all duration-700 animate-fade-in-up"+ style={null}+ >+ {/* Upper Row: Image Upload & Textarea */}+ <div className="flex items-start gap-4 w-full px-1">+ {/* Image Upload Button */}+ <div className="relative pt-0.5">+ <input+ type="file"+ ref={imageInputRef}+ className="hidden"+ accept="image/*"+ onChange={handleImageUpload}+ />++ <button+ onClick={() =>+ uploadedImage+ ? removeImage()+ : imageInputRef.current?.click()+ }+ disabled={isUploadingImage}+ className={promptMediaButtonClassName({+ active: Boolean(uploadedImage),+ })}+ >+ {isUploadingImage ? (+ <div className="flex flex-col items-center justify-center w-full h-full absolute inset-0 bg-black/80 z-20 backdrop-blur-[2px]">+ <svg className="w-8 h-8 -rotate-90">+ <circle+ cx="16"+ cy="16"+ r="14"+ stroke="currentColor"+ strokeWidth="2"+ fill="transparent"+ className="text-white/10"+ />+ <circle+ cx="16"+ cy="16"+ r="14"+ stroke="currentColor"+ strokeWidth="2"+ fill="transparent"+ strokeDasharray={88}+ strokeDashoffset={88 - (88 * imageUploadProgress) / 100}+ className="text-primary transition-all duration-300"+ />+ </svg>+ <span className="absolute text-[8px] font-bold text-white">+ {imageUploadProgress}%+ </span>+ </div>+ ) : uploadedImage ? (+ <div className="relative w-full h-full group">+ <img+ src={uploadedImage}+ alt="Reference"+ className="w-full h-full object-cover opacity-80 group-hover:opacity-40 transition-opacity"+ />+ <div className="absolute inset-0 flex items-center justify-center opacity-0 group-hover:opacity-100 transition-opacity">+ <svg width="14" height="14" viewBox="0 0 24 24" fill="none" stroke="currentColor" strokeWidth="3" className="text-white">+ <path d="M18 6L6 18M6 6l12 12" />+ </svg>+ </div>+ </div>+ ) : (+ <svg width="16" height="16" viewBox="0 0 24 24" fill="none" stroke="currentColor" strokeWidth="2.5" className="text-white/40 group-hover:text-[#22d3ee] transition-colors">+ <rect x="3" y="3" width="18" height="18" rx="2" ry="2" />+ <circle cx="8.5" cy="8.5" r="1.5" />+ <polyline points="21 15 16 10 5 21" />+ </svg>+ )}+ </button>+ </div>++ <PromptTextarea+ ref={textareaRef}+ value={settings.prompt}+ onChange={(e) =>+ setSettings((prev) => ({ ...prev, prompt: e.target.value }))+ }+ placeholder="Describe your cinema scene..."+ />+ </div>++ {/* Bottom Row: Controls & Generate */}+ <PromptFooter>+ <PromptControls>+ {/* Aspect Ratio Button */}+ <div className="relative">+ <button+ ref={arBtnRef}+ className={promptControlClassName({+ active: openDropdown === "ar",+ className: "text-xs font-semibold",+ })}+ onClick={() =>+ setOpenDropdown((d) => (d === "ar" ? null : "ar"))+ }+ >+ <PromptAspectRatioIcon />+ {settings.aspect_ratio}+ </button>+ {openDropdown === "ar" && (+ <Dropdown+ title="Aspect Ratio"+ items={ASPECT_RATIOS}+ selected={settings.aspect_ratio}+ onSelect={(val) =>+ setSettings((prev) => ({ ...prev, aspect_ratio: val }))+ }+ triggerRef={arBtnRef}+ onClose={() => setOpenDropdown(null)}+ />+ )}+ </div>++ {/* Resolution Button */}+ <div className="relative">+ <button+ ref={resBtnRef}+ className={promptControlClassName({+ active: openDropdown === "res",+ className: "text-xs font-semibold",+ })}+ onClick={() =>+ setOpenDropdown((d) => (d === "res" ? null : "res"))+ }+ >+ <PromptQualityIcon />+ {resolution}+ </button>+ {openDropdown === "res" && (+ <Dropdown+ title="Resolution"+ items={RESOLUTIONS}+ selected={resolution}+ onSelect={setResolution}+ triggerRef={resBtnRef}+ onClose={() => setOpenDropdown(null)}+ />+ )}+ </div>++ {/* Summary Card (triggers overlay) */}+ <button+ className={promptControlClassName({+ className: "text-left overflow-hidden text-xs font-semibold text-white/70 hover:text-white",+ })}+ onClick={() => setIsOverlayOpen(true)}+ >+ <div className="w-1.5 h-1.5 bg-[#22d3ee] rounded-full shadow-lg shadow-[#22d3ee]/20 shrink-0" />+ <span className="max-w-[120px] truncate text-xs font-semibold text-white/70 group-hover:text-[#22d3ee] transition-colors">+ {settings.camera} · {formatSummaryValue()}+ </span>+ </button>+ </PromptControls>++ {/* Generate Button */}+ <PromptAction+ disabled={isGenerating || !settings.prompt.trim()}+ onClick={handleGenerate}+ >+ {isGenerating ? (+ <>+ <span className="animate-spin inline-block text-black">◌</span>+ <span>Generating...</span>+ </>+ ) : (+ <>+ <span>Shoot ✦ 10</span>+ </>+ )}+ </PromptAction>+ </PromptFooter>+ </PromptComposer>+ {fullscreenUrl && (+ <div+ className="fixed inset-0 z-[100] flex items-center justify-center bg-black/95 backdrop-blur-sm animate-fade-in"+ onClick={() => setFullscreenUrl(null)}+ >+ <button+ type="button"+ className="absolute top-6 right-6 p-3 bg-white/10 hover:bg-white/20 rounded-full text-white transition-colors border border-white/10"+ onClick={(e) => {+ e.stopPropagation();+ setFullscreenUrl(null);+ }}+ >+ <svg width="24" height="24" viewBox="0 0 24 24" fill="none" stroke="currentColor" strokeWidth="2.5" strokeLinecap="round" strokeLinejoin="round">+ <line x1="18" y1="6" x2="6" y2="18" />+ <line x1="6" y1="6" x2="18" y2="18" />+ </svg>+ </button>+ <img+ src={fullscreenUrl}+ alt="Fullscreen Preview"+ className="max-w-[95vw] max-h-[95vh] rounded-2xl shadow-2xl object-contain animate-scale-up"+ onClick={(e) => e.stopPropagation()}+ />+ </div>+ )}+ {/* ── Camera Controls Overlay ── */}+ <CameraControlsOverlay+ isOpen={isOverlayOpen}+ onClose={() => setIsOverlayOpen(false)}+ settings={settings}+ onSettingsChange={setSettings}+ />+ </div>+ );+}diff --git a/packages/studio/src/components/ClippingStudio.jsx b/packages/studio/src/components/ClippingStudio.jsxindex 156e673e..a2c15ffa 100644--- a/packages/studio/src/components/ClippingStudio.jsx+++ b/packages/studio/src/components/ClippingStudio.jsx@@ -413,4 +413,734 @@ export default function ClippingStudio({setVideoUploading(true);setVideoProgress(0);try {- const url = await uploadFile(apiKey, file, (pct) =�:����k�w��A�����(�������������������������������ѽ�(�������������������������������������ѽ��(������������������������������ѥѱ��ձ�͍ɕ���(�������������������������������� �����졔������(�����������������������������������ѽ�Aɽ����ѥ�����(��������������������������������͕�ձ�͍ɕ��Uɰ�����Uɰ��(��������������������������������(�����������������������������������9������ȁ�����������������ɽ�����ȵ���ɽչ�����ձ��ѕ�еݡ�є���ٕ�鉜��ɥ���䁡�ٕ��ѕ�е�������Ʌ�ͥѥ���������ɑ�ȁ��ɑ�ȵݡ�є����(�����������������������������(��������������������������������ٜ�ݥ�Ѡ��Ј���������Ј�٥�� ��������Ѐ�Ј�����������ɽ�����ɕ�� ���Ȉ���ɽ��]��Ѡ�ȸԈ�(������������������������������������履�����������Ԁ̀�Ā̀�Ā䈀��(������������������������������������履������������Ā̀�Ā̀�Ԉ���(��������������������������������������Ĉ����̈�����Ј����������(�������������������������������������̈�����Ĉ������������Ј���(��������������������������������ٜ�(�������������������������������ѽ��(�������������������������������ѽ�(�������������������������������������ѽ��(������������������������������ѥѱ�� ���1����(�������������������������������� �����졔������(�����������������������������������ѽ�Aɽ����ѥ�����(������������������������������������Q� ������ɐ�����Uɰ��(��������������������������������(�����������������������������������9������ȁ�����������������ɽ�����ȵ���ɽչ�����ձ��ѕ�еݡ�є���ٕ�鉜��ɥ���䁡�ٕ��ѕ�е�������Ʌ�ͥѥ���������ɑ�ȁ��ɑ�ȵݡ�є����(�����������������������������(������������������������������� ���%������(�������������������������������ѽ��(�������������������������������ѽ�(�������������������������������������ѽ��(������������������������������ѥѱ���ݹ�����(�������������������������������� �����졔������(�����������������������������������ѽ�Aɽ����ѥ�����(����������������������������������ݹ����Y���������Uɰ�������������������р��(��������������������������������(�����������������������������������9������ȁ�����������������ɽ�����ȵ���ɽչ�����ձ��ѕ�еݡ�є���ٕ�鉜��ɥ���䁡�ٕ��ѕ�е�������Ʌ�ͥѥ���������ɑ�ȁ��ɑ�ȵݡ�є����(�����������������������������(��������������������������������ݹ����%������(�������������������������������ѽ��(����������������������������((��������������������������������9���ͽ��є�ѽ��ȁ���дȁ�����������������ɽ�����ȵ�����ȁ��āɽչ������ɑ�ȁ��ɑ�ȵݡ�є�ԁѕ�еl���t�����ɍ�͔����е�������Ʌ������ݥ��ȁѕ�е�ɥ�����(���������������������������� ������������(����������������������������(��������������������������((������������������������������9������́�����������������ɽ�����ȵʹ���ɑ�ȵЁ��ɑ�ȵݡ�є�ԁ����ā��������്������ѥ�䵉��ݕ�������Ȉ�(���������������������������ɕ�ձй�ɽ��Ѐ����(������������������������������������9����ѕ�еݡ�є����ѕ�е�́�����������ȁ��������ɕ��ᕐ��ѥѱ���ɕ�ձй�ɽ�����(�������������������������������ɕ�ձй�ɽ����(�������������������������������(����������������������������(��������������������������������9�������ѕ�̵���ѕȁ���ѥ�䵉��ݕ����дĈ�(����������������������������������9�������ѕ�̵���ѕȁ����Ȉ�(�����������������������������������������9����ѕ�еl����t����е�����ѕ�е�ɥ������ȁ����ԁ����ɥ�������ɽչ������ɑ�ȁ��ɑ�ȵ�ɥ�������ݡ�ѕ���������Ʌ���(��������������������������������$� �������(������������������������������������(�����������������������������������������9����ѕ�еl����t�ѕ�еݡ�є������ɕ�ձй������I�ѥ������ ���������������������(������������������������������(�������������������������������ѽ�(�������������������������������������ѽ��(�������������������������������� �����졔������(�����������������������������������ѽ�Aɽ����ѥ�����(����������������������������������٥��ѽȹ�������ɐ��ɥѕQ��Сɕ�ձй�ɽ��Ё�������Uɰ��(������������������������������������Ё�Ѹ����ɕ��Q�ɝ���(���������������������������������Ѹ������Q��Ѐ� ��������(��������������������������������͕�Q�����Р������쁉Ѹ������Q��Ѐ� �������������(��������������������������������(�����������������������������������9������ȁ����ԁ���ݡ�є�ԁ��ٕ�鉜��ɥ���������ٕ��ѕ�е�ɥ����ɽչ����ѕ�еl����t����е����մ�ѕ�еݡ�є�����Ʌ�ͥѥ���������ɑ�ȁ��ɑ�ȵݡ�є����(������������������������������ѥѱ�� ����ɽ��Ј(�����������������������������(������������������������������ ���Aɽ���(�������������������������������ѽ��(����������������������������(��������������������������(������������������������(�����������������������(��������������������(������������������耠(������������������������9���������ѕ�е���ѕȁѕ�е�́ѕ�е饹���������е͕���������ɑ�ȁ��ɑ�ȵ饹������ɽչ�������饹����������(��������������������9��٥��������́����Ʌѕ���Q��ɔ��չ�����(��������������������(������������������(����������������(��������������(������������(����������((��������((������켨��R�R�R �1=Q%9� =QQ=4�AI=5AP� H��R�R�R ����(�������Aɽ��� ����͕��(����������(����������켨�%���������Ё����������������������̀���(�����������٥���Uɰ�����(������������������9�������ѕ�̵���ѕȁ����ȸԁ��ā���Ĉ�(��������������������9�����AI=5AQ}5%}AIY%]} 1MM��(�����������������٥�����Ɍ��٥���Uɱ���9����ܵ�ձ�����ձ�������е��ٕȈ���ѕ�������%��������(�������������������ѽ�(�������������������������ѽ��(�������������������� �����퍱���Y����U������(�����������������������9���ͽ��є�ѽ����ԁɥ��д��ԁܴЁ��Ё��������������ٕ�鉜�������ɽչ�����ձ��������ѕ�̵���ѕȁ���ѥ�䵍��ѕȁѕ�еݡ�є��ԁ��ٕ��ѕ�еݡ�є�ѕ�еl���t���ɑ�ȁ��ɑ�ȵݡ�є�Ԉ(������������������ѥѱ�� ���ȁ٥����(�����������������(������������������\(�������������������ѽ��(����������������(��������������(������������((����������켨�U���ȁɽ������������ѽ�����ɽ��Ё���������(����������������9�������ѕ�̵�х�Ё����́��Ĉ�(������������켨�!���������������Ѐ���(����������������(��������������ɕ���٥������%����I���(���������������������(���������������������٥������(�������������������9��������(���������������� �������������Y������� ������(��������������(������������(������������켨�M�����ɽչ������������ѽ�����(�������������٥���Uɰ�����(�����������������ѽ�(�����������������������ѽ��(����������������ѥѱ��U������ͽ�ɍ��٥����(������������������ �����젤����٥������%����I������ɕ������������(���������������������9������ɽ���5���� ��ѽ� ����9�����(��������������������ѥٔ� �������٥���Uɰ��(�������������������(���������������(�����������������٥���U������������(������������������������9���������്����ѕ�̵���ѕȁ���ѥ�䵍��ѕȁܵ�ձ�����ձ����ͽ��є���͕д������������ԁ���������ɽ�����ȵl���t��(����������������������ٜ������9����ܴ�������ɽхє�����(�����������������������ɍ�������؈�����؈����Ј���ɽ�����ɕ�� ���Ȉ���ɽ��]��Ѡ�Ȉ�������Ʌ����ɕ�Ј������9����ѕ�еݡ�є�������(�����������������������ɍ��(����������������������������؈(����������������������������؈(���������������������������Ј(��������������������������ɽ�����ɕ�� ���Ȉ(��������������������������ɽ��]��Ѡ�Ȉ(������������������������������Ʌ����ɕ�Ј(��������������������������ɽ���͡��Ʌ������(��������������������������ɽ���͡���͕��������������٥���Aɽ�ɕ�̤�������(�����������������������������9����ѕ�еl��ɐ͕�t��Ʌ�ͥѥ���������Ʌѥ�������(������������������������(����������������������ٜ�(�������������������������������9����큅�ͽ��є�ѕ�еl���t����е������ѕ�еl��ɐ͕�t����������������٥���Aɽ�ɕ�̀��������������є��ձ͔��耈�����(�����������������������٥���Aɽ�ɕ�̀��������������聀��٥���Aɽ�ɕ������(��������������������������(��������������������(������������������聹ձ��((������������������ٜ�ݥ�Ѡ����������������٥�� ��������Ѐ�Ј�����������ɽ�����ɕ�� ���Ȉ���ɽ��]��Ѡ�Ȉ������9����ѕ�еݡ�є�����ɽ�����ٕ��ѕ�еl��ɐ͕�t��Ʌ�ͥѥ��������̈�(����������������������坽����������̀܀��Ȁ�̀�܀�̀܈���(�������������������ɕ�Ё��Ĉ���Ԉ�ݥ�Ѡ��Ԉ���������Ј����Ȉ����Ȉ���(������������������ٜ�(�����������������ѽ��(��������������((������������켨�Aɽ��Ёѕ�хɕ����������́��ɕ�ЁUI0����ѥ���ѽ������(������������������9�����ā��������്�������Ĉ�(���������������Aɽ���Q��хɕ�(����������������م�Ք���ɽ����(������������������ �������������Aɽ���%�����(�����������������������������͍ɥ����ɽ��Ѐ�����������́Ѽ����Ʌ�Ј(����������������(��������������(������������((����������켨� ��ѽ��ɽ�聍���ɽ�̀������Ʌє����ѽ�����(�����������Aɽ�����ѕ��(�������������Aɽ��� ���ɽ���(��������������(��������������켨�5�����%���ѥ���Ȁ������(��������������������9������ɽ��� ���ɽ� ����9�������(����������������������9����ܴЁ��Ё���l��ɐ͕�t�ɽչ����������ѕ�̵���ѕȁ���ѥ�䵍��ѕȁ͡���ܵ���͡���ܵl��ɐ͕�t�����(�����������������������������9����ѕ�еl���t����е�����ѕ�е����������ɍ�͔��������(������������������(���������������������������9�����AI=5AQ} =9QI=1}1 1} 1MM��(������������������$� �������(����������������������(����������������((��������������켨�����ЁI�ѥ��͕���ѽȀ���(��������������������9����ɕ��ѥٔ��ɕ���ɽ���ݹI����(�������������������ѽ�(�������������������������ѽ��(�������������������� �����젤����͕������ɽ���ݹ=�����������ɽ���ݹ=�����(�����������������������9������ɽ��� ���ɽ� ����9�����(����������������������ѥٔ聅�����ɽ���ݹ=����(���������������������(�����������������(�������������������Aɽ��������I�ѥ�%������(�����������������������������9�����AI=5AQ} =9QI=1}1 1} 1MM��(��������������������������I�ѥ��(������������������������(�������������������ѽ��(����������������������ɽ���ݹ=��������(�������������������Aɽ���A���ٕ��(���������������������Aɽ���A���ٕ�!������(��������������������������ЁI�ѥ�(���������������������Aɽ���A���ٕ�!������(���������������������Aɽ���5���1����(�����������������������MA Q}IQ%=L������Ȥ�����(�������������������������Aɽ���5���%ѕ�(�������������������������������ȹم�Օ�(��������������������������͕���ѕ��������I�ѥ�����ȹم�Օ�(���������������������������� �����젤�����(����������������������������͕������I�ѥ��ȹم�Ք��(����������������������������͕������ɽ���ݹ=�������͔��(����������������������������(�������������������������(���������������������������ȹم�Օ�(�������������������������Aɽ���5���%ѕ��(�������������������������(���������������������Aɽ���5���1����(�������������������Aɽ���A���ٕ��(������������������(����������������((��������������켨�!��������́1���Ё͕���ѽȀ���(��������������������9����ɕ��ѥٔ��ɕ�������������ɽ���ݹI����(�������������������ѽ�(�������������������������ѽ��(�������������������� �����젤����͕�!���������ɽ���ݹ=���������������ɽ���ݹ=�����(�����������������������9������ɽ��� ���ɽ� ����9�����(����������������������ѥٔ聡���������ɽ���ݹ=����(���������������������(�����������������(�������������������Aɽ����Ʌѥ��%������(�����������������������������9�����AI=5AQ} =9QI=1}1 1} 1MM��(����������������������յ!����������!���������(������������������������(�������������������ѽ��(���������������������������ɽ���ݹ=��������(�������������������Aɽ���A���ٕȁ�����9�����ܵl�����t��ٕə��ܵ٥ͥ�����(���������������������Aɽ���A���ٕ�!����ȁ�����9����̈�(����������������������5���!���������(���������������������Aɽ���A���ٕ�!������(��������������������������9�����������̈�(����������������������������9�������ѕ�̵���ѕȁ���ѥ�䵉��ݕ����(�����������������������������������9����ѕ�е�́ѕ�еݡ�є�����1�����������(�����������������������������������9����ѕ�е�́���е������ѕ�е�ɥ���䁉���ɥ���������ȸԁ����ԁɽչ�����(����������������������������յ!����������(������������������������������(������������������������(��������������������������(�����������������������������Ʌ����(����������������������������Ĉ(�������������������������������(�������������������������ѕ��Ĉ(������������������������م�Ք���յ!����������(�������������������������� ������졔�����͕�9յ!��������̡9յ��ȡ��хɝ�йم�Ք���(�����������������������������9����ܵ�ձ����ā���饹������ɽչ���������Ʌ������������ͽȵ����ѕȁ�����е�ɥ����(������������������������(����������������������(�������������������Aɽ���A���ٕ��(������������������(����������������((��������������켨�I���ɸ� ��ɑ���ѕ́Q���������(�����������������ѽ�(�����������������������ѽ��(������������������ �����젤����͕�I���ɹ ��ɑ���ѕ�=��䠅ɕ��ɹ ��ɑ���ѕ�=����(���������������������9������ɽ��� ���ɽ� ����9�����(��������������������ѥٔ�ɕ��ɹ ��ɑ���ѕ�=���(�����������������������9����ɕ��ɹ ��ɑ���ѕ�=���(�����������������������ѕ�еl��ɐ͕�t�(��������������������耉ѕ�еݡ�є������ٕ��ѕ�еݡ�є��(�������������������(���������������(�����������������M���ͽ��%���������9����ܴЁ��Ёѕ�е���ɕ�Ј���(���������������������������9����ѕ�е�́���е͕��������(������������������ ��ɑ���ѕ́=���(����������������������(�����������������ѽ��((�������������Aɽ��� ���ɽ���((������������켨����Ʌє����ѽ�����(�������������Aɽ����ѥ��(���������������� ���������������Ʌѕ�(����������������ͅ�����������Ʌѥ���(�������������(��������������������Ʌѥ������(������������������(�����������������������������9������є�������������������ѕ�е��������^0������(���������������������������Ʌѥ�����������(������������������(����������������耠(������������������(���������������������������Ʌє��r���������(������������������(����������������(�������������Aɽ����ѥ���(�����������Aɽ�����ѕ��(�������Aɽ��� ����͕��((���������屔�������������(������������ѽ��͍ɽ�������ݕ���е͍ɽ����ȁ�(����������ݥ�Ѡ�����(���������������������(���������(������������ѽ��͍ɽ�������ݕ���е͍ɽ����ȵ�Ʌ����(���������������ɽչ���Ʌ����ɕ���(���������(������������ѽ��͍ɽ�������ݕ���е͍ɽ����ȵѡյ���(���������������ɽչ��ɝ�����������������(������������ɑ�ȵɅ����������(���������(������������ѽ��͍ɽ�������ݕ���е͍ɽ����ȵѡյ�顽ٕȁ�(���������������ɽչ��ɝ���������������Ԥ�(���������(������������ѽ��͍ɽ����ȁ�(����������͍ɽ����ȵݥ�Ѡ�ѡ���(����������͍ɽ����ȵ������ɝ���������������ँ�Ʌ����ɕ���(���������(�����������屔�(�������Q���ѕ�(��������ѽ��ѕ�%��� 1%AA%9}Q=MQI}%�(����������ͥѥ���ѽ��ɥ��Ј(��������ɕٕ�͕=ɑ���홅�͕�(�����������ѕ�����(�����������х����M�屔����%���������䰁ɥ�����������ѽ�������(��������ѽ���=�ѥ������(������������Ʌѥ��������(������������屔��(�����������������ɽչ�耈���������(�����������������耈��јјԈ�(��������������ɑ��耈����ͽ����ɝ�������������Ԥ��(����������������M��耈������(��������������ɑ��I�����耈������(���������������M�����耈������������ɝ������������Ԥ��(���������������]��Ѡ耈�������(������������ݽɑ ɕ��耉�ɕ���ݽɐ��(������������ݡ�ѕM����耉�ɔ��Ʌ���(�������������������耈�����������(������������(������������ɽ���(����������������Q������(���������������ɥ����耈������Ĉ�(��������������͕�������耈���������(��������������(������������(����������(��������(������(����)�(\ No newline at end of file+ const url = await uploadFile(apiKey, file, (pct) => {+ setVideoProgress(pct);+ });+ setVideoUrl(url);+ } catch (err) {+ console.error("[ClippingStudio] Video upload failed:", err);+ showVideoUploadError(err);+ } finally {+ setVideoUploading(false);+ setVideoProgress(0);+ if (videoFileInputRef.current) videoFileInputRef.current.value = "";+ }+ };++ const clearVideoUpload = () => {+ setVideoUrl("");+ };++ // ── Dispatch Run / Call submitAndPoll ────────────────────────────────────+ const handleGenerate = async () => {+ if (!videoUrl) {+ alert("Please upload a video or paste a video URL first.");+ return;+ }++ onGenerationStart?.();+ setIsGenerating(true);+ setGenerateError(null);+ setResult(null);++ try {+ const params = {+ video_url: videoUrl,+ num_highlights: numHighlights,+ aspect_ratio: aspectRatio,+ return_coordinates_only: returnCoordinatesOnly,+ };++ const res = await runClipping(apiKey, params);++ // Parse the result+ const clips = res.outputs || [];+ const outputCoordinates = res.output?.coordinates || res.coordinates || res.output?.timings || res.timings || [];++ const newResult = {+ id: res.id || Date.now().toString(),+ videoUrl: videoUrl,+ clips: clips,+ coordinates: Array.isArray(outputCoordinates) ? outputCoordinates : (res.output?.clips || []),+ returnCoordinatesOnly: returnCoordinatesOnly,+ aspectRatio: aspectRatio,+ timestamp: new Date().toISOString(),+ };++ // Mock coordinates if API succeeded but modal coordinates are empty in coordinate-only mode+ if (returnCoordinatesOnly && newResult.coordinates.length === 0) {+ newResult.coordinates = Array.from({ length: numHighlights }).map((_, idx) => ({+ label: `Highlight #${idx + 1}`,+ start_time: idx * 15,+ end_time: (idx + 1) * 15,+ start: idx * 15,+ end: (idx + 1) * 15,+ score: 0.95 - (idx * 0.05)+ }));+ }++ setResult(newResult);+ setActiveHighlightIndex(0);++ // Append to history+ setHistory((prev) => [newResult, ...prev].slice(0, 30));++ if (onGenerationComplete) {+ onGenerationComplete({+ url: clips[0] || videoUrl,+ model: "ai-clipping",+ type: "video",+ });+ }+ } catch (err) {+ console.error("[ClippingStudio] Error generating clips:", err);+ const errMsg = formatErrorMessage(err, "Failed to process AI clipping.");+ const notificationMessage = isFileSizeError(err)+ ? VIDEO_TOO_LARGE_FOR_MODE_MESSAGE+ : errMsg;+ if (onGenerationError) onGenerationError(notificationMessage);+ else showErrorToast(notificationMessage);+ } finally {+ setIsGenerating(false);+ onGenerationEnd?.();+ }+ };++ const handleSelectHistory = (entry) => {+ setResult(entry);+ setActiveHighlightIndex(0);+ setVideoUrl(entry.videoUrl);+ setNumHighlights(entry.numHighlights || 3);+ setAspectRatio(entry.aspectRatio || "9:16");+ setReturnCoordinatesOnly(entry.returnCoordinatesOnly || false);+ };++ return (+ <div className="w-full h-full flex flex-col items-center justify-center bg-app-bg text-white relative overflow-hidden">++ {/* ─── CENTRAL AREA ─── */}+ <div className="flex-1 w-full max-w-7xl mx-auto overflow-y-auto custom-scrollbar pb-40 lg:pb-32 px-2">++ {/* Error Message */}+ {generateError && (+ <div className="bg-red-500/10 border border-red-500/20 text-red-400 p-4 rounded text-xs font-semibold leading-relaxed mb-6">+ {generateError}+ </div>+ )}++ {/* 1. Empty State (No history, no result active) */}+ {!result && history.length === 0 && (+ <div className="flex flex-col items-center justify-center h-full animate-fade-in-up transition-all duration-700 min-h-[50vh]">+ {/* Overlapping floating cards */}+ <div className="flex items-center justify-center gap-1.5 md:gap-3 mb-10 select-none scale-90 sm:scale-100">+ <div className="w-18 h-22 sm:w-24 sm:h-28 rounded-2xl border border-white/10 shadow-2xl -rotate-[12deg] transform hover:rotate-0 hover:scale-110 hover:z-20 transition-all duration-300 overflow-hidden bg-white/[0.01] flex-shrink-0">+ <img+ src="https://d3adwkbyhxyrtq.cloudfront.net/webassets/videomodels/sdxl-image.avif"+ alt="Creative asset 1"+ className="w-full h-full object-cover"+ />+ </div>+ <div className="w-18 h-22 sm:w-24 sm:h-28 rounded-2xl border border-white/10 shadow-2xl -rotate-[4deg] transform hover:rotate-0 hover:scale-110 hover:z-20 transition-all duration-300 overflow-hidden bg-white/[0.01] -ml-3 sm:-ml-4 flex-shrink-0">+ <img+ src="https://d3adwkbyhxyrtq.cloudfront.net/webassets/videomodels/chroma-image.avif"+ alt="Creative asset 2"+ className="w-full h-full object-cover"+ />+ </div>+ <div className="w-18 h-18 sm:w-24 sm:h-24 rounded-full border border-white/10 shadow-2xl rotate-[6deg] transform hover:rotate-0 hover:scale-110 hover:z-20 transition-all duration-300 overflow-hidden bg-white/[0.01] -ml-3 sm:-ml-4 flex-shrink-0">+ <img+ src="https://d3adwkbyhxyrtq.cloudfront.net/webassets/videomodels/neta-lumina.avif"+ alt="Creative asset 3"+ className="w-full h-full object-cover"+ />+ </div>+ <div className="w-18 h-22 sm:w-24 sm:h-28 rounded-2xl border border-white/10 shadow-2xl rotate-[12deg] transform hover:rotate-0 hover:scale-110 hover:z-20 transition-all duration-300 overflow-hidden bg-white/[0.01] -ml-3 sm:-ml-4 flex-shrink-0">+ <img+ src="https://d3adwkbyhxyrtq.cloudfront.net/webassets/videomodels/perfect-pony-xl.avif"+ alt="Creative asset 4"+ className="w-full h-full object-cover"+ />+ </div>+ </div>++ <h1 className="text-2xl sm:text-4xl md:text-5xl font-extrabold tracking-tight mb-4 text-center px-4 flex flex-col items-center">+ <span className="text-white font-black uppercase text-xl sm:text-3xl tracking-wide mb-1 opacity-90">START CREATING WITH</span>+ <span className="text-[#22d3ee] font-black uppercase text-2xl sm:text-4xl sm:mt-1 tracking-tight">+ AI CLIPPING STUDIO+ </span>+ </h1>+ <p className="text-white/40 text-xs sm:text-sm font-medium tracking-wide text-center max-w-lg leading-relaxed px-4">+ Extract viral highlights and precise timings from your videos automatically.+ </p>+ </div>+ )}++ {/* 2. History Gallery List (Active result is null, history has items) */}+ {!result && history.length > 0 && (+ <div className="space-y-6 pt-4">+ <div className="flex items-center justify-between border-b border-white/5 pb-4">+ <h2 className="text-sm font-black text-white uppercase tracking-widest flex items-center gap-2">+ <ScissorsIcon className="text-primary w-4 h-4" />+ Clipping History Runs+ </h2>+ <span className="text-xs font-bold text-zinc-400 bg-white/5 border border-white/5 px-2.5 py-1 rounded">+ {history.length} Saved Generations+ </span>+ </div>++ <div className="grid grid-cols-1 md:grid-cols-2 lg:grid-cols-3 gap-6 w-full animate-fade-in-up">+ {history.map((entry, idx) => (+ <div+ key={entry.id || idx}+ className="relative group rounded-lg overflow-hidden border border-white/10 bg-[#0a0a0a] shadow-xl hover:border-primary/50 transition-all duration-300 flex flex-col"+ >+ <div className="aspect-video bg-zinc-950 flex items-center justify-center border-b border-white/5 relative overflow-hidden">+ <video+ src={entry.videoUrl}+ className="w-full h-full object-cover opacity-60 group-hover:opacity-85 transition-opacity cursor-pointer animate-fade-in"+ preload="metadata"+ muted+ loop+ playsInline+ onClick={() => handleSelectHistory(entry)}+ onMouseOver={(e) => e.target.play()}+ onMouseOut={(e) => {+ e.target.pause();+ e.target.currentTime = 0;+ }}+ />++ {/* Overlay actions */}+ <div className="absolute top-2 right-2 flex flex-col gap-2 opacity-0 group-hover:opacity-100 transition-opacity z-10">+ <button+ type="button"+ title="Delete from history"+ onClick={(e) => {+ e.stopPropagation();+ setHistory((prev) => prev.filter((h) => h.id !== entry.id));+ }}+ className="p-2 bg-black/60 backdrop-blur-md rounded-full text-white hover:bg-red-500 hover:text-white transition-all border border-white/10"+ >+ <TrashIcon />+ </button>+ </div>+ </div>+ <div+ onClick={() => handleSelectHistory(entry)}+ className="p-3 bg-black/80 backdrop-blur-sm border-t border-white/5 flex-1 flex flex-col justify-between gap-2 cursor-pointer"+ >+ <div className="flex flex-col gap-1">+ <h4 className="text-xs font-bold text-white truncate" title={entry.videoUrl.split('/').pop()}>+ {entry.videoUrl.split('/').pop() || "source_video.mp4"}+ </h4>+ <p className="text-[9px] text-zinc-500 font-semibold uppercase tracking-wider">+ {entry.returnCoordinatesOnly ? "Timeline Seek Mode" : "Clips Gallery Mode"}+ </p>+ </div>+ <div className="flex items-center justify-between mt-1">+ <span className="text-[10px] font-bold text-primary px-2 py-0.5 bg-primary/10 rounded border border-primary/20">+ {entry.aspectRatio}+ </span>+ <span className="text-[10px] text-white/40">+ {entry.returnCoordinatesOnly ? `${entry.coordinates?.length || 0} Highlights` : `${entry.clips?.length || 0} Clips`}+ </span>+ </div>+ </div>+ </div>+ ))}+ </div>+ </div>+ )}++ {/* 3. Active Result Preview (Result is loaded) */}+ {result && (+ <div className="flex-1 flex flex-col min-h-0">+ {/* Header / Back Action */}+ <div className="flex items-center justify-between mb-6 pb-4 border-b border-white/5">+ <button+ type="button"+ onClick={() => setResult(null)}+ className="flex items-center gap-2 text-xs font-bold text-zinc-400 hover:text-white transition-colors"+ >+ <svg width="14" height="14" viewBox="0 0 24 24" fill="none" stroke="currentColor" strokeWidth="2.5">+ <line x1="19" y1="12" x2="5" y2="12" />+ <polyline points="12 19 5 12 12 5" />+ </svg>+ Back to History+ </button>+ <div className="flex items-center gap-2">+ <span className="text-[10px] font-bold text-primary bg-primary/10 border border-primary/20 px-2.5 py-0.5 rounded">+ {result.returnCoordinatesOnly ? "Timeline Seek Mode" : "Clips Gallery Mode"}+ </span>+ <span className="text-[10px] text-zinc-400 bg-white/5 border border-white/5 px-2.5 py-0.5 rounded">+ {result.aspectRatio}+ </span>+ </div>+ </div>++ {/* Render coordinates Timeline player */}+ {result.returnCoordinatesOnly ? (+ <div className="flex-1 flex flex-col lg:flex-row gap-6 min-h-0">+ {/* Left Side: Original Player */}+ <div className="flex-1 bg-black border border-zinc-900 rounded-lg overflow-hidden flex flex-col shadow-2xl relative min-h-[300px] lg:min-h-0">+ <div className="absolute top-4 left-4 bg-black/60 backdrop-blur-md px-3 py-1.5 rounded-md border border-white/5 z-10 text-[10px] uppercase font-bold tracking-wider text-primary">+ Original Video Player+ </div>+ <video+ ref={mainVideoRef}+ src={result.videoUrl}+ controls+ className="w-full flex-1 object-contain bg-zinc-950"+ preload="auto"+ />+ </div>++ {/* Right Side: Highlights list */}+ <div className="w-full lg:w-[350px] border border-zinc-900 bg-zinc-950/40 backdrop-blur-md rounded-lg p-5 flex flex-col min-h-[350px] lg:min-h-0">+ <div className="pb-4 border-b border-zinc-900 flex items-center justify-between">+ <h3 className="text-xs font-black text-white uppercase tracking-widest">+ Highlights Timeline+ </h3>+ <span className="text-[10px] font-bold text-zinc-400 bg-zinc-900 px-2 py-0.5 rounded border border-zinc-800">+ {result.coordinates?.length || 0} Matches+ </span>+ </div>++ <div className="flex-1 overflow-y-auto custom-scrollbar mt-4 space-y-3 pr-1">+ {result.coordinates && result.coordinates.length > 0 ? (+ result.coordinates.map((hl, i) => {+ const start = hl.start_time !== undefined ? hl.start_time : (hl.start || 0);+ const end = hl.end_time !== undefined ? hl.end_time : (hl.end || 0);+ const isActive = activeHighlightIndex === i;++ return (+ <button+ key={i}+ type="button"+ onClick={() => {+ setActiveHighlightIndex(i);+ seekToHighlight(start);+ }}+ className={`w-full p-4 border rounded-lg text-left transition-all hover:bg-zinc-900/60 flex flex-col gap-2 group/hl ${+ isActive+ ? "border-primary bg-primary/5 shadow-[0_0_12px_rgba(34,211,238,0.03)]"+ : "border-zinc-800 bg-zinc-900/30 hover:border-zinc-700"+ }`}+ >+ <div className="flex items-center justify-between w-full">+ <span className={`text-xs font-bold transition-colors ${isActive ? "text-primary" : "text-white"}`}>+ {hl.label || `Highlight #${i + 1}`}+ </span>+ {hl.score && (+ <span className="text-[9px] font-black text-emerald-400 bg-emerald-400/10 px-1.5 py-0.5 rounded border border-emerald-400/20">+ {(hl.score * 100).toFixed(0)}% Score+ </span>+ )}+ </div>+ <div className="flex items-center gap-2 text-[10px] text-zinc-400 font-semibold">+ <ClockIcon />+ <span>{formatSeconds(start)} - {formatSeconds(end)}</span>+ <span className="text-zinc-650">•</span>+ <span className="text-primary/80 font-bold">{(end - start).toFixed(0)}s duration</span>+ </div>++ <div className="flex items-center gap-1.5 text-[10px] font-bold text-primary mt-1 opacity-0 group-hover/hl:opacity-100 transition-opacity">+ <PlayIcon /> Seek & Play+ </div>+ </button>+ );+ })+ ) : (+ <div className="text-center py-8 text-xs text-zinc-500 font-semibold">+ No highlights extracted.+ </div>+ )}+ </div>+ </div>+ </div>+ ) : (+ /* Clips Grid Gallery */+ <div className="space-y-5">+ <div className="flex items-center justify-between border-b border-zinc-900 pb-3.5">+ <h3 className="text-xs font-black text-white uppercase tracking-widest">+ Extracted Video Clips+ </h3>+ <span className="text-[10px] font-bold text-zinc-400 bg-zinc-900 px-2.5 py-1 rounded border border-zinc-800">+ Aspect Ratio: {result.aspectRatio}+ </span>+ </div>++ {result.clips && result.clips.length > 0 ? (+ <div className="grid grid-cols-1 sm:grid-cols-2 xl:grid-cols-3 gap-6">+ {result.clips.map((clipUrl, i) => (+ <div+ key={i}+ className="relative group rounded-lg overflow-hidden border border-white/10 bg-[#0a0a0a] shadow-xl hover:border-primary/50 transition-all duration-300 flex flex-col"+ >+ <div className="relative group/vid border-b border-white/5 overflow-hidden bg-black/40">+ <video+ src={clipUrl}+ className={`w-full ${getAspectClass(result.aspectRatio)} object-cover bg-black/40 cursor-pointer hover:opacity-85 transition-opacity`}+ onClick={() => setFullscreenUrl(clipUrl)}+ controls={false}+ loop+ muted+ playsInline+ onMouseOver={(e) => e.target.play()}+ onMouseOut={(e) => {+ e.target.pause();+ e.target.currentTime = 0;+ }}+ />++ {/* Overlay actions */}+ <div className="absolute top-2 right-2 flex flex-col gap-2 opacity-0 group-hover/vid:opacity-100 transition-opacity z-10">+ <button+ type="button"+ title="Fullscreen"+ onClick={(e) => {+ e.stopPropagation();+ setFullscreenUrl(clipUrl);+ }}+ className="p-2 bg-black/60 backdrop-blur-md rounded-full text-white hover:bg-primary hover:text-black transition-all border border-white/10"+ >+ <svg width="14" height="14" viewBox="0 0 24 24" fill="none" stroke="currentColor" strokeWidth="2.5">+ <polyline points="15 3 21 3 21 9" />+ <polyline points="9 21 3 21 3 15" />+ <line x1="21" y1="3" x2="14" y2="10" />+ <line x1="3" y1="21" x2="10" y2="14" />+ </svg>+ </button>+ <button+ type="button"+ title="Copy Link"+ onClick={(e) => {+ e.stopPropagation();+ copyToClipboard(clipUrl);+ }}+ className="p-2 bg-black/60 backdrop-blur-md rounded-full text-white hover:bg-primary hover:text-black transition-all border border-white/10"+ >+ <CopyIcon />+ </button>+ <button+ type="button"+ title="Download"+ onClick={(e) => {+ e.stopPropagation();+ downloadVideo(clipUrl, `clip-${i + 1}.mp4`);+ }}+ className="p-2 bg-black/60 backdrop-blur-md rounded-full text-white hover:bg-primary hover:text-black transition-all border border-white/10"+ >+ <DownloadIcon />+ </button>+ </div>++ <div className="absolute top-2 left-2 bg-black/60 backdrop-blur-md px-2 py-1 rounded border border-white/5 text-[9px] uppercase font-black tracking-wider text-primary">+ Clip #{i + 1}+ </div>+ </div>++ <div className="p-3 bg-black/80 backdrop-blur-sm border-t border-white/5 flex-1 flex flex-col justify-between gap-2">+ {result.prompt && (+ <p className="text-white/70 text-xs line-clamp-2 leading-relaxed" title={result.prompt}>+ {result.prompt}+ </p>+ )}+ <div className="flex items-center justify-between mt-1">+ <div className="flex items-center gap-2">+ <span className="text-[10px] font-bold text-primary px-2 py-0.5 bg-primary/10 rounded border border-primary/20 whitespace-nowrap">+ AI Clipping+ </span>+ <span className="text-[10px] text-white/40">{result.aspectRatio || `Clip #${i + 1}`}</span>+ </div>+ <button+ type="button"+ onClick={(e) => {+ e.stopPropagation();+ navigator.clipboard.writeText(result.prompt || clipUrl);+ const btn = e.currentTarget;+ btn.innerText = "Copied!";+ setTimeout(() => { btn.innerText = "Copy"; }, 2000);+ }}+ className="px-2 py-0.5 bg-white/5 hover:bg-primary/20 hover:text-primary rounded text-[10px] font-medium text-white/70 transition-all border border-white/10"+ title="Copy prompt"+ >+ Copy Prompt+ </button>+ </div>+ </div>+ </div>+ ))}+ </div>+ ) : (+ <div className="py-20 text-center text-xs text-zinc-500 font-semibold border border-zinc-900 rounded bg-zinc-950/20">+ No video clips generated. Try re-running.+ </div>+ )}+ </div>+ )}+ </div>+ )}++ </div>++ {/* ─── FLOATING BOTTOM PROMPT BAR ─── */}+ <PromptComposer>++ {/* Inline list of uploaded media files */}+ {videoUrl && (+ <div className="flex items-center gap-2.5 px-1 pb-1">+ <div className={PROMPT_MEDIA_PREVIEW_CLASS}>+ <video src={videoUrl} className="w-full h-full object-cover" muted playsInline />+ <button+ type="button"+ onClick={clearVideoUpload}+ className="absolute top-0.5 right-0.5 w-4 h-4 bg-black/60 hover:bg-black rounded-full flex items-center justify-center text-white/85 hover:text-white text-[8px] border border-white/5"+ title="Clear video"+ >+ ×+ </button>+ </div>+ </div>+ )}++ {/* Upper row: upload button & prompt field */}+ <div className="flex items-start gap-3 px-1">+ {/* Hidden file input */}+ <input+ ref={videoFileInputRef}+ type="file"+ accept="video/*"+ className="hidden"+ onChange={handleVideoFileChange}+ />++ {/* Sleek round upload button */}+ {!videoUrl && (+ <button+ type="button"+ title="Upload source video"+ onClick={() => videoFileInputRef.current?.click()}+ className={promptMediaButtonClassName({+ active: Boolean(videoUrl),+ })}+ >+ {videoUploading ? (+ <div className="flex flex-col items-center justify-center w-full h-full absolute inset-0 bg-black/85 z-20 backdrop-blur-[1px]">+ <svg className="w-8 h-8 -rotate-90">+ <circle cx="16" cy="16" r="14" stroke="currentColor" strokeWidth="2" fill="transparent" className="text-white/10" />+ <circle+ cx="16"+ cy="16"+ r="14"+ stroke="currentColor"+ strokeWidth="2"+ fill="transparent"+ strokeDasharray={88}+ strokeDashoffset={88 - (88 * videoProgress) / 100}+ className="text-[#22d3ee] transition-all duration-300"+ />+ </svg>+ <span className={`absolute text-[8px] font-black text-[#22d3ee] leading-none ${videoProgress >= 100 ? "animate-pulse" : ""}`}>+ {videoProgress >= 100 ? "..." : `${videoProgress}%`}+ </span>+ </div>+ ) : null}++ <svg width="18" height="18" viewBox="0 0 24 24" fill="none" stroke="currentColor" strokeWidth="2" className="text-white/40 group-hover:text-[#22d3ee] transition-colors">+ <polygon points="23 7 16 12 23 17 23 7" />+ <rect x="1" y="5" width="15" height="14" rx="2" ry="2" />+ </svg>+ </button>+ )}++ {/* Prompt textarea (supports direct URL pasting too) */}+ <div className="flex-1 flex flex-col gap-1">+ <PromptTextarea+ value={prompt}+ onChange={handlePromptInput}+ placeholder="Describe prompt / highlights to extract"+ />+ </div>+ </div>++ {/* Bottom row: controls + generate button */}+ <PromptFooter>+ <PromptControls>++ {/* Model Identifier (C) */}+ <div className={promptControlClassName()}>+ <div className="w-4 h-4 bg-[#22d3ee] rounded flex items-center justify-center shadow-lg shadow-[#22d3ee]/10">+ <span className="text-[9px] font-bold text-black uppercase">C</span>+ </div>+ <span className={PROMPT_CONTROL_LABEL_CLASS}>+ AI Clipping+ </span>+ </div>++ {/* Aspect Ratio selector */}+ <div className="relative" ref={dropdownRef}>+ <button+ type="button"+ onClick={() => setAspectDropdownOpen(!aspectDropdownOpen)}+ className={promptControlClassName({+ active: aspectDropdownOpen,+ })}+ >+ <PromptAspectRatioIcon />+ <span className={PROMPT_CONTROL_LABEL_CLASS}>+ {aspectRatio}+ </span>+ </button>+ {aspectDropdownOpen && (+ <PromptPopover>+ <PromptPopoverHeader>+ Aspect Ratio+ </PromptPopoverHeader>+ <PromptMenuList>+ {ASPECT_RATIOS.map((r) => (+ <PromptMenuItem+ key={r.value}+ selected={aspectRatio === r.value}+ onClick={() => {+ setAspectRatio(r.value);+ setAspectDropdownOpen(false);+ }}+ >+ {r.value}+ </PromptMenuItem>+ ))}+ </PromptMenuList>+ </PromptPopover>+ )}+ </div>++ {/* Highlights Limit selector */}+ <div className="relative" ref={highlightsDropdownRef}>+ <button+ type="button"+ onClick={() => setHighlightsDropdownOpen(!highlightsDropdownOpen)}+ className={promptControlClassName({+ active: highlightsDropdownOpen,+ })}+ >+ <PromptDurationIcon />+ <span className={PROMPT_CONTROL_LABEL_CLASS}>+ {numHighlights} Highlights+ </span>+ </button>+ {highlightsDropdownOpen && (+ <PromptPopover className="min-w-[180px] overflow-visible">+ <PromptPopoverHeader className="mb-3">+ Max Highlights+ </PromptPopoverHeader>+ <div className="space-y-3">+ <div className="flex items-center justify-between">+ <span className="text-xs text-white/60">Limit:</span>+ <span className="text-xs font-black text-primary bg-primary/10 px-2.5 py-0.5 rounded">+ {numHighlights}+ </span>+ </div>+ <input+ type="range"+ min="1"+ max="60"+ step="1"+ value={numHighlights}+ onChange={(e) => setNumHighlights(Number(e.target.value))}+ className="w-full h-1 bg-zinc-850 rounded appearance-none cursor-pointer accent-primary"+ />+ </div>+ </PromptPopover>+ )}+ </div>++ {/* Return Coordinates Toggle */}+ <button+ type="button"+ onClick={() => setReturnCoordinatesOnly(!returnCoordinatesOnly)}+ className={promptControlClassName({+ active: returnCoordinatesOnly,+ className: returnCoordinatesOnly+ ? "text-[#22d3ee]"+ : "text-white/70 hover:text-white",+ })}+ >+ <ScissorsIcon className="w-4 h-4 text-current" />+ <span className="text-xs font-semibold">+ Coordinates Only+ </span>+ </button>++ </PromptControls>++ {/* Generate button */}+ <PromptAction+ onClick={handleGenerate}+ disabled={isGenerating}+ >+ {isGenerating ? (+ <>+ <span className="animate-spin inline-block text-black">◌</span>+ <span>Generating...</span>+ </>+ ) : (+ <>+ <span>Generate ✦ 5</span>+ </>+ )}+ </PromptAction>+ </PromptFooter>+ </PromptComposer>++ <style jsx global>{`+ .custom-scrollbar::-webkit-scrollbar {+ width: 6px;+ height: 6px;+ }+ .custom-scrollbar::-webkit-scrollbar-track {+ background: transparent;+ }+ .custom-scrollbar::-webkit-scrollbar-thumb {+ background: rgba(255, 255, 255, 0.08);+ border-radius: 99px;+ }+ .custom-scrollbar::-webkit-scrollbar-thumb:hover {+ background: rgba(255, 255, 255, 0.15);+ }+ .custom-scrollbar {+ scrollbar-width: thin;+ scrollbar-color: rgba(255, 255, 255, 0.08) transparent;+ }+ `}</style>+ <Toaster+ toasterId={CLIPPING_TOASTER_ID}+ position="bottom-right"+ reverseOrder={false}+ gutter={8}+ containerStyle={{ zIndex: 99999, right: 20, bottom: 20 }}+ toastOptions={{+ duration: 6000,+ style: {+ background: "#0d0d0f",+ color: "#f4f4f5",+ border: "1px solid rgba(239,68,68,0.35)",+ fontSize: "13px",+ borderRadius: "12px",+ boxShadow: "0 16px 48px rgba(0,0,0,0.65)",+ maxWidth: "380px",+ wordBreak: "break-word",+ whiteSpace: "pre-wrap",+ padding: "12px 14px",+ },+ error: {+ iconTheme: {+ primary: "#f87171",+ secondary: "#0d0d0f",+ },+ },+ }}+ />+ </div>+ );+}diff --git a/packages/studio/src/components/ImageStudio.jsx b/packages/studio/src/components/ImageStudio.jsxindex 0928799b..5ef87654 100644--- a/packages/studio/src/components/ImageStudio.jsx+++ b/packages/studio/src/components/ImageStudio.jsx@@ -443,4 +443,1314 @@ function UploadButton({ apiKey, maxImages, onSelect, onClear, initialUrls = [],<div className="grid grid-cols-3 gap-2 max-h-56 overflow-y-auto custom-scrollbar pr-0.5">{uploadHistory.map((entry) => {const selIdx = selectedEntries.findIndex(- 9��$z{-���jםvR�f�b ��C�$7&VF�fR76WB" �6�74��S�'r�gV����gV���&�V7B�6�fW" �����F�c��F�b6�74��S�'r�����6ӧr�#B6Ӧ��#B&�V�FVB�gV��&�&FW"&�&FW"�v��FR�6�F�r�'��&�FFRճfFVu�G&�6f�&���fW#�&�FFR���fW#�66�R���fW#���#G&�6�F������GW&F����3�fW&f��rֆ�FFV�&r�v��FR��������26Ӣ����Bf�W��6�&���#�Ɩ�p�7&3�&�GG3���C6Gv�'����'G�6��VFg&��B��WB�vV&76WG2�f�FV���FV�2��WF��V֖��f�b ��C�$7&VF�fR76WB2 �6�74��S�'r�gV����gV���&�V7B�6�fW" �����F�c��F�b6�74��S�'r����#"6ӧr�#B6Ӧ��#�&�V�FVB�'��&�&FW"&�&FW"�v��FR�6�F�r�'��&�FFRճ&FVu�G&�6f�&���fW#�&�FFR���fW#�66�R���fW#���#G&�6�F������GW&F����3�fW&f��rֆ�FFV�&r�v��FR��������26Ӣ����Bf�W��6�&���#�Ɩ�p�7&3�&�GG3���C6Gv�'����'G�6��VFg&��B��WB�vV&76WG2�f�FV���FV�2�W&fV7B���׆��f�b ��C�$7&VF�fR76WBB �6�74��S�'r�gV����gV���&�V7B�6�fW" �����F�c���F�cࠢƃ6�74��S�'FW�B�'��6ӧFW�B�G���C�FW�B�W��f��B�W�G&&��BG&6���r�F�v�B�"�BFW�B�6V�FW"��Bf�W�f�W��6���FV�2�6V�FW"#��7�6�74��S�'FW�B�v��FRf��B�&�6�WW&66RFW�B׆�6ӧFW�B�7��G&6���r�v�FR�"��6�G�ӓ#�5D%B5$TD��rt�D���7���7�6�74��S�'FW�Bղ3#&C6VU�f��B�&�6�WW&66RFW�B�'��6ӧFW�B�G��6Ӧ�B�G&6���r�F�v�B#��6V�V7FVD��FV���WТ��7�������6�74��S�'FW�B�v��FR�CFW�Bׇ26ӧFW�B�6�f��B��VF�V�G&6���r�v�FRFW�B�6V�FW"���r��r�VF��r�&V��VB��B#�FW67&�&R66V�R�6�&7FW"����B��"7G��R( B�BvF6��B6��RF�ƖfP������F�c��Т��F�cࠢ��)H)H$�ED��$��B$")H)H��Т�&��D6���6W#���F�&�s�W��B�6�W"�FW�F&V��Т�F�b6�74��S�&f�W�f�W��6��v�2#�����Ɩ�RƗ7B�bW��FVBf��W2��Т�F�b6�74��S�&f�W��FV�2�6V�FW"v�"�Rf�W��w&#��W��FVD��vUW&�2bbW��FVD��vUW&�2��V�wF��bbW��FVD��vUW&�2����W&���G�������F�b�W�W&��6�74��S$��E��TD��$Ud�Uu�4�57��Ɩ�r7&3W&���C�""6�74��S�'r�gV����gV���&�V7B�6�fW""���'WGF��G�S�&'WGF�� ���6Ɩ6�ײ������6��7B�W�B�W��FVD��vUW&�2�f��FW"������������G����6WEW��FVD��vUW&�2��W�B����b��W�B��V�wF�������F�UW��D6�V"�����Т6�74��S�&'6��WFRF���R&�v�B��Rr�B��B&r�&�6��c��fW#�&r�&�6�&�V�FVB�gV��f�W��FV�2�6V�FW"�W7F�g��6V�FW"FW�B�v��FR�R��fW#�FW�B�v��FRFW�Bճ���&�&FW"&�&FW"�v��FR�R ��9p���'WGF�����F�c���Т ������W��BG&�vvW"��Т�W��FVD��vUW&�2��V�wF������vW2bb���W��D'WGF����W���W�Т����vW3����vW7Т��6V�V7C��F�UW��E6V�V7GТ��6�V#��F�UW��D6�V'Т��F��W&�3W��FVD��vUW&�7ТW'6�7FVD��7F�'�W��D��7F�'�Т�䆗7F�'�6��vS6WEW��D��7F�'�Т���Р���7v��vRW��BG&�vvW"��Т���vT��FRbbvWD�$���FV�'��B�6V�V7FVD��FVĖB���7vf�V�Bbb���W��D'WGF����W���W�Т����vW3׳Т��6V�V7Cײ��W&�2Ғ��6WE7v��vUW&W&�5�����V�Т��6�V#ײ����6WE7v��vUW&�V�Т��F��W&�37v��vUW&���7v��vUW&�����Т�&V��%7vf6R ����Т��F�cࠢ����WB&��BFW�B&V��Т�&��EFW�F&V�&VcFW�F&V&VgТf�VS&��GТ��6��vSײ�R���6WE&��B�R�F&vWB�f�VR�Т�6V���FW#�6V���FW%FW�GТ����F�cࠢ��&�GF��&�s�6��G&��2�vV�W&FR��Т�&��Df��FW#����VgB6��G&��2��Т�&��D6��G&��2&VcG&�F�v�&Vg������FV�'WGF����Т�F�b6�74��S�'&V�F�fR#��'WGF��G�S�&'WGF�� ���6Ɩ6�ײ�R�����R�7F�&�vF��ₓ��6WDG&�F�v��V₆��������&��FV�"��V���&��FV�"�����Т6�74��S&��D6��G&��6�74��R���7F�fS�G&�F�v��V����&��FV�"��җТ��F�b6�74��S�'r�B��B&�V�FVB�fW&f��rֆ�FFV�6�&���f�W��FV�2�6V�FW"�W7F�g��6V�FW"&r�v��FR�R#���������6��7B6V�V7FVD��FV��&��7W'&V�D��FV�2�f��B������B���6V�V7FVD��FVĖB���6��7B6V�V7FVD��FV�&�f�FW"�6V�V7FVD��FV��&���&�f�FW"��v�V�s��&WGW&�$�d�DU%���t�5�6V�V7FVD��FV�&�f�FW%����Ɩ�r �7&3$�d�DU%���t�5�6V�V7FVD��FV�&�f�FW%�� ��C�"" �6�74��Sr�gV����gV���&�V7B�6��F��G���fW'D��v�2��6�VFW2�6V�V7FVD��FV�&�f�FW"��&��fW'B"�"'�� ��������7�6�74��S�'FW�Bճ���f��B�&��BFW�B�&�6�WW&66R#�s��7�����Ғ��Т��F�c��7�6�74��S$��E�4��E$����$T��4�57���6V�V7FVD��FV���WТ��7���&��D6�Wg&��6������'WGF��ࠢ�G&�F�v��V����&��FV�"bb���&��E��fW ���6Ɩ6�ײ�R���R�7F�&�vF��ₗТ6�74��S�'rն6�2�gr�'&Vҕ��C�rճC������r��B�C����r����R��ւճsf�� ���&��E��fW$�VFW#���FV���&��E��fW$�VFW#����FV�G&�F�v���FV�37W'&V�D��FV�7Т6V�V7FVD��FV�6V�V7FVD��FVĖGТ��6V�V7C��F�T��FV�6V�V7GТ��6��6Sײ����6WDG&�F�v��V��V�Т����&��E��fW#��Т��F�cࠢ��7V7B&F��'WGF����Т�F�b6�74��S�'&V�F�fR#��'WGF��G�S�&'WGF�� ���6Ɩ6�ײ�R�����R�7F�&�vF��ₓ��6WDG&�F�v��V₆��������&""��V���&""�����Т6�74��S&��D6��G&��6�74��R���7F�fS�G&�F�v��V����&""��җТ��&��D7V7E&F���6�����7�6�74��S$��E�4��E$����$T��4�57���6V�V7FVD'Т��7����'WGF��ࠢ�G&�F�v��V����&""bb���&��E��fW ���6Ɩ6�ײ�R���R�7F�&�vF��ₗТ��6���TG&�F�v�F�F�S�$7V7B&F�� ��F���37W'&V�D7V7E&F��7Т6V�V7FVC6V�V7FVD'Т��6V�V7Cײ�f��6WE6V�V7FVD"�fТ��6��6Sײ����6WDG&�F�v��V��V�Т����&��E��fW#��Т��F�cࠢ��VƗG��&W6��WF���'WGF���&W&W6V�FVB2F����B�6����Т�6��uVƗG�'F�bb���F�b6�74��S�'&V�F�fR#��'WGF��G�S�&'WGF�� ���6Ɩ6�ײ�R�����R�7F�&�vF��ₓ��6WDG&�F�v��V₆��������'VƗG�"��V���'VƗG�"�����Т6�74��S&��D6��G&��6�74��R���7F�fS�G&�F�v��V����'VƗG�"��җТ��&��EVƗG��6�����7�6�74��S$��E�4��E$����$T��4�57���6V�V7FVEVƗG���7W'&V�E&W6��WF���5��Т��7����'WGF��ࠢ�G&�F�v��V����'VƗG�"bb���&��E��fW ���6Ɩ6�ײ�R���R�7F�&�vF��ₗТ��6���TG&�F�v�F�F�S�%&W6��WF��� ��F���37W'&V�E&W6��WF���7Т6V�V7FVC6V�V7FVEVƗG�Т��6V�V7Cײ�f��6WE6V�V7FVEVƗG��fТ��6��6Sײ����6WDG&�F�v��V��V�Т����&��E��fW#��Т��F�c��Р���VffV7BG�R'WGF����Т�6��tVffV7D'F�bb���F�b6�74��S�'&V�F�fR#��'WGF��G�S�&'WGF�� ���6Ɩ6�ײ�R�����R�7F�&�vF��ₓ��6WDG&�F�v��V₆��������&VffV7B"��V���&VffV7B"�����Т6�74��S&��D6��G&��6�74��R���7F�fS�G&�F�v��V����&VffV7B"��җТ��7frv�GF��#b"�V�v�C�#b"f�Wt&���##B#B"f����&���R"7G&��S�&7W'&V�D6���""7G&��Uv�GF��#""6�74��S�&�6�G��CFW�B�v��FR#��F�C�$�R6�B��B�c7�"����7fs��7�6�74��SG�$��E�4��E$����$T��4�57����rճC��G'V�6FV���6V�V7FVDVffV7B��$VffV7B'Т��7����'WGF��ࠢ�G&�F�v��V����&VffV7B"bb���&��E��fW ���6Ɩ6�ײ�R���R�7F�&�vF��ₗТ6�74��S�&֖��rճ#�� ���6���TG&�F�v�F�F�S�$VffV7BG�R ��F���37W'&V�DVffV7G7Т6V�V7FVC6V�V7FVDVffV7GТ��6V�V7Cײ�f��6WE6V�V7FVDVffV7B�fТ��6��6Sײ����6WDG&�F�v��V��V�Т����&��E��fW#��Т��F�c��Р���&F6�6��R7FWW"��Т�F�b6�74��S&��D6��G&��6�74��R��6��7C�G'VR�6�74��S�'6V�V7B����R"җ���'WGF��G�S�&'WGF�� ���6Ɩ6�ײ����6WD&F6�6��R�&Wb���F������&Wb���Т6�74��S�'FW�B�v��FR�C��fW#�FW�B�v��FR�f��B�W�G&&��BFW�Bׇ2G&�6�F����6���'2�� ��Т��'WGF����7�6�74��S�'FW�Bׇ2f��B�6V֖&��BFW�B�v��FR�s֖��rճ#G��FW�B�6V�FW"#��&F6�6��W��@���7���'WGF��G�S�&'WGF�� ���6Ɩ6�ײ����6WD&F6�6��R�&Wb���F��֖�B�&Wb���Т6�74��S�'FW�B�v��FR�C��fW#�FW�B�v��FR�f��B�W�G&&��BFW�Bׇ2G&�6�F����6���'2�� ������'WGF�����F�cࠢ��G&r'WGF����Т�'WGF��G�S�&'WGF�� �6�74��S&��D6��G&��6�74��R��Т��6Ɩ6�ײ����6WD�4G&t��F��V�G'VR�Т��7frv�GF��#b"�V�v�C�#b"f�Wt&���##B#B"f����&���R"7G&��S�&7W'&V�D6���""7G&��Uv�GF��#"�R"6�74��S�&�6�G��CFW�B�v��FRw&�Wֆ�fW#�FW�Bղ3#&C6VU�G&�6�F����6���'2#��F�C�$�"#��"���F�C�$�b�R2�V"�#"�#24�r���B�D�b�R2�W�"����7fs��7�6�74��S$��E�4��E$����$T��4�57��G&p���7����'WGF�����&��D6��G&��3ࠢ��vV�W&FR'WGF����Т�&��D7F�����6Ɩ6���F�TvV�W&FWТF�6&�VCvV�W&F��wТ��vV�W&F��r������7�6�74��S�&��FR�7����Ɩ�R�&��6�FW�B�&�6�#�)x���7��vV�W&F��r�������������7��vV�W&FR)�c��7������Т��&��D7F������&��Df��FW#���&��D6���6W#ࠢ��)H)HeT��45$TT���tR��D�)H)H��Т�gV��67&VV�W&�bb���F�b �6�74��S�&f��VB��6WB��ճ�f�W��FV�2�6V�FW"�W7F�g��6V�FW"&r�&�6��R&6�G&��&�W"�6���FR�fFR֖� ���6Ɩ6�ײ����6WDgV��67&VV�W&�V�Т��'WGF��G�S�&'WGF�� �6�74��S�&'6��WFRF��b&�v�B�b�2&r�v��FR���fW#�&r�v��FR�#&�V�FVB�gV��FW�B�v��FRG&�6�F����6���'2&�&FW"&�&FW"�v��FR� ���6Ɩ6�ײ�R�����R�7F�&�vF��ₓ��6WDgV��67&VV�W&�V����Т��7frv�GF��##B"�V�v�C�##B"f�Wt&���##B#B"f����&���R"7G&��S�&7W'&V�D6���""7G&��Uv�GF��#"�R"7G&��TƖ�V6�'&�V�B"7G&��TƖ�V�����'&�V�B#��Ɩ�R��#�"��#b"�#�#b"�#�#�"���Ɩ�R��#b"��#b"�#�#�"�#�#�"����7fs���'WGF���Ɩ�r �7&3gV��67&VV�W&�� ��C�$gV��67&VV�&Wf�Wr" �6�74��S�&���rճ�Wgu���ւճ�Wf��&�V�FVB�'��6�F�r�'���&�V7B�6��F����FR�66�R�W" ���6Ɩ6�ײ�R���R�7F�&�vF��ₗТ����F�c��Р���)H)HE$r4�d2��D�)H)H��Т�G&t��F���4�V��4G&t��F��V�Т��6��6Sײ����6WD�4G&t��F��V�f�6R�Т��W���W�Т&F6�6��S׳Т��FD��7F�'��FV�FEF�7F�'�Т���F�7FW"�6�F����'F��&�v�B"6��F��W%7G��S����FW���������F�7D�F���3�GW&F���S�7G��S��&6�w&�V�C�r3��"r�6���#�r6fffffbr�&�&FW#�s�6�ƖB&v&�#SR�#SR�#SR��R�r�f��E6��S�s7�r�&�&FW%&F�W3�s'�r�&��6�F�s�s�3�&v&�����b�r���v�GF��sCC�r�v�&D'&V��v'&V��v�&Br�v��FU76S�w&R�w&r�FF��s�s'�g�r�������F�c�����\ No newline at end of file+ (e) => e.url === entry.url,+ );+ const isSelected = selIdx !== -1;+ const atMax =+ isMulti && !isSelected && selectedEntries.length >= maxImages;++ return (+ <div+ key={entry.id}+ title={entry.name}+ onClick={() => entry.url && handleCellClick(entry)}+ className={`relative rounded-xl overflow-hidden border-2 cursor-pointer group/cell aspect-square transition-all ${+ isSelected+ ? "border-primary shadow-glow"+ : "border-white/10 hover:border-white/30"+ } ${atMax ? "opacity-40 cursor-not-allowed" : ""} ${!entry.url ? "cursor-wait" : ""}`}+ >+ {entry.url ? (+ <img+ src={entry.url}+ alt={entry.name}+ className="w-full h-full object-cover"+ />+ ) : (+ <div className="w-full h-full bg-white/5 flex flex-col items-center justify-center">+ <div className="w-8 h-8 rounded-full border-2 border-primary/30 border-t-primary animate-spin mb-1" />+ <span className="text-[10px] font-black text-primary">+ {entry.progress}%+ </span>+ </div>+ )}++ {/* Hover overlay with delete */}+ {entry.url && (+ <div className="absolute inset-0 bg-black/60 opacity-0 group-hover/cell:opacity-100 transition-opacity flex items-end justify-end p-1">+ <button+ type="button"+ title="Remove from history"+ onClick={(e) => handleRemoveFromHistory(e, entry)}+ className="w-5 h-5 bg-red-500/80 hover:bg-red-500 rounded-md flex items-center justify-center transition-colors"+ >+ <svg+ width="8"+ height="8"+ viewBox="0 0 24 24"+ fill="none"+ stroke="white"+ strokeWidth="3"+ >+ <line x1="18" y1="6" x2="6" y2="18" />+ <line x1="6" y1="6" x2="18" y2="18" />+ </svg>+ </button>+ </div>+ )}++ {/* Selection badge */}+ {isSelected && (+ <div className="absolute top-1 left-1 min-w-[20px] h-5 bg-primary rounded-full flex items-center justify-center px-1">+ {isMulti ? (+ <span className="text-[10px] font-black text-black">+ {selIdx + 1}+ </span>+ ) : (+ <svg+ width="9"+ height="9"+ viewBox="0 0 24 24"+ fill="none"+ stroke="black"+ strokeWidth="4"+ >+ <polyline points="20 6 9 17 4 12" />+ </svg>+ )}+ </div>+ )}+ </div>+ );+ })}+ </div>+ )}++ {/* Bottom bar for multi-select */}+ {isMulti && hasSelection && (+ <div className="mt-3 pt-3 border-t border-white/5 flex items-center justify-between">+ <span className="text-xs text-secondary">+ {count} of {maxImages} selected+ </span>+ <button+ type="button"+ onClick={handleDone}+ className="px-4 py-1.5 bg-primary text-black rounded-xl text-xs font-black transition-all hover:scale-105"+ >+ Use Selected+ </button>+ </div>+ )}+ </PromptPopover>+ )}+ </div>+ );+}++// ─── ModelDropdown ────────────────────────────────────────────────────────────++const PROVIDER_LOGOS = {+ openai: "https://cdn.muapi.ai/models/openai.png",+ google: "https://cdn.muapi.ai/models/gemini.png",+ kling: "https://cdn.muapi.ai/models/kling.png",+ alibaba: "https://cdn.muapi.ai/models/alibaba.png",+ bytedance: "https://cdn.muapi.ai/models/bytedance.png",+ blackforest: "https://cdn.muapi.ai/models/bfl.png",+ minimax: "https://cdn.muapi.ai/models/minimax.png",+ suno: "https://cdn.muapi.ai/models/suno.png",+ anthropic: "https://cdn.muapi.ai/models/claude.png",+ meshy: "https://cdn.muapi.ai/models/meshy-3.png",+ tripo3d: "https://cdn.muapi.ai/models/tripo3d.png",+ grok: "https://cdn.muapi.ai/models/xai.png",+ muapi: "https://cdn.muapi.ai/models/muapi.png",+ midjourney: "https://cdn.muapi.ai/models/midjourney.png",+ vidu: "https://cdn.muapi.ai/models/vidu.png",+ runway: "https://cdn.muapi.ai/models/runway.png",+ luma: "https://cdn.muapi.ai/models/luma.png",+ ideogram: "https://cdn.muapi.ai/models/ideogram.png",+ leonardoai: "https://cdn.muapi.ai/models/leonardoai.png",+ hunyuan: "https://cdn.muapi.ai/models/hunyuan.png",+ hidream: "https://cdn.muapi.ai/models/hidream.png",+ lightricks: "https://cdn.muapi.ai/models/lightricks.png",+ pixverse: "https://cdn.muapi.ai/models/pixverse.png",+ reve: "https://cdn.muapi.ai/models/reve.png",+ stability: "https://cdn.muapi.ai/models/stability.png"+};++const invertLogos = ['openai', 'blackforest', 'runway', 'ideogram', 'lightricks', 'grok'];++function ModelDropdown({ models, selectedModel, onSelect, onClose }) {+ const [search, setSearch] = useState("");++ // Find current model's provider to pre-select the provider tab ("slide")+ const currentModelObj = models.find((m) => m.id === selectedModel);+ const initialProvider = currentModelObj?.provider || "all";+ const [selectedProvider, setSelectedProvider] = useState(initialProvider);++ const activeItemRef = useRef(null);++ useEffect(() => {+ // Automatically scroll the active model into view when opening+ if (activeItemRef.current) {+ activeItemRef.current.scrollIntoView({ block: "nearest" });+ }+ }, []);++ const getProviderStyle = (provider) => {+ switch (provider) {+ case "grok":+ return { text: "xI", bg: "bg-orange-500/10 text-orange-400 border-orange-500/25" };+ case "openai":+ return { text: "O", bg: "bg-emerald-500/10 text-emerald-400 border-emerald-500/25" };+ case "google":+ return { text: "G", bg: "bg-blue-500/10 text-blue-400 border-blue-500/25" };+ case "blackforest":+ return { text: "BF", bg: "bg-amber-500/10 text-amber-400 border-amber-500/25" };+ case "bytedance":+ return { text: "BD", bg: "bg-purple-500/10 text-purple-400 border-purple-500/25" };+ case "midjourney":+ return { text: "MJ", bg: "bg-indigo-500/10 text-indigo-400 border-indigo-500/25" };+ case "kling":+ return { text: "KL", bg: "bg-rose-500/10 text-rose-400 border-rose-500/25" };+ case "vidu":+ return { text: "VD", bg: "bg-cyan-500/10 text-cyan-400 border-cyan-500/25" };+ case "minimax":+ return { text: "MX", bg: "bg-pink-500/10 text-pink-400 border-pink-500/25" };+ case "ideogram":+ return { text: "ID", bg: "bg-yellow-500/10 text-yellow-400 border-yellow-500/25" };+ case "luma":+ return { text: "LM", bg: "bg-teal-500/10 text-teal-400 border-teal-500/25" };+ case "alibaba":+ return { text: "AL", bg: "bg-sky-500/10 text-sky-400 border-sky-500/25" };+ case "leonardoai":+ return { text: "LE", bg: "bg-violet-500/10 text-violet-400 border-violet-500/25" };+ case "stability":+ return { text: "SD", bg: "bg-fuchsia-500/10 text-fuchsia-400 border-fuchsia-500/25" };+ default:+ const name = provider ? provider.toUpperCase() : "AI";+ return { text: name.substring(0, 2), bg: "bg-primary/10 text-primary border-primary/25" };+ }+ };++ // Dynamically compute list of providers from the input models list+ const availableProviders = [];+ const seenProviders = new Set();++ models.forEach(m => {+ const pId = m.provider || 'muapi';+ const pName = m.provider_name || 'Muapi';+ if (!seenProviders.has(pId)) {+ seenProviders.add(pId);+ availableProviders.push({ id: pId, name: pName });+ }+ });++ const filtered = models.filter((m) => {+ // 1. Filter by provider tab+ if (selectedProvider !== "all") {+ const pId = m.provider || 'muapi';+ if (pId !== selectedProvider) return false;+ }+ // 2. Filter by search query+ const query = search.toLowerCase();+ return (+ m.name.toLowerCase().includes(query) ||+ m.id.toLowerCase().includes(query)+ );+ });++ const invertLogos = ['openai', 'blackforest', 'runway', 'ideogram', 'lightricks', 'grok'];++ return (+ <div className="flex gap-4 h-full max-h-[60vh] min-h-[350px] overflow-x-hidden">+ {/* Left Sidebar: Provider tabs */}+ <div className="flex flex-col gap-2.5 items-center pr-2 border-r border-white/5 shrink-0 select-none overflow-y-auto custom-scrollbar w-14 pt-0.5">+ <button+ type="button"+ onClick={() => setSelectedProvider("all")}+ className={`w-8 h-8 rounded-full flex items-center justify-center border transition-all flex-shrink-0 cursor-pointer ${+ selectedProvider === "all"+ ? "bg-white/10 text-yellow-400 border-yellow-500/30 shadow-md scale-105"+ : "bg-white/[0.02] text-white/50 border-white/[0.03] hover:bg-white/5 hover:text-white"+ }`}+ title="All Providers"+ >+ <svg width="15" height="15" viewBox="0 0 24 24" fill={selectedProvider === "all" ? "currentColor" : "none"} stroke="currentColor" strokeWidth="2">+ <polygon points="12 2 15.09 8.26 22 9.27 17 14.14 18.18 21.02 12 17.77 5.82 21.02 7 14.14 2 9.27 8.91 8.26 12 2" />+ </svg>+ </button>++ {availableProviders.map(p => {+ const style = getProviderStyle(p.id);+ const isSelected = selectedProvider === p.id;+ return (+ <button+ key={p.id}+ type="button"+ onClick={() => setSelectedProvider(p.id)}+ className={`w-8 h-8 flex-shrink-0 rounded-full flex items-center justify-center font-black text-[10px] border transition-all flex-shrink-0 cursor-pointer overflow-hidden ${+ isSelected+ ? `${style.bg} border-white/25 scale-105 shadow-md`+ : "bg-white/[0.02] text-white/40 border-white/[0.02] hover:bg-white/5 hover:text-white/80"+ }`}+ title={p.name}+ >+ {PROVIDER_LOGOS[p.id] ? (+ <img+ src={PROVIDER_LOGOS[p.id]}+ alt={p.name}+ className={`w-full h-full rounded-full object-contain ${invertLogos.includes(p.id) ? "invert" : ""}`}+ />+ ) : (+ style.text+ )}+ </button>+ );+ })}+ </div>++ {/* Right Pane: Search input + Models list */}+ <div className="flex-1 flex flex-col gap-2 min-w-0">+ <div className="border-b border-white/5 shrink-0 pb-2">+ <div className="flex items-center gap-3 bg-white/5 rounded-xl px-4 py-2 border border-white/5 focus-within:border-primary/50 transition-colors">+ <svg+ width="14"+ height="14"+ viewBox="0 0 24 24"+ fill="none"+ stroke="currentColor"+ strokeWidth="3"+ className="text-muted"+ >+ <circle cx="11" cy="11" r="8" />+ <path d="M21 21l-4.35-4.35" />+ </svg>+ <input+ type="text"+ placeholder="Search models..."+ value={search}+ onClick={(e) => e.stopPropagation()}+ onChange={(e) => setSearch(e.target.value)}+ className="bg-transparent border-none text-xs text-white focus:ring-0 w-full p-0 focus:outline-none"+ />+ </div>+ </div>++ <div className="text-xs font-semibold text-secondary py-1 shrink-0 flex items-center justify-between">+ <span>Available models</span>+ {selectedProvider !== "all" && (+ <span className="text-[10px] bg-white/5 px-2 py-0.5 rounded text-white/60">+ {availableProviders.find(p => p.id === selectedProvider)?.name || selectedProvider}+ </span>+ )}+ </div>++ <div className="flex flex-col gap-1.5 overflow-y-auto custom-scrollbar pr-1 pb-2 flex-1">+ {filtered.length === 0 ? (+ <div className="text-xs text-white/30 text-center py-6">+ No models found+ </div>+ ) : (+ filtered.map((m) => (+ <div+ key={m.id}+ ref={selectedModel === m.id ? activeItemRef : null}+ onClick={(e) => {+ e.stopPropagation();+ onSelect(m);+ onClose();+ }}+ className={`flex items-center justify-between p-3 hover:bg-white/5 rounded-lg cursor-pointer transition-all border border-transparent hover:border-white/5 ${+ selectedModel === m.id ? "bg-white/5 border-white/5" : ""+ }`}+ >+ <div className="flex items-center gap-3">+ {PROVIDER_LOGOS[m.provider] ? (+ <div className="w-8 h-8 rounded-full border border-white/5 overflow-hidden shrink-0 flex items-center justify-center bg-white/[0.02]">+ <img+ src={PROVIDER_LOGOS[m.provider]}+ alt={m.provider_name}+ className={`w-full h-full object-contain p-1 ${invertLogos.includes(m.provider) ? "invert" : ""}`}+ />+ </div>+ ) : (+ <div+ className={`w-8 h-8 ${+ m.family === "kontext"+ ? "bg-blue-500/10 text-blue-400 border-blue-500/10"+ : m.family === "effects"+ ? "bg-purple-500/10 text-purple-400 border-purple-500/10"+ : "bg-primary/10 text-primary border-primary/10"+ } border rounded-full flex items-center justify-center font-bold text-xs shadow-inner uppercase`}+ >+ {m.name.charAt(0)}+ </div>+ )}+ <div className="flex flex-col gap-0.5 min-w-0">+ <span className="text-xs font-bold text-white tracking-tight truncate">+ {m.name}+ </span>+ {selectedProvider === "all" && m.provider_name && (+ <span className="text-[9px] text-white/40">+ {m.provider_name}+ </span>+ )}+ </div>+ </div>+ {selectedModel === m.id && (+ <svg+ width="14"+ height="14"+ viewBox="0 0 24 24"+ fill="none"+ stroke="#22d3ee"+ strokeWidth="4"+ >+ <polyline points="20 6 9 17 4 12" />+ </svg>+ )}+ </div>+ ))+ )}+ </div>+ </div>+ </div>+ );+}++// ─── SimpleDropdown ───────────────────────────────────────────────────────────++function SimpleDropdown({ title, options, selected, onSelect, onClose }) {+ return (+ <>+ <PromptPopoverHeader>{title}</PromptPopoverHeader>+ <PromptMenuList>+ {options.map((opt) => (+ <PromptMenuItem+ key={opt}+ selected={selected === opt}+ onClick={(e) => {+ e.stopPropagation();+ onSelect(opt);+ onClose();+ }}+ >+ {opt}+ </PromptMenuItem>+ ))}+ </PromptMenuList>+ </>+ );+}++// ─── Main Component ───────────────────────────────────────────────────────────++export default function ImageStudio({+ apiKey,+ onGenerationStart,+ onGenerationEnd,+ onGenerationComplete,+ onGenerationError,+ historyItems,+ droppedFiles,+ onFilesHandled,+}) {+ const LEGACY_PERSIST_KEY = "hg_image_studio_persistent";+ const PERSIST_KEY = scopedPersistKey(LEGACY_PERSIST_KEY, apiKey);+ useEffect(() => {+ migrateLegacyPersistKey(LEGACY_PERSIST_KEY, PERSIST_KEY);+ }, [PERSIST_KEY]);++ // ── Model / mode state ──────────────────────────────────────────────────+ const [imageMode, setImageMode] = useState(false); // false=t2i, true=i2i+ const [selectedModelId, setSelectedModelId] = useState(t2iModels[0].id);+ const [selectedModelName, setSelectedModelName] = useState(t2iModels[0].name);+ const [selectedAr, setSelectedAr] = useState(+ t2iModels[0].inputs?.aspect_ratio?.default || "1:1",+ );+ const [selectedQuality, setSelectedQuality] = useState(() => {+ const resolutions = getResolutionsForModel(t2iModels[0].id);+ return resolutions[0] || null;+ });+ const [selectedEffect, setSelectedEffect] = useState("");+ const [maxImages, setMaxImages] = useState(1);++ // ── Prompt / upload state ───────────────────────────────────────────────+ const [prompt, setPrompt] = useState("");+ const [uploadedImageUrls, setUploadedImageUrls] = useState([]);+ const [swapImageUrl, setSwapImageUrl] = useState(null);+ const [uploadHistory, setUploadHistory] = useState([]); // persisted reference images history++ // ── UI state ────────────────────────────────────────────────────────────+ const [dropdownOpen, setDropdownOpen] = useState(null); // 'model' | 'ar' | 'quality' | null+ const [generating, setGenerating] = useState(false);+ const [generateError, setGenerateError] = useState(null);+ const [fullscreenUrl, setFullscreenUrl] = useState(null);+ const [isDrawModalOpen, setIsDrawModalOpen] = useState(false);++ // ── Canvas / history state ──────────────────────────────────────────────+ const [currentImageUrl, setCurrentImageUrl] = useState(null);+ const [activeHistoryIdx, setActiveHistoryIdx] = useState(0);+ const [batchSize, setBatchSize] = useState(1);+ const [localHistory, setLocalHistory] = useState([]); // [{id,url,prompt,model,aspect_ratio,timestamp}]++ // Use prop history if provided, otherwise local+ const history = historyItems ?? localHistory;++ // ── Refs ────────────────────────────────────────────────────────────────+ const textareaRef = useRef(null);+ const dropdownRef = useRef(null);+ const uploadPickerResetRef = useRef(null); // not used directly — managed via key++ // ── Close dropdown on outside click ─────────────────────────────────────+ useEffect(() => {+ if (!dropdownOpen) return;+ const handler = (e) => {+ if (dropdownRef.current && !dropdownRef.current.contains(e.target)) {+ setDropdownOpen(null);+ }+ };+ window.addEventListener("click", handler);+ return () => window.removeEventListener("click", handler);+ }, [dropdownOpen]);++ // ── Persistence: Load ────────────────────────────────────────────────────+ useEffect(() => {+ try {+ const stored = localStorage.getItem(PERSIST_KEY);+ if (stored) {+ const data = JSON.parse(stored);+ if (data.imageMode !== undefined) setImageMode(data.imageMode);+ if (data.selectedModelId) setSelectedModelId(data.selectedModelId);+ if (data.selectedModelName) setSelectedModelName(data.selectedModelName);+ if (data.selectedAr) setSelectedAr(data.selectedAr);+ if (data.selectedQuality) setSelectedQuality(data.selectedQuality);+ if (data.selectedEffect) setSelectedEffect(data.selectedEffect);+ if (data.maxImages) setMaxImages(data.maxImages);+ if (data.prompt) setPrompt(data.prompt);+ if (data.uploadedImageUrls) setUploadedImageUrls(data.uploadedImageUrls);+ if (data.uploadHistory) setUploadHistory(data.uploadHistory);+ if (data.batchSize) setBatchSize(data.batchSize);+ if (data.localHistory) setLocalHistory(data.localHistory);+ }+ } catch (err) {+ console.warn("Failed to load ImageStudio persistence:", err);+ }+ }, []);++ // ── Adjust height on load ────────────────────────────────────────────────+ // ── Persistence: Save ────────────────────────────────────────────────────+ useEffect(() => {+ const timer = setTimeout(() => {+ try {+ const state = {+ imageMode,+ selectedModelId,+ selectedModelName,+ selectedAr,+ selectedQuality,+ selectedEffect,+ maxImages,+ prompt,+ uploadedImageUrls,+ uploadHistory,+ batchSize,+ localHistory,+ };+ localStorage.setItem(PERSIST_KEY, JSON.stringify(state));+ } catch (err) {+ console.warn("Failed to save ImageStudio persistence:", err);+ }+ }, 500); // 500ms debounce+ return () => clearTimeout(timer);+ }, [+ imageMode,+ selectedModelId,+ selectedModelName,+ selectedAr,+ selectedQuality,+ selectedEffect,+ maxImages,+ prompt,+ uploadedImageUrls,+ uploadHistory,+ batchSize,+ localHistory,+ ]);++ const processDroppedImages = async (files) => {+ const MAX_IMAGE_SIZE = 10 * 1024 * 1024; // 10MB+ const tooLarge = files.filter((f) => f.size > MAX_IMAGE_SIZE);+ if (tooLarge.length > 0) {+ alert(+ `The following images are too large (max 10MB): ${tooLarge.map((f) => f.name).join(", ")}`+ );+ return;+ }++ setGenerating(true); // Show as generating/busy+ try {+ const toUpload =+ maxImages === 1 ? files.slice(0, 1) : files.slice(0, maxImages);+ const urls = await Promise.all(+ toUpload.map(async (file) => {+ try {+ return await uploadFile(apiKey, file);+ } catch (err) {+ console.error(+ "[ImageStudio] Drop upload failed for",+ file.name,+ err+ );+ throw err;+ }+ })+ );++ handleUploadSelect({ urls });+ } catch (err) {+ alert(`Image upload failed: ${err.message}`);+ } finally {+ setGenerating(false);+ }+ };++ // ── Handle Dropped Files ────────────────────────────────────────────────+ useEffect(() => {+ if (droppedFiles && droppedFiles.length > 0) {+ const imageFiles = droppedFiles.filter(f => f.type.startsWith('image/'));+ if (imageFiles.length > 0) {+ processDroppedImages(imageFiles);+ }+ onFilesHandled?.();+ }+ }, [droppedFiles, onFilesHandled, processDroppedImages]);++ // ── Derived: current model lists & helpers ───────────────────────────────+ const currentModels = imageMode ? i2iModels : t2iModels;+ const currentAspectRatios = imageMode+ ? getAspectRatiosForI2IModel(selectedModelId)+ : getAspectRatiosForModel(selectedModelId);+ const currentResolutions = imageMode+ ? getResolutionsForI2IModel(selectedModelId)+ : getResolutionsForModel(selectedModelId);+ const currentQualityField = imageMode+ ? getQualityFieldForI2IModel(selectedModelId)+ : getQualityFieldForModel(selectedModelId);+ const showQualityBtn = currentResolutions.length > 0;+ const currentEffects = imageMode ? getEffectsForI2IModel(selectedModelId) : [];+ const showEffectBtn = currentEffects.length > 0;++ // ── Textarea auto-resize ─────────────────────────────────────────────────+ // ── Upload picker callbacks ──────────────────────────────────────────────+ const handleUploadSelect = useCallback(+ ({ url, urls }) => {+ const newUrls = urls || [url];+ setUploadedImageUrls(newUrls);++ if (!imageMode) {+ // Find the i2i sibling of the currently selected t2i model.+ // Many models follow conventions, but some have completely irregular names —+ // those are handled via a hardcoded exceptions map.+ const curId = selectedModelId;+ const i2iIds = new Set(i2iModels.map((m) => m.id));++ // Hardcoded exceptions for models with irregular t2i → i2i naming+ const EXCEPTIONS = {+ 'reve-text-to-image': 'reve-image-edit',+ 'wan2.1-text-to-image': 'wan2.5-image-edit', // no wan2.1 i2i — closest+ 'wan2.5-text-to-image': 'wan2.5-image-edit',+ 'wan2.6-text-to-image': 'wan2.6-image-edit',+ 'kling-o1-text-to-image': 'kling-o1-edit-image',+ 'vidu-q2-text-to-image': 'vidu-q2-reference-to-image',+ 'bytedance-seedream-v3': 'bytedance-seededit-v3',+ 'bytedance-seedream-v4': 'bytedance-seedream-edit-v4',+ 'ideogram-v3-t2i': 'ideogram-v3-reframe',+ };++ const findI2I = (id) => i2iModels.find((m) => m.id === id) ?? null;++ const target =+ // 0. Hardcoded exceptions for irregular names+ findI2I(EXCEPTIONS[curId]) ||+ // 1. Model exists directly in i2i list (e.g. qwen-text-to-image-2512, flux-pulid, flux-redux)+ findI2I(curId) ||+ // 2. {id}-edit suffix (e.g. nano-banana → nano-banana-edit, gpt-image-1.5 → gpt-image-1.5-edit)+ findI2I(`${curId}-edit`) ||+ // 3. -t2i → -i2i (e.g. flux-kontext-dev-t2i → flux-kontext-dev-i2i)+ (curId.includes('-t2i') && findI2I(curId.replace('-t2i', '-i2i'))) ||+ // 4. text-to-image → image-to-image (e.g. gpt4o-text-to-image, midjourney-v7, grok-imagine)+ (curId.includes('text-to-image') && findI2I(curId.replace('text-to-image', 'image-to-image'))) ||+ // 5. Prefix match fallback (e.g. minimax-image-01 → minimax-image-01-subject-reference)+ i2iModels.find((m) => m.id.startsWith(curId)) ||+ // 6. No sibling exists — use first i2i model+ i2iModels[0];++ const ars = getAspectRatiosForI2IModel(target.id);+ const resolutions = getResolutionsForI2IModel(target.id);+ const effects = getEffectsForI2IModel(target.id);+ setImageMode(true);+ setSelectedModelId(target.id);+ setSelectedModelName(target.name);+ setSelectedAr(ars[0] || "1:1");+ setSelectedQuality(resolutions[0] || null);+ setSelectedEffect(effects.length > 0 ? (getDefaultEffectForI2IModel(target.id) || effects[0]) : "");+ setMaxImages(getMaxImagesForI2IModel(target.id));+ }+ },+ [imageMode, selectedModelId],+ );++ const handleUploadClear = useCallback(() => {+ setUploadedImageUrls([]);+ setImageMode(false);++ // Find the t2i parent of the currently selected i2i model (reverse of upload logic)+ const curId = selectedModelId;+ const findT2I = (id) => id ? (t2iModels.find((m) => m.id === id) ?? null) : null;++ // Reverse exceptions map (i2i → t2i for irregular names)+ const REVERSE_EXCEPTIONS = {+ 'reve-image-edit': 'reve-text-to-image',+ 'wan2.5-image-edit': 'wan2.5-text-to-image',+ 'wan2.6-image-edit': 'wan2.6-text-to-image',+ 'kling-o1-edit-image': 'kling-o1-text-to-image',+ 'vidu-q2-reference-to-image': 'vidu-q2-text-to-image',+ 'bytedance-seededit-v3': 'bytedance-seedream-v3',+ 'bytedance-seedream-edit-v4': 'bytedance-seedream-v4',+ 'ideogram-v3-reframe': 'ideogram-v3-t2i',+ };++ const target =+ // 0. Hardcoded reverse exceptions+ findT2I(REVERSE_EXCEPTIONS[curId]) ||+ // 1. Model exists directly in t2i list (e.g. qwen-text-to-image-2512, flux-pulid, flux-redux)+ findT2I(curId) ||+ // 2. Strip -edit suffix (e.g. nano-banana-edit → nano-banana, gpt-image-1.5-edit → gpt-image-1.5)+ (curId.endsWith('-edit') && findT2I(curId.slice(0, -5))) ||+ // 3. -i2i → -t2i (e.g. flux-kontext-dev-i2i → flux-kontext-dev-t2i)+ (curId.includes('-i2i') && findT2I(curId.replace('-i2i', '-t2i'))) ||+ // 4. image-to-image → text-to-image (e.g. gpt4o-image-to-image → gpt4o-text-to-image)+ (curId.includes('image-to-image') && findT2I(curId.replace('image-to-image', 'text-to-image'))) ||+ // 5. No parent found — use first t2i model+ t2iModels[0];++ const ars = getAspectRatiosForModel(target.id);+ const resolutions = getResolutionsForModel(target.id);+ setSelectedModelId(target.id);+ setSelectedModelName(target.name);+ setSelectedAr(ars[0] || "1:1");+ setSelectedQuality(resolutions[0] || null);+ setSelectedEffect("");+ setMaxImages(1);+ }, [selectedModelId]);++ // ── Model selection ──────────────────────────────────────────────────────+ const handleModelSelect = (m) => {+ const ars = imageMode+ ? getAspectRatiosForI2IModel(m.id)+ : getAspectRatiosForModel(m.id);+ const resolutions = imageMode+ ? getResolutionsForI2IModel(m.id)+ : getResolutionsForModel(m.id);+ setSelectedModelId(m.id);+ setSelectedModelName(m.name);+ setSelectedAr(ars[0] || "1:1");+ setSelectedQuality(resolutions[0] || null);+ setSwapImageUrl(null);+ if (imageMode) {+ setMaxImages(getMaxImagesForI2IModel(m.id));+ const effects = getEffectsForI2IModel(m.id);+ setSelectedEffect(effects.length > 0 ? (getDefaultEffectForI2IModel(m.id) || effects[0]) : "");+ } else {+ setSelectedEffect("");+ }+ };++ // ── History helpers ──────────────────────────────────────────────────────+ const addToHistory = useCallback(+ (entry) => {+ if (!historyItems) {+ setLocalHistory((prev) => [entry, ...prev.slice(0, 49)]);+ }+ setActiveHistoryIdx(0);+ setCurrentImageUrl(entry.url);+ },+ [historyItems],+ );++ // ── View state ─────────────────────────────────────++ const resetToPrompt = () => {+ setCurrentImageUrl(null);+ setPrompt("");+ setUploadedImageUrls([]);+ setImageMode(false);+ const firstT2I = t2iModels[0];+ const ars = getAspectRatiosForModel(firstT2I.id);+ const resolutions = getResolutionsForModel(firstT2I.id);+ setSelectedModelId(firstT2I.id);+ setSelectedModelName(firstT2I.name);+ setSelectedAr(ars[0] || "1:1");+ setSelectedQuality(resolutions[0] || null);+ setSelectedEffect("");+ setMaxImages(1);+ };++ // ── Generation ───────────────────────────────────────────────────────────+ const handleGenerate = async () => {+ if (generating) return;++ if (imageMode) {+ if (uploadedImageUrls.length === 0) {+ alert("Please upload a reference image first.");+ return;+ }+ const modelInfo = getI2IModelById(selectedModelId);+ if (modelInfo?.swapField && !swapImageUrl) {+ alert("Please upload a swap face image.");+ return;+ }+ } else {+ if (!prompt.trim()) {+ alert("Please enter a prompt to generate an image.");+ return;+ }+ }++ onGenerationStart?.();+ setGenerating(true);+ setGenerateError(null);++ try {+ const results = await Promise.all(+ Array.from({ length: batchSize }).map(async () => {+ if (imageMode) {+ const genParams = {+ model: selectedModelId,+ images_list: uploadedImageUrls,+ image_url: uploadedImageUrls[0],+ aspect_ratio: selectedAr,+ };+ if (swapImageUrl) genParams.swap_url = swapImageUrl;+ if (prompt.trim()) genParams.prompt = prompt.trim();+ if (currentQualityField && selectedQuality) {+ genParams[currentQualityField] = selectedQuality;+ }+ if (showEffectBtn && selectedEffect) genParams.name = selectedEffect;+ return await generateI2I(apiKey, genParams);+ } else {+ const genParams = {+ model: selectedModelId,+ prompt: prompt.trim(),+ aspect_ratio: selectedAr,+ };+ if (currentQualityField && selectedQuality) {+ genParams[currentQualityField] = selectedQuality;+ }+ return await generateImage(apiKey, genParams);+ }+ })+ );++ results.forEach((res) => {+ if (res && res.url) {+ const entry = {+ id: res.id || Math.random().toString(36).substring(7),+ url: res.url,+ prompt: prompt.trim(),+ model: selectedModelId,+ aspect_ratio: selectedAr,+ timestamp: new Date().toISOString(),+ };+ addToHistory(entry);+ onGenerationComplete?.({+ url: res.url,+ model: selectedModelId,+ prompt: prompt.trim(),+ type: "image",+ });+ }+ });+ } catch (e) {+ console.error("[ImageStudio] Generation failed:", e);+ const errMsg = formatErrorMessage(e, "Image generation failed");+ if (onGenerationError) onGenerationError(errMsg);+ else toast.error(errMsg);+ } finally {+ setGenerating(false);+ onGenerationEnd?.();+ }+ };++ const placeholderText =+ uploadedImageUrls.length > 1+ ? `${uploadedImageUrls.length} images selected — describe the transformation (optional)`+ : imageMode+ ? "Describe how to transform this image (optional)"+ : "Describe the image you want to create";++ // ── Render ───────────────────────────────────────────────────────────────+ return (+ <div className="w-full h-full flex flex-col items-center justify-center bg-app-bg relative p-4 md:p-6 overflow-hidden">++ {/* ── CENTRAL GALLERY AREA ── */}+ <div className="flex-1 w-full max-w-7xl mx-auto overflow-y-auto custom-scrollbar pb-40 lg:pb-32 px-2">+ {history.length > 0 ? (+ <div className="grid grid-cols-1 sm:grid-cols-2 md:grid-cols-3 lg:grid-cols-4 gap-6 w-full pt-4 animate-fade-in-up">+ {history.map((entry, idx) => (+ <div+ key={entry.id || idx}+ className="relative group rounded-lg overflow-hidden border border-white/10 bg-[#0a0a0a] shadow-xl hover:border-primary/50 transition-all duration-300 flex flex-col"+ >+ <img+ src={entry.url}+ alt={entry.prompt?.substring(0, 30) || "Generated image"}+ className="w-full aspect-square object-cover bg-black/40 cursor-pointer hover:opacity-80 transition-opacity"+ onClick={() => setFullscreenUrl(entry.url)}+ />++ {/* Overlay actions */}+ <div className="absolute top-2 right-2 flex flex-col gap-2 opacity-0 group-hover:opacity-100 transition-opacity">+ <button+ type="button"+ title="Fullscreen"+ onClick={(e) => {+ e.stopPropagation();+ setFullscreenUrl(entry.url);+ }}+ className="p-2 bg-black/60 backdrop-blur-md rounded-full text-white hover:bg-primary hover:text-black transition-all border border-white/10"+ >+ <svg width="14" height="14" viewBox="0 0 24 24" fill="none" stroke="currentColor" strokeWidth="2.5">+ <polyline points="15 3 21 3 21 9" />+ <polyline points="9 21 3 21 3 15" />+ <line x1="21" y1="3" x2="14" y2="10" />+ <line x1="3" y1="21" x2="10" y2="14" />+ </svg>+ </button>+ <button+ type="button"+ title="Download"+ onClick={(e) => {+ e.stopPropagation();+ downloadImage(entry.url, `muapi-${entry.id || idx}.jpg`);+ }}+ className="p-2 bg-black/60 backdrop-blur-md rounded-full text-white hover:bg-primary hover:text-black transition-all border border-white/10"+ >+ <svg width="14" height="14" viewBox="0 0 24 24" fill="none" stroke="currentColor" strokeWidth="2.5">+ <path d="M21 15v4a2 2 0 01-2 2H5a2 2 0 01-2-2v-4M7 10l5 5 5-5M12 15V3" />+ </svg>+ </button>+ <button+ type="button"+ title="Delete"+ onClick={(e) => {+ e.stopPropagation();+ if (confirm("Are you sure you want to delete this generated item?")) {+ setLocalHistory(prev => prev.filter((_, i) => i !== idx));+ }+ }}+ className="p-2 bg-black/60 backdrop-blur-md rounded-full text-red-400 hover:bg-red-500 hover:text-white transition-all border border-white/10"+ >+ <svg width="14" height="14" viewBox="0 0 24 24" fill="none" stroke="currentColor" strokeWidth="2.5">+ <polyline points="3 6 5 6 21 6" />+ <path d="M19 6v14a2 2 0 01-2 2H7a2 2 0 01-2-2V6m3 0V4a2 2 0 012-2h4a2 2 0 012 2v2" />+ <line x1="10" y1="11" x2="10" y2="17" />+ <line x1="14" y1="11" x2="14" y2="17" />+ </svg>+ </button>+ </div>++ {/* Prompt & Details */}+ <div className="p-3 bg-black/80 backdrop-blur-sm border-t border-white/5 flex-1 flex flex-col justify-between gap-2">+ <p className="text-white/70 text-xs line-clamp-3 leading-relaxed" title={entry.prompt}>+ {entry.prompt || "No prompt provided"}+ </p>+ <div className="flex items-center justify-between mt-1">+ <div className="flex items-center gap-2">+ <span className="text-[10px] font-bold text-primary px-2 py-0.5 bg-primary/10 rounded border border-primary/20 capitalize">+ {entry.model?.replace("-", " ") || "Image Studio"}+ </span>+ <span className="text-[10px] text-white/40">{entry.aspect_ratio}</span>+ </div>+ {entry.prompt && (+ <button+ type="button"+ onClick={(e) => {+ e.stopPropagation();+ navigator.clipboard.writeText(entry.prompt);+ const btn = e.currentTarget;+ btn.innerText = "Copied!";+ setTimeout(() => { btn.innerText = "Copy"; }, 2000);+ }}+ className="px-2 py-0.5 bg-white/5 hover:bg-primary/20 hover:text-primary rounded text-[10px] font-medium text-white/70 transition-all border border-white/10"+ title="Copy prompt"+ >+ Copy Prompt+ </button>+ )}+ </div>+ </div>+ </div>+ ))}+ </div>+ ) : (+ <div className="flex flex-col items-center justify-center h-full animate-fade-in-up transition-all duration-700 min-h-[50vh]">+ {/* Overlapping floating cards */}+ <div className="flex items-center justify-center gap-1.5 md:gap-3 mb-10 select-none scale-90 sm:scale-100">+ <div className="w-18 h-22 sm:w-24 sm:h-28 rounded-2xl border border-white/10 shadow-2xl -rotate-[12deg] transform hover:rotate-0 hover:scale-110 hover:z-20 transition-all duration-300 overflow-hidden bg-white/[0.01] flex-shrink-0">+ <img+ src="https://d3adwkbyhxyrtq.cloudfront.net/webassets/videomodels/sdxl-image.avif"+ alt="Creative asset 1"+ className="w-full h-full object-cover"+ />+ </div>+ <div className="w-18 h-22 sm:w-24 sm:h-28 rounded-2xl border border-white/10 shadow-2xl -rotate-[4deg] transform hover:rotate-0 hover:scale-110 hover:z-20 transition-all duration-300 overflow-hidden bg-white/[0.01] -ml-3 sm:-ml-4 flex-shrink-0">+ <img+ src="https://d3adwkbyhxyrtq.cloudfront.net/webassets/videomodels/chroma-image.avif"+ alt="Creative asset 2"+ className="w-full h-full object-cover"+ />+ </div>+ <div className="w-18 h-18 sm:w-24 sm:h-24 rounded-full border border-white/10 shadow-2xl rotate-[6deg] transform hover:rotate-0 hover:scale-110 hover:z-20 transition-all duration-300 overflow-hidden bg-white/[0.01] -ml-3 sm:-ml-4 flex-shrink-0">+ <img+ src="https://d3adwkbyhxyrtq.cloudfront.net/webassets/videomodels/neta-lumina.avif"+ alt="Creative asset 3"+ className="w-full h-full object-cover"+ />+ </div>+ <div className="w-18 h-22 sm:w-24 sm:h-28 rounded-2xl border border-white/10 shadow-2xl rotate-[12deg] transform hover:rotate-0 hover:scale-110 hover:z-20 transition-all duration-300 overflow-hidden bg-white/[0.01] -ml-3 sm:-ml-4 flex-shrink-0">+ <img+ src="https://d3adwkbyhxyrtq.cloudfront.net/webassets/videomodels/perfect-pony-xl.avif"+ alt="Creative asset 4"+ className="w-full h-full object-cover"+ />+ </div>+ </div>++ <h1 className="text-2xl sm:text-4xl md:text-5xl font-extrabold tracking-tight mb-4 text-center px-4 flex flex-col items-center">+ <span className="text-white font-black uppercase text-xl sm:text-3xl tracking-wide mb-1 opacity-90">START CREATING WITH</span>+ <span className="text-[#22d3ee] font-black uppercase text-2xl sm:text-4xl sm:mt-1 tracking-tight">+ {selectedModelName}+ </span>+ </h1>+ <p className="text-white/40 text-xs sm:text-sm font-medium tracking-wide text-center max-w-lg leading-relaxed px-4">+ Describe a scene, character, mood, or style — and watch it come to life+ </p>+ </div>+ )}+ </div>++ {/* ── BOTTOM PROMPT BAR ── */}+ <PromptComposer>+ {/* Top row: upload picker + textarea */}+ <div className="flex flex-col gap-3">+ {/* Inline list of uploaded files */}+ <div className="flex items-center gap-2.5 flex-wrap">+ {uploadedImageUrls && uploadedImageUrls.length > 0 && uploadedImageUrls.map((url, idx) => (+ <div key={url} className={PROMPT_MEDIA_PREVIEW_CLASS}>+ <img src={url} alt="" className="w-full h-full object-cover" />+ <button+ type="button"+ onClick={() => {+ const next = uploadedImageUrls.filter((_, i) => i !== idx);+ setUploadedImageUrls(next);+ if (next.length === 0) handleUploadClear();+ }}+ className="absolute top-0.5 right-0.5 w-4 h-4 bg-black/60 hover:bg-black rounded-full flex items-center justify-center text-white/85 hover:text-white text-[8px] border border-white/5"+ >+ ×+ </button>+ </div>+ ))}++ {/* Main Upload Trigger */}+ {uploadedImageUrls.length < maxImages && (+ <UploadButton+ apiKey={apiKey}+ maxImages={maxImages}+ onSelect={handleUploadSelect}+ onClear={handleUploadClear}+ initialUrls={uploadedImageUrls}+ persistedHistory={uploadHistory}+ onHistoryChange={setUploadHistory}+ />+ )}++ {/* Swap Image Upload Trigger */}+ {imageMode && getI2IModelById(selectedModelId)?.swapField && (+ <UploadButton+ apiKey={apiKey}+ maxImages={1}+ onSelect={({ urls }) => setSwapImageUrl(urls[0] || null)}+ onClear={() => setSwapImageUrl(null)}+ initialUrls={swapImageUrl ? [swapImageUrl] : []}+ label="Swap Face"+ />+ )}+ </div>++ {/* Input prompt text area */}+ <PromptTextarea+ ref={textareaRef}+ value={prompt}+ onChange={(e) => setPrompt(e.target.value)}+ placeholder={placeholderText}+ />+ </div>++ {/* Bottom row: controls + generate */}+ <PromptFooter>+ {/* Left controls */}+ <PromptControls ref={dropdownRef}>+ {/* Model button */}+ <div className="relative">+ <button+ type="button"+ onClick={(e) => {+ e.stopPropagation();+ setDropdownOpen((o) => (o === "model" ? null : "model"));+ }}+ className={promptControlClassName({+ active: dropdownOpen === "model",+ })}+ >+ <div className="w-4 h-4 rounded overflow-hidden shrink-0 flex items-center justify-center bg-white/5">+ {(() => {+ const selectedModelObj = currentModels.find(m => m.id === selectedModelId);+ const selectedModelProvider = selectedModelObj?.provider || 'muapi';+ return PROVIDER_LOGOS[selectedModelProvider] ? (+ <img+ src={PROVIDER_LOGOS[selectedModelProvider]}+ alt=""+ className={`w-full h-full object-contain ${invertLogos.includes(selectedModelProvider) ? "invert" : ""}`}+ />+ ) : (+ <span className="text-[9px] font-bold text-black uppercase">G</span>+ );+ })()}+ </div>+ <span className={PROMPT_CONTROL_LABEL_CLASS}>+ {selectedModelName}+ </span>+ <PromptChevronIcon />+ </button>++ {dropdownOpen === "model" && (+ <PromptPopover+ onClick={(e) => e.stopPropagation()}+ className="w-[calc(100vw-2rem)] md:w-[480px] max-w-md md:max-w-none max-h-[70vh]"+ >+ <PromptPopoverHeader>Model</PromptPopoverHeader>+ <ModelDropdown+ models={currentModels}+ selectedModel={selectedModelId}+ onSelect={handleModelSelect}+ onClose={() => setDropdownOpen(null)}+ />+ </PromptPopover>+ )}+ </div>++ {/* Aspect ratio button */}+ <div className="relative">+ <button+ type="button"+ onClick={(e) => {+ e.stopPropagation();+ setDropdownOpen((o) => (o === "ar" ? null : "ar"));+ }}+ className={promptControlClassName({+ active: dropdownOpen === "ar",+ })}+ >+ <PromptAspectRatioIcon />+ <span className={PROMPT_CONTROL_LABEL_CLASS}>+ {selectedAr}+ </span>+ </button>++ {dropdownOpen === "ar" && (+ <PromptPopover+ onClick={(e) => e.stopPropagation()}+ >+ <SimpleDropdown+ title="Aspect Ratio"+ options={currentAspectRatios}+ selected={selectedAr}+ onSelect={(val) => setSelectedAr(val)}+ onClose={() => setDropdownOpen(null)}+ />+ </PromptPopover>+ )}+ </div>++ {/* Quality/resolution button (represented as Diamond icon) */}+ {showQualityBtn && (+ <div className="relative">+ <button+ type="button"+ onClick={(e) => {+ e.stopPropagation();+ setDropdownOpen((o) => (o === "quality" ? null : "quality"));+ }}+ className={promptControlClassName({+ active: dropdownOpen === "quality",+ })}+ >+ <PromptQualityIcon />+ <span className={PROMPT_CONTROL_LABEL_CLASS}>+ {selectedQuality || currentResolutions[0]}+ </span>+ </button>++ {dropdownOpen === "quality" && (+ <PromptPopover+ onClick={(e) => e.stopPropagation()}+ >+ <SimpleDropdown+ title="Resolution"+ options={currentResolutions}+ selected={selectedQuality}+ onSelect={(val) => setSelectedQuality(val)}+ onClose={() => setDropdownOpen(null)}+ />+ </PromptPopover>+ )}+ </div>+ )}++ {/* Effect type button */}+ {showEffectBtn && (+ <div className="relative">+ <button+ type="button"+ onClick={(e) => {+ e.stopPropagation();+ setDropdownOpen((o) => (o === "effect" ? null : "effect"));+ }}+ className={promptControlClassName({+ active: dropdownOpen === "effect",+ })}+ >+ <svg width="16" height="16" viewBox="0 0 24 24" fill="none" stroke="currentColor" strokeWidth="2" className="opacity-40 text-white">+ <path d="M5 3l14 9-14 9V3z" />+ </svg>+ <span className={`${PROMPT_CONTROL_LABEL_CLASS} max-w-[140px] truncate`}>+ {selectedEffect || "Effect"}+ </span>+ </button>++ {dropdownOpen === "effect" && (+ <PromptPopover+ onClick={(e) => e.stopPropagation()}+ className="min-w-[200px]"+ >+ <SimpleDropdown+ title="Effect Type"+ options={currentEffects}+ selected={selectedEffect}+ onSelect={(val) => setSelectedEffect(val)}+ onClose={() => setDropdownOpen(null)}+ />+ </PromptPopover>+ )}+ </div>+ )}++ {/* Batch size stepper */}+ <div className={promptControlClassName({ compact: true, className: "select-none" })}>+ <button+ type="button"+ onClick={() => setBatchSize(prev => Math.max(1, prev - 1))}+ className="text-white/40 hover:text-white/80 font-extrabold text-xs transition-colors px-1"+ >+ -+ </button>+ <span className="text-xs font-semibold text-white/70 min-w-[24px] text-center">+ {batchSize}/4+ </span>+ <button+ type="button"+ onClick={() => setBatchSize(prev => Math.min(4, prev + 1))}+ className="text-white/40 hover:text-white/80 font-extrabold text-xs transition-colors px-1"+ >+ ++ </button>+ </div>++ {/* Draw button */}+ <button+ type="button"+ className={promptControlClassName()}+ onClick={() => setIsDrawModalOpen(true)}+ >+ <svg width="16" height="16" viewBox="0 0 24 24" fill="none" stroke="currentColor" strokeWidth="2.5" className="opacity-40 text-white group-hover:text-[#22d3ee] transition-colors">+ <path d="M12 20h9" />+ <path d="M16.5 3.5a2.121 2.121 0 013 3L7 19l-4 1 1-4L16.5 3.5z" />+ </svg>+ <span className={PROMPT_CONTROL_LABEL_CLASS}>+ Draw+ </span>+ </button>+ </PromptControls>++ {/* Generate button */}+ <PromptAction+ onClick={handleGenerate}+ disabled={generating}+ >+ {generating ? (+ <>+ <span className="animate-spin inline-block text-black">◌</span>+ Generating...+ </>+ ) : (+ <>+ <span>Generate ✦</span>+ </>+ )}+ </PromptAction>+ </PromptFooter>+ </PromptComposer>++ {/* ── FULLSCREEN IMAGE MODAL ── */}+ {fullscreenUrl && (+ <div+ className="fixed inset-0 z-[100] flex items-center justify-center bg-black/95 backdrop-blur-sm animate-fade-in"+ onClick={() => setFullscreenUrl(null)}+ >+ <button+ type="button"+ className="absolute top-6 right-6 p-3 bg-white/10 hover:bg-white/20 rounded-full text-white transition-colors border border-white/10"+ onClick={(e) => {+ e.stopPropagation();+ setFullscreenUrl(null);+ }}+ >+ <svg width="24" height="24" viewBox="0 0 24 24" fill="none" stroke="currentColor" strokeWidth="2.5" strokeLinecap="round" strokeLinejoin="round">+ <line x1="18" y1="6" x2="6" y2="18" />+ <line x1="6" y1="6" x2="18" y2="18" />+ </svg>+ </button>+ <img+ src={fullscreenUrl}+ alt="Fullscreen Preview"+ className="max-w-[95vw] max-h-[95vh] rounded-2xl shadow-2xl object-contain animate-scale-up"+ onClick={(e) => e.stopPropagation()}+ />+ </div>+ )}++ {/* ── DRAW CANVAS MODAL ── */}+ <DrawModal+ isOpen={isDrawModalOpen}+ onClose={() => setIsDrawModalOpen(false)}+ apiKey={apiKey}+ batchSize={1}+ onAddHistoryItem={addToHistory}+ />+ <Toaster position="top-right" containerStyle={{ zIndex: 99999 }} toastOptions={{ duration: 5000, style: { background: '#18181b', color: '#ffffff', border: '1px solid rgba(255,255,255,0.15)', fontSize: '13px', borderRadius: '12px', boxShadow: '0 10px 30px rgba(0,0,0,0.6)', maxWidth: '440px', wordBreak: 'break-word', whiteSpace: 'pre-wrap', padding: '12px 16px' } }} />+ </div>+ );+}diff --git a/packages/studio/src/components/LipSyncStudio.jsx b/packages/studio/src/components/LipSyncStudio.jsxindex 4d9e36d5..c24558f2 100644--- a/packages/studio/src/components/LipSyncStudio.jsx+++ b/packages/studio/src/components/LipSyncStudio.jsx@@ -457,4 +457,708 @@ export default function LipSyncStudio({internalHistory,]);- // ── Derived model info ──────────────────��t����k�w��@�������������������Ĉ������������܈���(����������������������������Ј�����Ĉ�����Ј�����܈���(����������������������ٜ�(���������������������ѽ��(������������������((����������������켨��х��̀���(����������������������9������́�����������������ɽ�����ȵʹ���ɑ�ȵЁ��ɑ�ȵݡ�є�ԁ����ā��������്������ѥ�䵉��ݕ�������Ȉ�(������������������핹����ɽ��Ѐ����(����������������������������9����ѕ�еݡ�є����ѕ�е�́�����������ȁ��������ɕ��ᕐ��ѥѱ��핹����ɽ�����(����������������������핹����ɽ����(�����������������������(��������������������(������������������������9�������ѕ�̵���ѕȁ���ѥ�䵉��ݕ��������Ʌ������ā�дĈ�(��������������������������9�������ѕ�̵���ѕȁ����Ȉ�(���������������������������������9����ѕ�еl����t����е�����ѕ�е�ɥ������ȁ����ԁ����ɥ�������ɽչ������ɑ�ȁ��ɑ�ȵ�ɥ�������ݡ�ѕ���������Ʌ���(������������������������1���M幌(����������������������������(����������������������핹���ɕͽ��ѥ�������(�����������������������������������9����ѕ�еl����t�ѕ�еݡ�є�����핹���ɕͽ��ѥ���������(������������������������(����������������������(��������������������핹����ɽ��Ѐ����(�������������������������ѽ�(�������������������������������ѽ��(�������������������������� �����졔������(�����������������������������ѽ�Aɽ����ѥ�����(����������������������������٥��ѽȹ�������ɐ��ɥѕQ��С������ɽ��Ф�(������������������������������Ё�Ѹ����ɕ��Q�ɝ���(���������������������������Ѹ������Q��Ѐ� ��������(��������������������������͕�Q�����Р������쁉Ѹ������Q��Ѐ� �������������(��������������������������(�����������������������������9������ȁ����ԁ���ݡ�є�ԁ��ٕ�鉜��ɥ���������ٕ��ѕ�е�ɥ����ɽչ����ѕ�еl����t����е����մ�ѕ�еݡ�є�����Ʌ�ͥѥ���������ɑ�ȁ��ɑ�ȵݡ�є����(������������������������ѥѱ�� ����ɽ��Ј(�����������������������(������������������������ ���Aɽ���(�������������������������ѽ��(����������������������(��������������������(������������������(����������������(���������������(������������(����������耠(����������������9���������്����ѕ�̵���ѕȁ���ѥ�䵍��ѕȁ���ձ�������є�������������Ʌ�ͥѥ���������Ʌѥ�������������l��١t��(������������켨�=ٕɱ�����������ѥ�����ɑ̀���(������������������9�������ѕ�̵���ѕȁ���ѥ�䵍��ѕȁ����ĸԁ��靅��́������͕���е�����͍�������ʹ�͍���������(��������������������9����ܴ������ȁʹ�ܴ�Ёʹ頴���ɽչ�����ᰁ��ɑ�ȁ��ɑ�ȵݡ�є����͡���ܴ�ᰀ�ɽхє�l�ɑ��t��Ʌ�͙�ɴ���ٕ��ɽхє�����ٕ��͍����������ٕ�������Ʌ�ͥѥ���������Ʌѥ��������ٕə��ܵ����������ݡ�є�l����t�����͡ɥ������(����������������(�������������������Ɍ�����輽�ͅ�ݭ������Ĺ���Ց�ɽ�й��нݕ���͕�̽٥��������̽͑ᰵ�������٥��(���������������������� ɕ�ѥٔ���͕ЀĈ(�����������������������9����ܵ�ձ�����ձ�������е��ٕȈ(������������������(����������������(��������������������9����ܴ������ȁʹ�ܴ�Ёʹ頴���ɽչ�����ᰁ��ɑ�ȁ��ɑ�ȵݡ�є����͡���ܴ�ᰀ�ɽхє�lё��t��Ʌ�͙�ɴ���ٕ��ɽхє�����ٕ��͍����������ٕ�������Ʌ�ͥѥ���������Ʌѥ��������ٕə��ܵ����������ݡ�є�l����t�����́ʹ赵��Ё����͡ɥ������(����������������(�������������������Ɍ�����輽�ͅ�ݭ������Ĺ���Ց�ɽ�й��нݕ���͕�̽٥��������̽��ɽ����������٥��(���������������������� ɕ�ѥٔ���͕ЀȈ(�����������������������9����ܵ�ձ�����ձ�������е��ٕȈ(������������������(����������������(��������������������9����ܴ��������ʹ�ܴ�Ёʹ頴�Ёɽչ�����ձ����ɑ�ȁ��ɑ�ȵݡ�є����͡���ܴ�ᰁɽхє�lّ��t��Ʌ�͙�ɴ���ٕ��ɽхє�����ٕ��͍����������ٕ�������Ʌ�ͥѥ���������Ʌѥ��������ٕə��ܵ����������ݡ�є�l����t�����́ʹ赵��Ё����͡ɥ������(����������������(�������������������Ɍ�����輽�ͅ�ݭ������Ĺ���Ց�ɽ�й��нݕ���͕�̽٥��������̽��ф��յ�����٥��(���������������������� ɕ�ѥٔ���͕Ѐ̈(�����������������������9����ܵ�ձ�����ձ�������е��ٕȈ(������������������(����������������(��������������������9����ܴ������ȁʹ�ܴ�Ёʹ頴���ɽչ�����ᰁ��ɑ�ȁ��ɑ�ȵݡ�є����͡���ܴ�ᰁɽхє�l�ɑ��t��Ʌ�͙�ɴ���ٕ��ɽхє�����ٕ��͍����������ٕ�������Ʌ�ͥѥ���������Ʌѥ��������ٕə��ܵ����������ݡ�є�l����t�����́ʹ赵��Ё����͡ɥ������(����������������(�������������������Ɍ�����輽�ͅ�ݭ������Ĺ���Ց�ɽ�й��нݕ���͕�̽٥��������̽��ə��е�����٥��(���������������������� ɕ�ѥٔ���͕ЀЈ(�����������������������9����ܵ�ձ�����ձ�������е��ٕȈ(������������������(����������������(��������������((�������������ā�����9����ѕ�д�ᰁʹ�ѕ�д�ᰁ���ѕ�д�ᰁ���е���Ʌ������Ʌ������ѥ��Ё���Ёѕ�е���ѕȁ��Ё��������്����ѕ�̵���ѕȈ�(�������������������������9����ѕ�еݡ�є����е����������ɍ�͔�ѕ�еᰁʹ�ѕ�д�ᰁ�Ʌ������ݥ������ā�����������MQIP� IQ%9�]%Q ������(�������������������������9����ѕ�еl��ɐ͕�t����е����������ɍ�͔�ѕ�д�ᰁʹ�ѕ�д�ᰁʹ�дā�Ʌ������ѥ��Ј�(����������������1%@�Me9�MQU%<(��������������������(���������������(��������������������9����ѕ�еݡ�є����ѕ�е�́ʹ�ѕ�еʹ����е����մ��Ʌ������ݥ���ѕ�е���ѕȁ���ܵ�����������ɕ��ᕐ���Ј�(��������������M幌����ٽ����ݥѠ���䁙����٥����Ѽ��ɕ�є��ɕ��մ�х�������مх�́����٥���̸(���������������(������������(����������(��������((������켨��R�R � =QQ=4�AI=5AP� H��R�R ����(�������Aɽ��� ����͕��(����������켨�5����ѽ�����ɽ܀���(����������������9�������ѕ�̵���ѕȁ��Ĉ�(�������������Aɽ���M�����ѕ� ���ɽ��(�������������Aɽ���M������=�ѥ��(���������������������ѽ��(���������������� �������ݥэ�Q�%�����(��������������͕���ѕ��������5������������(�������������(����������������ٜ�ݥ�Ѡ��̈���������̈�٥�� ��������Ѐ�Ј�����������ɽ�����ɕ�� ���Ȉ���ɽ��]��Ѡ�Ȉ��ɥ�����������Ք��(�����������������ɕ�Ё��̈���̈�ݥ�Ѡ�������������������Ȉ���(�����������������ɍ�������Ԉ�����Ԉ���ĸԈ���(�������������������Ѡ����Ā�ԴԴ�0Ԁ�Ĉ���(����������������ٜ�(��������������A���Ʌ�Ё%����(�������������Aɽ���M������=�ѥ���(�������������Aɽ���M������=�ѥ��(���������������������ѽ��(���������������� �������ݥэ�Q�Y�����(��������������͕���ѕ��������5�������٥�����(�������������(����������������ٜ�ݥ�Ѡ��̈���������̈�٥�� ��������Ѐ�Ј�����������ɽ�����ɕ�� ���Ȉ���ɽ��]��Ѡ�Ȉ��ɥ�����������Ք��(�����������������ɕ�Ё��Ȉ���Ԉ�ݥ�Ѡ��Ԉ���������Ј����Ȉ���(�������������������Ѡ����܀���Դ������Դ̈���(����������������ٜ�(��������������Y����(�������������Aɽ���M������=�ѥ���(�������������Aɽ���M�����ѕ� ���ɽ��(������������((����������켨�U�����́ɽ܀���(����������������9�������ѕ�̵���ѕȁ����ȁ��Ĉ�(������������������9�������ѕ�̵���ѕȁ����Ȉ�(��������������켨�%����������ȃ�P����䁥����������������(��������������������5����������������(�����������������5����A����� ��ѽ�(������������������������������(������������������������%�����(������������������������(����������������������ٜ(����������������������ݥ�Ѡ��؈(������������������������������؈(����������������������٥�� ��������Ѐ�Ј(�����������������������������(������������������������ɽ�����ɕ�� ���Ȉ(������������������������ɽ��]��Ѡ�Ȉ(���������������������������9����ѕ�еݡ�є�����ɽ�����ٕ��ѕ�еl��ɐ͕�t��Ʌ�ͥѥ��������̈(���������������������(�����������������������ɕ�Ё��̈���̈�ݥ�Ѡ�������������������Ȉ����Ȉ���(�����������������������ɍ�������Ԉ�����Ԉ���ĸԈ���(��������������������������履�����������Ā�Ԁ����Ԁ�Ĉ���(����������������������ٜ�(�������������������(��������������������U�������������%����U������(�������������������� �����젤�����(��������������������͕�%����Uɰ��ձ���(��������������������͕�%����Mхє�UA1=}MQQ�%1��(��������������������͕�%����9��������(��������������������(������������������������Mхє�������Mхѕ�(�������������������ɽ�ɕ���������Aɽ�ɕ���(����������������������9����������9����(�������������������ɕ٥��Uɰ�������Uɱ�(��������������������Y�����홅�͕�(���������������������-������-���(������������������(����������������((��������������켨�Y����������ȃ�P����䁥��٥������������(��������������������5�������٥���������(�����������������5����A����� ��ѽ�(�������������������������٥������(������������������������Y�����(������������������������(���������������������Y����%���������9����ѕ�еݡ�є�����ɽ�����ٕ��ѕ�еl��ɐ͕�t��Ʌ�ͥѥ��������̈���(�������������������(��������������������U�������������Y����A����(�������������������� �����젤�����(��������������������͕�Y����Uɰ��ձ���(��������������������͕�Y����Mхє�UA1=}MQQ�%1��(��������������������͕�Y����9��������(��������������������(������������������������Mхє��٥���Mхѕ�(�������������������ɽ�ɕ����٥���Aɽ�ɕ���(����������������������9�����٥���9����(�������������������ɕ٥��Uɰ��٥���Uɱ�(��������������������Y��������Օ�(���������������������-������-���(������������������(����������������((��������������켨�Ց��������ȃ�P���݅�́٥ͥ�������(���������������5����A����� ��ѽ�(�����������������������Ց�����(����������������������Ց���(����������������������(�������������������5��%���������9����ѕ�еݡ�є�����ɽ�����ٕ��ѕ�еl��ɐ͕�t��Ʌ�ͥѥ��������̈���(�����������������(������������������U�������������Ց��A����(������������������ �����젤�����(������������������͕�Ց��Uɰ��ձ���(������������������͕�Ց��Mхє�UA1=}MQQ�%1��(������������������͕�Ց��9��������(������������������(����������������������Mхє��Ց��Mхѕ�(�����������������ɽ�ɕ����Ց��Aɽ�ɕ���(��������������������9�����Ց��9����(�����������������ɕ٥��Uɰ���ձ��(������������������Y�����홅�͕�(�������������������-������-���(����������������(��������������((������������켨�Aɽ��Ёѕ�хɕ�����(������������������9�����ā��������്����(���������������Aɽ���Q��хɕ�(����������������ɕ���ѕ�хɕ�I���(����������������م�Ք���ɽ����(������������������ �������������Aɽ���%�����(�����������������������������͍ɥ������������屔����(����������������(��������������(������������((����������켨� ��ѽ������ɽ�́ɽ܀���(�����������Aɽ�����ѕ��(�������������Aɽ��� ���ɽ���(��������������켨�5�����͕���ѽȀ���(��������������������9����ɕ��ѥٔ��(�������������������ѽ�(������������������ɕ�������� ѹI���(�������������������������ѽ��(�������������������� �����졔������(�����������������������ѽ�Aɽ����ѥ�����(��������������������͕�=���ɽ���ݸ�(��������������������������ɽ���ݸ������������ձ��耉�������(����������������������(��������������������(�����������������������9������ɽ��� ���ɽ� ����9�����(����������������������ѥٔ聽���ɽ���ݸ���������(���������������������(�����������������(������������������������9����̸ܴԁ��̸ԁ���l��ɐ͕�t�ɽչ����ʹ�������ѕ�̵���ѕȁ���ѥ�䵍��ѕȈ�(�������������������������������9����ѕ�еl���t����е������ѕ�е�������(����������������������L(��������������������������(��������������������(�����������������������������9�����AI=5AQ} =9QI=1}1 1} 1MM��(���������������������͕���ѕ�5���������������M����Ё�������(������������������������(�������������������Aɽ��� ���ɽ�%������(�������������������ѽ��(�����������������ɽ���ݸ(��������������������=���������ɽ���ݸ���������(������������������ѥѱ��5�����(�������������������ѕ���������ɽ���ݹ%ѕ���(������������������͕���ѕ�%���͕���ѕ�5����%��(��������������������M�������������5����M������(�������������������� ��͔�젤����͕�=���ɽ���ݸ��ձ���(������������������������I��������� ѹI���(�����������������������9����ܴ������ܵm���������ܴ�ɕ��t�(������������������(����������������((��������������켨�I�ͽ��ѥ���͕���ѽȀ���(���������������͡��I�ͽ��ѥ�������(����������������������9����ɕ��ѥٔ��(���������������������ѽ�(��������������������ɕ���ɕͽ��ѥ�� ѹI���(���������������������������ѽ��(���������������������� �����졔������(�������������������������ѽ�Aɽ����ѥ�����(����������������������͕�=���ɽ���ݸ�(����������������������������ɽ���ݸ����ɕͽ��ѥ�������ձ��耉ɕͽ��ѥ����(������������������������(����������������������(�������������������������9������ɽ��� ���ɽ� ����9�����(������������������������ѥٔ聽���ɽ���ݸ����ɕͽ��ѥ����(�����������������������(�������������������(���������������������Aɽ���EՅ����%������(�������������������������������9�����AI=5AQ} =9QI=1}1 1} 1MM��(�����������������������͕���ѕ�I�ͽ��ѥ���(��������������������������(���������������������ѽ��(�������������������ɽ���ݸ(����������������������=���������ɽ���ݸ����ɕͽ��ѥ����(��������������������ѥѱ��I�ͽ��ѥ���(���������������������ѕ����ɕͽ��ѥ��ɽ���ݹ%ѕ���(��������������������͕���ѕ�%���͕���ѕ�I�ͽ��ѥ���(����������������������M������졥ѕ������͕�M����ѕ�I�ͽ��ѥ����ѕ������(���������������������� ��͔�젤����͕�=���ɽ���ݸ��ձ���(��������������������������I����ɕͽ��ѥ�� ѹI���(��������������������(������������������(����������������(�������������Aɽ��� ���ɽ���((������������켨����Ʌє����ѽ�����(�������������Aɽ����ѥ��(���������������� ���������������Ʌѕ�(����������������ͅ�����������Ʌѥ���(�������������(��������������������Ʌѥ������(������������������(�����������������������������9������є�������������������ѕ�е�������(���������������������^0(������������������������숀��(���������������������Ʌѥ�����(������������������(����������������耠(������������������(������������������������M幌�1��������(������������������(����������������(�������������Aɽ����ѥ���(�����������Aɽ�����ѕ��(�������Aɽ��� ����͕��((������켨��R�R �U11M I8�5%�5=0��R�R ����(�������ձ�͍ɕ��Uɰ�����(���������(���������������9���ᕐ���͕д���l���t�������ѕ�̵���ѕȁ���ѥ�䵍��ѕȁ����������ԁ�����ɽ�����ȵʹ������є���������(������������ �����젤����͕�ձ�͍ɕ��Uɰ��ձ���(���������(�������������ѽ�(�������������������ѽ��(�����������������9���ͽ��є�ѽ��ɥ��д��́���ݡ�є������ٕ�鉜�ݡ�є����ɽչ�����ձ��ѕ�еݡ�є��Ʌ�ͥѥ��������́��ɑ�ȁ��ɑ�ȵݡ�є����(�������������� �����졔������(�����������������ѽ�Aɽ����ѥ�����(��������������͕�ձ�͍ɕ��Uɰ��ձ���(��������������(�����������(��������������ٜ�ݥ�Ѡ��Ј���������Ј�٥�� ��������Ѐ�Ј�����������ɽ�����ɕ�� ���Ȉ���ɽ��]��Ѡ�ȸԈ���ɽ��1�������ɽչ�����ɽ��1��������ɽչ���(��������������������������؈����؈����������(�������������������؈����؈�����������������(��������������ٜ�(�������������ѽ��(�����������٥����(�������������Ɍ��ձ�͍ɕ��Uɱ�(����������������ɽ�̀(��������������ѽA���(�����������������(�����������������9����ܵl����t���ൠ�l��١t�ɽչ�����ᰁ͡���ܴ�ᰁ�����е���х��������є�͍��������(�������������� �����졔��������ѽ�Aɽ����ѥ�����(������������(����������(��������(�������Q���ѕȁ��ͥѥ���ѽ��ɥ��Ј����х����M�屔����%������������ѽ���=�ѥ�����쁑�Ʌѥ�����������屔�쁉����ɽչ�耜�����ň��������耜������������ɑ��耜����ͽ����ɝ������������Ԥ�������M��耜���������ɑ��I�����耜����������M�����耜������������ɝ�����������ؤ������]��Ѡ耜��������ݽɑ ɕ��耝�ɕ���ݽɐ���ݡ�ѕM����耝�ɔ��Ʌ�����������耜���������������(������(����)�\ No newline at end of file+ // ── Derived model info ──────────────────────────────────────────────────+ const selectedModel = lipsyncModels.find((m) => m.id === selectedModelId);+ const resolutionOptions = getResolutionsForLipSyncModel(selectedModelId);+ const showResolution = resolutionOptions.length > 0;+ const showPrompt = !!selectedModel?.hasPrompt;++ // ── Sync model when mode changes ────────────────────────────────────────+ useEffect(() => {+ if (hasRestored.current) return;+ const models =+ inputMode === "image" ? imageLipSyncModels : videoLipSyncModels;+ const first = models[0];+ if (!first) return;+ setSelectedModelId(first.id);+ setSelectedResolution(first.inputs?.resolution?.default ?? "480p");+ }, [inputMode]);++ // ── Upload handlers ─────────────────────────────────────────────────────+ const handleImageUpload = useCallback(+ async (file) => {+ if (file.size > 10 * 1024 * 1024) {+ alert("Image exceeds 10MB limit.");+ return;+ }+ setImageState(UPLOAD_STATE.UPLOADING);+ setImageProgress(0);+ try {+ const url = await uploadFile(apiKey, file, (pct) => {+ setImageProgress(pct);+ });+ setImageUrl(url);+ setImageName(file.name);+ setImageState(UPLOAD_STATE.READY);+ } catch (err) {+ setImageState(UPLOAD_STATE.IDLE);+ alert(`Image upload failed: ${err.message}`);+ } finally {+ setImageProgress(0);+ }+ },+ [apiKey],+ );++ const handleVideoPick = useCallback(+ async (file) => {+ if (file.size > 50 * 1024 * 1024) {+ alert("Video exceeds 50MB limit.");+ return;+ }+ setVideoState(UPLOAD_STATE.UPLOADING);+ setVideoProgress(0);+ try {+ const url = await uploadFile(apiKey, file, (pct) => {+ setVideoProgress(pct);+ });+ setVideoUrl(url);+ setVideoName(file.name);+ setVideoState(UPLOAD_STATE.READY);+ } catch (err) {+ setVideoState(UPLOAD_STATE.IDLE);+ alert(`Video upload failed: ${err.message}`);+ } finally {+ setVideoProgress(0);+ }+ },+ [apiKey],+ );++ const handlePromptInput = (e) => {+ setPrompt(e.target.value);+ };++ const handleAudioPick = useCallback(+ async (file) => {+ if (file.size > 10 * 1024 * 1024) {+ alert("Audio file exceeds 10MB limit.");+ return;+ }+ setAudioState(UPLOAD_STATE.UPLOADING);+ setAudioProgress(0);+ try {+ const url = await uploadFile(apiKey, file, (pct) => {+ setAudioProgress(pct);+ });+ setAudioUrl(url);+ setAudioName(file.name);+ setAudioState(UPLOAD_STATE.READY);+ } catch (err) {+ setAudioState(UPLOAD_STATE.IDLE);+ alert(`Audio upload failed: ${err.message}`);+ } finally {+ setAudioProgress(0);+ }+ },+ [apiKey],+ );++ // ── Handle Dropped Files ────────────────────────────────────────────────+ useEffect(() => {+ if (droppedFiles && droppedFiles.length > 0) {+ const imageFiles = droppedFiles.filter(f => f.type.startsWith('image/'));+ const videoFiles = droppedFiles.filter(f => f.type.startsWith('video/'));+ const audioFiles = droppedFiles.filter(f => f.type.startsWith('audio/'));++ if (audioFiles.length > 0) {+ handleAudioPick(audioFiles[0]);+ } else if (videoFiles.length > 0) {+ switchToVideo();+ handleVideoPick(videoFiles[0]);+ } else if (imageFiles.length > 0) {+ switchToImage();+ handleImageUpload(imageFiles[0]);+ }+ onFilesHandled?.();+ }+ }, [droppedFiles, onFilesHandled, handleAudioPick, handleVideoPick, handleImageUpload]);++ // ── Mode toggle ─────────────────────────────────────────────────────────+ const switchToImage = () => {+ if (inputMode === "image") return;+ setInputMode("image");+ setVideoUrl(null);+ setVideoState(UPLOAD_STATE.IDLE);+ setVideoName("");+ const first = imageLipSyncModels[0];+ if (first) {+ setSelectedModelId(first.id);+ setSelectedResolution(first.inputs?.resolution?.default ?? "480p");+ }+ };++ const switchToVideo = () => {+ if (inputMode === "video") return;+ setInputMode("video");+ setImageUrl(null);+ setImageState(UPLOAD_STATE.IDLE);+ setImageName("");+ const first = videoLipSyncModels[0];+ if (first) {+ setSelectedModelId(first.id);+ setSelectedResolution(first.inputs?.resolution?.default ?? "480p");+ }+ };++ // ── Model selection ─────────────────────────────────────────────────────+ const handleModelSelect = (model) => {+ setSelectedModelId(model.id);+ const resolutions = getResolutionsForLipSyncModel(model.id);+ if (resolutions.length > 0) {+ setSelectedResolution(+ model.inputs?.resolution?.default ?? resolutions[0],+ );+ }+ };++ // ── History helpers ─────────────────────────────────────────────────────+ const addToInternalHistory = useCallback((entry) => {+ setInternalHistory((prev) => [entry, ...prev].slice(0, 30));+ }, []);++ const downloadFile = async (url, filename) => {+ try {+ const response = await fetch(url);+ const blob = await response.blob();+ const blobUrl = URL.createObjectURL(blob);+ const a = document.createElement("a");+ a.href = blobUrl;+ a.download = filename;+ document.body.appendChild(a);+ a.click();+ document.body.removeChild(a);+ URL.revokeObjectURL(blobUrl);+ } catch {+ window.open(url, "_blank");+ }+ };++ // ── Generation ──────────────────────────────────────────────────────────+ const handleGenerate = async () => {+ if (!audioUrl) {+ alert("Please upload an audio file first.");+ return;+ }+ if (inputMode === "image" && !imageUrl) {+ alert("Please upload a portrait image first.");+ return;+ }+ if (inputMode === "video" && !videoUrl) {+ alert("Please upload a source video first.");+ return;+ }++ onGenerationStart?.();+ setIsGenerating(true);+ setGenerateError(null);++ try {+ const lipsyncParams = {+ model: selectedModelId,+ audio_url: audioUrl,+ };+ if (inputMode === "image") lipsyncParams.image_url = imageUrl;+ else lipsyncParams.video_url = videoUrl;+ if (prompt && selectedModel?.hasPrompt) lipsyncParams.prompt = prompt;+ if (showResolution) lipsyncParams.resolution = selectedResolution;+ if (selectedModel?.hasSeed) lipsyncParams.seed = -1;++ const res = await processLipSync(apiKey, lipsyncParams);++ if (!res?.url) throw new Error("No video URL returned by API");++ const genId = res.id || Date.now().toString();+ const entry = {+ id: genId,+ url: res.url,+ prompt,+ model: selectedModelId,+ timestamp: new Date().toISOString(),+ };++ if (!historyItems) addToInternalHistory(entry);++ setActiveResultUrl(res.url);+ setActiveHistoryIdx(0);+ setView("result");++ if (onGenerationComplete) {+ onGenerationComplete({+ url: res.url,+ model: selectedModelId,+ prompt,+ type: "lipsync",+ });+ }+ } catch (e) {+ console.error("[LipSyncStudio]", e);+ const errMsg = formatErrorMessage(e, "Lip sync generation failed");+ if (onGenerationError) onGenerationError(errMsg);+ else toast.error(errMsg);+ } finally {+ setIsGenerating(false);+ onGenerationEnd?.();+ }+ };++ // ── Reset to input view ─────────────────────────────────────────────────+ const handleNew = () => {+ setView("input");+ setActiveResultUrl(null);+ setPrompt("");+ setImageUrl(null);+ setImageState(UPLOAD_STATE.IDLE);+ setImageName("");+ setVideoUrl(null);+ setVideoState(UPLOAD_STATE.IDLE);+ setVideoName("");+ setAudioUrl(null);+ setAudioState(UPLOAD_STATE.IDLE);+ setAudioName("");+ };++ // ── Media status labels ─────────────────────────────────────────────────+ const mediaStatusText =+ inputMode === "image"+ ? imageState === UPLOAD_STATE.READY+ ? `✓ ${imageName}`+ : "No image"+ : videoState === UPLOAD_STATE.READY+ ? `✓ ${videoName}`+ : "No video";+ const mediaStatusClass =+ (inputMode === "image" ? imageState : videoState) === UPLOAD_STATE.READY+ ? "text-primary"+ : "text-muted";++ const audioStatusText =+ audioState === UPLOAD_STATE.READY ? `✓ ${audioName}` : "No audio";+ const audioStatusClass =+ audioState === UPLOAD_STATE.READY ? "text-primary" : "text-muted";++ const hasHistory = history.length > 0;++ // ── Dropdown item lists ─────────────────────────────────────────────────+ const modelDropdownItems = currentModels;+ const resolutionDropdownItems = resolutionOptions.map((r) => ({+ id: r,+ name: r,+ }));++ // ── Render ──────────────────────────────────────────────────────────────+ return (+ <div className="w-full h-full flex flex-col items-center justify-center bg-app-bg relative overflow-hidden">++ {/* ── CENTRAL GALLERY AREA ── */}+ <div className="flex-1 w-full max-w-7xl mx-auto overflow-y-auto custom-scrollbar pb-40 lg:pb-32 px-2">+ {history.length > 0 ? (+ <div className="grid grid-cols-1 md:grid-cols-2 lg:grid-cols-3 gap-6 w-full pt-4 animate-fade-in-up">+ {history.map((entry, idx) => (+ <div+ key={entry.id || idx}+ className="relative group rounded-2xl overflow-hidden border border-white/10 bg-[#0a0a0a] shadow-xl hover:border-primary/50 transition-all duration-300 flex flex-col"+ >+ <video+ src={entry.url}+ className="w-full aspect-video object-cover bg-black/40 cursor-pointer hover:opacity-80 transition-opacity"+ onClick={() => setFullscreenUrl(entry.url)}+ controls={false}+ loop+ muted+ playsInline+ onMouseOver={(e) => e.target.play()}+ onMouseOut={(e) => {+ e.target.pause();+ e.target.currentTime = 0;+ }}+ />++ {/* Overlay actions */}+ <div className="absolute top-2 right-2 flex flex-col gap-2 opacity-0 group-hover:opacity-100 transition-opacity">+ <button+ type="button"+ title="Fullscreen"+ onClick={(e) => {+ e.stopPropagation();+ setFullscreenUrl(entry.url);+ }}+ className="p-2 bg-black/60 backdrop-blur-md rounded-full text-white hover:bg-primary hover:text-black transition-all border border-white/10"+ >+ <svg width="14" height="14" viewBox="0 0 24 24" fill="none" stroke="currentColor" strokeWidth="2.5">+ <polyline points="15 3 21 3 21 9" />+ <polyline points="9 21 3 21 3 15" />+ <line x1="21" y1="3" x2="14" y2="10" />+ <line x1="3" y1="21" x2="10" y2="14" />+ </svg>+ </button>+ <button+ type="button"+ title="Download"+ onClick={(e) => {+ e.stopPropagation();+ downloadFile(entry.url, `lipsync-${entry.id || idx}.mp4`);+ }}+ className="p-2 bg-black/60 backdrop-blur-md rounded-full text-white hover:bg-primary hover:text-black transition-all border border-white/10"+ >+ <svg width="14" height="14" viewBox="0 0 24 24" fill="none" stroke="currentColor" strokeWidth="2.5">+ <path d="M21 15v4a2 2 0 01-2 2H5a2 2 0 01-2-2v-4M7 10l5 5 5-5M12 15V3" />+ </svg>+ </button>+ <button+ type="button"+ title="Delete"+ onClick={(e) => {+ e.stopPropagation();+ if (confirm("Are you sure you want to delete this generated item?")) {+ setInternalHistory(prev => prev.filter((_, i) => i !== idx));+ }+ }}+ className="p-2 bg-black/60 backdrop-blur-md rounded-full text-red-400 hover:bg-red-500 hover:text-white transition-all border border-white/10"+ >+ <svg width="14" height="14" viewBox="0 0 24 24" fill="none" stroke="currentColor" strokeWidth="2.5">+ <polyline points="3 6 5 6 21 6" />+ <path d="M19 6v14a2 2 0 01-2 2H7a2 2 0 01-2-2V6m3 0V4a2 2 0 012-2h4a2 2 0 012 2v2" />+ <line x1="10" y1="11" x2="10" y2="17" />+ <line x1="14" y1="11" x2="14" y2="17" />+ </svg>+ </button>+ </div>++ {/* Details */}+ <div className="p-3 bg-black/80 backdrop-blur-sm border-t border-white/5 flex-1 flex flex-col justify-between gap-2">+ {entry.prompt && (+ <p className="text-white/70 text-xs line-clamp-2 leading-relaxed" title={entry.prompt}>+ {entry.prompt}+ </p>+ )}+ <div className="flex items-center justify-between flex-wrap gap-1 mt-1">+ <div className="flex items-center gap-2">+ <span className="text-[10px] font-bold text-primary px-2 py-0.5 bg-primary/10 rounded border border-primary/20 whitespace-nowrap">+ Lip Sync+ </span>+ {entry.resolution && (+ <span className="text-[10px] text-white/40">{entry.resolution}</span>+ )}+ </div>+ {entry.prompt && (+ <button+ type="button"+ onClick={(e) => {+ e.stopPropagation();+ navigator.clipboard.writeText(entry.prompt);+ const btn = e.currentTarget;+ btn.innerText = "Copied!";+ setTimeout(() => { btn.innerText = "Copy"; }, 2000);+ }}+ className="px-2 py-0.5 bg-white/5 hover:bg-primary/20 hover:text-primary rounded text-[10px] font-medium text-white/70 transition-all border border-white/10"+ title="Copy prompt"+ >+ Copy Prompt+ </button>+ )}+ </div>+ </div>+ </div>+ ))}+ </div>+ ) : (+ <div className="flex flex-col items-center justify-center h-full animate-fade-in-up transition-all duration-700 min-h-[50vh]">+ {/* Overlapping floating cards */}+ <div className="flex items-center justify-center gap-1.5 md:gap-3 mb-10 select-none scale-90 sm:scale-100">+ <div className="w-18 h-22 sm:w-24 sm:h-28 rounded-2xl border border-white/10 shadow-2xl -rotate-[12deg] transform hover:rotate-0 hover:scale-110 hover:z-20 transition-all duration-300 overflow-hidden bg-white/[0.01] flex-shrink-0">+ <img+ src="https://d3adwkbyhxyrtq.cloudfront.net/webassets/videomodels/sdxl-image.avif"+ alt="Creative asset 1"+ className="w-full h-full object-cover"+ />+ </div>+ <div className="w-18 h-22 sm:w-24 sm:h-28 rounded-2xl border border-white/10 shadow-2xl -rotate-[4deg] transform hover:rotate-0 hover:scale-110 hover:z-20 transition-all duration-300 overflow-hidden bg-white/[0.01] -ml-3 sm:-ml-4 flex-shrink-0">+ <img+ src="https://d3adwkbyhxyrtq.cloudfront.net/webassets/videomodels/chroma-image.avif"+ alt="Creative asset 2"+ className="w-full h-full object-cover"+ />+ </div>+ <div className="w-18 h-18 sm:w-24 sm:h-24 rounded-full border border-white/10 shadow-2xl rotate-[6deg] transform hover:rotate-0 hover:scale-110 hover:z-20 transition-all duration-300 overflow-hidden bg-white/[0.01] -ml-3 sm:-ml-4 flex-shrink-0">+ <img+ src="https://d3adwkbyhxyrtq.cloudfront.net/webassets/videomodels/neta-lumina.avif"+ alt="Creative asset 3"+ className="w-full h-full object-cover"+ />+ </div>+ <div className="w-18 h-22 sm:w-24 sm:h-28 rounded-2xl border border-white/10 shadow-2xl rotate-[12deg] transform hover:rotate-0 hover:scale-110 hover:z-20 transition-all duration-300 overflow-hidden bg-white/[0.01] -ml-3 sm:-ml-4 flex-shrink-0">+ <img+ src="https://d3adwkbyhxyrtq.cloudfront.net/webassets/videomodels/perfect-pony-xl.avif"+ alt="Creative asset 4"+ className="w-full h-full object-cover"+ />+ </div>+ </div>++ <h1 className="text-2xl sm:text-4xl md:text-5xl font-extrabold tracking-tight mb-4 text-center px-4 flex flex-col items-center">+ <span className="text-white font-black uppercase text-xl sm:text-3xl tracking-wide mb-1 opacity-90">START CREATING WITH</span>+ <span className="text-[#22d3ee] font-black uppercase text-2xl sm:text-4xl sm:mt-1 tracking-tight">+ LIP SYNC STUDIO+ </span>+ </h1>+ <p className="text-white/40 text-xs sm:text-sm font-medium tracking-wide text-center max-w-lg leading-relaxed px-4">+ Sync any voice with any face video to create premium talking avatars and videos.+ </p>+ </div>+ )}+ </div>++ {/* ── BOTTOM PROMPT BAR ── */}+ <PromptComposer>+ {/* Mode toggle row */}+ <div className="flex items-center px-1">+ <PromptSegmentedControl>+ <PromptSegmentOption+ type="button"+ onClick={switchToImage}+ selected={inputMode === "image"}+ >+ <svg width="13" height="13" viewBox="0 0 24 24" fill="none" stroke="currentColor" strokeWidth="2" aria-hidden="true">+ <rect x="3" y="3" width="18" height="18" rx="2" />+ <circle cx="8.5" cy="8.5" r="1.5" />+ <path d="m21 15-5-5L5 21" />+ </svg>+ Portrait Image+ </PromptSegmentOption>+ <PromptSegmentOption+ type="button"+ onClick={switchToVideo}+ selected={inputMode === "video"}+ >+ <svg width="13" height="13" viewBox="0 0 24 24" fill="none" stroke="currentColor" strokeWidth="2" aria-hidden="true">+ <rect x="2" y="5" width="15" height="14" rx="2" />+ <path d="m17 10 5-3v10l-5-3" />+ </svg>+ Video+ </PromptSegmentOption>+ </PromptSegmentedControl>+ </div>++ {/* Uploads row */}+ <div className="flex items-center gap-2 px-1">+ <div className="flex items-center gap-2">+ {/* Image picker — only in image mode */}+ {inputMode === "image" && (+ <MediaPickerButton+ accept="image/*"+ label="Image"+ icon={+ <svg+ width="16"+ height="16"+ viewBox="0 0 24 24"+ fill="none"+ stroke="currentColor"+ strokeWidth="2"+ className="text-white/40 group-hover:text-[#22d3ee] transition-colors"+ >+ <rect x="3" y="3" width="18" height="18" rx="2" ry="2" />+ <circle cx="8.5" cy="8.5" r="1.5" />+ <polyline points="21 15 16 10 5 21" />+ </svg>+ }+ onUpload={handleImageUpload}+ onClear={() => {+ setImageUrl(null);+ setImageState(UPLOAD_STATE.IDLE);+ setImageName("");+ }}+ uploadState={imageState}+ progress={imageProgress}+ fileName={imageName}+ previewUrl={imageUrl}+ isVideo={false}+ apiKey={apiKey}+ />+ )}++ {/* Video picker — only in video mode */}+ {inputMode === "video" && (+ <MediaPickerButton+ accept="video/*"+ label="Video"+ icon={+ <VideoIcon className="text-white/40 group-hover:text-[#22d3ee] transition-colors" />+ }+ onUpload={handleVideoPick}+ onClear={() => {+ setVideoUrl(null);+ setVideoState(UPLOAD_STATE.IDLE);+ setVideoName("");+ }}+ uploadState={videoState}+ progress={videoProgress}+ fileName={videoName}+ previewUrl={videoUrl}+ isVideo={true}+ apiKey={apiKey}+ />+ )}++ {/* Audio picker — always visible */}+ <MediaPickerButton+ accept="audio/*"+ label="Audio"+ icon={+ <MicIcon className="text-white/40 group-hover:text-[#22d3ee] transition-colors" />+ }+ onUpload={handleAudioPick}+ onClear={() => {+ setAudioUrl(null);+ setAudioState(UPLOAD_STATE.IDLE);+ setAudioName("");+ }}+ uploadState={audioState}+ progress={audioProgress}+ fileName={audioName}+ previewUrl={null}+ isVideo={false}+ apiKey={apiKey}+ />+ </div>++ {/* Prompt textarea */}+ <div className="flex-1 flex flex-col">+ <PromptTextarea+ ref={textareaRef}+ value={prompt}+ onChange={handlePromptInput}+ placeholder="Describe speech style..."+ />+ </div>+ </div>++ {/* Bottom controls row */}+ <PromptFooter>+ <PromptControls>+ {/* Model selector */}+ <div className="relative">+ <button+ ref={modelBtnRef}+ type="button"+ onClick={(e) => {+ e.stopPropagation();+ setOpenDropdown(+ openDropdown === "model" ? null : "model",+ );+ }}+ className={promptControlClassName({+ active: openDropdown === "model",+ })}+ >+ <div className="w-3.5 h-3.5 bg-[#22d3ee] rounded-sm flex items-center justify-center">+ <span className="text-[9px] font-black text-black">+ S+ </span>+ </div>+ <span className={PROMPT_CONTROL_LABEL_CLASS}>+ {selectedModel?.name ?? "Select model"}+ </span>+ <PromptChevronIcon />+ </button>+ <Dropdown+ isOpen={openDropdown === "model"}+ title="Model"+ items={modelDropdownItems}+ selectedId={selectedModelId}+ onSelect={handleModelSelect}+ onClose={() => setOpenDropdown(null)}+ anchorRef={modelBtnRef}+ className="w-80 max-w-[calc(100vw-3rem)]"+ />+ </div>++ {/* Resolution selector */}+ {showResolution && (+ <div className="relative">+ <button+ ref={resolutionBtnRef}+ type="button"+ onClick={(e) => {+ e.stopPropagation();+ setOpenDropdown(+ openDropdown === "resolution" ? null : "resolution",+ );+ }}+ className={promptControlClassName({+ active: openDropdown === "resolution",+ })}+ >+ <PromptQualityIcon />+ <span className={PROMPT_CONTROL_LABEL_CLASS}>+ {selectedResolution}+ </span>+ </button>+ <Dropdown+ isOpen={openDropdown === "resolution"}+ title="Resolution"+ items={resolutionDropdownItems}+ selectedId={selectedResolution}+ onSelect={(item) => setSelectedResolution(item.id)}+ onClose={() => setOpenDropdown(null)}+ anchorRef={resolutionBtnRef}+ />+ </div>+ )}+ </PromptControls>++ {/* Generate button */}+ <PromptAction+ onClick={handleGenerate}+ disabled={isGenerating}+ >+ {isGenerating ? (+ <>+ <span className="animate-spin inline-block text-black">+ ◌+ </span>{" "}+ Generating...+ </>+ ) : (+ <>+ <span>Sync Lip</span>+ </>+ )}+ </PromptAction>+ </PromptFooter>+ </PromptComposer>++ {/* ── FULLSCREEN MEDIA MODAL ── */}+ {fullscreenUrl && (+ <div+ className="fixed inset-0 z-[100] flex items-center justify-center bg-black/95 backdrop-blur-sm animate-fade-in"+ onClick={() => setFullscreenUrl(null)}+ >+ <button+ type="button"+ className="absolute top-6 right-6 p-3 bg-white/10 hover:bg-white/20 rounded-full text-white transition-colors border border-white/10"+ onClick={(e) => {+ e.stopPropagation();+ setFullscreenUrl(null);+ }}+ >+ <svg width="24" height="24" viewBox="0 0 24 24" fill="none" stroke="currentColor" strokeWidth="2.5" strokeLinecap="round" strokeLinejoin="round">+ <line x1="18" y1="6" x2="6" y2="18" />+ <line x1="6" y1="6" x2="18" y2="18" />+ </svg>+ </button>+ <video+ src={fullscreenUrl}+ controls+ autoPlay+ loop+ className="max-w-[95vw] max-h-[95vh] rounded-2xl shadow-2xl object-contain animate-scale-up"+ onClick={(e) => e.stopPropagation()}+ />+ </div>+ )}+ <Toaster position="top-right" containerStyle={{ zIndex: 99999 }} toastOptions={{ duration: 5000, style: { background: '#18181b', color: '#ffffff', border: '1px solid rgba(255,255,255,0.15)', fontSize: '13px', borderRadius: '12px', boxShadow: '0 10px 30px rgba(0,0,0,0.6)', maxWidth: '440px', wordBreak: 'break-word', whiteSpace: 'pre-wrap', padding: '12px 16px' } }} />+ </div>+ );+}diff --git a/packages/studio/src/components/MarketingStudio.jsx b/packages/studio/src/components/MarketingStudio.jsxindex 8756bba7..2c5bcf79 100644--- a/packages/studio/src/components/MarketingStudio.jsx+++ b/packages/studio/src/components/MarketingStudio.jsx@@ -373,4 +373,584 @@ export default function MarketingStudio({if (target === 'product') setProductImage(url);else setAvatarImage(url);} catch (err) { alert(err.message); }- }�nw����k�w��@����������͕����ѥ����%����̡mt��(���������������������(��������������������(������������������(����������������((��������������켨��ɵ�Ё ��ѽ�����(��������������������9����ɕ��ѥٔ��(�������������������ѽ�(�������������������� �����졔�����쁔��ѽ�Aɽ����ѥ�����͕�ɽ���ݸ��ɽ���ݸ����ɵ�М����ձ��耝��ɵ�М����(�����������������������9������ɽ��� ���ɽ� ����9�����(����������������������ѥٔ聑ɽ���ݸ����ɵ�Ј�(���������������������(�����������������(������������������������9����ܴЁ��Ё����ɥ�������ɽչ����������ѕ�̵���ѕȁ���ѥ�䵍��ѕȁ��ɑ�ȁ��ɑ�ȵ�ɥ��������(�������������������������������9����ѕ�еl���t����е������ѕ�е�ɥ��������ɍ�͔��T������(��������������������(�����������������������������9�����AI=5AQ} =9QI=1}1 1} 1MM�����Ʌ�̹��ɵ���������(�������������������Aɽ��� ���ɽ�%������(�������������������ѽ��(�����������������ɽ���ݸ�(��������������������=�����ɽ���ݸ����ɵ�Н�(������������������ѥѱ��Y������ɵ�ЁAɕ͕�̈(�������������������ѕ����MMQL�՝��(������������������͕���ѕ�%�����Ʌ�̹��ɵ���(��������������������M������졥ѕ������͕�A�Ʌ�̡쀸����Ʌ�̰���ɵ��聥ѕ��������٥���Uɰ聥ѕ���ɰ����(�������������������� ��͔�젤����͕�ɽ���ݸ��ձ���(��������������������Y����(������������������(����������������((��������������켨�مхȁAɕ͕Ё ��ѽ�����(��������������������9����ɕ��ѥٔ�������ѕ�̵���ѕȁ����ĸԈ�(�������������������ѽ�(�������������������� �����졔�����쁔��ѽ�Aɽ����ѥ�����͕�ɽ���ݸ��ɽ���ݸ���مхȜ����ձ��耝�مхȜ����(�����������������������9������ɽ��� ���ɽ� ����9�����(����������������������ѥٔ聑ɽ���ݸ���مхȈ�(���������������������(�����������������(������������������������9����ܴЁ��Ёɽչ�����ձ���ٕə��ܵ���������ɑ�ȁ��ɑ�ȵݡ�є����͡���ܵ����Ȉ�(����������������������Ɍ��مх�%��������MMQL��مх�l�t��ɱ���9����ܵ�ձ�����ձ�������е��ٕȈ���(��������������������(�����������������������������9�����AI=5AQ} =9QI=1}1 1} 1MM��(���������������������MMQL��مхȹ�������������ɰ����مх�%����������������M����Ёمхȉ�(������������������������(�������������������Aɽ��� ���ɽ�%������(�������������������ѽ��((�����������������مх�%���������(���������������������ѽ�(���������������������������ѽ��(��������������������ѥѱ�����ɝ��͕���ѕ���مхȈ(���������������������� �����졔������(�������������������������ѽ�Aɽ����ѥ�����(��������������������������Ё���ɕ��مхȀ�MMQL��مхȹ�������������ɰ����مх�%������(�����������������������������ɕ��مхȤ��(������������������������͕�Aɕ٥��مхȡ���ɕ��مхȤ�(����������������������͔��(������������������������͕�Aɕ٥��مхȡ쁥�耉���ѽ��������耉 ��ѽ��U��������مхȈ���ɰ聅مх�%��������(�����������������������(����������������������(�������������������������9������ɽ��� ���ɽ� ����9�����(��������������������������=������Ք�(���������������������������9���耉ѕ�еݡ�є������ٕ��ѕ�еl��ɐ͕�t��(�����������������������(�������������������(����������������������ٜ�ݥ�Ѡ��Ј���������Ј�٥�� ��������Ѐ�Ј�����������ɽ�����ɕ�� ���Ȉ���ɽ��]��Ѡ�ȸԈ�(�����������������������ɍ�������Ĉ�����Ĉ��������(����������������������������Ĉ�����Ĉ�����ظ�Ԉ�����ظ�Ԉ���(����������������������������Ĉ�����������Ĉ�����Ј���(����������������������������������Ĉ�����Ј�����Ĉ���(����������������������ٜ�(���������������������ѽ��(������������������((�����������������ɽ���ݸ�(��������������������=�����ɽ���ݸ���مхȝ�(������������������ѥѱ��مхȁAɕ͕�̈(�������������������ѕ����MMQL��مх��(������������������͕���ѕ�%���مх�%�����(��������������������M������졥ѕ������͕�مх�%������ѕ���ɰ��(��������������������Aɕ٥���졥ѕ������͕�Aɕ٥��مхȡ�ѕ���(�������������������� ��͔�젤����͕�ɽ���ݸ��ձ���(������������������(����������������((��������������켨�M������ ���ɽ�̀���(���������������l�Ʌѥ�����ɕ̜�����Ʌѥ���t������������(����������������������������9����ɕ��ѥٔ��(���������������������ѽ�(���������������������� �����졔�����쁔��ѽ�Aɽ����ѥ�����͕�ɽ���ݸ��ɽ���ݸ�������ձ��聭�����(�������������������������9������ɽ��� ���ɽ� ����9�����(������������������������ѥٔ聑ɽ���ݸ����(���������������������������9����(�������������������������ɽ���ݸ����(�����������������������������ѕ�е�́���е͕�������ѕ�еl��ɐ͕�t�(��������������������������耉ѕ�е�́���е͕�������ѕ�еݡ�є�����(�����������������������(�������������������(���������������������������Ʌѥ������(�����������������������Aɽ��������I�ѥ�%������(����������������������聭�����ɕ̈����(�����������������������Aɽ���EՅ����%������(����������������������耠(�����������������������Aɽ����Ʌѥ��%������(����������������������(�������������������������������9�����AI=5AQ} =9QI=1}1 1} 1MM��(�����������������������������Ʌѥ�����������Ʌ��m���u�̀����Ʌ��m���u�(��������������������������(���������������������ѽ��(�������������������M�����ɽ���ݸ�(����������������������=�����ɽ���ݸ�����(��������������������ѥѱ���(����������������������������Ʌѥ��(�������������������������������ЁI�ѥ��(������������������������聭�����ɕ̈(�����������������������������I�ͽ��ѥ���(��������������������������耉�Ʌѥ���(���������������������(����������������������ѥ�����=AQ%=9Mm���u�(��������������������͕���ѕ�����Ʌ��m���u�(����������������������M�������م������͕�A�Ʌ�̡쀸����Ʌ�̰�m���t�م�����(���������������������� ��͔�젤����͕�ɽ���ݸ��ձ���(��������������������(������������������(�����������������(�������������Aɽ��� ���ɽ���((�������������Aɽ����ѥ��(���������������� ���������������Ʌѕ�(����������������ͅ�����������Ʌѥ���(�������������(��������������������Ʌѥ������(������������������(�����������������������������9������є�������������������ѕ�е��������^0������(���������������������Ʌѥ�����(������������������(����������������耠(����������������������1�չ��������(����������������(�������������Aɽ����ѥ���(�����������Aɽ�����ѕ��(�������Aɽ��� ����͕��((������켨�ձ�͍ɕ���Aɕ٥�܀���(�������ձ�͍ɕ��Uɰ�����(��������������9���ᕐ���͕д���l���t�������ѕ�̵���ѕȁ���ѥ�䵍��ѕȁ����������ԁ�����ɽ�����ȵʹ������є������������ �����젤����͕�ձ�͍ɕ��Uɰ��ձ����(�������������ѽ�������9���ͽ��є�ѽ��ɥ��д��́���ݡ�є������ٕ�鉜�ݡ�є����ɽչ�����ձ��ѕ�еݡ�є���ɑ�ȁ��ɑ�ȵݡ�є�����Ʌ�ͥѥ��������́͡���ܴ�ᰈ�� ��͕Mٜ������ѽ��(�����������٥�����Ɍ��ձ�͍ɕ��Uɱ��ɽ�́��ѽA��䁍����9����ܵl����t���ൠ�l��١t�ɽչ�������͡���ܴ�ᰁ�����є�͍���������� �����픀������ѽ�Aɽ����ѥ������(����������(��������((������켨��R�R �YQH�U11M I8�AIY%\�5=0��R�R ����(��������ɕ٥��مхȀ����(����������(���������������9���ᕐ���͕д���l���t�������ѕ�̵���ѕȁ���ѥ�䵍��ѕȁ�����������������ɽ�����ȵ��������є���������͕���е�����(������������ �����젤����͕�Aɕ٥��مхȡ�ձ���(���������(����������켨� ��͔����ѽ����ɽ�̤����ѡ��ɥ��Ё��ɹ�Ȁ���(�������������ѽ�(�������������������ѽ��(�����������������9���ͽ��є�ѽ��ɥ��д��́���ݡ�є������ٕ�鉜�ݡ�є����ɽչ�����ձ��ѕ�еݡ�є��Ʌ�ͥѥ��������́��ɑ�ȁ��ɑ�ȵݡ�є�������������є���������(�������������� �����졔������(�����������������ѽ�Aɽ����ѥ�����(��������������͕�Aɕ٥��مхȡ�ձ���(��������������(�����������(������������� ��͕Mٜ���(�������������ѽ��((����������켨�%����Ё�幅���� ML������ѥ������Ʌ��̀���(�������������屔��(���������������Ʌ��́ͱ����������Ё�(������������������(�����������������Ʌ�͙�ɴ��Ʌ�ͱ�ѕ`����ँ͍�������Ԥ�(�������������������ѕ�聉��Ƞ����(����������������������������(���������������(��������������������(�����������������Ʌ�͙�ɴ��Ʌ�ͱ�ѕ`����͍����Ĥ�(�������������������ѕ�聉��Ƞ���(��������������������������(���������������(�������������(���������������Ʌ��́ͱ��������ɕ�(������������������(�����������������Ʌ�͙�ɴ��Ʌ�ͱ�ѕ`�����ँ͍�������Ԥ�(�������������������ѕ�聉��Ƞ����(����������������������������(���������������(��������������������(�����������������Ʌ�͙�ɴ��Ʌ�ͱ�ѕ`����͍����Ĥ�(�������������������ѕ�聉��Ƞ���(��������������������������(���������������(�������������(������������������є�ͱ�������Ё�(�������������������ѥ���ͱ����������Ѐ����́�Չ�����饕Ƞ���ذ�İ���̰�Ĥ����݅ɑ��(�������������(������������������є�ͱ�����ɕ�(�������������������ѥ���ͱ��������ɕ����́�Չ�����饕Ƞ���ذ�İ���̰�Ĥ����݅ɑ��(�������������(���������������屔�((����������켨�1��Ё�ɽ܁ ��ѽ�����(������������ɕ٥��مхȹ�������ѽ�������(���������������ѽ�(���������������������ѽ��(�������������������9���ͽ��є����д��Ё���ݡ�є�ԁ��ٕ�鉜�ݡ�є������ٕ��ѕ�е�ɥ����ɽչ�����ձ��ѕ�еݡ�є��Ʌ�ͥѥ���������ɑ�ȁ��ɑ�ȵݡ�є��������(���������������� �����졔������(�������������������ѽ�Aɽ����ѥ�����(��������������������Ё���ɕ��%������MMQL��مхȹ����%���ࡄ�������������ɕ٥��مхȹ����(�����������������������ɕ��%��������Ĥ��(����������������������Ё�ɕ�مхȀ�MMQL��مх�l����ɕ��%�������Ā��MMQL��مхȹ����Ѡ����MMQL��مхȹ����ѡt�(������������������͕�M�����ɕ�ѥ�����ɕ؈��(������������������͕�Aɕ٥��مхȡ�ɕ�مхȤ�(�����������������(����������������(�������������(����������������ٜ�ݥ�Ѡ��Ј���������Ј�٥�� ��������Ѐ�Ј�����������ɽ�����ɕ�� ���Ȉ���ɽ��]��Ѡ�̈���ɽ��1�������ɽչ�����ɽ��1��������ɽչ���(��������������������履�����������Ԁ�����Ȁ�Ԁ؈���(����������������ٜ�(���������������ѽ��(������������((����������켨�I���Ё�ɽ܁ ��ѽ�����(������������ɕ٥��مхȹ�������ѽ�������(���������������ѽ�(���������������������ѽ��(�������������������9���ͽ��є�ɥ��д��Ё���ݡ�є�ԁ��ٕ�鉜�ݡ�є������ٕ��ѕ�е�ɥ����ɽչ�����ձ��ѕ�еݡ�є��Ʌ�ͥѥ���������ɑ�ȁ��ɑ�ȵݡ�є��������(���������������� �����졔������(�������������������ѽ�Aɽ����ѥ�����(��������������������Ё���ɕ��%������MMQL��مхȹ����%���ࡄ�������������ɕ٥��مхȹ����(�����������������������ɕ��%��������Ĥ��(����������������������Ё����مхȀ�MMQL��مх�l����ɕ��%�������Ĥ���MMQL��مхȹ����ѡt�(������������������͕�M�����ɕ�ѥ�������Ј��(������������������͕�Aɕ٥��مхȡ����مхȤ�(�����������������(����������������(�������������(����������������ٜ�ݥ�Ѡ��Ј���������Ј�٥�� ��������Ѐ�Ј�����������ɽ�����ɕ�� ���Ȉ���ɽ��]��Ѡ�̈���ɽ��1�������ɽչ�����ɽ��1��������ɽչ���(��������������������履���������������Ԁ�Ȁ�؈���(����������������ٜ�(���������������ѽ��(������������((����������켨����ɝ���%����� �ɐ�����ͥ����������̀���(����������������9�������ѕ�̵���ѕȁ������靅���ȁ���ܵl����t����ѥ�䵍��ѕȁɕ��ѥٔ��(������������켨�Aɕ٥��́مхȁ �ɐ��1��Ёͥ�������(��������������ɕ٥��مхȹ�������ѽ�������(����������������(������������������ �����졔������(���������������������ѽ�Aɽ����ѥ�����(����������������������Ё���ɕ��%������MMQL��مхȹ����%���ࡄ�������������ɕ٥��مхȹ����(�������������������������ɕ��%��������Ĥ��(������������������������Ё�ɕ�مхȀ�MMQL��مх�l����ɕ��%�������Ā��MMQL��مхȹ����Ѡ����MMQL��مхȹ����ѡt�(��������������������͕�M�����ɕ�ѥ�����ɕ؈��(��������������������͕�Aɕ٥��مхȡ�ɕ�مхȤ�(�������������������(������������������(���������������������9����������陱������്����ѕ�̵���ѕȁ������������ٕ�����������͍�����ԁ��ٕ��͍��������Ʌ�ͥѥ���������Ʌѥ����������ͽȵ����ѕȁ͕���е��������ܵl����t���ൠ�l��١t�ɽչ����ᰁ�ٕə��ܵ���������ɑ�ȁ��ɑ�ȵݡ�є�ԁ���l�������t����(���������������(����������������(�������������������Ɍ��MMQL��مх�l�MMQL��مхȹ����%���ࡄ�������������ɕ٥��مхȹ������Ā��MMQL��مхȹ����Ѡ����MMQL��مхȹ����ѡt��ɱ�(����������������������Aɕ٥��́مхȈ(�����������������������9����ܵ�ձ�����ձ�������е��ٕȁ�����еl̼�t�(������������������(����������������(��������������((������������켨�5�����ѥٔ�مхȁ �ɐ����(��������������(��������������������ɕ٥��مхȹ���(�������������������9�����ɕ��ѥٔ���������്����ѕ�̵���ѕȁ���ܵl����t���鵅�ܵl����t���ൠ�l��١t�������(����������������ͱ����ɕ�ѥ�������Ј���������є�ͱ�������Ј�耉�����є�ͱ�����ɕ؈(�����������������(���������������� �����졔��������ѽ�Aɽ����ѥ�����(�������������(��������������������9����ɕ��ѥٔ�ɽչ�����ᰁ�ٕə��ܵ���������ɑ�ȁ��ɑ�ȵݡ�є�������l�������t�͡���ܴ�ᰈ�(����������������(�������������������Ɍ���ɕ٥��مхȹ�ɱ�(������������������������ɕ٥��مхȹ�����(�����������������������9����ܵl����t���鵅�ܵl����t���ൠ�l��١t���鵅ൠ�l��١t������е���х���(������������������(����������������(����������������켨�=ٕɱ��ݥѠ�9�������ѡ��مхȀ���(����������������������9���ͽ��є����ѽ�������д��ɥ��д������Ʌ����еѼ�Ё�ɽ�����������٥�����������Ѽ��Ʌ����ɕ�Ё��Ё�д�����������്����ѕ�̵���ѕȁ���ѥ�䵕�������̈�(�������������������ȁ�����9����ѕ�еᰁ���е������ѕ�еݡ�є��Ʌ������ݥ�������ɍ�͔��(����������������������ɕ٥��مхȹ�����(���������������������(������������������(������������������켨�M����Ё���ѽ�����ѡ������ɝ������������(���������������������ѽ�(���������������������������ѽ��(���������������������� �����젤�����(����������������������͕�مх�%������ɕ٥��مхȹ�ɰ��(����������������������͕�Aɕ٥��مхȡ�ձ���(����������������������͕�ɽ���ݸ��ձ���(����������������������(�������������������������9����l��ɐ͕�t�ѕ�е����������ȸԁɽչ�����ձ�����е�����ѕ�еʹ���ٕ���������ԁ��ٕ��͍������ԁ��ѥٔ�͍�����ԁ�Ʌ�ͥѥ�������������ѕ�̵���ѕȁ���ѥ�䵍��ѕȁ����ĸԁ͡���ܵ���͡���ܵl��ɐ͕�t����(�������������������(��������������������� ����Mٜ���(��������������������M����Ёمх�(���������������������ѽ��(������������������(����������������(��������������((������������켨�9��Ёمхȁ �ɐ��I���Ёͥ�������(��������������ɕ٥��مхȹ�������ѽ�������(����������������(������������������ �����졔������(���������������������ѽ�Aɽ����ѥ�����(����������������������Ё���ɕ��%������MMQL��مхȹ����%���ࡄ�������������ɕ٥��مхȹ����(�������������������������ɕ��%��������Ĥ��(������������������������Ё����مхȀ�MMQL��مх�l����ɕ��%�������Ĥ���MMQL��مхȹ����ѡt�(��������������������͕�M�����ɕ�ѥ�������Ј��(��������������������͕�Aɕ٥��مхȡ����مхȤ�(�������������������(������������������(���������������������9����������陱������്����ѕ�̵���ѕȁ������������ٕ�����������͍�����ԁ��ٕ��͍��������Ʌ�ͥѥ���������Ʌѥ����������ͽȵ����ѕȁ͕���е��������ܵl����t���ൠ�l��١t�ɽչ����ᰁ�ٕə��ܵ���������ɑ�ȁ��ɑ�ȵݡ�є�ԁ���l�������t����(���������������(����������������(�������������������Ɍ��MMQL��مх�l�MMQL��مхȹ����%���ࡄ�������������ɕ٥��مхȹ������Ĥ���MMQL��مхȹ����ѡt��ɱ�(����������������������9��ЁمхȈ(�����������������������9����ܵ�ձ�����ձ�������е��ٕȁ�����еl̼�t�(������������������(����������������(��������������(������������(����������(��������(������(����)�(\ No newline at end of file+ }+ setUploadProgress(p => ({ ...p, [target]: 0 }));+ };++ const handleGenerate = async () => {+ if (!prompt.trim()) return alert("Please enter an ad script.");+ if (!productImage) return alert("Please upload a product image.");++ onGenerationStart?.();+ setIsGenerating(true);+ try {+ const result = await generateMarketingStudioAd(apiKey, {+ prompt,+ aspect_ratio: params.ratio,+ duration: params.duration,+ resolution: params.res,+ images_list: [productImage, avatarImage, ...additionalImages].filter(Boolean),+ video_files: params.videoUrl ? [params.videoUrl] : []+ });++ if (result?.url) {+ const entry = {+ id: Date.now(),+ url: result.url,+ prompt,+ format: params.format,+ timestamp: new Date().toISOString()+ };+ if (!historyItems) {+ setLocalHistory(prev => [entry, ...prev]);+ }+ setFullscreenUrl(result.url);+ onGenerationComplete?.({ url: result.url, type: "video" });+ }+ } catch (err) {+ onGenerationError?.(err.message?.slice(0, 120) || "Marketing generation failed");+ } finally {+ setIsGenerating(false);+ onGenerationEnd?.();+ }+ };++ // ── Render ─────────────────────────────────────────────────────────────────++ return (+ <div className="w-full h-full flex flex-col items-center justify-center bg-app-bg relative overflow-hidden">+ <style>{SCROLLBAR_STYLE}</style>++ {/* ── MAIN CONTENT AREA ── */}+ <div className="flex-1 w-full max-w-7xl mx-auto overflow-y-auto custom-scrollbar pb-40 lg:pb-32 px-2">+ {history.length > 0 ? (+ <div className="grid grid-cols-1 md:grid-cols-2 lg:grid-cols-3 gap-6 w-full pt-4 animate-fade-in-up">+ {history.map(entry => (+ <div key={entry.id} className="relative group rounded-lg overflow-hidden border border-white/10 bg-[#0a0a0a] shadow-xl hover:border-primary/50 transition-all duration-300 flex flex-col">+ <video+ src={entry.url}+ className="w-full aspect-video object-cover cursor-pointer hover:opacity-80 transition-opacity"+ onClick={() => setFullscreenUrl(entry.url)}+ muted loop onMouseOver={e => e.target.play()} onMouseOut={e => { e.target.pause(); e.target.currentTime = 0; }}+ />++ {/* Actions Overlay */}+ <div className="absolute top-2 right-2 flex flex-col gap-2 opacity-0 group-hover:opacity-100 transition-opacity">+ <button+ type="button"+ title="Fullscreen"+ onClick={(e) => {+ e.stopPropagation();+ setFullscreenUrl(entry.url);+ }}+ className="p-2 bg-black/60 backdrop-blur-md rounded-full text-white hover:bg-primary hover:text-black transition-all border border-white/10"+ >+ <svg width="14" height="14" viewBox="0 0 24 24" fill="none" stroke="currentColor" strokeWidth="2.5">+ <polyline points="15 3 21 3 21 9" />+ <polyline points="9 21 3 21 3 15" />+ <line x1="21" y1="3" x2="14" y2="10" />+ <line x1="3" y1="21" x2="10" y2="14" />+ </svg>+ </button>+ <button+ onClick={(e) => { e.stopPropagation(); downloadFile(entry.url, `marketing-ad-${entry.id}.mp4`); }}+ className="p-2 bg-black/60 backdrop-blur-md rounded-full text-white hover:bg-primary hover:text-black transition-all border border-white/10"+ title="Download"+ >+ <svg width="14" height="14" viewBox="0 0 24 24" fill="none" stroke="currentColor" strokeWidth="2.5">+ <path d="M21 15v4a2 2 0 01-2 2H5a2 2 0 01-2-2v-4M7 10l5 5 5-5M12 15V3" />+ </svg>+ </button>+ <button+ type="button"+ title="Delete"+ onClick={(e) => {+ e.stopPropagation();+ if (confirm("Are you sure you want to delete this generated item?")) {+ if (!historyItems) {+ setLocalHistory(prev => prev.filter(h => h.id !== entry.id));+ }+ }+ }}+ className="p-2 bg-black/60 backdrop-blur-md rounded-full text-red-400 hover:bg-red-500 hover:text-white transition-all border border-white/10"+ >+ <svg width="14" height="14" viewBox="0 0 24 24" fill="none" stroke="currentColor" strokeWidth="2.5">+ <polyline points="3 6 5 6 21 6" />+ <path d="M19 6v14a2 2 0 01-2 2H7a2 2 0 01-2-2V6m3 0V4a2 2 0 012-2h4a2 2 0 012 2v2" />+ <line x1="10" y1="11" x2="10" y2="17" />+ <line x1="14" y1="11" x2="14" y2="17" />+ </svg>+ </button>+ </div>++ <div className="p-3 bg-black/80 backdrop-blur-sm border-t border-white/5 flex items-center justify-between gap-2">+ <div className="flex items-center gap-2">+ <span className="text-[9px] font-black text-primary px-2 py-0.5 bg-primary/10 rounded border border-primary/20 uppercase tracking-tighter">+ Marketing Studio+ </span>+ {entry.format && (+ <span className="text-[9px] text-white/40 font-bold">{entry.format}</span>+ )}+ </div>+ {entry.prompt && (+ <button+ type="button"+ onClick={(e) => {+ e.stopPropagation();+ navigator.clipboard.writeText(entry.prompt);+ const btn = e.currentTarget;+ btn.innerText = "Copied!";+ setTimeout(() => { btn.innerText = "Copy Prompt"; }, 2000);+ }}+ className="px-2 py-1 bg-white/5 hover:bg-primary/20 hover:text-primary rounded text-[10px] font-medium text-white/70 transition-all border border-white/10"+ >+ Copy Prompt+ </button>+ )}+ </div>+ </div>+ ))}+ </div>+ ) : (+ <div className="flex flex-col items-center justify-center h-full animate-fade-in-up transition-all duration-700 min-h-[50vh]">+ {/* Overlapping floating cards */}+ <div className="flex items-center justify-center gap-1.5 md:gap-3 mb-10 select-none scale-90 sm:scale-100">+ <div className="w-18 h-22 sm:w-24 sm:h-28 rounded-2xl border border-white/10 shadow-2xl -rotate-[12deg] transform hover:rotate-0 hover:scale-110 hover:z-20 transition-all duration-300 overflow-hidden bg-white/[0.01] flex-shrink-0">+ <img+ src="https://d3adwkbyhxyrtq.cloudfront.net/webassets/videomodels/sdxl-image.avif"+ alt="Creative asset 1"+ className="w-full h-full object-cover"+ />+ </div>+ <div className="w-18 h-22 sm:w-24 sm:h-28 rounded-2xl border border-white/10 shadow-2xl -rotate-[4deg] transform hover:rotate-0 hover:scale-110 hover:z-20 transition-all duration-300 overflow-hidden bg-white/[0.01] -ml-3 sm:-ml-4 flex-shrink-0">+ <img+ src="https://d3adwkbyhxyrtq.cloudfront.net/webassets/videomodels/chroma-image.avif"+ alt="Creative asset 2"+ className="w-full h-full object-cover"+ />+ </div>+ <div className="w-18 h-18 sm:w-24 sm:h-24 rounded-full border border-white/10 shadow-2xl rotate-[6deg] transform hover:rotate-0 hover:scale-110 hover:z-20 transition-all duration-300 overflow-hidden bg-white/[0.01] -ml-3 sm:-ml-4 flex-shrink-0">+ <img+ src="https://d3adwkbyhxyrtq.cloudfront.net/webassets/videomodels/neta-lumina.avif"+ alt="Creative asset 3"+ className="w-full h-full object-cover"+ />+ </div>+ <div className="w-18 h-22 sm:w-24 sm:h-28 rounded-2xl border border-white/10 shadow-2xl rotate-[12deg] transform hover:rotate-0 hover:scale-110 hover:z-20 transition-all duration-300 overflow-hidden bg-white/[0.01] -ml-3 sm:-ml-4 flex-shrink-0">+ <img+ src="https://d3adwkbyhxyrtq.cloudfront.net/webassets/videomodels/perfect-pony-xl.avif"+ alt="Creative asset 4"+ className="w-full h-full object-cover"+ />+ </div>+ </div>++ <h1 className="text-2xl sm:text-4xl md:text-5xl font-extrabold tracking-tight mb-4 text-center px-4 flex flex-col items-center">+ <span className="text-white font-black uppercase text-xl sm:text-3xl tracking-wide mb-1 opacity-90">START CREATING WITH</span>+ <span className="text-[#22d3ee] font-black uppercase text-2xl sm:text-4xl sm:mt-1 tracking-tight">+ MARKETING STUDIO+ </span>+ </h1>+ <p className="text-white/40 text-xs sm:text-sm font-medium tracking-wide text-center max-w-lg leading-relaxed px-4">+ Describe your scene, upload your product, and watch high-converting AI video ads come to life.+ </p>+ </div>+ )}+ </div>++ {/* ── BOTTOM PROMPT BAR ── */}+ <PromptComposer>+ {additionalImages.length > 0 && (+ <div className="flex items-center gap-1.5">+ {additionalImages.map((img, idx) => (+ <div key={idx} className="relative group/img flex-shrink-0">+ <img src={img} className="w-9 h-9 rounded-full object-cover border border-white/10" />+ <button+ onClick={() => setAdditionalImages(prev => prev.filter((_, i) => i !== idx))}+ className="absolute -top-1 -right-1 w-3.5 h-3.5 bg-black/80 text-white rounded-full flex items-center justify-center opacity-0 group-hover/img:opacity-100 transition-opacity border border-white/10"+ >+ <CloseSvg />+ </button>+ </div>+ ))}+ </div>+ )}+ {/* Top Row: Full-width Textarea */}+ <div className="w-full relative">+ <PromptTextarea+ ref={textareaRef}+ value={prompt}+ onChange={(e) => setPrompt(e.target.value)}+ placeholder="Describe your ad script... Use @image1 for product, @image2 for avatar."+ />+ </div>++ {/* Bottom Row: Uploads + Controls + Generate */}+ <PromptFooter>+ <PromptControls>++ {/* Asset Uploads Group */}+ <div className="flex items-center gap-1.5 pr-3 border-r border-white/10">+ <UploadSlot+ label="Product"+ icon={<ProductIcon />}+ url={productImage}+ progress={uploadProgress.product}+ onUpload={(e) => handleUpload(e, 'product')}+ onClear={() => setProductImage(null)}+ />+ <UploadSlot+ label="Avatar"+ icon={<AvatarIcon />}+ url={avatarImage}+ progress={uploadProgress.avatar}+ onUpload={(e) => handleUpload(e, 'avatar')}+ onClear={() => setAvatarImage(null)}+ />+ <UploadSlot+ label="References"+ icon={<RefIcon />}+ url={additionalImages[0]}+ progress={uploadProgress.additional}+ multiple+ images={additionalImages}+ onUpload={(e) => handleUpload(e, 'additional')}+ onClear={(idx) => {+ if (idx !== undefined) {+ setAdditionalImages(prev => prev.filter((_, i) => i !== idx));+ } else {+ setAdditionalImages([]);+ }+ }}+ />+ </div>++ {/* Format Button */}+ <div className="relative">+ <button+ onClick={(e) => { e.stopPropagation(); setDropdown(dropdown === 'format' ? null : 'format'); }}+ className={promptControlClassName({+ active: dropdown === "format",+ })}+ >+ <div className="w-4 h-4 bg-primary/10 rounded flex items-center justify-center border border-primary/20">+ <span className="text-[8px] font-black text-primary uppercase">U</span>+ </div>+ <span className={PROMPT_CONTROL_LABEL_CLASS}>{params.format}</span>+ <PromptChevronIcon />+ </button>+ <Dropdown+ isOpen={dropdown === 'format'}+ title="Video Format Presets"+ items={ASSETS.ugc}+ selectedId={params.format}+ onSelect={(item) => setParams({ ...params, format: item.name, videoUrl: item.url })}+ onClose={() => setDropdown(null)}+ isVideo+ />+ </div>++ {/* Avatar Preset Button */}+ <div className="relative flex items-center gap-1.5">+ <button+ onClick={(e) => { e.stopPropagation(); setDropdown(dropdown === 'avatar' ? null : 'avatar'); }}+ className={promptControlClassName({+ active: dropdown === "avatar",+ })}+ >+ <div className="w-4 h-4 rounded-full overflow-hidden border border-white/20 shadow-inner">+ <img src={avatarImage || ASSETS.avatar[0].url} className="w-full h-full object-cover" />+ </div>+ <span className={PROMPT_CONTROL_LABEL_CLASS}>+ {ASSETS.avatar.find(a => a.url === avatarImage)?.name || "Select Avatar"}+ </span>+ <PromptChevronIcon />+ </button>++ {avatarImage && (+ <button+ type="button"+ title="Enlarge selected avatar"+ onClick={(e) => {+ e.stopPropagation();+ const currentAvatar = ASSETS.avatar.find(a => a.url === avatarImage);+ if (currentAvatar) {+ setPreviewAvatar(currentAvatar);+ } else {+ setPreviewAvatar({ id: "custom", name: "Custom Uploaded Avatar", url: avatarImage });+ }+ }}+ className={promptControlClassName({+ iconOnly: true,+ className: "text-white/40 hover:text-[#22d3ee]",+ })}+ >+ <svg width="14" height="14" viewBox="0 0 24 24" fill="none" stroke="currentColor" strokeWidth="2.5">+ <circle cx="11" cy="11" r="8" />+ <line x1="21" y1="21" x2="16.65" y2="16.65" />+ <line x1="11" y1="8" x2="11" y2="14" />+ <line x1="8" y1="11" x2="14" y2="11" />+ </svg>+ </button>+ )}++ <Dropdown+ isOpen={dropdown === 'avatar'}+ title="Avatar Presets"+ items={ASSETS.avatar}+ selectedId={avatarImage}+ onSelect={(item) => setAvatarImage(item.url)}+ onPreview={(item) => setPreviewAvatar(item)}+ onClose={() => setDropdown(null)}+ />+ </div>++ {/* Simple Controls */}+ {['ratio', 'res', 'duration'].map(key => (+ <div key={key} className="relative">+ <button+ onClick={(e) => { e.stopPropagation(); setDropdown(dropdown === key ? null : key); }}+ className={promptControlClassName({+ active: dropdown === key,+ className:+ dropdown === key+ ? "text-xs font-semibold text-[#22d3ee]"+ : "text-xs font-semibold text-white/70",+ })}+ >+ {key === "ratio" ? (+ <PromptAspectRatioIcon />+ ) : key === "res" ? (+ <PromptQualityIcon />+ ) : (+ <PromptDurationIcon />+ )}+ <span className={PROMPT_CONTROL_LABEL_CLASS}>+ {key === "duration" ? `${params[key]}s` : params[key]}+ </span>+ </button>+ <SimpleDropdown+ isOpen={dropdown === key}+ title={+ key === "ratio"+ ? "Aspect Ratio"+ : key === "res"+ ? "Resolution"+ : "Duration"+ }+ options={OPTIONS[key]}+ selected={params[key]}+ onSelect={(val) => setParams({ ...params, [key]: val })}+ onClose={() => setDropdown(null)}+ />+ </div>+ ))}+ </PromptControls>++ <PromptAction+ onClick={handleGenerate}+ disabled={isGenerating}+ >+ {isGenerating ? (+ <>+ <span className="animate-spin inline-block text-black">◌</span>+ Generating...+ </>+ ) : (+ <span>Launch</span>+ )}+ </PromptAction>+ </PromptFooter>+ </PromptComposer>++ {/* Fullscreen Preview */}+ {fullscreenUrl && (+ <div className="fixed inset-0 z-[100] flex items-center justify-center bg-black/95 backdrop-blur-sm animate-fade-in" onClick={() => setFullscreenUrl(null)}>+ <button className="absolute top-6 right-6 p-3 bg-white/10 hover:bg-white/20 rounded-full text-white border border-white/10 transition-colors shadow-2xl"><CloseSvg /></button>+ <video src={fullscreenUrl} controls autoPlay className="max-w-[95vw] max-h-[95vh] rounded-lg shadow-4xl animate-scale-up" onClick={e => e.stopPropagation()} />+ </div>+ )}++ {/* ── AVATAR FULLSCREEN PREVIEW MODAL ── */}+ {previewAvatar && (+ <div+ className="fixed inset-0 z-[100] flex items-center justify-center bg-black/40 backdrop-blur-md animate-fade-in select-none"+ onClick={() => setPreviewAvatar(null)}+ >+ {/* Close button (cross) in the right corner */}+ <button+ type="button"+ className="absolute top-6 right-6 p-3 bg-white/10 hover:bg-white/20 rounded-full text-white transition-colors border border-white/10 z-50 animate-fade-in"+ onClick={(e) => {+ e.stopPropagation();+ setPreviewAvatar(null);+ }}+ >+ <CloseSvg />+ </button>++ {/* Inject dynamic CSS animation keyframes */}+ <style>{`+ @keyframes slide-in-next {+ 0% {+ transform: translateX(80px) scale(0.95);+ filter: blur(4px);+ opacity: 0.5;+ }+ 100% {+ transform: translateX(0) scale(1);+ filter: blur(0);+ opacity: 1;+ }+ }+ @keyframes slide-in-prev {+ 0% {+ transform: translateX(-80px) scale(0.95);+ filter: blur(4px);+ opacity: 0.5;+ }+ 100% {+ transform: translateX(0) scale(1);+ filter: blur(0);+ opacity: 1;+ }+ }+ .animate-slide-next {+ animation: slide-in-next 350ms cubic-bezier(0.16, 1, 0.3, 1) forwards;+ }+ .animate-slide-prev {+ animation: slide-in-prev 350ms cubic-bezier(0.16, 1, 0.3, 1) forwards;+ }+ `}</style>++ {/* Left Arrow Button */}+ {previewAvatar.id !== "custom" && (+ <button+ type="button"+ className="absolute left-6 p-4 bg-white/5 hover:bg-white/10 hover:text-primary rounded-full text-white transition-all border border-white/10 z-50"+ onClick={(e) => {+ e.stopPropagation();+ const currentIndex = ASSETS.avatar.findIndex(a => a.id === previewAvatar.id);+ if (currentIndex !== -1) {+ const prevAvatar = ASSETS.avatar[(currentIndex - 1 + ASSETS.avatar.length) % ASSETS.avatar.length];+ setSlideDirection("prev");+ setPreviewAvatar(prevAvatar);+ }+ }}+ >+ <svg width="24" height="24" viewBox="0 0 24 24" fill="none" stroke="currentColor" strokeWidth="3" strokeLinecap="round" strokeLinejoin="round">+ <polyline points="15 18 9 12 15 6" />+ </svg>+ </button>+ )}++ {/* Right Arrow Button */}+ {previewAvatar.id !== "custom" && (+ <button+ type="button"+ className="absolute right-6 p-4 bg-white/5 hover:bg-white/10 hover:text-primary rounded-full text-white transition-all border border-white/10 z-50"+ onClick={(e) => {+ e.stopPropagation();+ const currentIndex = ASSETS.avatar.findIndex(a => a.id === previewAvatar.id);+ if (currentIndex !== -1) {+ const nextAvatar = ASSETS.avatar[(currentIndex + 1) % ASSETS.avatar.length];+ setSlideDirection("next");+ setPreviewAvatar(nextAvatar);+ }+ }}+ >+ <svg width="24" height="24" viewBox="0 0 24 24" fill="none" stroke="currentColor" strokeWidth="3" strokeLinecap="round" strokeLinejoin="round">+ <polyline points="9 18 15 12 9 6" />+ </svg>+ </button>+ )}++ {/* Enlarged Image Card and side displays */}+ <div className="flex items-center gap-6 md:gap-12 max-w-[95vw] justify-center relative">+ {/* Previous Avatar Card (Left side) */}+ {previewAvatar.id !== "custom" && (+ <div+ onClick={(e) => {+ e.stopPropagation();+ const currentIndex = ASSETS.avatar.findIndex(a => a.id === previewAvatar.id);+ if (currentIndex !== -1) {+ const prevAvatar = ASSETS.avatar[(currentIndex - 1 + ASSETS.avatar.length) % ASSETS.avatar.length];+ setSlideDirection("prev");+ setPreviewAvatar(prevAvatar);+ }+ }}+ className="hidden md:flex flex-col items-center opacity-50 hover:opacity-60 scale-75 hover:scale-80 transition-all duration-300 cursor-pointer select-none max-w-[15vw] max-h-[50vh] rounded-xl overflow-hidden border border-white/5 bg-[#0d0d0f]/50"+ >+ <img+ src={ASSETS.avatar[(ASSETS.avatar.findIndex(a => a.id === previewAvatar.id) - 1 + ASSETS.avatar.length) % ASSETS.avatar.length].url}+ alt="Previous Avatar"+ className="w-full h-full object-cover aspect-[3/4]"+ />+ </div>+ )}++ {/* Main Active Avatar Card */}+ <div+ key={previewAvatar.id}+ className={`relative flex flex-col items-center max-w-[90vw] md:max-w-[45vw] max-h-[85vh] z-10 ${+ slideDirection === "next" ? "animate-slide-next" : "animate-slide-prev"+ }`}+ onClick={(e) => e.stopPropagation()}+ >+ <div className="relative rounded-2xl overflow-hidden border border-white/10 bg-[#0d0d0f] shadow-2xl">+ <img+ src={previewAvatar.url}+ alt={previewAvatar.name}+ className="max-w-[80vw] md:max-w-[40vw] max-h-[70vh] md:max-h-[65vh] object-contain"+ />++ {/* Overlay with Name of the Avatar */}+ <div className="absolute bottom-0 left-0 right-0 bg-gradient-to-t from-black/90 via-black/50 to-transparent p-4 pt-10 flex flex-col items-center justify-end gap-3">+ <h2 className="text-xl font-black text-white tracking-wide uppercase">+ {previewAvatar.name}+ </h2>++ {/* Select button on the enlarged image */}+ <button+ type="button"+ onClick={() => {+ setAvatarImage(previewAvatar.url);+ setPreviewAvatar(null);+ setDropdown(null);+ }}+ className="bg-[#22d3ee] text-black px-6 py-2.5 rounded-full font-bold text-sm hover:opacity-95 hover:scale-105 active:scale-95 transition-all flex items-center justify-center gap-1.5 shadow-lg shadow-[#22d3ee]/20"+ >+ <CheckSvg />+ Select Avatar+ </button>+ </div>+ </div>+ </div>++ {/* Next Avatar Card (Right side) */}+ {previewAvatar.id !== "custom" && (+ <div+ onClick={(e) => {+ e.stopPropagation();+ const currentIndex = ASSETS.avatar.findIndex(a => a.id === previewAvatar.id);+ if (currentIndex !== -1) {+ const nextAvatar = ASSETS.avatar[(currentIndex + 1) % ASSETS.avatar.length];+ setSlideDirection("next");+ setPreviewAvatar(nextAvatar);+ }+ }}+ className="hidden md:flex flex-col items-center opacity-50 hover:opacity-60 scale-75 hover:scale-80 transition-all duration-300 cursor-pointer select-none max-w-[15vw] max-h-[50vh] rounded-xl overflow-hidden border border-white/5 bg-[#0d0d0f]/50"+ >+ <img+ src={ASSETS.avatar[(ASSETS.avatar.findIndex(a => a.id === previewAvatar.id) + 1) % ASSETS.avatar.length].url}+ alt="Next Avatar"+ className="w-full h-full object-cover aspect-[3/4]"+ />+ </div>+ )}+ </div>+ </div>+ )}+ </div>+ );+}diff --git a/packages/studio/src/components/RecastStudio.jsx b/packages/studio/src/components/RecastStudio.jsxindex 0a658fa6..25b61bf2 100644--- a/packages/studio/src/components/RecastStudio.jsx+++ b/packages/studio/src/components/RecastStudio.jsx@@ -459,4 +459,767 @@ export default function RecastStudio({return [];});- const [assetImages, setAssetImages] = useState(()�������k�w��Q������9���������്����ѕ�̵���ѕȁ���ѥ�䵍��ѕȁ���ձ�������є�������������Ʌ�ͥѥ���������Ʌѥ�������������l��١t��(������������켨�=ٕɱ�����������ѥ�����ɑ̀���(������������������9�������ѕ�̵���ѕȁ���ѥ�䵍��ѕȁ����ĸԁ��靅��́������͕���е�����͍�������ʹ�͍���������(��������������������9����ܴ������ȁʹ�ܴ�Ёʹ頴���ɽչ�����ᰁ��ɑ�ȁ��ɑ�ȵݡ�є����͡���ܴ�ᰀ�ɽхє�l�ɑ��t��Ʌ�͙�ɴ���ٕ��ɽхє�����ٕ��͍����������ٕ�������Ʌ�ͥѥ���������Ʌѥ��������ٕə��ܵ����������ݡ�є�l����t�����͡ɥ������(����������������(�������������������Ɍ�����輽�ͅ�ݭ������Ĺ���Ց�ɽ�й��нݕ���͕�̽٥��������̽͑ᰵ�������٥��(���������������������� ɕ�ѥٔ���͕ЀĈ(�����������������������9����ܵ�ձ�����ձ�������е��ٕȈ(������������������(����������������(��������������������9����ܴ������ȁʹ�ܴ�Ёʹ頴���ɽչ�����ᰁ��ɑ�ȁ��ɑ�ȵݡ�є����͡���ܴ�ᰀ�ɽхє�lё��t��Ʌ�͙�ɴ���ٕ��ɽхє�����ٕ��͍����������ٕ�������Ʌ�ͥѥ���������Ʌѥ��������ٕə��ܵ����������ݡ�є�l����t�����́ʹ赵��Ё����͡ɥ������(����������������(�������������������Ɍ�����輽�ͅ�ݭ������Ĺ���Ց�ɽ�й��нݕ���͕�̽٥��������̽��ɽ����������٥��(���������������������� ɕ�ѥٔ���͕ЀȈ(�����������������������9����ܵ�ձ�����ձ�������е��ٕȈ(������������������(����������������(��������������������9����ܴ��������ʹ�ܴ�Ёʹ頴�Ёɽչ�����ձ����ɑ�ȁ��ɑ�ȵݡ�є����͡���ܴ�ᰁɽхє�lّ��t��Ʌ�͙�ɴ���ٕ��ɽхє�����ٕ��͍����������ٕ�������Ʌ�ͥѥ���������Ʌѥ��������ٕə��ܵ����������ݡ�є�l����t�����́ʹ赵��Ё����͡ɥ������(����������������(�������������������Ɍ�����輽�ͅ�ݭ������Ĺ���Ց�ɽ�й��нݕ���͕�̽٥��������̽��ф��յ�����٥��(���������������������� ɕ�ѥٔ���͕Ѐ̈(�����������������������9����ܵ�ձ�����ձ�������е��ٕȈ(������������������(����������������(��������������������9����ܴ������ȁʹ�ܴ�Ёʹ頴���ɽչ�����ᰁ��ɑ�ȁ��ɑ�ȵݡ�є����͡���ܴ�ᰁɽхє�l�ɑ��t��Ʌ�͙�ɴ���ٕ��ɽхє�����ٕ��͍����������ٕ�������Ʌ�ͥѥ���������Ʌѥ��������ٕə��ܵ����������ݡ�є�l����t�����́ʹ赵��Ё����͡ɥ������(����������������(�������������������Ɍ�����輽�ͅ�ݭ������Ĺ���Ց�ɽ�й��нݕ���͕�̽٥��������̽��ə��е�����٥��(���������������������� ɕ�ѥٔ���͕ЀЈ(�����������������������9����ܵ�ձ�����ձ�������е��ٕȈ(������������������(����������������(��������������((�������������ā�����9����ѕ�д�ᰁʹ�ѕ�д�ᰁ���ѕ�д�ᰁ���е���Ʌ������Ʌ������ѥ��Ё���Ёѕ�е���ѕȁ��Ё��������്����ѕ�̵���ѕȈ�(�������������������������9����ѕ�еݡ�є����е����������ɍ�͔�ѕ�еᰁʹ�ѕ�д�ᰁ�Ʌ������ݥ������ā�����������MQIP� IQ%9�]%Q ������(�������������������������9����ѕ�еl��ɐ͕�t����е����������ɍ�͔�ѕ�д�ᰁʹ�ѕ�д�ᰁʹ�дā�Ʌ������ѥ��Ј�(���������������� =d�M]@�MQU%<(��������������������(���������������(��������������������9����ѕ�еݡ�є����ѕ�е�́ʹ�ѕ�еʹ����е����մ��Ʌ������ݥ���ѕ�е���ѕȁ���ܵ�����������ɕ��ᕐ���Ј�(��������������M݅��ѡ�����Ʌ�ѕȁ������٥�����幅������䁉䁍���ͥ�����٥���������������хɝ�Ё���Ʌ�ѕȁ������(���������������(������������(����������(��������((������켨��R�R � =QQ=4�AI=5AP� H��R�R ����(�������Aɽ��� ����͕��(����������켨�U�����́ɽ܀���(����������������9�������ѕ�̵���ѕȁ����ȁ��Ĉ�(������������������9�������ѕ�̵���ѕȁ����Ȉ�(��������������켨�M��ɍ��٥�������(���������������5����A����� ��ѽ�(�����������������������٥������(����������������������Y�����(�����������������������Y����%���������9����ѕ�еݡ�є�����ɽ�����ٕ��ѕ�еl��ɐ͕�t��Ʌ�ͥѥ��������̈����(������������������U�������������Y����A����(������������������ �����젤�����(������������������͕�Y����Uɰ��ձ���(������������������͕�Y����Mхє�UA1=}MQQ�%1��(������������������͕�Y����9��������(������������������(����������������������Mхє��٥���Mхѕ�(�����������������ɽ�ɕ����٥���Aɽ�ɕ���(��������������������9�����٥���9����(�����������������ɕ٥��Uɰ��٥���Uɱ�(������������������Y��������Օ�(����������������((��������������켨� ��Ʌ�ѕȁ���������(���������������5����A����� ��ѽ�(����������������������������(���������������������� ��Ʌ�ѕȁ������(�����������������������%����%���������9����ѕ�еݡ�є�����ɽ�����ٕ��ѕ�еl��ɐ͕�t��Ʌ�ͥѥ��������̈����(������������������U�������������%����U������(������������������ �����젤�����(������������������͕�%����Uɰ��ձ���(������������������͕�%����Mхє�UA1=}MQQ�%1��(������������������͕�%����9��������(������������������(����������������������Mхє�������Mхѕ�(�����������������ɽ�ɕ���������Aɽ�ɕ���(��������������������9����������9����(�����������������ɕ٥��Uɰ�������Uɱ�(������������������Y�����홅�͕�(����������������(��������������((������������켨�Aɽ��Ёѕ�хɕ�����(������������������9�����ā��������്����(���������������Aɽ���Q��хɕ�(����������������ɕ���ѕ�хɕ�I���(����������������م�Ք���ɽ����(������������������ �������������Aɽ���%�����(����������������������������=�ѥ������P���͍ɥ���ѡ����ѥ����ȁ͍�������(����������������(��������������(������������((����������켨� ��ѽ������ɽ�́ɽ܀���(�����������Aɽ�����ѕ��(�������������Aɽ��� ���ɽ���(��������������켨�5�����͕���ѽȀ���(��������������������9����ɕ��ѥٔ��(�������������������ѽ�(������������������ɕ�������� ѹI���(�������������������������ѽ��(�������������������� �����졔������(�����������������������ѽ�Aɽ����ѥ�����(��������������������͕�=���ɽ���ݸ�����ɽ���ݸ������������ձ��耉��������(��������������������(�����������������������9������ɽ��� ���ɽ� ����9�����(����������������������ѥٔ聽���ɽ���ݸ���������(���������������������(�����������������(������������������������9����̸ܴԁ��̸ԁ���l��ɐ͕�t�ɽչ����ʹ�������ѕ�̵���ѕȁ���ѥ�䵍��ѕȈ�(�������������������������������9����ѕ�еl���t����е������ѕ�е�������H������(��������������������(�����������������������������9�����AI=5AQ} =9QI=1}1 1} 1MM��(���������������������͕���ѕ�5���������������M����Ё�������(������������������������(�������������������Aɽ��� ���ɽ�%������(�������������������ѽ��(�����������������ɽ���ݸ(��������������������=���������ɽ���ݸ���������(������������������ѥѱ��5�����(�������������������ѕ����ɕ����5������(������������������͕���ѕ�%���͕���ѕ�5����%��(��������������������M�������������5����M������(�������������������� ��͔�젤����͕�=���ɽ���ݸ��ձ���(������������������������I��������� ѹI���(�����������������������9����ܴ������ܵm���������ܴ�ɕ��t�(������������������(����������������((��������������켨�����ЁɅѥ��͕���ѽȀ���(���������������͡������Ѐ����(����������������������9����ɕ��ѥٔ��(���������������������ѽ�(��������������������ɕ�������� ѹI���(���������������������������ѽ��(���������������������� �����졔������(�������������������������ѽ�Aɽ����ѥ�����(����������������������͕�=���ɽ���ݸ�����ɽ���ݸ�������Ј����ձ��耉�����Ј��(����������������������(�������������������������9������ɽ��� ���ɽ� ����9�����(������������������������ѥٔ聽���ɽ���ݸ�������Ј�(�����������������������(�������������������(���������������������Aɽ��������I�ѥ�%������(�������������������������������9�����AI=5AQ} =9QI=1}1 1} 1MM��(�����������������������͕���ѕ������I�ѥ��(��������������������������(���������������������Aɽ��� ���ɽ�%������(���������������������ѽ��(�������������������ɽ���ݸ(����������������������=���������ɽ���ݸ�������Љ�(��������������������ѥѱ������ЁI�ѥ��(���������������������ѕ���������ɽ���ݹ%ѕ���(��������������������͕���ѕ�%���͕���ѕ������I�ѥ��(����������������������M������졥ѕ������͕�M����ѕ������I�ѥ���ѕ������(���������������������� ��͔�젤����͕�=���ɽ���ݸ��ձ���(��������������������������I��������� ѹI���(��������������������(������������������(����������������((��������������켨� ��Ʌ�ѕȁ=ɥ��хѥ���͕���ѽȀ���(���������������͕���ѕ�5����%����������̸���ɼ�ɕ���Ј�����(����������������������9����ɕ��ѥٔ��(���������������������ѽ�(��������������������ɕ����ɥ��хѥ�� ѹI���(���������������������������ѽ��(���������������������� �����졔������(�������������������������ѽ�Aɽ����ѥ�����(����������������������͕�=���ɽ���ݸ�����ɽ���ݸ���ɥ��хѥ�������ձ��耉�ɥ��хѥ�����(����������������������(�������������������������9������ɽ��� ���ɽ� ����9�����(������������������������ѥٔ聽���ɽ���ݸ���ɥ��хѥ����(�����������������������(�������������������(�������������������������������9����ѕ�е�́���е͕�������ѕ�е���ɕ�Ё�����������ɽ�����ٕ�������������Ʌ�ͥѥ�����������(����������������������=ɥ��хѥ���(��������������������������(�������������������������������9����ѕ�е�́���е͕�������ѕ�е���ɕ�Ё����х��锈�(����������������������퍡�Ʌ�ѕ�=ɥ��хѥ���(��������������������������(���������������������Aɽ��� ���ɽ�%������(���������������������ѽ��(�������������������ɽ���ݸ(����������������������=���������ɽ���ݸ���ɥ��хѥ����(��������������������ѥѱ��=ɥ��хѥ���(���������������������ѕ����l(����������������������쁥�耉������������耉%���������͍ɥ�ѥ��耉U͔��������ɥ��хѥ����5�����́٥��������(����������������������쁥�耉٥����������耉Y���������͍ɥ�ѥ��耉U͔�٥�����ɥ��хѥ����5�����́٥��������(��������������������u�(��������������������͕���ѕ�%��퍡�Ʌ�ѕ�=ɥ��хѥ���(����������������������M������졥ѕ������͕� ��Ʌ�ѕ�=ɥ��хѥ����ѕ������(���������������������� ��͔�젤����͕�=���ɽ���ݸ��ձ���(��������������������������I�����ɥ��хѥ�� ѹI���(�������������������������9����ܴ�Ј(��������������������(������������������(����������������((��������������켨��͕�́1��Ʌ��͕���ѽȀ���(��������������������9����ɕ��ѥٔ��(�������������������ѽ�(������������������ɕ����͕�� ѹI���(�������������������������ѽ��(�������������������� �����졔������(�����������������������ѽ�Aɽ����ѥ�����(��������������������͕�=���ɽ���ݸ�����ɽ���ݸ����͕�̈����ձ��耉��͕�̈��(��������������������(�����������������������9������ɽ��� ���ɽ� ����9�����(����������������������ѥٔ聽���ɽ���ݸ����͕�̈�(���������������������(�����������������(��������������������ٜ(��������������������ݥ�Ѡ��Ј(����������������������������Ј(��������������������٥�� ��������Ѐ�Ј(���������������������������(����������������������ɽ�����ɕ�� ���Ȉ(����������������������ɽ��]��Ѡ�Ȉ(�������������������������9����ѕ�еݡ�є�����ɽ�����ٕ��ѕ�еl��ɐ͕�t��Ʌ�ͥѥ��������̈(�������������������(�����������������������Ѡ���4Ѐ���ȸԀȸԀ����ĀظԀ�� ������(�����������������������Ѡ���4ظԀ� ����� ظ�ȸԀȸԀ����ĀЀ���ش��ȸԀȸԀ����ĀظԀ�舀��(��������������������ٜ�(�����������������������������9����ѕ�е�́���е͕�������ѕ�еݡ�є�����ɽ�����ٕ��ѕ�еl��ɐ͕�t��Ʌ�ͥѥ��������̈�(��������������������1��Ʌ��(������������������������(�������������������Aɽ��� ���ɽ�%������(�������������������ѽ��(���������������������ɽ���ݸ����͕�̈�����(��������������������͕��ɽ���ݸ(��������������������٥�������͕�Y������(�����������������������������͕�%������(��������������������ɕ�ձ�����͕�I��ձ���(����������������������M�����Y�������ɰ������������(����������������������͕�Y����Uɰ��ɰ��(����������������������͕�Y����9�������������M����ѕ��Y�������(����������������������͕�Y����Mхє�UA1=}MQQ�Id��(����������������������͕�=���ɽ���ݸ��ձ���(����������������������(����������������������M�����%�������ɰ������������(����������������������͕�%����Uɰ��ɰ��(����������������������͕�%����9�������������M����ѕ��%�������(����������������������͕�%����Mхє�UA1=}MQQ�Id��(����������������������͕�=���ɽ���ݸ��ձ���(����������������������(����������������������M�����I��ձ��Y�������ɰ������������(����������������������͕�Y����Uɰ��ɰ��(����������������������͕�Y����9�������������I��ձЁY�������(����������������������͕�Y����Mхє�UA1=}MQQ�Id��(����������������������͕�=���ɽ���ݸ��ձ���(����������������������(�������������������������ѕ�͕������������ѕ�͕��(��������������������͕�ձ�͍ɕ��Uɰ��͕�ձ�͍ɕ��Uɱ�(���������������������� ��͔�젤����͕�=���ɽ���ݸ��ձ���(��������������������������I�����͕�� ѹI���(��������������������(������������������(����������������(�������������Aɽ��� ���ɽ���((������������켨����Ʌє����ѽ�����(�������������Aɽ����ѥ��(���������������� ���������������Ʌѕ�(����������������ͅ�����������Ʌѥ���(�������������(��������������������Ʌѥ������(������������������(�����������������������������9������є�������������������ѕ�е��������^0������숀��(������������������M݅��������(������������������(����������������耠(����������������������M݅�� ���������(����������������(�������������Aɽ����ѥ���(�����������Aɽ�����ѕ��(�������Aɽ��� ����͕��((������켨��R�R �U11M I8�5%�5=0��R�R ����(�������ձ�͍ɕ��Uɰ�����(����������(���������������9���ᕐ���͕д���l���t�������ѕ�̵���ѕȁ���ѥ�䵍��ѕȁ����������ԁ�����ɽ�����ȵʹ������є���������(������������ �����젤����͕�ձ�͍ɕ��Uɰ��ձ���(���������(�������������ѽ�(�������������������ѽ��(�����������������9���ͽ��є�ѽ��ɥ��д��́���ݡ�є������ٕ�鉜�ݡ�є����ɽչ�����ձ��ѕ�еݡ�є��Ʌ�ͥѥ��������́��ɑ�ȁ��ɑ�ȵݡ�є����(�������������� �����졔������(�����������������ѽ�Aɽ����ѥ�����(��������������͕�ձ�͍ɕ��Uɰ��ձ���(��������������(�����������(��������������ٜ�ݥ�Ѡ��Ј���������Ј�٥�� ��������Ѐ�Ј�����������ɽ�����ɕ�� ���Ȉ���ɽ��]��Ѡ�ȸԈ���ɽ��1�������ɽչ�����ɽ��1��������ɽչ���(��������������������������؈����؈����������(�������������������؈����؈�����������������(��������������ٜ�(�������������ѽ��(����������젠������(����������������Ё��%����ձ�͍ɕ��Uɰ���э���p��������������ݕ���٥���������(���������������������������ձ�͍ɕ��Uɰ�����Ց�̠����������̼������(���������������������������ձ�͍ɕ��Uɰ�����Ց�̠������������(���������������������������ձ�͍ɕ��Uɰ��х���]�Ѡ����ф饵������(������������ɕ��ɸ���%������(��������������(�����������������Ɍ��ձ�͍ɕ��Uɱ�(��������������������ձ�͍ɕ���Aɕ٥�܈(���������������������9����ܵl����t���ൠ�l��١t�ɽչ�����ᰁ͡���ܴ�ᰁ�����е���х��������є�͍�������(������������������ �����졔��������ѽ�Aɽ����ѥ�����(����������������(��������������耠(���������������٥���(�����������������Ɍ��ձ�͍ɕ��Uɱ�(��������������������ɽ��(������������������ѽA���(��������������������(���������������������9����ܵl����t���ൠ�l��١t�ɽչ�����ᰁ͡���ܴ�ᰁ�����е���х��������є�͍�������(������������������ �����졔��������ѽ�Aɽ����ѥ�����(����������������(��������������(���������������(����������(��������(�������Q���ѕȁ��ͥѥ���ѽ��ɥ��Ј����х����M�屔����%������������ѽ���=�ѥ�����쁑�Ʌѥ�����������屔�쁉����ɽչ�耜�����ň��������耜������������ɑ��耜����ͽ����ɝ������������Ԥ�������M��耜���������ɑ��I�����耜����������M�����耜������������ɝ�����������ؤ������]��Ѡ耜��������ݽɑ ɕ��耝�ɕ���ݽɐ���ݡ�ѕM����耝�ɔ��Ʌ�����������耜���������������(������(����)�(\ No newline at end of file+ const [assetImages, setAssetImages] = useState(() => {+ if (typeof window !== "undefined") {+ try {+ const stored = localStorage.getItem("hg_recast_studio_assets");+ if (stored) {+ const data = JSON.parse(stored);+ return data.images || [];+ }+ } catch (err) {}+ }+ return [];+ });++ const [assetResults, setAssetResults] = useState(() => {+ if (typeof window !== "undefined") {+ try {+ const stored = localStorage.getItem("hg_recast_studio_assets");+ if (stored) {+ const data = JSON.parse(stored);+ return data.results || [];+ }+ } catch (err) {}+ }+ return [];+ });++ // ── Generation / UI state ─────────────────────────────────────────────────+ const [isGenerating, setIsGenerating] = useState(false);+ const [generateError, setGenerateError] = useState(null);+ const [fullscreenUrl, setFullscreenUrl] = useState(null);++ // ── History ───────────────────────────────────────────────────────────────+ const [internalHistory, setInternalHistory] = useState([]);+ const history = historyItems ?? internalHistory;++ // ── Dropdown state ────────────────────────────────────────────────────────+ const [openDropdown, setOpenDropdown] = useState(null); // 'model' | 'aspect' | 'orientation' | 'assets' | null+ const modelBtnRef = useRef(null);+ const aspectBtnRef = useRef(null);+ const orientationBtnRef = useRef(null);+ const assetsBtnRef = useRef(null);+ const textareaRef = useRef(null);+ const hasRestored = useRef(false);++ // ── Persistence: Load ──────────────────────────────────────────────────────+ useEffect(() => {+ try {+ const stored = localStorage.getItem(PERSIST_KEY);+ if (stored) {+ const data = JSON.parse(stored);+ if (data.selectedModelId) setSelectedModelId(data.selectedModelId);+ if (data.selectedAspectRatio) setSelectedAspectRatio(data.selectedAspectRatio);+ if (data.characterOrientation) setCharacterOrientation(data.characterOrientation);+ if (data.videoUrl) {+ setVideoUrl(data.videoUrl);+ setVideoState(UPLOAD_STATE.READY);+ }+ if (data.imageUrl) {+ setImageUrl(data.imageUrl);+ setImageState(UPLOAD_STATE.READY);+ }+ if (data.videoName) setVideoName(data.videoName);+ if (data.imageName) setImageName(data.imageName);+ if (data.prompt) setPrompt(data.prompt);+ if (data.internalHistory) setInternalHistory(data.internalHistory);+ }+ } catch (err) {+ console.warn("Failed to load RecastStudio persistence:", err);+ } finally {+ hasRestored.current = true;+ }+ }, []);++ // ── Save Assets ────────────────────────────────────────────────────────────+ useEffect(() => {+ try {+ localStorage.setItem(+ "hg_recast_studio_assets",+ JSON.stringify({+ videos: assetVideos,+ images: assetImages,+ results: assetResults,+ })+ );+ } catch (err) {+ console.warn("Failed to save RecastStudio assets:", err);+ }+ }, [assetVideos, assetImages, assetResults]);++ const handleDeleteAsset = (tab, url) => {+ if (tab === "videos") {+ setAssetVideos((prev) => prev.filter((item) => item.url !== url));+ } else if (tab === "images") {+ setAssetImages((prev) => prev.filter((item) => item.url !== url));+ } else {+ setAssetResults((prev) => prev.filter((item) => item.url !== url));+ }+ };++ // ── Persistence: Save ──────────────────────────────────────────────────────+ useEffect(() => {+ const timer = setTimeout(() => {+ try {+ localStorage.setItem(+ PERSIST_KEY,+ JSON.stringify({+ selectedModelId,+ selectedAspectRatio,+ characterOrientation,+ videoUrl,+ videoName,+ imageUrl,+ imageName,+ prompt,+ internalHistory,+ }),+ );+ } catch (err) {+ console.warn("Failed to save RecastStudio persistence:", err);+ }+ }, 500);+ return () => clearTimeout(timer);+ }, [+ selectedModelId,+ selectedAspectRatio,+ characterOrientation,+ videoUrl,+ videoName,+ imageUrl,+ imageName,+ prompt,+ internalHistory,+ ]);++ // ── Derived model info ──────────────────────────────────────────────────────+ const selectedModel = getRecastModelById(selectedModelId);+ const aspectOptions = getAspectRatiosForRecastModel(selectedModelId);+ const showAspect = aspectOptions.length > 0;+ const showPrompt = !!selectedModel?.hasPrompt;++ // ── Upload handlers ─────────────────────────────────────────────────────────+ const handleVideoPick = useCallback(+ async (file) => {+ if (file.size > 50 * 1024 * 1024) {+ alert("Video exceeds 50MB limit.");+ return;+ }+ setVideoState(UPLOAD_STATE.UPLOADING);+ setVideoProgress(0);+ try {+ const url = await uploadFile(apiKey, file, (pct) => setVideoProgress(pct));+ setVideoUrl(url);+ setVideoName(file.name);+ setVideoState(UPLOAD_STATE.READY);++ // Add to assets+ setAssetVideos((prev) => {+ const exists = prev.some((item) => item.url === url);+ if (exists) return prev;+ return [{ url, name: file.name, timestamp: new Date().toISOString() }, ...prev].slice(0, 30);+ });+ } catch (err) {+ setVideoState(UPLOAD_STATE.IDLE);+ alert(`Video upload failed: ${err.message}`);+ } finally {+ setVideoProgress(0);+ }+ },+ [apiKey],+ );++ const handlePromptInput = (e) => {+ setPrompt(e.target.value);+ };++ const handleImageUpload = useCallback(+ async (file) => {+ if (file.size > 10 * 1024 * 1024) {+ alert("Image exceeds 10MB limit.");+ return;+ }+ setImageState(UPLOAD_STATE.UPLOADING);+ setImageProgress(0);+ try {+ const url = await uploadFile(apiKey, file, (pct) => setImageProgress(pct));+ setImageUrl(url);+ setImageName(file.name);+ setImageState(UPLOAD_STATE.READY);++ // Add to assets+ setAssetImages((prev) => {+ const exists = prev.some((item) => item.url === url);+ if (exists) return prev;+ return [{ url, name: file.name, timestamp: new Date().toISOString() }, ...prev].slice(0, 30);+ });+ } catch (err) {+ setImageState(UPLOAD_STATE.IDLE);+ alert(`Image upload failed: ${err.message}`);+ } finally {+ setImageProgress(0);+ }+ },+ [apiKey],+ );++ // ── Handle Dropped Files ────────────────────────────────────────────────────+ useEffect(() => {+ if (droppedFiles && droppedFiles.length > 0) {+ const imageFiles = droppedFiles.filter((f) => f.type.startsWith("image/"));+ const videoFiles = droppedFiles.filter((f) => f.type.startsWith("video/"));+ if (videoFiles.length > 0) handleVideoPick(videoFiles[0]);+ if (imageFiles.length > 0) handleImageUpload(imageFiles[0]);+ onFilesHandled?.();+ }+ }, [droppedFiles, onFilesHandled, handleVideoPick, handleImageUpload]);++ // ── Model selection ─────────────────────────────────────────────────────────+ const handleModelSelect = (model) => {+ setSelectedModelId(model.id);+ const ratios = getAspectRatiosForRecastModel(model.id);+ if (ratios.length > 0) {+ setSelectedAspectRatio(model.inputs?.aspect_ratio?.default ?? ratios[0]);+ }+ };++ // ── History helpers ─────────────────────────────────────────────────────────+ const addToInternalHistory = useCallback((entry) => {+ setInternalHistory((prev) => [entry, ...prev].slice(0, 30));+ }, []);++ const downloadFile = async (url, filename) => {+ try {+ const response = await fetch(url);+ const blob = await response.blob();+ const blobUrl = URL.createObjectURL(blob);+ const a = document.createElement("a");+ a.href = blobUrl;+ a.download = filename;+ document.body.appendChild(a);+ a.click();+ document.body.removeChild(a);+ URL.revokeObjectURL(blobUrl);+ } catch {+ window.open(url, "_blank");+ }+ };++ // ── Generation ──────────────────────────────────────────────────────────────+ const handleGenerate = async () => {+ if (!videoUrl) {+ alert("Please upload a source video first.");+ return;+ }+ if (!imageUrl) {+ alert("Please upload a character image first.");+ return;+ }++ onGenerationStart?.();+ setIsGenerating(true);+ setGenerateError(null);++ try {+ const params = {+ model: selectedModelId,+ video_url: videoUrl,+ image_url: imageUrl,+ };+ if (showAspect) params.aspect_ratio = selectedAspectRatio;+ if (prompt && selectedModel?.hasPrompt) params.prompt = prompt;+ if (selectedModelId === "kling-v3.0-pro-recast") {+ params.character_orientation = characterOrientation;+ }++ const res = await processRecast(apiKey, params);++ if (!res?.url) throw new Error("No video URL returned by API");++ const genId = res.id || Date.now().toString();+ const entry = {+ id: genId,+ url: res.url,+ prompt,+ model: selectedModel?.name || selectedModelId,+ timestamp: new Date().toISOString(),+ };++ if (!historyItems) addToInternalHistory(entry);++ // Add to assets+ setAssetResults((prev) => {+ const url = res.url;+ const name = prompt ? (prompt.slice(0, 20) + "...") : `Result ${new Date().toLocaleTimeString()}`;+ const exists = prev.some((item) => item.url === url);+ if (exists) return prev;+ return [{ url, name, timestamp: new Date().toISOString() }, ...prev].slice(0, 30);+ });++ if (onGenerationComplete) {+ onGenerationComplete({+ url: res.url,+ model: selectedModelId,+ prompt,+ type: "recast",+ });+ }+ } catch (e) {+ console.error("[RecastStudio]", e);+ const errMsg = formatErrorMessage(e, "Body swap generation failed");+ if (onGenerationError) onGenerationError(errMsg);+ else toast.error(errMsg);+ } finally {+ setIsGenerating(false);+ onGenerationEnd?.();+ }+ };++ // ── Dropdown item lists ─────────────────────────────────────────────────────+ const aspectDropdownItems = aspectOptions.map((r) => ({ id: r, name: r }));++ // ── Render ────────────────────────────────────────────────────────────────+ return (+ <div className="w-full h-full flex flex-col items-center justify-center bg-app-bg relative overflow-hidden">++ {/* ── CENTRAL GALLERY AREA ── */}+ <div className="flex-1 w-full max-w-7xl mx-auto overflow-y-auto custom-scrollbar pb-40 lg:pb-32 px-2">+ {history.length > 0 ? (+ <div className="grid grid-cols-1 md:grid-cols-2 lg:grid-cols-3 gap-6 w-full pt-4 animate-fade-in-up">+ {history.map((entry, idx) => (+ <div+ key={entry.id || idx}+ className="relative group rounded-2xl overflow-hidden border border-white/10 bg-[#0a0a0a] shadow-xl hover:border-primary/50 transition-all duration-300 flex flex-col"+ >+ <video+ src={entry.url}+ className="w-full aspect-video object-cover bg-black/40 cursor-pointer hover:opacity-80 transition-opacity"+ onClick={() => setFullscreenUrl(entry.url)}+ controls={false}+ loop+ muted+ playsInline+ onMouseOver={(e) => e.target.play()}+ onMouseOut={(e) => {+ e.target.pause();+ e.target.currentTime = 0;+ }}+ />++ {/* Overlay actions */}+ <div className="absolute top-2 right-2 flex flex-col gap-2 opacity-0 group-hover:opacity-100 transition-opacity">+ <button+ type="button"+ title="Fullscreen"+ onClick={(e) => {+ e.stopPropagation();+ setFullscreenUrl(entry.url);+ }}+ className="p-2 bg-black/60 backdrop-blur-md rounded-full text-white hover:bg-primary hover:text-black transition-all border border-white/10"+ >+ <svg width="14" height="14" viewBox="0 0 24 24" fill="none" stroke="currentColor" strokeWidth="2.5">+ <polyline points="15 3 21 3 21 9" />+ <polyline points="9 21 3 21 3 15" />+ <line x1="21" y1="3" x2="14" y2="10" />+ <line x1="3" y1="21" x2="10" y2="14" />+ </svg>+ </button>+ <button+ type="button"+ title="Download"+ onClick={(e) => {+ e.stopPropagation();+ downloadFile(entry.url, `bodyswap-${entry.id || idx}.mp4`);+ }}+ className="p-2 bg-black/60 backdrop-blur-md rounded-full text-white hover:bg-primary hover:text-black transition-all border border-white/10"+ >+ <svg width="14" height="14" viewBox="0 0 24 24" fill="none" stroke="currentColor" strokeWidth="2.5">+ <path d="M21 15v4a2 2 0 01-2 2H5a2 2 0 01-2-2v-4M7 10l5 5 5-5M12 15V3" />+ </svg>+ </button>+ <button+ type="button"+ title="Delete"+ onClick={(e) => {+ e.stopPropagation();+ if (confirm("Are you sure you want to delete this generated item?")) {+ setInternalHistory(prev => prev.filter((_, i) => i !== idx));+ }+ }}+ className="p-2 bg-black/60 backdrop-blur-md rounded-full text-red-400 hover:bg-red-500 hover:text-white transition-all border border-white/10"+ >+ <svg width="14" height="14" viewBox="0 0 24 24" fill="none" stroke="currentColor" strokeWidth="2.5">+ <polyline points="3 6 5 6 21 6" />+ <path d="M19 6v14a2 2 0 01-2 2H7a2 2 0 01-2-2V6m3 0V4a2 2 0 012-2h4a2 2 0 012 2v2" />+ <line x1="10" y1="11" x2="10" y2="17" />+ <line x1="14" y1="11" x2="14" y2="17" />+ </svg>+ </button>+ </div>++ {/* Details */}+ <div className="p-3 bg-black/80 backdrop-blur-sm border-t border-white/5 flex-1 flex flex-col justify-between gap-2">+ {entry.prompt && (+ <p className="text-white/70 text-xs line-clamp-2 leading-relaxed" title={entry.prompt}>+ {entry.prompt}+ </p>+ )}+ <div className="flex items-center justify-between flex-wrap gap-1 mt-1">+ <span className="text-[10px] font-bold text-primary px-2 py-0.5 bg-primary/10 rounded border border-primary/20 whitespace-nowrap">+ Body Swap+ </span>+ {entry.prompt && (+ <button+ type="button"+ onClick={(e) => {+ e.stopPropagation();+ navigator.clipboard.writeText(entry.prompt);+ const btn = e.currentTarget;+ btn.innerText = "Copied!";+ setTimeout(() => { btn.innerText = "Copy"; }, 2000);+ }}+ className="px-2 py-0.5 bg-white/5 hover:bg-primary/20 hover:text-primary rounded text-[10px] font-medium text-white/70 transition-all border border-white/10"+ title="Copy prompt"+ >+ Copy Prompt+ </button>+ )}+ </div>+ </div>+ </div>+ ))}+ </div>+ ) : (+ <div className="flex flex-col items-center justify-center h-full animate-fade-in-up transition-all duration-700 min-h-[50vh]">+ {/* Overlapping floating cards */}+ <div className="flex items-center justify-center gap-1.5 md:gap-3 mb-10 select-none scale-90 sm:scale-100">+ <div className="w-18 h-22 sm:w-24 sm:h-28 rounded-2xl border border-white/10 shadow-2xl -rotate-[12deg] transform hover:rotate-0 hover:scale-110 hover:z-20 transition-all duration-300 overflow-hidden bg-white/[0.01] flex-shrink-0">+ <img+ src="https://d3adwkbyhxyrtq.cloudfront.net/webassets/videomodels/sdxl-image.avif"+ alt="Creative asset 1"+ className="w-full h-full object-cover"+ />+ </div>+ <div className="w-18 h-22 sm:w-24 sm:h-28 rounded-2xl border border-white/10 shadow-2xl -rotate-[4deg] transform hover:rotate-0 hover:scale-110 hover:z-20 transition-all duration-300 overflow-hidden bg-white/[0.01] -ml-3 sm:-ml-4 flex-shrink-0">+ <img+ src="https://d3adwkbyhxyrtq.cloudfront.net/webassets/videomodels/chroma-image.avif"+ alt="Creative asset 2"+ className="w-full h-full object-cover"+ />+ </div>+ <div className="w-18 h-18 sm:w-24 sm:h-24 rounded-full border border-white/10 shadow-2xl rotate-[6deg] transform hover:rotate-0 hover:scale-110 hover:z-20 transition-all duration-300 overflow-hidden bg-white/[0.01] -ml-3 sm:-ml-4 flex-shrink-0">+ <img+ src="https://d3adwkbyhxyrtq.cloudfront.net/webassets/videomodels/neta-lumina.avif"+ alt="Creative asset 3"+ className="w-full h-full object-cover"+ />+ </div>+ <div className="w-18 h-22 sm:w-24 sm:h-28 rounded-2xl border border-white/10 shadow-2xl rotate-[12deg] transform hover:rotate-0 hover:scale-110 hover:z-20 transition-all duration-300 overflow-hidden bg-white/[0.01] -ml-3 sm:-ml-4 flex-shrink-0">+ <img+ src="https://d3adwkbyhxyrtq.cloudfront.net/webassets/videomodels/perfect-pony-xl.avif"+ alt="Creative asset 4"+ className="w-full h-full object-cover"+ />+ </div>+ </div>++ <h1 className="text-2xl sm:text-4xl md:text-5xl font-extrabold tracking-tight mb-4 text-center px-4 flex flex-col items-center">+ <span className="text-white font-black uppercase text-xl sm:text-3xl tracking-wide mb-1 opacity-90">START CREATING WITH</span>+ <span className="text-[#22d3ee] font-black uppercase text-2xl sm:text-4xl sm:mt-1 tracking-tight">+ BODY SWAP STUDIO+ </span>+ </h1>+ <p className="text-white/40 text-xs sm:text-sm font-medium tracking-wide text-center max-w-lg leading-relaxed px-4">+ Swap the character in any video dynamically by choosing a video clip and a target character image.+ </p>+ </div>+ )}+ </div>++ {/* ── BOTTOM PROMPT BAR ── */}+ <PromptComposer>+ {/* Uploads row */}+ <div className="flex items-center gap-2 px-1">+ <div className="flex items-center gap-2">+ {/* Source video */}+ <MediaPickerButton+ accept="video/*"+ label="Video"+ icon={<VideoIcon className="text-white/40 group-hover:text-[#22d3ee] transition-colors" />}+ onUpload={handleVideoPick}+ onClear={() => {+ setVideoUrl(null);+ setVideoState(UPLOAD_STATE.IDLE);+ setVideoName("");+ }}+ uploadState={videoState}+ progress={videoProgress}+ fileName={videoName}+ previewUrl={videoUrl}+ isVideo={true}+ />++ {/* Character image */}+ <MediaPickerButton+ accept="image/*"+ label="Character image"+ icon={<ImageIcon className="text-white/40 group-hover:text-[#22d3ee] transition-colors" />}+ onUpload={handleImageUpload}+ onClear={() => {+ setImageUrl(null);+ setImageState(UPLOAD_STATE.IDLE);+ setImageName("");+ }}+ uploadState={imageState}+ progress={imageProgress}+ fileName={imageName}+ previewUrl={imageUrl}+ isVideo={false}+ />+ </div>++ {/* Prompt textarea */}+ <div className="flex-1 flex flex-col">+ <PromptTextarea+ ref={textareaRef}+ value={prompt}+ onChange={handlePromptInput}+ placeholder="Optional — describe the motion or scene..."+ />+ </div>+ </div>++ {/* Bottom controls row */}+ <PromptFooter>+ <PromptControls>+ {/* Model selector */}+ <div className="relative">+ <button+ ref={modelBtnRef}+ type="button"+ onClick={(e) => {+ e.stopPropagation();+ setOpenDropdown(openDropdown === "model" ? null : "model");+ }}+ className={promptControlClassName({+ active: openDropdown === "model",+ })}+ >+ <div className="w-3.5 h-3.5 bg-[#22d3ee] rounded-sm flex items-center justify-center">+ <span className="text-[9px] font-black text-black">R</span>+ </div>+ <span className={PROMPT_CONTROL_LABEL_CLASS}>+ {selectedModel?.name ?? "Select model"}+ </span>+ <PromptChevronIcon />+ </button>+ <Dropdown+ isOpen={openDropdown === "model"}+ title="Model"+ items={recastModels}+ selectedId={selectedModelId}+ onSelect={handleModelSelect}+ onClose={() => setOpenDropdown(null)}+ anchorRef={modelBtnRef}+ className="w-80 max-w-[calc(100vw-2rem)]"+ />+ </div>++ {/* Aspect ratio selector */}+ {showAspect && (+ <div className="relative">+ <button+ ref={aspectBtnRef}+ type="button"+ onClick={(e) => {+ e.stopPropagation();+ setOpenDropdown(openDropdown === "aspect" ? null : "aspect");+ }}+ className={promptControlClassName({+ active: openDropdown === "aspect",+ })}+ >+ <PromptAspectRatioIcon />+ <span className={PROMPT_CONTROL_LABEL_CLASS}>+ {selectedAspectRatio}+ </span>+ <PromptChevronIcon />+ </button>+ <Dropdown+ isOpen={openDropdown === "aspect"}+ title="Aspect Ratio"+ items={aspectDropdownItems}+ selectedId={selectedAspectRatio}+ onSelect={(item) => setSelectedAspectRatio(item.id)}+ onClose={() => setOpenDropdown(null)}+ anchorRef={aspectBtnRef}+ />+ </div>+ )}++ {/* Character Orientation selector */}+ {selectedModelId === "kling-v3.0-pro-recast" && (+ <div className="relative">+ <button+ ref={orientationBtnRef}+ type="button"+ onClick={(e) => {+ e.stopPropagation();+ setOpenDropdown(openDropdown === "orientation" ? null : "orientation");+ }}+ className={promptControlClassName({+ active: openDropdown === "orientation",+ })}+ >+ <span className="text-xs font-semibold text-current opacity-50 group-hover:opacity-100 transition-opacity">+ Orientation:+ </span>+ <span className="text-xs font-semibold text-current capitalize">+ {characterOrientation}+ </span>+ <PromptChevronIcon />+ </button>+ <Dropdown+ isOpen={openDropdown === "orientation"}+ title="Orientation"+ items={[+ { id: "image", name: "Image", description: "Use image orientation (Max 10s video)" },+ { id: "video", name: "Video", description: "Use video orientation (Max 30s video)" },+ ]}+ selectedId={characterOrientation}+ onSelect={(item) => setCharacterOrientation(item.id)}+ onClose={() => setOpenDropdown(null)}+ anchorRef={orientationBtnRef}+ className="w-64"+ />+ </div>+ )}++ {/* Assets Library selector */}+ <div className="relative">+ <button+ ref={assetsBtnRef}+ type="button"+ onClick={(e) => {+ e.stopPropagation();+ setOpenDropdown(openDropdown === "assets" ? null : "assets");+ }}+ className={promptControlClassName({+ active: openDropdown === "assets",+ })}+ >+ <svg+ width="14"+ height="14"+ viewBox="0 0 24 24"+ fill="none"+ stroke="currentColor"+ strokeWidth="2"+ className="text-white/50 group-hover:text-[#22d3ee] transition-colors"+ >+ <path d="M4 19.5A2.5 2.5 0 0 1 6.5 17H20" />+ <path d="M6.5 2H20v20H6.5A2.5 2.5 0 0 1 4 19.5v-15A2.5 2.5 0 0 1 6.5 2z" />+ </svg>+ <span className="text-xs font-semibold text-white/70 group-hover:text-[#22d3ee] transition-colors">+ Library+ </span>+ <PromptChevronIcon />+ </button>+ {openDropdown === "assets" && (+ <AssetsDropdown+ videos={assetVideos}+ images={assetImages}+ results={assetResults}+ onSelectVideo={(url, name) => {+ setVideoUrl(url);+ setVideoName(name || "Selected Video");+ setVideoState(UPLOAD_STATE.READY);+ setOpenDropdown(null);+ }}+ onSelectImage={(url, name) => {+ setImageUrl(url);+ setImageName(name || "Selected Image");+ setImageState(UPLOAD_STATE.READY);+ setOpenDropdown(null);+ }}+ onSelectResultAsVideo={(url, name) => {+ setVideoUrl(url);+ setVideoName(name || "Result Video");+ setVideoState(UPLOAD_STATE.READY);+ setOpenDropdown(null);+ }}+ onDeleteAsset={handleDeleteAsset}+ setFullscreenUrl={setFullscreenUrl}+ onClose={() => setOpenDropdown(null)}+ anchorRef={assetsBtnRef}+ />+ )}+ </div>+ </PromptControls>++ {/* Generate button */}+ <PromptAction+ onClick={handleGenerate}+ disabled={isGenerating}+ >+ {isGenerating ? (+ <>+ <span className="animate-spin inline-block text-black">◌</span>{" "}+ Swapping...+ </>+ ) : (+ <span>Swap Body</span>+ )}+ </PromptAction>+ </PromptFooter>+ </PromptComposer>++ {/* ── FULLSCREEN MEDIA MODAL ── */}+ {fullscreenUrl && (+ <div+ className="fixed inset-0 z-[100] flex items-center justify-center bg-black/95 backdrop-blur-sm animate-fade-in"+ onClick={() => setFullscreenUrl(null)}+ >+ <button+ type="button"+ className="absolute top-6 right-6 p-3 bg-white/10 hover:bg-white/20 rounded-full text-white transition-colors border border-white/10"+ onClick={(e) => {+ e.stopPropagation();+ setFullscreenUrl(null);+ }}+ >+ <svg width="24" height="24" viewBox="0 0 24 24" fill="none" stroke="currentColor" strokeWidth="2.5" strokeLinecap="round" strokeLinejoin="round">+ <line x1="18" y1="6" x2="6" y2="18" />+ <line x1="6" y1="6" x2="18" y2="18" />+ </svg>+ </button>+ {(() => {+ const isImg = fullscreenUrl.match(/\.(jpeg|jpg|gif|png|webp|avif)/i) ||+ fullscreenUrl.includes("/ai-images/") ||+ fullscreenUrl.includes("image") ||+ fullscreenUrl.startsWith("data:image");+ return isImg ? (+ <img+ src={fullscreenUrl}+ alt="Fullscreen Preview"+ className="max-w-[95vw] max-h-[95vh] rounded-2xl shadow-2xl object-contain animate-scale-up"+ onClick={(e) => e.stopPropagation()}+ />+ ) : (+ <video+ src={fullscreenUrl}+ controls+ autoPlay+ loop+ className="max-w-[95vw] max-h-[95vh] rounded-2xl shadow-2xl object-contain animate-scale-up"+ onClick={(e) => e.stopPropagation()}+ />+ );+ })()}+ </div>+ )}+ <Toaster position="top-right" containerStyle={{ zIndex: 99999 }} toastOptions={{ duration: 5000, style: { background: '#18181b', color: '#ffffff', border: '1px solid rgba(255,255,255,0.15)', fontSize: '13px', borderRadius: '12px', boxShadow: '0 10px 30px rgba(0,0,0,0.6)', maxWidth: '440px', wordBreak: 'break-word', whiteSpace: 'pre-wrap', padding: '12px 16px' } }} />+ </div>+ );+}diff --git a/packages/studio/src/components/VibeMotionStudio.jsx b/packages/studio/src/components/VibeMotionStudio.jsxindex 11331a35..156d7ffa 100644--- a/packages/studio/src/components/VibeMotionStudio.jsx+++ b/packages/studio/src/components/VibeMotionStudio.jsx@@ -328,5 +328,377 @@ export default function VibeMotionStudio({? "bg-[#22d3ee]/20 text-[#22d3ee] border-[#22d3ee]/30": "bg-violet-600/30 text-violet-300 border-violet-500/30"}`}>- {entry.mode === "edit" ? "������k�w��E��9�������ѕ�̵���ѕȁ���ѥ�䵉��ݕ����дā�����Ʌ������Ĉ�(��������������������������9�������ѕ�̵���ѕȁ����Ȉ�(���������������������������������9����ѕ�еl����t����е�����ѕ�е�ɥ������ȁ����ԁ����ɥ�������ɽչ������ɑ�ȁ��ɑ�ȵ�ɥ�������ݡ�ѕ���������Ʌ���(������������������������Y����5�ѥ��(����������������������������(����������������������������9����������Ȉ�(������������������������핹��久�����I�ѥ������(�������������������������������������9����ѕ�еl����t�ѕ�еݡ�є�����핹��久�����I�ѥ��������(��������������������������(������������������������핹��乑�Ʌѥ�������(�������������������������������������9����ѕ�еl����t�ѕ�еݡ�є�����핹��乑�Ʌѥ����������(��������������������������(������������������������(����������������������(��������������������핹����ɽ��Ѐ����(�������������������������ѽ�(�������������������������������ѽ��(�������������������������� �����졔������(�����������������������������ѽ�Aɽ����ѥ�����(����������������������������٥��ѽȹ�������ɐ��ɥѕQ��С������ɽ��Ф�(������������������������������Ё�Ѹ����ɕ��Q�ɝ���(���������������������������Ѹ������Q��Ѐ� ��������(��������������������������͕�Q�����Р������쁉Ѹ������Q��Ѐ� �������������(��������������������������(�����������������������������9������ȁ����ԁ���ݡ�є�ԁ��ٕ�鉜��ɥ���������ٕ��ѕ�е�ɥ����ɽչ����ѕ�еl����t����е����մ�ѕ�еݡ�є�����Ʌ�ͥѥ���������ɑ�ȁ��ɑ�ȵݡ�є����(������������������������ѥѱ�� ����ɽ��Ј(�����������������������(������������������������ ���Aɽ���(�������������������������ѽ��(����������������������(��������������������(������������������(����������������(���������������(������������(����������者����Ʌѥ������(��������������R�R �����Mхє��R�R ���(����������������9���������്����ѕ�̵���ѕȁ���ѥ�䵍��ѕȁ���ձ�������є�������������Ʌ�ͥѥ���������Ʌѥ�������������l��١t��(������������켨�=ٕɱ�����������ѥ�����ɑ̀���(������������������9�������ѕ�̵���ѕȁ���ѥ�䵍��ѕȁ����ĸԁ��靅��́������͕���е�����͍�������ʹ�͍���������(��������������������9����ܴ������ȁʹ�ܴ�Ёʹ頴���ɽչ�����ᰁ��ɑ�ȁ��ɑ�ȵݡ�є����͡���ܴ�ᰀ�ɽхє�l�ɑ��t��Ʌ�͙�ɴ���ٕ��ɽхє�����ٕ��͍����������ٕ�������Ʌ�ͥѥ���������Ʌѥ��������ٕə��ܵ����������ݡ�є�l����t�����͡ɥ������(����������������(�������������������Ɍ�����輽�ͅ�ݭ������Ĺ���Ց�ɽ�й��нݕ���͕�̽٥��������̽͑ᰵ�������٥��(���������������������� ɕ�ѥٔ���͕ЀĈ(�����������������������9����ܵ�ձ�����ձ�������е��ٕȈ(������������������(����������������(��������������������9����ܴ������ȁʹ�ܴ�Ёʹ頴���ɽչ�����ᰁ��ɑ�ȁ��ɑ�ȵݡ�є����͡���ܴ�ᰀ�ɽхє�lё��t��Ʌ�͙�ɴ���ٕ��ɽхє�����ٕ��͍����������ٕ�������Ʌ�ͥѥ���������Ʌѥ��������ٕə��ܵ����������ݡ�є�l����t�����́ʹ赵��Ё����͡ɥ������(����������������(�������������������Ɍ�����輽�ͅ�ݭ������Ĺ���Ց�ɽ�й��нݕ���͕�̽٥��������̽��ɽ����������٥��(���������������������� ɕ�ѥٔ���͕ЀȈ(�����������������������9����ܵ�ձ�����ձ�������е��ٕȈ(������������������(����������������(��������������������9����ܴ��������ʹ�ܴ�Ёʹ頴�Ёɽչ�����ձ����ɑ�ȁ��ɑ�ȵݡ�є����͡���ܴ�ᰁɽхє�lّ��t��Ʌ�͙�ɴ���ٕ��ɽхє�����ٕ��͍����������ٕ�������Ʌ�ͥѥ���������Ʌѥ��������ٕə��ܵ����������ݡ�є�l����t�����́ʹ赵��Ё����͡ɥ������(����������������(�������������������Ɍ�����輽�ͅ�ݭ������Ĺ���Ց�ɽ�й��нݕ���͕�̽٥��������̽��ф��յ�����٥��(���������������������� ɕ�ѥٔ���͕Ѐ̈(�����������������������9����ܵ�ձ�����ձ�������е��ٕȈ(������������������(����������������(��������������������9����ܴ������ȁʹ�ܴ�Ёʹ頴���ɽչ�����ᰁ��ɑ�ȁ��ɑ�ȵݡ�є����͡���ܴ�ᰁɽхє�l�ɑ��t��Ʌ�͙�ɴ���ٕ��ɽхє�����ٕ��͍����������ٕ�������Ʌ�ͥѥ���������Ʌѥ��������ٕə��ܵ����������ݡ�є�l����t�����́ʹ赵��Ё����͡ɥ������(����������������(�������������������Ɍ�����輽�ͅ�ݭ������Ĺ���Ց�ɽ�й��нݕ���͕�̽٥��������̽��ə��е�����٥��(���������������������� ɕ�ѥٔ���͕ЀЈ(�����������������������9����ܵ�ձ�����ձ�������е��ٕȈ(������������������(����������������(��������������((�������������ā�����9����ѕ�д�ᰁʹ�ѕ�д�ᰁ���ѕ�д�ᰁ���е���Ʌ������Ʌ������ѥ��Ё���Ёѕ�е���ѕȁ��Ё��������്����ѕ�̵���ѕȈ�(�������������������������9����ѕ�еݡ�є����е����������ɍ�͔�ѕ�еᰁʹ�ѕ�д�ᰁ�Ʌ������ݥ������ā�����������MQIP� IQ%9�]%Q ������(�������������������������9����ѕ�еl��ɐ͕�t����е����������ɍ�͔�ѕ�д�ᰁʹ�ѕ�д�ᰁʹ�дā�Ʌ������ѥ��Ј�(����������������Y% �5=Q%=8�MQU%<(��������������������(���������������(��������������������9����ѕ�еݡ�є����ѕ�е�́ʹ�ѕ�еʹ����е����մ��Ʌ������ݥ���ѕ�е���ѕȁ���ܵ�����������ɕ��ᕐ���Ј�(�����������������Ʌє������ѕ����ѥ����Ʌ����́�ɽ����ѕ�Ё�ɽ��Ѓ�P�����ѥ�������Ʌ��䰁��ф������̰������ɕٕ��̰�������ɔ�(���������������(������������(����������聹ձ��(��������((������켨��R�R � =QQ=4�AI=5AP� H��P���э��́Y����M�Ց����ᅍѱ䃊R�R ����(�������Aɽ��� ����͕��((����������켨��R�R �Q���I���5����Q����������ЁM��ɍ�� ����ȃ�R�R ����(����������������9�������ѕ�̵���ѕȁ���ѥ�䵉��ݕ�������́��Ĉ�(������������켨�1����5����ѽ�������������(�������������Aɽ���M�����ѕ� ���ɽ�������9�����͡ɥ������(���������������Aɽ���M������=�ѥ��(�����������������������ѽ��(������������������ �����젤�����͕����5�������͔��͕����M��ɍ�%���ձ�����(����������������͕���ѕ��셕���5����(���������������(�������������������Ʌє(���������������Aɽ���M������=�ѥ���(���������������Aɽ���M������=�ѥ��(�����������������������ѽ��(������������������ �����젤����͕����5������Ք��(������������������ͅ�����핑��M��ɍ�̹����Ѡ������(����������������͕���ѕ��핑��5����(���������������������9���ͅ����������������ͅ�������ͽȵ��е����ݕ��(���������������(�������������������(���������������Aɽ���M������=�ѥ���(�������������Aɽ���M�����ѕ� ���ɽ��((������������켨�I�������Ё������х��́�����ȁ��ͥ���ѽ��������ѽ�̀���(������������핑��5��������(��������������������9�������ѕ�̵���ѕȁ����ȁ��́��ā���l��ɐ͕�t�ԁ��ɑ�ȁ��ɑ�ȵl��ɐ͕�t����ɽչ�����ձ��ѕ�еl����t�ѕ�еl��ɐ͕�t����е����մ��Ʌ������ѥ��Ё����ܴ�����ܵ�ձ���ٕə��ܵ��������(������������������ٜ�ݥ�Ѡ��Ȉ���������Ȉ�٥�� ��������Ѐ�Ј�����������ɽ�����ɕ�� ���Ȉ���ɽ��]��Ѡ�ȸԈ������9�����͡ɥ������(���������������������Ѡ���4�Ā� фȀȀ������Ȁ���фȀȀ������Ȁɠ�фȀȀ������ȴ�ش܈��(���������������������Ѡ���4��ԀȸՄȸ��Āȸ��Ā����Ā̀�0�Ȁ�հ�ЀĀĴЀ�Դ��舼�(������������������ٜ�(���������������������������9������չ��є��(�������������������ͽ�ɍ�����(�������������������������ѥ��耈��ͽ�ɍ������ɽ�����ͱ��������ԥ���ͽ�ɍ������ɽ���������Ѡ����Ԁ�������耈��(��������������������耉M����Ё��ͽ�ɍ������Ʌѥ����ɽ��ѡ����������(����������������������(�������������������ѽ�(�������������������� �����젤�����͕����5�������͔��͕����M��ɍ�%���ձ���͕�Aɽ��Р������(�����������������������9������Ѽ�ѕ�еl��ɐ͕�t������ٕ��ѕ�еl��ɐ͕�t��Ʌ�ͥѥ��������́ѕ�еʹ������������������͡ɥ�����(������������������ѥѱ�� ��������Ё5����(�����������������(������������������\(�������������������ѽ��(����������������(��������������(������������((������������켨� ��ѽ��Q��хɕ���ձ��ݥ�Ѡ����(������������������9����ܵ�ձ���(���������������Aɽ���Q��хɕ�(����������������ɕ���ѕ�хɕ�I���(����������������م�Ք���ɽ����(������������������ ������졔�����͕�Aɽ��С��хɝ�йم�Ք��(������������������-���ݸ��������-���ݹ�(�����������������������������(����������������������5���(������������������������͍ɥ���ݡ�ЁѼ���������P��������������ɽչ��Ѽ���ɬ����䰁��������́�������������ѥ���ϊ���(��������������������耉�͍ɥ���ѡ����ѥ����Ʌ������P������ѕ��ͅ��́��͡���ɐ�ݥѠ����ݥ�����ȁ�����́����ɥͥ����յ���̜�(�����������������(����������������(��������������((����������켨��R�R ��ɽȁ�����ȃ�R�R ����(����������흕��Ʌѕ�ɽȀ����(������������������9�������ѕ�̵���ѕȁ����ȁ��́��ĸԁ���ɕ�����������ɑ�ȁ��ɑ�ȵɕ���������ɽչ����ѕ�еɕ������ѕ�е�̈�(����������������ٜ�ݥ�Ѡ��Ȉ���������Ȉ�٥�� ��������Ѐ�Ј�����������ɽ�����ɕ�� ���Ȉ���ɽ��]��Ѡ�Ȉ��ɍ�������Ȉ�����Ȉ��������������Ȉ�����������Ȉ�����Ȉ��������Ȉ�����؈�����ȸ�Ĉ�����؈����ٜ�(��������������흕��Ʌѕ�ɽ��(��������������(������������((����������켨��R�R � ���ɽ�́ɽ�聑ɽ���ݹ̀������Ʌє����ѽ���R�R ����(�����������Aɽ�����ѕ��(�������������Aɽ��� ���ɽ�́ɕ��퍽��ɽ��I����((��������������켨��R�R �����ЁI�ѥ���ɽ���ݸ��R�R ����(��������������������9����ɕ��ѥٔ��(�������������������ѽ�(�������������������������ѽ��(�������������������� ������ѽ����ɽ���ݸ���Ȉ��(�����������������������9������ɽ��� ���ɽ� ����9�����(����������������������ѥٔ聽���ɽ���ݸ���Ȉ�(���������������������(�����������������(�������������������Aɽ��������I�ѥ�%������(�����������������������������9�����AI=5AQ} =9QI=1}1 1} 1MM��(��������������������������I�ѥ��(������������������������(�������������������ѽ��(���������������������ɽ���ݸ���Ȉ�����(�������������������Aɽ���A���ٕ��(���������������������Aɽ���A���ٕ�!����������ЁI�ѥ��Aɽ���A���ٕ�!������(���������������������Aɽ���5���1����(�����������������������MA Q}IQ%=L�������Ȥ�����(�������������������������ɽ���ݹ%ѕ�(���������������������������������(�����������������������������������(��������������������������͕���ѕ��������I�ѥ�������(���������������������������� �����젤�����͕������I�ѥ���Ȥ�͕�=���ɽ���ݸ��ձ�����(��������������������������(�������������������������(���������������������Aɽ���5���1����(�������������������Aɽ���A���ٕ��(������������������(����������������((��������������켨��R�R ��Ʌѥ����ɽ���ݸ��R�R ����(��������������������9����ɕ��ѥٔ��(�������������������ѽ�(�������������������������ѽ��(�������������������� ������ѽ����ɽ���ݸ����Ȉ��(�����������������������9������ɽ��� ���ɽ� ����9�����(����������������������ѥٔ聽���ɽ���ݸ����Ȉ�(���������������������(�����������������(�������������������Aɽ����Ʌѥ��%������(�����������������������������9�����AI=5AQ} =9QI=1}1 1} 1MM��(����������������������Ʌѥ����(������������������������(�������������������ѽ��(���������������������ɽ���ݸ����Ȉ�����(�������������������Aɽ���A���ٕ��(���������������������Aɽ���A���ٕ�!�������Ʌѥ���Aɽ���A���ٕ�!������(���������������������Aɽ���5���1����(�����������������������UIQ%=9}=AQ%=9L�������������(�������������������������ɽ���ݹ%ѕ�(��������������������������������(��������������������������������퀑��́�(��������������������������͕���ѕ����Ʌѥ�������(���������������������������� �����젤�����͕��Ʌѥ������͕�=���ɽ���ݸ��ձ�����(��������������������������(�������������������������(���������������������Aɽ���5���1����(�������������������Aɽ���A���ٕ��(������������������(����������������((��������������켨���Ёͽ�ɍ�������ȁ�ɽ���ݸ��P�����͡�ݸ�������Ё��������(��������������핑��5�����������M��ɍ�̹����Ѡ���������(����������������������9����ɕ��ѥٔ��(���������������������ѽ�(���������������������������ѽ��(���������������������� ������ѽ����ɽ���ݸ��ͽ�ɍ����(�������������������������9������ɽ��� ���ɽ� ����9����쁅�ѥٔ���Ք����(�������������������(��������������������������9����ܴЁ��Ё���l��ɐ͕�t����ɽչ����������ѕ�̵���ѕȁ���ѥ�䵍��ѕȁ��ɑ�ȁ��ɑ�ȵl��ɐ͕�t�����(������������������������ٜ�ݥ�Ѡ�䈁�������䈁٥�� ��������Ѐ�Ј�����������ɽ����ɐ͕�����ɽ��]��Ѡ�̈���ɽ��1�������ɽչ�����ɽ��1��������ɽչ���(���������������������������Ѡ���4�Ā� фȀȀ������Ȁ���фȀȀ������Ȁɠ�фȀȀ������ȴ�ش܈��(���������������������������Ѡ���4��ԀȸՄȸ��Āȸ��Ā����Ā̀�0�Ȁ�հ�ЀĀĴЀ�Դ��舼�(������������������������ٜ�(����������������������(�������������������������������9����퀑�AI=5AQ} =9QI=1}1 1} 1MM�ѕ�еl��ɐ͕�t�������ܵl�����t���չ��ѕ���(�����������������������ͽ�ɍ��������M��ɍ�耑�ͽ�ɍ������ɽ�����ͱ���������������耉A����ͽ�ɍ�����(��������������������������(���������������������Aɽ��� ���ɽ�%������(���������������������ѽ��(�����������������������ɽ���ݸ����ͽ�ɍ�������(���������������������Aɽ���A���ٕȁ�����9����ܴ�Ј�(�����������������������Aɽ���A���ٕ�!������M��ɍ�����Ʌѥ���Aɽ���A���ٕ�!������(����������������������������9���������്�������Ĉ�(������������������������핑��M��ɍ�̹������Ɍ������(����������������������������(����������������������������������Ɍ�ɕ�Օ��%��(���������������������������������9�������ѕ�̵���ѕȁ����́��ȁ��ٕ�鉜�ݡ�є�ԁɽչ�������ͽȵ����ѕȁ�Ʌ�ͥѥ��������ɽ�����Ј(������������������������������ �����젤�����͕����M��ɍ�%���Ɍ�ɕ�Օ��%���͕�=���ɽ���ݸ��ձ�����(���������������������������(����������������������������������9����ܴ�����܁ɽչ�����ٕə��ܵ�����������������������͡ɥ�������ɑ�ȁ��ɑ�ȵݡ�є�Ԉ�(�������������������������������٥�����Ɍ���Ɍ��ɱ���9����ܵ�ձ�����ձ�������е��ٕȈ���ѕ�������%��������(������������������������������(����������������������������������9�����ā����ܴ���(��������������������������������������9����ѕ�еl����t�ѕ�еݡ�є������չ��є���������ѥ��Ё�ɽ�����ٕȽ����ѕ�еݡ�є����Ɍ��ɽ�������(��������������������������������������9����ѕ�еl���t�ѕ�еݡ�є�����д��Ԉ���Ɍ�������I�ѥ��-܁��Ɍ���Ʌѥ�������(������������������������������(����������������������������핑��M��ɍ�%������Ɍ�ɕ�Օ��%������ ����Mٜ����(����������������������������(���������������������������(������������������������(���������������������Aɽ���A���ٕ��(��������������������(������������������(����������������((�������������������������9����ѕ�еl����t�ѕ�еݡ�є�����������ʹ鉱�������Ȉ� �ɰ��ѕȁѼ��ո������(�������������Aɽ��� ���ɽ���((������������켨��R�R ����Ʌє� ��ѽ���P���э��́Y����M�Ց����ᅍѱ䃊R�R ����(�������������Aɽ����ѥ��(���������������� ���������������Ʌѕ�(����������������ͅ�����흕��Ʌѥ��������ɽ��й�ɥ������������5������������M��ɍ�%���(�������������(��������������흕��Ʌѥ������(������������������(�����������������������������9������є�������������������ѕ�е��������^0������숀��(������������������핑��5�������I���������耉���Ʌѥ�������(������������������(����������������聕���5�������(����������������������I����������(����������������耠(�������������������������Ʌє������(����������������(�������������Aɽ����ѥ���(�����������Aɽ�����ѕ��(�������Aɽ��� ����͕��(�������Q���ѕȁ��ͥѥ���ѽ��ɥ��Ј����х����M�屔����%������������ѽ���=�ѥ�����쁑�Ʌѥ�����������屔�쁉����ɽչ�耜�����ň��������耜������������ɑ��耜����ͽ����ɝ������������Ԥ�������M��耜���������ɑ��I�����耜����������M�����耜������������ɝ�����������ؤ������]��Ѡ耜��������ݽɑ ɕ��耝�ɕ���ݽɐ���ݡ�ѕM����耝�ɔ��Ʌ�����������耜���������������(������(����)�\ No newline at end of file+ {entry.mode === "edit" ? "✏ Edit" : "✦ Generated"}+ </div>++ {/* ── Hover overlay actions ── */}+ <div className="absolute top-2 right-2 flex flex-col gap-2 opacity-0 group-hover:opacity-100 transition-opacity">+ <button+ type="button"+ title="Fullscreen"+ onClick={(e) => { e.stopPropagation(); setFullscreenUrl(entry.url); }}+ className="p-2 bg-black/60 backdrop-blur-md rounded-full text-white hover:bg-primary hover:text-black transition-all border border-white/10"+ >+ <svg width="14" height="14" viewBox="0 0 24 24" fill="none" stroke="currentColor" strokeWidth="2.5">+ <polyline points="15 3 21 3 21 9" />+ <polyline points="9 21 3 21 3 15" />+ <line x1="21" y1="3" x2="14" y2="10" />+ <line x1="3" y1="21" x2="10" y2="14" />+ </svg>+ </button>+ <button+ type="button"+ title="Download"+ onClick={(e) => { e.stopPropagation(); downloadFile(entry.url, `motion-${entry.id || idx}.mp4`); }}+ className="p-2 bg-black/60 backdrop-blur-md rounded-full text-white hover:bg-primary hover:text-black transition-all border border-white/10"+ >+ <svg width="14" height="14" viewBox="0 0 24 24" fill="none" stroke="currentColor" strokeWidth="2.5">+ <path d="M21 15v4a2 2 0 01-2 2H5a2 2 0 01-2-2v-4M7 10l5 5 5-5M12 15V3" />+ </svg>+ </button>+ {entry.requestId && entry.canEdit !== false ? (+ <button+ type="button"+ title="Remix this generation"+ onClick={(e) => {+ e.stopPropagation();+ setEditMode(true);+ setEditSourceId(entry.requestId);+ setPrompt("");+ setTimeout(() => textareaRef.current?.focus(), 50);+ }}+ className="p-2 bg-black/60 backdrop-blur-md rounded-full text-white hover:bg-[#22d3ee] hover:text-black transition-all border border-white/10"+ >+ <svg width="14" height="14" viewBox="0 0 24 24" fill="none" stroke="currentColor" strokeWidth="2.5" strokeLinecap="round" strokeLinejoin="round">+ <path d="M11 4H4a2 2 0 0 0-2 2v14a2 2 0 0 0 2 2h14a2 2 0 0 0 2-2v-7"/>+ <path d="M18.5 2.5a2.121 2.121 0 0 1 3 3L12 15l-4 1 1-4 9.5-9.5z"/>+ </svg>+ </button>+ ) : entry.requestId && entry.canEdit === false ? (+ /* Legacy generation — animation code not saved by API, remix not available */+ <div+ title="Legacy generation — remix not available. Generate a new motion graphic to enable editing."+ className="p-2 bg-black/60 backdrop-blur-md rounded-full text-white/20 border border-white/5 cursor-not-allowed"+ >+ <svg width="14" height="14" viewBox="0 0 24 24" fill="none" stroke="currentColor" strokeWidth="2.5" strokeLinecap="round" strokeLinejoin="round" className="opacity-40">+ <path d="M11 4H4a2 2 0 0 0-2 2v14a2 2 0 0 0 2 2h14a2 2 0 0 0 2-2v-7"/>+ <path d="M18.5 2.5a2.121 2.121 0 0 1 3 3L12 15l-4 1 1-4 9.5-9.5z"/>+ <line x1="4" y1="4" x2="20" y2="20" stroke="currentColor" strokeWidth="2"/>+ </svg>+ </div>+ ) : null}+ <button+ type="button"+ title="Delete"+ onClick={(e) => {+ e.stopPropagation();+ if (confirm("Are you sure you want to delete this generated item?")) {+ setHistory(prev => prev.filter((_, i) => i !== idx));+ }+ }}+ className="p-2 bg-black/60 backdrop-blur-md rounded-full text-red-400 hover:bg-red-500 hover:text-white transition-all border border-white/10"+ >+ <svg width="14" height="14" viewBox="0 0 24 24" fill="none" stroke="currentColor" strokeWidth="2.5">+ <polyline points="3 6 5 6 21 6" />+ <path d="M19 6v14a2 2 0 01-2 2H7a2 2 0 01-2-2V6m3 0V4a2 2 0 012-2h4a2 2 0 012 2v2" />+ <line x1="10" y1="11" x2="10" y2="17" />+ <line x1="14" y1="11" x2="14" y2="17" />+ </svg>+ </button>+ </div>++ {/* ── Card footer: prompt + metadata ── */}+ <div className="p-3 bg-black/80 backdrop-blur-sm border-t border-white/5 flex-1 flex flex-col justify-between gap-2">+ <p className="text-white/70 text-xs line-clamp-3 leading-relaxed" title={entry.prompt}>+ {entry.prompt || "No prompt"}+ </p>+ <div className="flex items-center justify-between mt-1 flex-wrap gap-1">+ <div className="flex items-center gap-2">+ <span className="text-[10px] font-bold text-primary px-2 py-0.5 bg-primary/10 rounded border border-primary/20 whitespace-nowrap">+ Vibe Motion+ </span>+ <div className="flex gap-2">+ {entry.aspectRatio && (+ <span className="text-[10px] text-white/40">{entry.aspectRatio}</span>+ )}+ {entry.duration && (+ <span className="text-[10px] text-white/40">{entry.duration}s</span>+ )}+ </div>+ </div>+ {entry.prompt && (+ <button+ type="button"+ onClick={(e) => {+ e.stopPropagation();+ navigator.clipboard.writeText(entry.prompt);+ const btn = e.currentTarget;+ btn.innerText = "Copied!";+ setTimeout(() => { btn.innerText = "Copy"; }, 2000);+ }}+ className="px-2 py-0.5 bg-white/5 hover:bg-primary/20 hover:text-primary rounded text-[10px] font-medium text-white/70 transition-all border border-white/10"+ title="Copy prompt"+ >+ Copy Prompt+ </button>+ )}+ </div>+ </div>+ </div>+ ))}+ </div>+ ) : !generating ? (+ /* ── Empty State ── */+ <div className="flex flex-col items-center justify-center h-full animate-fade-in-up transition-all duration-700 min-h-[50vh]">+ {/* Overlapping floating cards */}+ <div className="flex items-center justify-center gap-1.5 md:gap-3 mb-10 select-none scale-90 sm:scale-100">+ <div className="w-18 h-22 sm:w-24 sm:h-28 rounded-2xl border border-white/10 shadow-2xl -rotate-[12deg] transform hover:rotate-0 hover:scale-110 hover:z-20 transition-all duration-300 overflow-hidden bg-white/[0.01] flex-shrink-0">+ <img+ src="https://d3adwkbyhxyrtq.cloudfront.net/webassets/videomodels/sdxl-image.avif"+ alt="Creative asset 1"+ className="w-full h-full object-cover"+ />+ </div>+ <div className="w-18 h-22 sm:w-24 sm:h-28 rounded-2xl border border-white/10 shadow-2xl -rotate-[4deg] transform hover:rotate-0 hover:scale-110 hover:z-20 transition-all duration-300 overflow-hidden bg-white/[0.01] -ml-3 sm:-ml-4 flex-shrink-0">+ <img+ src="https://d3adwkbyhxyrtq.cloudfront.net/webassets/videomodels/chroma-image.avif"+ alt="Creative asset 2"+ className="w-full h-full object-cover"+ />+ </div>+ <div className="w-18 h-18 sm:w-24 sm:h-24 rounded-full border border-white/10 shadow-2xl rotate-[6deg] transform hover:rotate-0 hover:scale-110 hover:z-20 transition-all duration-300 overflow-hidden bg-white/[0.01] -ml-3 sm:-ml-4 flex-shrink-0">+ <img+ src="https://d3adwkbyhxyrtq.cloudfront.net/webassets/videomodels/neta-lumina.avif"+ alt="Creative asset 3"+ className="w-full h-full object-cover"+ />+ </div>+ <div className="w-18 h-22 sm:w-24 sm:h-28 rounded-2xl border border-white/10 shadow-2xl rotate-[12deg] transform hover:rotate-0 hover:scale-110 hover:z-20 transition-all duration-300 overflow-hidden bg-white/[0.01] -ml-3 sm:-ml-4 flex-shrink-0">+ <img+ src="https://d3adwkbyhxyrtq.cloudfront.net/webassets/videomodels/perfect-pony-xl.avif"+ alt="Creative asset 4"+ className="w-full h-full object-cover"+ />+ </div>+ </div>++ <h1 className="text-2xl sm:text-4xl md:text-5xl font-extrabold tracking-tight mb-4 text-center px-4 flex flex-col items-center">+ <span className="text-white font-black uppercase text-xl sm:text-3xl tracking-wide mb-1 opacity-90">START CREATING WITH</span>+ <span className="text-[#22d3ee] font-black uppercase text-2xl sm:text-4xl sm:mt-1 tracking-tight">+ VIBE MOTION STUDIO+ </span>+ </h1>+ <p className="text-white/40 text-xs sm:text-sm font-medium tracking-wide text-center max-w-lg leading-relaxed px-4">+ Generate animated motion graphics from a text prompt — kinetic typography, data charts, logo reveals, and more.+ </p>+ </div>+ ) : null}+ </div>++ {/* ── BOTTOM PROMPT BAR — matches VideoStudio exactly ── */}+ <PromptComposer>++ {/* ── Top Row: Mode Toggle & Edit Source Banner ── */}+ <div className="flex items-center justify-between gap-3 px-1">+ {/* Left: Mode toggle pill */}+ <PromptSegmentedControl className="flex-shrink-0">+ <PromptSegmentOption+ type="button"+ onClick={() => { setEditMode(false); setEditSourceId(null); }}+ selected={!editMode}+ >+ Generate+ </PromptSegmentOption>+ <PromptSegmentOption+ type="button"+ onClick={() => setEditMode(true)}+ disabled={editSources.length === 0}+ selected={editMode}+ className="disabled:opacity-30 disabled:cursor-not-allowed"+ >+ Edit+ </PromptSegmentOption>+ </PromptSegmentedControl>++ {/* Right: Edit mode status banner beside toggle buttons */}+ {editMode && (+ <div className="flex items-center gap-2 px-3 py-1 bg-[#22d3ee]/5 border border-[#22d3ee]/10 rounded-full text-[11px] text-[#22d3ee] font-medium tracking-tight min-w-0 max-w-full overflow-hidden">+ <svg width="12" height="12" viewBox="0 0 24 24" fill="none" stroke="currentColor" strokeWidth="2.5" className="flex-shrink-0">+ <path d="M11 4H4a2 2 0 0 0-2 2v14a2 2 0 0 0 2 2h14a2 2 0 0 0 2-2v-7"/>+ <path d="M18.5 2.5a2.121 2.121 0 0 1 3 3L12 15l-4 1 1-4 9.5-9.5z"/>+ </svg>+ <span className="truncate">+ {sourceEntry+ ? `Editing: "${sourceEntry.prompt?.slice(0, 45)}${sourceEntry.prompt?.length > 45 ? "…" : ""}"`+ : "Select a source generation from the gallery"}+ </span>+ <button+ onClick={() => { setEditMode(false); setEditSourceId(null); setPrompt(""); }}+ className="ml-auto text-[#22d3ee]/40 hover:text-[#22d3ee] transition-colors text-sm leading-none flex-shrink-0"+ title="Cancel Edit Mode"+ >+ ×+ </button>+ </div>+ )}+ </div>++ {/* Bottom: Textarea full width */}+ <div className="w-full">+ <PromptTextarea+ ref={textareaRef}+ value={prompt}+ onChange={(e) => setPrompt(e.target.value)}+ onKeyDown={handleKeyDown}+ placeholder={+ editMode+ ? "Describe what to change — 'change background to dark navy, make bars gold, add particles…'"+ : "Describe the motion graphic — 'Animated sales dashboard with glowing bar charts and rising numbers'"+ }+ />+ </div>++ {/* ── Error banner ── */}+ {generateError && (+ <div className="flex items-center gap-2 px-3 py-1.5 bg-red-500/10 border border-red-500/20 rounded text-red-400 text-xs">+ <svg width="12" height="12" viewBox="0 0 24 24" fill="none" stroke="currentColor" strokeWidth="2"><circle cx="12" cy="12" r="10"/><line x1="12" y1="8" x2="12" y2="12"/><line x1="12" y1="16" x2="12.01" y2="16"/></svg>+ {generateError}+ </div>+ )}++ {/* ── Controls row: dropdowns + generate button ── */}+ <PromptFooter>+ <PromptControls ref={controlsRef}>++ {/* ── Aspect Ratio dropdown ── */}+ <div className="relative">+ <button+ type="button"+ onClick={toggleDropdown("ar")}+ className={promptControlClassName({+ active: openDropdown === "ar",+ })}+ >+ <PromptAspectRatioIcon />+ <span className={PROMPT_CONTROL_LABEL_CLASS}>+ {aspectRatio}+ </span>+ </button>+ {openDropdown === "ar" && (+ <PromptPopover>+ <PromptPopoverHeader>Aspect Ratio</PromptPopoverHeader>+ <PromptMenuList>+ {ASPECT_RATIOS.map((ar) => (+ <DropdownItem+ key={ar}+ label={ar}+ selected={aspectRatio === ar}+ onClick={() => { setAspectRatio(ar); setOpenDropdown(null); }}+ />+ ))}+ </PromptMenuList>+ </PromptPopover>+ )}+ </div>++ {/* ── Duration dropdown ── */}+ <div className="relative">+ <button+ type="button"+ onClick={toggleDropdown("dur")}+ className={promptControlClassName({+ active: openDropdown === "dur",+ })}+ >+ <PromptDurationIcon />+ <span className={PROMPT_CONTROL_LABEL_CLASS}>+ {duration}s+ </span>+ </button>+ {openDropdown === "dur" && (+ <PromptPopover>+ <PromptPopoverHeader>Duration</PromptPopoverHeader>+ <PromptMenuList>+ {DURATION_OPTIONS.map((d) => (+ <DropdownItem+ key={d}+ label={`${d}s`}+ selected={duration === d}+ onClick={() => { setDuration(d); setOpenDropdown(null); }}+ />+ ))}+ </PromptMenuList>+ </PromptPopover>+ )}+ </div>++ {/* Edit source picker dropdown — only shown in edit mode */}+ {editMode && editSources.length > 0 && (+ <div className="relative">+ <button+ type="button"+ onClick={toggleDropdown("source")}+ className={promptControlClassName({ active: true })}+ >+ <div className="w-4 h-4 bg-[#22d3ee]/20 rounded flex items-center justify-center border border-[#22d3ee]/30">+ <svg width="9" height="9" viewBox="0 0 24 24" fill="none" stroke="#22d3ee" strokeWidth="3" strokeLinecap="round" strokeLinejoin="round">+ <path d="M11 4H4a2 2 0 0 0-2 2v14a2 2 0 0 0 2 2h14a2 2 0 0 0 2-2v-7"/>+ <path d="M18.5 2.5a2.121 2.121 0 0 1 3 3L12 15l-4 1 1-4 9.5-9.5z"/>+ </svg>+ </div>+ <span className={`${PROMPT_CONTROL_LABEL_CLASS} text-[#22d3ee]/70 max-w-[120px] truncate`}>+ {sourceEntry ? `Source: ${sourceEntry.prompt?.slice(0, 20)}…` : "Pick source…"}+ </span>+ <PromptChevronIcon />+ </button>+ {openDropdown === "source" && (+ <PromptPopover className="w-64">+ <PromptPopoverHeader>Source Generation</PromptPopoverHeader>+ <div className="flex flex-col gap-1">+ {editSources.map((src) => (+ <div+ key={src.requestId}+ className="flex items-center gap-3 p-2 hover:bg-white/5 rounded cursor-pointer transition-all group/opt"+ onClick={() => { setEditSourceId(src.requestId); setOpenDropdown(null); }}+ >+ <div className="w-10 h-7 rounded overflow-hidden bg-black/40 flex-shrink-0 border border-white/5">+ <video src={src.url} className="w-full h-full object-cover" muted playsInline />+ </div>+ <div className="flex-1 min-w-0">+ <p className="text-[11px] text-white/70 truncate leading-tight group-hover/opt:text-white">{src.prompt}</p>+ <p className="text-[9px] text-white/30 mt-0.5">{src.aspectRatio} · {src.duration}s</p>+ </div>+ {editSourceId === src.requestId && <CheckSvg />}+ </div>+ ))}+ </div>+ </PromptPopover>+ )}+ </div>+ )}++ <span className="text-[10px] text-white/20 hidden sm:block ml-2">Ctrl+Enter to run</span>+ </PromptControls>++ {/* ── Generate Button — matches VideoStudio exactly ── */}+ <PromptAction+ onClick={handleGenerate}+ disabled={generating || !prompt.trim() || (editMode && !editSourceId)}+ >+ {generating ? (+ <>+ <span className="animate-spin inline-block text-black">◌</span>{" "}+ {editMode ? "Remixing..." : "Generating..."}+ </>+ ) : editMode ? (+ <span>Remix</span>+ ) : (+ <span>Generate</span>+ )}+ </PromptAction>+ </PromptFooter>+ </PromptComposer>+ <Toaster position="top-right" containerStyle={{ zIndex: 99999 }} toastOptions={{ duration: 5000, style: { background: '#18181b', color: '#ffffff', border: '1px solid rgba(255,255,255,0.15)', fontSize: '13px', borderRadius: '12px', boxShadow: '0 10px 30px rgba(0,0,0,0.6)', maxWidth: '440px', wordBreak: 'break-word', whiteSpace: 'pre-wrap', padding: '12px 16px' } }} />+ </div>+ );+}diff --git a/packages/studio/src/components/VideoStudio.jsx b/packages/studio/src/components/VideoStudio.jsxindex 95616327..3dba207f 100644--- a/packages/studio/src/components/VideoStudio.jsx+++ b/packages/studio/src/components/VideoStudio.jsx@@ -384,4 +384,1768 @@ function ModelDropdown({ imageMode, selectedModel, onSelect, onClose }) {<div className="text-xs font-bold text-orange-400/70 px-3 py-2 mt-1 border-t border-white/5">Video Tools</div>- {filteredV2V.map((m) => renderItem(�ݷ��$z{-���jם7��#b �7��#b �#�#B �7G&��S�&7W'&V�D6���" �7G&��Uv�GF��#" �f����'G&�7&V�B �7G&��TF6�'&�׳��Т7G&��TF6��fg6WC׳�������f�FV�&�w&W72��Т6�74��S�'FW�Bղ3#&C6VU�G&�6�F������GW&F����3 �����7fs��7�6�74��S�&'6��WFRFW�Bճ���f��B�&�6�FW�Bղ3#&C6VU��VF��r����R#�f�FV�&�w&W77�S��7����F�c������7fp�v�GF��#b ��V�v�C�#b �f�Wt&���##B#B �f����&���R �7G&��S�&7W'&V�D6���" �7G&��Uv�GF��#"�R �6�74��S�'FW�B�v��FR�Cw&�Wֆ�fW#�FW�Bղ3#&C6VU�G&�6�F����6���'2 ����ǖv�����G3�##2rb"#2r#2r"f����&7W'&V�D6���""���&V7B��#"��#R"v�GF��#R"�V�v�C�#B"'��#""'��#""f����&7W'&V�D6���""����7fs��Т��'WGF�����F�c��Т��F�cࠢ��&��BFW�F&V��Т�F�b6�74��S�&f�W��f�W�f�W��6��v�#��&��EFW�F&V�&VcFW�F&V&VgТf�VS&��GТ��6��vS��F�U&��D��WGТ�6V���FW#&��E�6V���FW'ТF�6&�VC&��DF�6&�VGТ����F�c���F�cࠢ��W�FV�B&��W"��Т��4W�FV�D��FRbb���F�b6�74��S�&f�W��FV�2�6V�FW"v�"��2���Rׂ�2&r�&��'��R&�&FW"&�&FW"�&��'��&�V�FVB��rFW�Bճ��FW�B�&��'��f��B��VF�V�G&6���r�F�v�B#��7fp�v�GF��#2 ��V�v�C�#2 �f�Wt&���##B#B �f����&���R �7G&��S�&7W'&V�D6���" �7G&��Uv�GF��#"�R ���F�C�$�R&�D�"V�rr�rr"����7fs��7��W�FV�F��r&Wf��W26VVF�6R"�vV�W&F�����7����F�c��Р���&�GF��&�s�6��G&��2�vV�W&FR��Т�&��Df��FW#��&��D6��G&��2&VcG&�F�v�&Vg������FV�'F���Т�F�b6�74��S�'&V�F�fR#��'WGF��G�S�&'WGF�� ���6Ɩ6�F�vv�TG&�F�v�&��FV�"�Т6�74��S&��D6��G&��6�74��R���7F�fS��V�G&�F�v����&��FV�"��җТ��F�b6�74��S�'r�B��B&�V�FVB�fW&f��rֆ�FFV�6�&���f�W��FV�2�6V�FW"�W7F�g��6V�FW"&r�v��FR�R#���������6��7B��7W'&V�D��FV�2�����C'd��FV�2����'d��FV�2����c'd��FV�5Ӱ�6��7B6V�V7FVD��FV��&����7W'&V�D��FV�2�f��B������B���6V�V7FVD��FV��6��7B6V�V7FVD��FV�&�f�FW"�6V�V7FVD��FV��&���&�f�FW"��v�V�s��&WGW&�$�d�DU%���t�5�6V�V7FVD��FV�&�f�FW%����Ɩ�r �7&3$�d�DU%���t�5�6V�V7FVD��FV�&�f�FW%�� ��C�"" �6�74��Sr�gV����gV���&�V7B�6��F��G���fW'D��v�2��6�VFW2�6V�V7FVD��FV�&�f�FW"��&��fW'B"�"'�� ��������7�6�74��S�'FW�Bճ���f��B�&��BFW�B�&�6�WW&66R#�c��7�����Ғ��Т��F�c��7�6�74��S$��E�4��E$����$T��4�57���6V�V7FVD��FV���WТ��7���&��D6�Wg&��6������'WGF�����V�G&�F�v����&��FV�"bb���&��E��fW ���6Ɩ6�ײ�R���R�7F�&�vF��ₗТ6�74��S�'rն6�2�gr�'&Vҕ��C�rճC������r��B�C����r����R��ւճsf�� ���&��E��fW$�VFW#���FV���&��E��fW$�VFW#����FV�G&�F�v���vT��FS��vT��FWТ6V�V7FVD��FV�6V�V7FVD��FV�Т��6V�V7C��F�T��FV�6V�V7GТ��6��6Sײ����6WD�V�G&�F�v��V�Т����&��E��fW#��Т��F�cࠢ��7V7B&F��'F���Т�6��t"bb���F�b6�74��S�'&V�F�fR#��'WGF��G�S�&'WGF�� ���6Ɩ6�F�vv�TG&�F�v�&""�Т6�74��S&��D6��G&��6�74��R���7F�fS��V�G&�F�v����&""��җТ��&��D7V7E&F���6�����7�6�74��S$��E�4��E$����$T��4�57���6V�V7FVD'Т��7����'WGF�����V�G&�F�v����&""bb���&��E��fW ���6Ɩ6�ײ�R���R�7F�&�vF��ₗТ��&��E��fW$�VFW#�7V7B&F����&��E��fW$�VFW#��&��D�V�TƗ7C��vWD7W'&V�D7V7E&F��2�6V�V7FVD��FV����"������&��D�V�T�FVТ�W�'Т6V�V7FVC6V�V7FVD"���'Т��6Ɩ6�ײ�R�����R�7F�&�vF��ₓ��6WE6V�V7FVD"�"���6WD�V�G&�F�v��V����Т��'Т��&��D�V�T�FV����Т��&��D�V�TƗ7C���&��E��fW#��Т��F�c��Р���VffV7B'F���Т�6��tVffV7Bbb���F�b6�74��S�'&V�F�fR#��'WGF��G�S�&'WGF�� ���6Ɩ6�F�vv�TG&�F�v�&VffV7B"�Т6�74��S&��D6��G&��6�74��R���7F�fS��V�G&�F�v����&VffV7B"��җТ��7fp�v�GF��#b ��V�v�C�#b �f�Wt&���##B#B �f����&���R �7G&��S�&7W'&V�D6���" �7G&��Uv�GF��#" �6�74��S�&�6�G��CFW�B�v��FR ���F�C�$�R6�B��B�c7�"����7fs��7�6�74��SG�$��E�4��E$����$T��4�57����rճC��G'V�6FV���6V�V7FVDVffV7B��$VffV7B'Т��7����'WGF�����V�G&�F�v����&VffV7B"bb���&��E��fW ���6Ɩ6�ײ�R���R�7F�&�vF��ₗТ6�74��S�&֖��rճ#�� ���&��E��fW$�VFW#�VffV7BG�P���&��E��fW$�VFW#��&��D�V�TƗ7C��vWDVffV7G4f�$�%d��FV6V�V7FVD��FV����Vfb������&��D�V�T�FVТ�W�VfgТ6V�V7FVC6V�V7FVDVffV7B���VfgТ��6Ɩ6�ײ�R�����R�7F�&�vF��ₓ��6WE6V�V7FVDVffV7B�Vfb���6WD�V�G&�F�v��V����Т��VfgТ��&��D�V�T�FV����Т��&��D�V�TƗ7C���&��E��fW#��Т��F�c��Р���GW&F���'F���Т�6��tGW&F���bb���F�b6�74��S�'&V�F�fR#��'WGF��G�S�&'WGF�� ���6Ɩ6�F�vv�TG&�F�v�&GW&F���"�Т6�74��S&��D6��G&��6�74��R���7F�fS��V�G&�F�v����&GW&F���"��җТ��&��DGW&F���6�����7�6�74��S$��E�4��E$����$T��4�57���6V�V7FVDGW&F����0���7����'WGF�����V�G&�F�v����&GW&F���"bb���&��E��fW ���6Ɩ6�ײ�R���R�7F�&�vF��ₗТ��&��E��fW$�VFW#�GW&F�����&��E��fW$�VFW#��&��D�V�TƗ7C��vWD7W'&V�DGW&F���2�6V�V7FVD��FV����B������&��D�V�T�FVТ�W�GТ6V�V7FVC6V�V7FVDGW&F������GТ��6Ɩ6�ײ�R�����R�7F�&�vF��ₓ��6WE6V�V7FVDGW&F���B���6WD�V�G&�F�v��V����Т��G�0���&��D�V�T�FV����Т��&��D�V�TƗ7C���&��E��fW#��Т��F�c��Р���&W6��WF���'F���Т�6��u&W6��WF���bb���F�b6�74��S�'&V�F�fR#��'WGF��G�S�&'WGF�� ���6Ɩ6�F�vv�TG&�F�v�'&W6��WF���"�Т6�74��S&��D6��G&��6�74��R���7F�fS��V�G&�F�v����'&W6��WF���"��җТ��&��EVƗG��6�����7�6�74��S$��E�4��E$����$T��4�57���6V�V7FVE&W6��WF�����#s#'Т��7����'WGF�����V�G&�F�v����'&W6��WF���"bb���&��E��fW ���6Ɩ6�ײ�R���R�7F�&�vF��ₗТ��&��E��fW$�VFW#�&W6��WF�����&��E��fW$�VFW#��&��D�V�TƗ7C��vWD7W'&V�E&W6��WF���2�6V�V7FVD��FV����"������&��D�V�T�FVТ�W�'Т6V�V7FVC6V�V7FVE&W6��WF������'Т��6Ɩ6�ײ�R�����R�7F�&�vF��ₓ��6WE6V�V7FVE&W6��WF���"���6WD�V�G&�F�v��V����Т��'Т��&��D�V�T�FV����Т��&��D�V�TƗ7C���&��E��fW#��Т��F�c��Р��6�W��D��vU&VfW&V�6Rbb���'WGF��G�S�&'WGF�� �6�74��S&��D6��G&��6�74��R��Т��6Ɩ6�ײ����6WD�4G&t��F��V�G'VR�Т��7fp�v�GF��#b ��V�v�C�#b �f�Wt&���##B#B �f����&���R �7G&��S�&7W'&V�D6���" �7G&��Uv�GF��#"�R �6�74��S�&�6�G��CFW�B�v��FRw&�Wֆ�fW#�FW�Bղ3#&C6VU�G&�6�F����6���'2 ���F�C�$�"#��"���F�C�$�b�R2�V"�#"�#24�r���B�D�b�R2�W�"����7fs��7�6�74��S$��E�4��E$����$T��4�57��G&s��7����'WGF����Т��&��D6��G&��3ࠢ��vV�W&FR'WGF����Т�&��D7F�����6Ɩ6���F�TvV�W&FWТF�6&�VCvV�W&F��wТ��vV�W&F��r������7�6�74��S�&��FR�7����Ɩ�R�&��6�FW�B�&�6�#�)x����7��"'ТvV�W&F��r�������������7��vV�W&FS��7������Т��&��D7F������&��Df��FW#���&��D6���6W#ࠢ��)H)HeT��45$TT�d�DT���D�)H)H��Т�gV��67&VV�W&�bb���F�b �6�74��S�&f��VB��6WB��ճ�f�W��FV�2�6V�FW"�W7F�g��6V�FW"&r�&�6��R&6�G&��&�W"�6���FR�fFR֖� ���6Ɩ6�ײ����6WDgV��67&VV�W&�V�Т��'WGF��G�S�&'WGF�� �6�74��S�&'6��WFRF��b&�v�B�b�2&r�v��FR���fW#�&r�v��FR�#&�V�FVB�gV��FW�B�v��FRG&�6�F����6���'2&�&FW"&�&FW"�v��FR� ���6Ɩ6�ײ�R�����R�7F�&�vF��ₓ��6WDgV��67&VV�W&�V����Т��7frv�GF��##B"�V�v�C�##B"f�Wt&���##B#B"f����&���R"7G&��S�&7W'&V�D6���""7G&��Uv�GF��#"�R"7G&��TƖ�V6�'&�V�B"7G&��TƖ�V�����'&�V�B#��Ɩ�R��#�"��#b"�#�#b"�#�#�"���Ɩ�R��#b"��#b"�#�#�"�#�#�"����7fs���'WGF����f�FV� �7&3gV��67&VV�W&�� �6��G&��2 �WF��� ���� �6�74��S�&���rճ�Wgu���ւճ�Wf��&�V�FVB�'��6�F�r�'���&�V7B�6��F����FR�66�R�W" ���6Ɩ6�ײ�R���R�7F�&�vF��ₗТ����F�c��Р��G&t��F���4�V��4G&t��F��V�Т��6��6Sײ����6WD�4G&t��F��V�f�6R�Т��W���W�Т&F6�6��S׳Т��FD��7F�'��FV���F�TG&u&VfW&V�6WТ���F�7FW"�6�F����'F��&�v�B"6��F��W%7G��S����FW���������F�7D�F���3�GW&F���S�7G��S��&6�w&�V�C�r3��"r�6���#�r6fffffbr�&�&FW#�s�6�ƖB&v&�#SR�#SR�#SR��R�r�f��E6��S�s7�r�&�&FW%&F�W3�s'�r�&��6�F�s�s�3�&v&�����b�r���v�GF��sCC�r�v�&D'&V��v'&V��v�&Br�v��FU76S�w&R�w&r�FF��s�s'�g�r�������F�c�����\ No newline at end of file+ {filteredV2V.map((m) => renderItem(m, true))}+ </>+ )}+ </>+ )}+ </div>+ </div>+ </div>+ );+}++// ── Control button ────────────────────────────────────────────────────────────++// ── Dropdown panel ─────────────────────────────────────────────────────────────+// Rendered inside a `relative` wrapper div; floats above the anchor button.++// ── Main component ────────────────────────────────────────────────────────────++export default function VideoStudio({+ apiKey,+ onGenerationStart,+ onGenerationEnd,+ onGenerationComplete,+ onGenerationError,+ historyItems,+ droppedFiles,+ onFilesHandled,+}) {+ const LEGACY_PERSIST_KEY = "hg_video_studio_persistent";+ const PERSIST_KEY = scopedPersistKey(LEGACY_PERSIST_KEY, apiKey);+ useEffect(() => {+ migrateLegacyPersistKey(LEGACY_PERSIST_KEY, PERSIST_KEY);+ }, [PERSIST_KEY]);++ // ── mode state ──+ const [imageMode, setImageMode] = useState(false); // i2v+ const [v2vMode, setV2vMode] = useState(false);++ // ── model / params ──+ const defaultModel = t2vModels[0];+ const [selectedModel, setSelectedModel] = useState(defaultModel.id);+ const [selectedModelName, setSelectedModelName] = useState(defaultModel.name);+ const [selectedAr, setSelectedAr] = useState(+ defaultModel.inputs?.aspect_ratio?.default || "16:9",+ );+ const [selectedDuration, setSelectedDuration] = useState(+ defaultModel.inputs?.duration?.default || 5,+ );+ const [selectedResolution, setSelectedResolution] = useState(+ defaultModel.inputs?.resolution?.default || "",+ );+ const [selectedQuality, setSelectedQuality] = useState(+ defaultModel.inputs?.quality?.default || "",+ );+ const [selectedMode, setSelectedMode] = useState("");+ const [selectedEffect, setSelectedEffect] = useState("");++ // ── upload progress ──+ const [imageProgress, setImageProgress] = useState(0);+ const [videoProgress, setVideoProgress] = useState(0);++ // ── control visibility ──+ const [showAr, setShowAr] = useState(true);+ const [showDuration, setShowDuration] = useState(true);+ const [showResolution, setShowResolution] = useState(false);+ const [showQuality, setShowQuality] = useState(false);+ const [showMode, setShowMode] = useState(false);+ const [showEffect, setShowEffect] = useState(false);++ // ── uploads ──+ const [uploadedImageUrl, setUploadedImageUrl] = useState(null);+ const [uploadedImageUrls, setUploadedImageUrls] = useState([]);+ const [imageUploading, setImageUploading] = useState(false);+ const [uploadedEndImageUrl, setUploadedEndImageUrl] = useState(null);+ const [endImageUploading, setEndImageUploading] = useState(false);+ const [endImageProgress, setEndImageProgress] = useState(0);+ const [uploadedVideoUrl, setUploadedVideoUrl] = useState(null);+ const [videoUploading, setVideoUploading] = useState(false);+ const [uploadedVideoName, setUploadedVideoName] = useState(null);++ // ── generation / canvas ──+ const [generating, setGenerating] = useState(false);+ const [generateError, setGenerateError] = useState(null);+ const [fullscreenUrl, setFullscreenUrl] = useState(null);+ const [canvasUrl, setCanvasUrl] = useState(null);+ const [canvasModel, setCanvasModel] = useState(null);+ const [showCanvas, setShowCanvas] = useState(false);+ const [isDrawModalOpen, setIsDrawModalOpen] = useState(false);+ const [lastGenerationId, setLastGenerationId] = useState(null);+ const [lastGenerationModel, setLastGenerationModel] = useState(null);++ // ── history ──+ const [localHistory, setLocalHistory] = useState([]);+ const [activeHistoryIdx, setActiveHistoryIdx] = useState(0);++ // ── dropdown ──+ const [openDropdown, setOpenDropdown] = useState(null); // 'model'|'ar'|'duration'|'resolution'|'quality'|'mode'|null++ // ── prompt ──+ const [prompt, setPrompt] = useState("");+ const [promptDisabled, setPromptDisabled] = useState(false);++ // ── refs ──+ const containerRef = useRef(null);+ const textareaRef = useRef(null);+ const dropdownRef = useRef(null);+ const imageFileInputRef = useRef(null);+ const endImageFileInputRef = useRef(null);+ const videoFileInputRef = useRef(null);+ const resultVideoRef = useRef(null);+ const hasRestored = useRef(false);++ // ── derived data ──+ const history = historyItems ?? localHistory;++ const getCurrentModels = useCallback(() => {+ if (v2vMode) return v2vModels;+ return imageMode ? i2vModels : t2vModels;+ }, [imageMode, v2vMode]);++ const getCurrentAspectRatios = useCallback(+ (id) =>+ imageMode+ ? getAspectRatiosForI2VModel(id)+ : getAspectRatiosForVideoModel(id),+ [imageMode],+ );++ const getCurrentDurations = useCallback(+ (id) =>+ imageMode ? getDurationsForI2VModel(id) : getDurationsForModel(id),+ [imageMode],+ );++ const getCurrentResolutions = useCallback(+ (id) =>+ imageMode+ ? getResolutionsForI2VModel(id)+ : getResolutionsForVideoModel(id),+ [imageMode],+ );++ const getCurrentModel = useCallback(+ () => getCurrentModels().find((m) => m.id === selectedModel),+ [getCurrentModels, selectedModel],+ );++ const isMotionControlSelection = useCallback(+ (modelId, isV2v) => {+ if (!isV2v) return false;+ const m = v2vModels.find((x) => x.id === modelId);+ return !!m?.imageField;+ },+ [],+ );++ // ── update controls when model/mode changes ──────────────────────────────+ const applyControlsForModel = useCallback(+ (modelId, isImageMode, isV2vMode) => {+ if (isV2vMode) {+ setShowAr(false);+ setShowDuration(false);+ setShowResolution(false);+ setShowQuality(false);+ setShowMode(false);+ setShowEffect(false);+ return;+ }++ const modelList = isImageMode ? i2vModels : t2vModels;+ const model = modelList.find((m) => m.id === modelId);++ const ars = isImageMode+ ? getAspectRatiosForI2VModel(modelId)+ : getAspectRatiosForVideoModel(modelId);+ if (ars.length > 0) {+ setSelectedAr(ars[0]);+ setShowAr(true);+ } else {+ setShowAr(false);+ }++ const durations = isImageMode+ ? getDurationsForI2VModel(modelId)+ : getDurationsForModel(modelId);+ if (durations.length > 0) {+ setSelectedDuration(durations[0]);+ setShowDuration(true);+ } else {+ setShowDuration(false);+ }++ const resolutions = isImageMode+ ? getResolutionsForI2VModel(modelId)+ : getResolutionsForVideoModel(modelId);+ if (resolutions.length > 0) {+ setSelectedResolution(resolutions[0]);+ setShowResolution(true);+ } else {+ setShowResolution(false);+ }++ const qualities = getQualitiesForModel(modelList, modelId);+ if (qualities.length > 0) {+ setSelectedQuality(model?.inputs?.quality?.default || qualities[0]);+ setShowQuality(true);+ } else {+ setSelectedQuality("");+ setShowQuality(false);+ }++ const modes = getModesForModel(modelId);+ if (modes.length > 0) {+ setSelectedMode(model?.inputs?.mode?.default || modes[0]);+ setShowMode(true);+ } else {+ setSelectedMode("");+ setShowMode(false);+ }++ const effects = isImageMode ? getEffectsForI2VModel(modelId) : [];+ if (effects.length > 0) {+ setSelectedEffect(getDefaultEffectForI2VModel(modelId) || effects[0]);+ setShowEffect(true);+ } else {+ setSelectedEffect("");+ setShowEffect(false);+ }+ },+ [],+ );++ // ── Persistence: Load ────────────────────────────────────────────────────+ useEffect(() => {+ try {+ const stored = localStorage.getItem(PERSIST_KEY);+ if (stored) {+ const data = JSON.parse(stored);+ if (data.imageMode !== undefined) setImageMode(data.imageMode);+ if (data.v2vMode !== undefined) setV2vMode(data.v2vMode);+ if (data.selectedModel) setSelectedModel(data.selectedModel);+ if (data.selectedModelName) setSelectedModelName(data.selectedModelName);+ if (data.selectedAr) setSelectedAr(data.selectedAr);+ if (data.selectedDuration) setSelectedDuration(data.selectedDuration);+ if (data.selectedResolution) setSelectedResolution(data.selectedResolution);+ if (data.selectedQuality) setSelectedQuality(data.selectedQuality);+ if (data.selectedMode) setSelectedMode(data.selectedMode);+ if (data.selectedEffect) setSelectedEffect(data.selectedEffect);+ if (data.uploadedImageUrl) setUploadedImageUrl(data.uploadedImageUrl);+ if (data.uploadedImageUrls) {+ setUploadedImageUrls(data.uploadedImageUrls);+ } else if (data.uploadedImageUrl) {+ setUploadedImageUrls([data.uploadedImageUrl]);+ }+ if (data.uploadedVideoUrl) setUploadedVideoUrl(data.uploadedVideoUrl);+ if (data.uploadedVideoName) setUploadedVideoName(data.uploadedVideoName);+ if (data.prompt) setPrompt(data.prompt);+ if (data.localHistory) setLocalHistory(data.localHistory);++ // Update control visibility based on restored model/mode+ applyControlsForModel(+ data.selectedModel || defaultModel.id,+ !!data.imageMode,+ !!data.v2vMode+ );+ }+ } catch (err) {+ console.warn("Failed to load VideoStudio persistence:", err);+ } finally {+ hasRestored.current = true;+ }+ }, [applyControlsForModel, defaultModel.id]);++ // ── Persistence: Save ────────────────────────────────────────────────────+ useEffect(() => {+ const timer = setTimeout(() => {+ try {+ const state = {+ imageMode,+ v2vMode,+ selectedModel,+ selectedModelName,+ selectedAr,+ selectedDuration,+ selectedResolution,+ selectedQuality,+ selectedMode,+ selectedEffect,+ uploadedImageUrl,+ uploadedImageUrls,+ uploadedVideoUrl,+ uploadedVideoName,+ prompt,+ localHistory,+ };+ localStorage.setItem(PERSIST_KEY, JSON.stringify(state));+ } catch (err) {+ console.warn("Failed to save VideoStudio persistence:", err);+ }+ }, 500); // 500ms debounce+ return () => clearTimeout(timer);+ }, [+ imageMode,+ v2vMode,+ selectedModel,+ selectedModelName,+ selectedAr,+ selectedDuration,+ selectedResolution,+ selectedQuality,+ selectedMode,+ selectedEffect,+ uploadedImageUrl,+ uploadedImageUrls,+ uploadedVideoUrl,+ uploadedVideoName,+ prompt,+ localHistory,+ ]);++ // ── Derived UI values ────────────────────────────────────────────────────++ const applyImageReferenceUrl = useCallback(+ (url) => {+ if (!url) return;++ setUploadedImageUrl(url);++ // Motion-control models use the image alongside the uploaded video.+ if (isMotionControlSelection(selectedModel, v2vMode)) {+ setUploadedImageUrls([url]);+ setPromptDisabled(false);+ return;+ }++ const currentT2V = t2vModels.find((model) => model.id === selectedModel);++ // Models with native image inputs stay in their current mode.+ if (currentT2V?.inputs?.images_list) {+ const maxImages = currentT2V.inputs.images_list.maxItems || 8;+ setUploadedImageUrls((previousUrls) => {+ if (previousUrls.includes(url)) return previousUrls;+ return [...previousUrls, url].slice(0, maxImages);+ });+ setPromptDisabled(false);+ return;+ }++ setUploadedVideoUrl(null);+ setUploadedVideoName(null);+ setV2vMode(false);++ const sibling = currentT2V?.family+ ? i2vModels.find((model) => model.family === currentT2V.family)+ : null;+ const targetModel = imageMode+ ? i2vModels.find((model) => model.id === selectedModel)+ : sibling || i2vModels[0];++ if (!targetModel) return;++ if (!imageMode) {+ setImageMode(true);+ setSelectedModel(targetModel.id);+ setSelectedModelName(targetModel.name);+ applyControlsForModel(targetModel.id, true, false);+ }++ const maxImages = getMaxImagesForI2VModel(targetModel.id);+ if (maxImages > 2) {+ setUploadedImageUrls((previousUrls) => {+ if (previousUrls.includes(url)) return previousUrls;+ return [...previousUrls, url].slice(0, maxImages);+ });+ } else {+ setUploadedImageUrls([url]);+ }+ setPromptDisabled(false);+ },+ [+ applyControlsForModel,+ imageMode,+ isMotionControlSelection,+ selectedModel,+ v2vMode,+ ],+ );++ const handleDrawReference = useCallback(+ (entry) => {+ applyImageReferenceUrl(entry?.url);+ },+ [applyImageReferenceUrl],+ );++ const uploadImageReference = useCallback(+ async (file) => {+ if (file.size > 10 * 1024 * 1024) {+ alert("Image exceeds 10MB limit.");+ return;+ }++ setImageUploading(true);+ setImageProgress(0);+ try {+ const url = await uploadFile(apiKey, file, setImageProgress);+ applyImageReferenceUrl(url);+ } catch (err) {+ console.error("[VideoStudio] Image upload failed:", err);+ alert(`Image upload failed: ${err.message}`);+ } finally {+ setImageUploading(false);+ setImageProgress(0);+ }+ },+ [apiKey, applyImageReferenceUrl],+ );++ const processDroppedVideo = useCallback(+ async (file) => {+ if (file.size > 50 * 1024 * 1024) {+ alert("Video exceeds 50MB limit.");+ return;+ }+ setVideoUploading(true);+ setVideoProgress(0);+ try {+ const url = await uploadFile(apiKey, file, setVideoProgress);+ setUploadedVideoUrl(url);+ setUploadedVideoName(file.name);+ if (imageMode) {+ setUploadedImageUrl(null);+ setImageMode(false);+ }+ setV2vMode(true);+ const firstV2V = v2vModels[0];+ setSelectedModel(firstV2V.id);+ setSelectedModelName(firstV2V.name);+ applyControlsForModel(firstV2V.id, false, true);+ setPrompt("");+ setPromptDisabled(true);+ } catch (err) {+ alert(`Video upload failed: ${err.message}`);+ } finally {+ setVideoUploading(false);+ setVideoProgress(0);+ }+ },+ [apiKey, applyControlsForModel, imageMode],+ );++ // ── Handle Dropped Files ────────────────────────────────────────────────+ useEffect(() => {+ if (droppedFiles && droppedFiles.length > 0) {+ const imageFiles = droppedFiles.filter(f => f.type.startsWith('image/'));+ const videoFiles = droppedFiles.filter(f => f.type.startsWith('video/'));++ if (videoFiles.length > 0) {+ processDroppedVideo(videoFiles[0]);+ } else if (imageFiles.length > 0) {+ uploadImageReference(imageFiles[0]);+ }+ onFilesHandled?.();+ }+ }, [droppedFiles, onFilesHandled, processDroppedVideo, uploadImageReference]);++ // Initialise controls for default model on mount+ useEffect(() => {+ if (hasRestored.current) return;+ applyControlsForModel(defaultModel.id, false, false);+ // eslint-disable-next-line react-hooks/exhaustive-deps+ }, []);++ // ── close dropdown on outside click ─────────────────────────────────────+ useEffect(() => {+ if (!openDropdown) return;+ const handler = (e) => {+ if (dropdownRef.current && !dropdownRef.current.contains(e.target)) {+ setOpenDropdown(null);+ }+ };+ window.addEventListener("click", handler);+ return () => window.removeEventListener("click", handler);+ }, [openDropdown]);++ const handlePromptInput = (e) => {+ setPrompt(e.target.value);+ };++ // ── image upload ─────────────────────────────────────────────────────────+ const handleImageFileChange = async (e) => {+ const file = e.target.files[0];+ if (!file) return;+ try {+ await uploadImageReference(file);+ } finally {+ if (imageFileInputRef.current) imageFileInputRef.current.value = "";+ }+ };++ const clearImageUpload = () => {+ setUploadedImageUrl(null);+ setUploadedImageUrls([]);+ setUploadedEndImageUrl(null);+ // Motion-control v2v or model with inputs.images_list: keep model, just drop the image+ if (isMotionControlSelection(selectedModel, v2vMode)) return;+ const currentT2V = t2vModels.find((m) => m.id === selectedModel);+ if (currentT2V?.inputs?.images_list) return;+ setImageMode(false);+ const first = t2vModels[0];+ setSelectedModel(first.id);+ setSelectedModelName(first.name);+ applyControlsForModel(first.id, false, false);+ setPromptDisabled(false);+ };++ const removeImageAtIndex = (idx) => {+ const nextUrls = uploadedImageUrls.filter((_, i) => i !== idx);+ setUploadedImageUrls(nextUrls);+ if (nextUrls.length === 0) {+ setUploadedImageUrl(null);+ // Reset to text-to-video if empty list+ if (isMotionControlSelection(selectedModel, v2vMode)) return;+ setImageMode(false);+ const first = t2vModels[0];+ setSelectedModel(first.id);+ setSelectedModelName(first.name);+ applyControlsForModel(first.id, false, false);+ setPromptDisabled(false);+ } else {+ setUploadedImageUrl(nextUrls[0]);+ }+ };++ // ── end-frame upload (FLF i2v models) ──────────────────────────────────────+ const handleEndImageFileChange = async (e) => {+ const file = e.target.files[0];+ if (!file) return;+ if (file.size > 10 * 1024 * 1024) {+ alert("Image exceeds 10MB limit.");+ return;+ }+ setEndImageUploading(true);+ setEndImageProgress(0);+ try {+ const url = await uploadFile(apiKey, file, (pct) => {+ setEndImageProgress(pct);+ });+ setUploadedEndImageUrl(url);+ } catch (err) {+ alert(`End frame upload failed: ${err.message}`);+ } finally {+ setEndImageUploading(false);+ setEndImageProgress(0);+ if (endImageFileInputRef.current) endImageFileInputRef.current.value = "";+ }+ };++ const clearEndImage = () => setUploadedEndImageUrl(null);++ // ── video upload ─────────────────────────────────────────────────────────+ const handleVideoFileChange = async (e) => {+ const file = e.target.files[0];+ if (!file) return;+ if (file.size > 50 * 1024 * 1024) {+ alert("Video exceeds 50MB limit.");+ return;+ }+ setVideoUploading(true);+ setVideoProgress(0);+ try {+ const url = await uploadFile(apiKey, file, (pct) => {+ setVideoProgress(pct);+ });+ setUploadedVideoUrl(url);+ setUploadedVideoName(file.name);++ if (isMotionControlSelection(selectedModel, v2vMode)) {+ // Already in motion-control mode — keep model and image, allow prompt+ setPromptDisabled(false);+ } else {+ // Model-native video reference (e.g. Seedance 2.0 Extend with inputs.video_files):+ // keep the current model & mode; just store the video URL as a reference+ const currentT2VOrExtend = t2vModels.find((m) => m.id === selectedModel);+ if (currentT2VOrExtend?.inputs?.video_files) {+ setPromptDisabled(false);+ } else {+ // Default v2v flow (e.g. watermark remover) — auto-pick the first v2v model+ if (imageMode) {+ setUploadedImageUrl(null);+ setImageMode(false);+ }+ setV2vMode(true);+ const firstV2V = v2vModels[0];+ setSelectedModel(firstV2V.id);+ setSelectedModelName(firstV2V.name);+ applyControlsForModel(firstV2V.id, false, true);+ setPrompt("");+ setPromptDisabled(true);+ }+ }+ } catch (err) {+ console.error("[VideoStudio] Video upload failed:", err);+ alert(`Video upload failed: ${err.message}`);+ } finally {+ setVideoUploading(false);+ setVideoProgress(0);+ if (videoFileInputRef.current) videoFileInputRef.current.value = "";+ }+ };++ const clearVideoUpload = () => {+ setUploadedVideoUrl(null);+ setUploadedVideoName(null);+ setV2vMode(false);+ const first = t2vModels[0];+ setSelectedModel(first.id);+ setSelectedModelName(first.name);+ applyControlsForModel(first.id, false, false);+ setPromptDisabled(false);+ };++ // ── model selection from dropdown ─────────────────────────────────────────+ const handleModelSelect = useCallback(+ (m, isV2V) => {+ if (isV2V) {+ setV2vMode(true);+ setImageMode(false);+ const isMC = !!m.imageField;+ if (!isMC) {+ // Single-input v2v (watermark remover etc.) — drop any image+ setUploadedImageUrl(null);+ }+ setSelectedModel(m.id);+ setSelectedModelName(m.name);+ applyControlsForModel(m.id, false, true);+ if (isMC) {+ // Motion-control: prompt is editable, video+image are needed+ setPromptDisabled(false);+ } else {+ setPrompt("");+ setPromptDisabled(true);+ }+ } else {+ if (v2vMode) {+ setV2vMode(false);+ setUploadedVideoUrl(null);+ setUploadedVideoName(null);+ setPromptDisabled(false);+ }+ setSelectedModel(m.id);+ setSelectedModelName(m.name);+ applyControlsForModel(m.id, imageMode, false);+ }+ },+ [v2vMode, imageMode, applyControlsForModel],+ );++ // ── add to local history ──────────────────────────────────────────────────+ const addToLocalHistory = useCallback((entry) => {+ setLocalHistory((prev) => [entry, ...prev].slice(0, 30));+ setActiveHistoryIdx(0);+ }, []);++ // ── show result in canvas ─────────────────────────────────────────────────+ const showVideoInCanvas = useCallback((url, model) => {+ setCanvasUrl(url);+ setCanvasModel(model);+ setShowCanvas(true);+ }, []);++ // ── generate ──────────────────────────────────────────────────────────────+ const handleGenerate = useCallback(async () => {+ const currentModel = getCurrentModel();+ const isExtendMode = currentModel?.requiresRequestId;+ const trimmedPrompt = prompt.trim();++ if (v2vMode) {+ if (!uploadedVideoUrl) {+ alert("Please upload a video first.");+ return;+ }+ if (currentModel?.imageField && !uploadedImageUrl) {+ alert("Please upload a reference image for motion control.");+ return;+ }+ if (currentModel?.promptRequired && !trimmedPrompt) {+ alert("Please describe the motion you want.");+ return;+ }+ } else if (isExtendMode) {+ if (!lastGenerationId) {+ alert(+ "No Seedance 2.0 generation found to extend. Generate a video first.",+ );+ return;+ }+ } else if (imageMode) {+ const maxImgs = getMaxImagesForI2VModel(selectedModel);+ if (maxImgs > 2) {+ if (uploadedImageUrls.length === 0) {+ alert("Please upload at least one reference image first.");+ return;+ }+ } else {+ if (!uploadedImageUrl) {+ alert("Please upload a start frame image first.");+ return;+ }+ }+ } else {+ if (!trimmedPrompt) {+ alert("Please enter a prompt to generate a video.");+ return;+ }+ }++ onGenerationStart?.();+ setGenerating(true);+ setGenerateError(null);++ let hadError = false;++ try {+ let res;++ if (v2vMode) {+ // V2V: dedicated processV2V handles single-input tools (e.g. watermark+ // remover) and motion-control models (which take video + image + prompt)+ const v2vParams = {+ model: selectedModel,+ video_url: uploadedVideoUrl,+ };+ if (currentModel?.imageField && uploadedImageUrl) {+ v2vParams.image_url = uploadedImageUrl;+ }+ if (currentModel?.hasPrompt && trimmedPrompt) {+ v2vParams.prompt = trimmedPrompt;+ }+ res = await processV2V(apiKey, v2vParams);+ if (!res?.url) throw new Error("No video URL returned by API");++ const genId = res.id || Date.now().toString();+ setLastGenerationId(null);+ setLastGenerationModel(null);+ const entry = {+ id: genId,+ url: res.url,+ prompt: currentModel?.hasPrompt ? trimmedPrompt : "",+ model: selectedModel,+ timestamp: new Date().toISOString(),+ };+ addToLocalHistory(entry);+ showVideoInCanvas(res.url, selectedModel);+ if (onGenerationComplete)+ onGenerationComplete({+ url: res.url,+ model: selectedModel,+ prompt: currentModel?.hasPrompt ? trimmedPrompt : "",+ type: "video",+ });+ } else if (imageMode) {+ const maxImgs = getMaxImagesForI2VModel(selectedModel);+ const i2vParams = { model: selectedModel };+ if (maxImgs > 2) {+ i2vParams.images_list = uploadedImageUrls;+ } else {+ i2vParams.image_url = uploadedImageUrl;+ }+ if (trimmedPrompt) i2vParams.prompt = trimmedPrompt;+ i2vParams.aspect_ratio = selectedAr;+ const i2vModel = i2vModels.find((m) => m.id === selectedModel);+ if (uploadedEndImageUrl && i2vModel?.lastImageField) {+ i2vParams.last_image = uploadedEndImageUrl;+ }+ const durations = getDurationsForI2VModel(selectedModel);+ if (durations.length > 0) i2vParams.duration = selectedDuration;+ const resolutions = getResolutionsForI2VModel(selectedModel);+ if (resolutions.length > 0) i2vParams.resolution = selectedResolution;+ if (selectedQuality) i2vParams.quality = selectedQuality;+ if (selectedMode) i2vParams.mode = selectedMode;+ if (showEffect && selectedEffect) i2vParams.name = selectedEffect;++ res = await generateI2V(apiKey, i2vParams);+ if (!res?.url) throw new Error("No video URL returned by API");++ const genId = res.id || Date.now().toString();+ if (selectedModel === "seedance-v2.0-i2v") {+ setLastGenerationId(genId);+ setLastGenerationModel(selectedModel);+ } else {+ setLastGenerationId(null);+ setLastGenerationModel(null);+ }+ const entry = {+ id: genId,+ url: res.url,+ prompt: trimmedPrompt,+ model: selectedModel,+ aspect_ratio: selectedAr,+ duration: selectedDuration,+ timestamp: new Date().toISOString(),+ };+ addToLocalHistory(entry);+ showVideoInCanvas(res.url, selectedModel);+ if (onGenerationComplete)+ onGenerationComplete({+ url: res.url,+ model: selectedModel,+ prompt: trimmedPrompt,+ type: "video",+ });+ } else {+ // T2V (including extend mode)+ const params = { model: selectedModel };+ if (trimmedPrompt) params.prompt = trimmedPrompt;++ if (isExtendMode) {+ params.request_id = lastGenerationId;+ // Optional reference media for Seedance 2.0 Extend:+ // images map to @image2…@image9 and videos map to @video1…@video3 in the prompt+ if (uploadedImageUrls.length > 0) {+ params.images_list = uploadedImageUrls;+ }+ if (uploadedVideoUrl) {+ params.videos_list = [uploadedVideoUrl];+ }+ } else {+ params.aspect_ratio = selectedAr;+ }++ const durations = getDurationsForModel(selectedModel);+ if (durations.length > 0) params.duration = selectedDuration;+ const resolutions = getResolutionsForVideoModel(selectedModel);+ if (resolutions.length > 0) params.resolution = selectedResolution;+ if (selectedQuality) params.quality = selectedQuality;+ if (selectedMode) params.mode = selectedMode;++ res = await generateVideo(apiKey, params);+ if (!res?.url) throw new Error("No video URL returned by API");++ const genId = res.id || Date.now().toString();+ if (+ selectedModel === "seedance-v2.0-t2v" ||+ selectedModel === "seedance-v2.0-i2v"+ ) {+ setLastGenerationId(genId);+ setLastGenerationModel(selectedModel);+ } else {+ setLastGenerationId(null);+ setLastGenerationModel(null);+ }+ const entry = {+ id: genId,+ url: res.url,+ prompt: trimmedPrompt,+ model: selectedModel,+ aspect_ratio: selectedAr,+ duration: selectedDuration,+ timestamp: new Date().toISOString(),+ };+ addToLocalHistory(entry);+ showVideoInCanvas(res.url, selectedModel);+ if (onGenerationComplete)+ onGenerationComplete({+ url: res.url,+ model: selectedModel,+ prompt: trimmedPrompt,+ type: "video",+ });+ }+ } catch (e) {+ hadError = true;+ console.error("[VideoStudio]", e);+ const errMsg = formatErrorMessage(e, "Video generation failed");+ if (onGenerationError) onGenerationError(errMsg);+ else toast.error(errMsg);+ } finally {+ setGenerating(false);+ onGenerationEnd?.();+ }+ }, [+ apiKey,+ prompt,+ v2vMode,+ imageMode,+ selectedModel,+ selectedAr,+ selectedDuration,+ selectedResolution,+ selectedQuality,+ selectedMode,+ selectedEffect,+ showEffect,+ uploadedImageUrl,+ uploadedImageUrls,+ uploadedVideoUrl,+ lastGenerationId,+ getCurrentModel,+ addToLocalHistory,+ showVideoInCanvas,+ onGenerationComplete,+ onGenerationEnd,+ onGenerationError,+ onGenerationStart,+ ]);++ // ── reset to prompt bar ───────────────────────────────────────────────────+ const resetToPromptBar = useCallback(() => {+ setShowCanvas(false);+ }, []);++ const handleNewPrompt = useCallback(() => {+ resetToPromptBar();+ setPrompt("");+ setUploadedImageUrl(null);+ setUploadedImageUrls([]);+ setImageMode(false);+ setUploadedVideoUrl(null);+ setUploadedVideoName(null);+ setV2vMode(false);+ const first = t2vModels[0];+ setSelectedModel(first.id);+ setSelectedModelName(first.name);+ applyControlsForModel(first.id, false, false);+ setPromptDisabled(false);+ setTimeout(() => textareaRef.current?.focus(), 50);+ }, [resetToPromptBar, applyControlsForModel]);++ const handleExtend = useCallback(() => {+ if (!lastGenerationId) return;+ resetToPromptBar();+ setPrompt("");+ setUploadedImageUrl(null);+ setUploadedImageUrls([]);+ setImageMode(false);+ setSelectedModel("seedance-v2.0-extend");+ setSelectedModelName("Seedance 2.0 Extend");+ applyControlsForModel("seedance-v2.0-extend", false, false);+ setPromptDisabled(false);+ setTimeout(() => textareaRef.current?.focus(), 50);+ }, [lastGenerationId, resetToPromptBar, applyControlsForModel]);++ // ── derived UI values ────────────────────────────────────────────────────+ const isSeedance2Canvas =+ canvasModel === "seedance-v2.0-t2v" || canvasModel === "seedance-v2.0-i2v";+ const currentModelObj = getCurrentModel();+ const isExtendMode = currentModelObj?.requiresRequestId;+ const canUploadImageReference =+ (!v2vMode || isMotionControlSelection(selectedModel, v2vMode)) &&+ (!isExtendMode || currentModelObj?.inputs?.images_list);++ const promptPlaceholder = v2vMode+ ? currentModelObj?.imageField+ ? currentModelObj?.promptRequired+ ? "Describe the motion"+ : "Describe the motion (optional)"+ : "Video ready — click Generate to remove watermark"+ : imageMode+ ? "Describe the motion or effect (optional)"+ : isExtendMode+ ? "Optional: describe how to continue the video..."+ : "Describe the video you want to create";++ const toggleDropdown = (type) => (e) => {+ e.stopPropagation();+ setOpenDropdown((prev) => (prev === type ? null : type));+ };++ // ── render ────────────────────────────────────────────────────────────────+ return (+ <div+ ref={containerRef}+ className="w-full h-full flex flex-col items-center justify-center bg-app-bg relative overflow-hidden"+ >+ {/* ── CENTRAL GALLERY AREA ── */}+ <div className="flex-1 w-full max-w-7xl mx-auto overflow-y-auto custom-scrollbar pb-40 lg:pb-32 px-2">+ {history.length > 0 ? (+ <div className="grid grid-cols-1 md:grid-cols-2 lg:grid-cols-3 gap-6 w-full pt-4 animate-fade-in-up">+ {history.map((entry, idx) => {+ const isSeedance2 = entry.model === "seedance-v2.0-t2v" || entry.model === "seedance-v2.0-i2v";+ return (+ <div+ key={entry.id || idx}+ className="relative group rounded-lg overflow-hidden border border-white/10 bg-[#0a0a0a] shadow-xl hover:border-primary/50 transition-all duration-300 flex flex-col"+ >+ <video+ src={entry.url}+ className="w-full aspect-video object-cover bg-black/40 cursor-pointer hover:opacity-80 transition-opacity"+ onClick={() => setFullscreenUrl(entry.url)}+ controls={false}+ loop+ muted+ playsInline+ onMouseOver={(e) => e.target.play()}+ onMouseOut={(e) => {+ e.target.pause();+ e.target.currentTime = 0;+ }}+ />++ {/* Overlay actions */}+ <div className="absolute top-2 right-2 flex flex-col gap-2 opacity-0 group-hover:opacity-100 transition-opacity">+ <button+ type="button"+ title="Fullscreen"+ onClick={(e) => {+ e.stopPropagation();+ setFullscreenUrl(entry.url);+ }}+ className="p-2 bg-black/60 backdrop-blur-md rounded-full text-white hover:bg-primary hover:text-black transition-all border border-white/10"+ >+ <svg width="14" height="14" viewBox="0 0 24 24" fill="none" stroke="currentColor" strokeWidth="2.5">+ <polyline points="15 3 21 3 21 9" />+ <polyline points="9 21 3 21 3 15" />+ <line x1="21" y1="3" x2="14" y2="10" />+ <line x1="3" y1="21" x2="10" y2="14" />+ </svg>+ </button>+ <button+ type="button"+ title="Download"+ onClick={(e) => {+ e.stopPropagation();+ downloadFile(entry.url, `video-${entry.id || idx}.mp4`);+ }}+ className="p-2 bg-black/60 backdrop-blur-md rounded-full text-white hover:bg-primary hover:text-black transition-all border border-white/10"+ >+ <svg width="14" height="14" viewBox="0 0 24 24" fill="none" stroke="currentColor" strokeWidth="2.5">+ <path d="M21 15v4a2 2 0 01-2 2H5a2 2 0 01-2-2v-4M7 10l5 5 5-5M12 15V3" />+ </svg>+ </button>+ {isSeedance2 && (+ <button+ type="button"+ title="Extend this video using Seedance 2.0 Extend"+ onClick={(e) => {+ e.stopPropagation();+ setLastGenerationId(entry.id);+ handleExtend();+ }}+ className="p-2 bg-black/60 backdrop-blur-md rounded-full text-white hover:bg-primary hover:text-black transition-all border border-white/10"+ >+ <svg width="14" height="14" viewBox="0 0 24 24" fill="none" stroke="currentColor" strokeWidth="2">+ <path d="M5 12h14M12 5l7 7-7 7" />+ </svg>+ </button>+ )}+ <button+ type="button"+ title="Delete"+ onClick={(e) => {+ e.stopPropagation();+ if (confirm("Are you sure you want to delete this generated item?")) {+ setLocalHistory(prev => prev.filter((_, i) => i !== idx));+ }+ }}+ className="p-2 bg-black/60 backdrop-blur-md rounded-full text-red-400 hover:bg-red-500 hover:text-white transition-all border border-white/10"+ >+ <svg width="14" height="14" viewBox="0 0 24 24" fill="none" stroke="currentColor" strokeWidth="2.5">+ <polyline points="3 6 5 6 21 6" />+ <path d="M19 6v14a2 2 0 01-2 2H7a2 2 0 01-2-2V6m3 0V4a2 2 0 012-2h4a2 2 0 012 2v2" />+ <line x1="10" y1="11" x2="10" y2="17" />+ <line x1="14" y1="11" x2="14" y2="17" />+ </svg>+ </button>+ </div>++ {/* Prompt & Details */}+ <div className="p-3 bg-black/80 backdrop-blur-sm border-t border-white/5 flex-1 flex flex-col justify-between gap-2">+ <p className="text-white/70 text-xs line-clamp-3 leading-relaxed" title={entry.prompt}>+ {entry.prompt || "No prompt provided"}+ </p>+ <div className="flex items-center justify-between mt-1 flex-wrap gap-1">+ <div className="flex items-center gap-2">+ <span className="text-[10px] font-bold text-primary px-2 py-0.5 bg-primary/10 rounded border border-primary/20 whitespace-nowrap capitalize">+ {entry.model?.replace("-", " ") || "Video Studio"}+ </span>+ <div className="flex gap-2">+ {entry.resolution && (+ <span className="text-[10px] text-white/40">{entry.resolution}</span>+ )}+ {entry.duration && (+ <span className="text-[10px] text-white/40">{entry.duration}s</span>+ )}+ </div>+ </div>+ {entry.prompt && (+ <button+ type="button"+ onClick={(e) => {+ e.stopPropagation();+ navigator.clipboard.writeText(entry.prompt);+ const btn = e.currentTarget;+ btn.innerText = "Copied!";+ setTimeout(() => { btn.innerText = "Copy"; }, 2000);+ }}+ className="px-2 py-0.5 bg-white/5 hover:bg-primary/20 hover:text-primary rounded text-[10px] font-medium text-white/70 transition-all border border-white/10"+ title="Copy prompt"+ >+ Copy Prompt+ </button>+ )}+ </div>+ </div>+ </div>+ );+ })}+ </div>+ ) : (+ <div className="flex flex-col items-center justify-center h-full animate-fade-in-up transition-all duration-700 min-h-[50vh]">+ {/* Overlapping floating cards */}+ <div className="flex items-center justify-center gap-1.5 md:gap-3 mb-10 select-none scale-90 sm:scale-100">+ <div className="w-18 h-22 sm:w-24 sm:h-28 rounded-2xl border border-white/10 shadow-2xl -rotate-[12deg] transform hover:rotate-0 hover:scale-110 hover:z-20 transition-all duration-300 overflow-hidden bg-white/[0.01] flex-shrink-0">+ <img+ src="https://d3adwkbyhxyrtq.cloudfront.net/webassets/videomodels/sdxl-image.avif"+ alt="Creative asset 1"+ className="w-full h-full object-cover"+ />+ </div>+ <div className="w-18 h-22 sm:w-24 sm:h-28 rounded-2xl border border-white/10 shadow-2xl -rotate-[4deg] transform hover:rotate-0 hover:scale-110 hover:z-20 transition-all duration-300 overflow-hidden bg-white/[0.01] -ml-3 sm:-ml-4 flex-shrink-0">+ <img+ src="https://d3adwkbyhxyrtq.cloudfront.net/webassets/videomodels/chroma-image.avif"+ alt="Creative asset 2"+ className="w-full h-full object-cover"+ />+ </div>+ <div className="w-18 h-18 sm:w-24 sm:h-24 rounded-full border border-white/10 shadow-2xl rotate-[6deg] transform hover:rotate-0 hover:scale-110 hover:z-20 transition-all duration-300 overflow-hidden bg-white/[0.01] -ml-3 sm:-ml-4 flex-shrink-0">+ <img+ src="https://d3adwkbyhxyrtq.cloudfront.net/webassets/videomodels/neta-lumina.avif"+ alt="Creative asset 3"+ className="w-full h-full object-cover"+ />+ </div>+ <div className="w-18 h-22 sm:w-24 sm:h-28 rounded-2xl border border-white/10 shadow-2xl rotate-[12deg] transform hover:rotate-0 hover:scale-110 hover:z-20 transition-all duration-300 overflow-hidden bg-white/[0.01] -ml-3 sm:-ml-4 flex-shrink-0">+ <img+ src="https://d3adwkbyhxyrtq.cloudfront.net/webassets/videomodels/perfect-pony-xl.avif"+ alt="Creative asset 4"+ className="w-full h-full object-cover"+ />+ </div>+ </div>++ <h1 className="text-2xl sm:text-4xl md:text-5xl font-extrabold tracking-tight mb-4 text-center px-4 flex flex-col items-center">+ <span className="text-white font-black uppercase text-xl sm:text-3xl tracking-wide mb-1 opacity-90">START CREATING WITH</span>+ <span className="text-[#22d3ee] font-black uppercase text-2xl sm:text-4xl sm:mt-1 tracking-tight">+ {selectedModelName}+ </span>+ </h1>+ <p className="text-white/40 text-xs sm:text-sm font-medium tracking-wide text-center max-w-lg leading-relaxed px-4">+ Animate images into stunning AI videos with motion effects+ </p>+ </div>+ )}+ </div>++ {/* ── BOTTOM PROMPT BAR ── */}+ <PromptComposer>+ <div className="flex flex-col gap-3">+ {/* Inline list of uploaded media files */}+ <div className="flex items-center gap-2.5 flex-wrap">+ {/* Main image preview */}+ {uploadedImageUrl && (+ <div className={PROMPT_MEDIA_PREVIEW_CLASS}>+ <img src={uploadedImageUrl} alt="" className="w-full h-full object-cover" />+ <button+ type="button"+ onClick={clearImageUpload}+ className="absolute top-0.5 right-0.5 w-4 h-4 bg-black/60 hover:bg-black rounded-full flex items-center justify-center text-white/85 hover:text-white text-[8px] border border-white/5"+ >+ ×+ </button>+ </div>+ )}++ {/* End frame image preview */}+ {uploadedEndImageUrl && (+ <div className={PROMPT_MEDIA_PREVIEW_CLASS}>+ <img src={uploadedEndImageUrl} alt="" className="w-full h-full object-cover" />+ <button+ type="button"+ onClick={clearEndImage}+ className="absolute top-0.5 right-0.5 w-4 h-4 bg-black/60 hover:bg-black rounded-full flex items-center justify-center text-white/85 hover:text-white text-[8px] border border-white/5"+ >+ ×+ </button>+ <span className="absolute bottom-0.5 left-0.5 px-1 h-3.5 bg-black/60 rounded-md text-[7px] font-black text-[#22d3ee] leading-none flex items-center justify-center pointer-events-none">+ END+ </span>+ </div>+ )}++ {/* Video preview */}+ {uploadedVideoUrl && (+ <div className={PROMPT_MEDIA_PREVIEW_CLASS}>+ <video src={uploadedVideoUrl} className="w-full h-full object-cover" muted />+ <button+ type="button"+ onClick={clearVideoUpload}+ className="absolute top-0.5 right-0.5 w-4 h-4 bg-black/60 hover:bg-black rounded-full flex items-center justify-center text-white/85 hover:text-white text-[8px] border border-white/5"+ >+ ×+ </button>+ </div>+ )}++ {/* Multiple images layout if supported */}+ {imageMode && getMaxImagesForI2VModel(selectedModel) > 2 && (+ <>+ {uploadedImageUrls.map((url, idx) => (+ <div key={url} className={PROMPT_MEDIA_PREVIEW_CLASS}>+ <img src={url} alt="" className="w-full h-full object-cover" />+ <button+ type="button"+ onClick={() => removeImageAtIndex(idx)}+ className="absolute top-0.5 right-0.5 w-4 h-4 bg-black/60 hover:bg-black rounded-full flex items-center justify-center text-white/85 hover:text-white text-[8px] border border-white/5"+ >+ ×+ </button>+ <span className="absolute bottom-0.5 right-0.5 px-1 h-3.5 bg-black/60 rounded-full text-[8px] font-black text-[#22d3ee] leading-none flex items-center justify-center pointer-events-none">+ {idx + 1}+ </span>+ </div>+ ))}+ </>+ )}++ {/* Upload trigger buttons */}+ {/* Image upload button — shown when the model accepts image input:+ • T2V mode: uploading an image auto-switches to the sibling I2V model+ • I2V mode: uploading the start-frame (multi-image logic applies)+ • V2V motion-control: reference image is required alongside the video+ • T2V with inputs.images_list: optional reference images (e.g. Seedance 2.0 Extend)+ • Hidden in regular V2V mode (watermark remover etc. needs no image)+ • Hidden for extend-type models without inputs.images_list */}+ {canUploadImageReference && (+ getMaxImagesForI2VModel(selectedModel) > 2 ? (+ uploadedImageUrls.length < getMaxImagesForI2VModel(selectedModel) && (+ <div className="relative">+ <input+ ref={imageFileInputRef}+ type="file"+ accept="image/*"+ className="hidden"+ onChange={handleImageFileChange}+ />+ <button+ type="button"+ title="Upload reference image"+ onClick={() => imageFileInputRef.current?.click()}+ className={promptMediaButtonClassName()}+ >+ {imageUploading ? (+ <div className="flex flex-col items-center justify-center w-full h-full absolute inset-0 bg-black/80 z-20 backdrop-blur-[2px]">+ <svg className="w-8 h-8 -rotate-90">+ <circle cx="16" cy="16" r="14" stroke="currentColor" strokeWidth="2" fill="transparent" className="text-white/10" />+ <circle+ cx="16"+ cy="16"+ r="14"+ stroke="currentColor"+ strokeWidth="2"+ fill="transparent"+ strokeDasharray={88}+ strokeDashoffset={88 - (88 * imageProgress) / 100}+ className="text-[#22d3ee] transition-all duration-300"+ />+ </svg>+ <span className="absolute text-[9px] font-black text-[#22d3ee] leading-none">{imageProgress}%</span>+ </div>+ ) : (+ <svg width="16" height="16" viewBox="0 0 24 24" fill="none" stroke="currentColor" strokeWidth="2.5" className="text-white/40 group-hover:text-[#22d3ee] transition-colors">+ <line x1="12" y1="5" x2="12" y2="19" />+ <line x1="5" y1="12" x2="19" y2="12" />+ </svg>+ )}+ </button>+ </div>+ )+ ) : (+ !uploadedImageUrl && (+ <div className="relative">+ <input+ ref={imageFileInputRef}+ type="file"+ accept="image/*"+ className="hidden"+ onChange={handleImageFileChange}+ />+ <button+ type="button"+ title="Upload reference image"+ onClick={() => imageFileInputRef.current?.click()}+ className={promptMediaButtonClassName()}+ >+ {imageUploading ? (+ <div className="flex flex-col items-center justify-center w-full h-full absolute inset-0 bg-black/80 z-20 backdrop-blur-[2px]">+ <svg className="w-8 h-8 -rotate-90">+ <circle cx="16" cy="16" r="14" stroke="currentColor" strokeWidth="2" fill="transparent" className="text-white/10" />+ <circle+ cx="16"+ cy="16"+ r="14"+ stroke="currentColor"+ strokeWidth="2"+ fill="transparent"+ strokeDasharray={88}+ strokeDashoffset={88 - (88 * imageProgress) / 100}+ className="text-[#22d3ee] transition-all duration-300"+ />+ </svg>+ <span className="absolute text-[9px] font-black text-[#22d3ee] leading-none">{imageProgress}%</span>+ </div>+ ) : (+ <svg width="16" height="16" viewBox="0 0 24 24" fill="none" stroke="currentColor" strokeWidth="2.5" className="text-white/40 group-hover:text-[#22d3ee] transition-colors">+ <line x1="12" y1="5" x2="12" y2="19" />+ <line x1="5" y1="12" x2="19" y2="12" />+ </svg>+ )}+ </button>+ </div>+ )+ )+ )}++ {/* End frame image button */}+ {imageMode && i2vModels.find((m) => m.id === selectedModel)?.lastImageField && !uploadedEndImageUrl && (+ <div className="relative">+ <input+ ref={endImageFileInputRef}+ type="file"+ accept="image/*"+ className="hidden"+ onChange={handleEndImageFileChange}+ />+ <button+ type="button"+ title="Upload end frame (optional)"+ onClick={() => endImageFileInputRef.current?.click()}+ className={promptMediaButtonClassName()}+ >+ {endImageUploading ? (+ <div className="flex flex-col items-center justify-center w-full h-full absolute inset-0 bg-black/80 z-20 backdrop-blur-[2px]">+ <svg className="w-8 h-8 -rotate-90">+ <circle cx="16" cy="16" r="14" stroke="currentColor" strokeWidth="2" fill="transparent" className="text-white/10" />+ <circle+ cx="16"+ cy="16"+ r="14"+ stroke="currentColor"+ strokeWidth="2"+ fill="transparent"+ strokeDasharray={88}+ strokeDashoffset={88 - (88 * endImageProgress) / 100}+ className="text-[#22d3ee] transition-all duration-300"+ />+ </svg>+ <span className="absolute text-[9px] font-black text-[#22d3ee] leading-none">{endImageProgress}%</span>+ </div>+ ) : (+ <svg width="16" height="16" viewBox="0 0 24 24" fill="none" stroke="currentColor" strokeWidth="2.5" className="text-white/40 group-hover:text-[#22d3ee] transition-colors">+ <line x1="12" y1="5" x2="12" y2="19" />+ <line x1="5" y1="12" x2="19" y2="12" />+ </svg>+ )}+ </button>+ </div>+ )}++ {/* Video upload button — shown when a V2V model is active, OR when+ the current model has inputs.video_files (e.g. Seedance 2.0 Extend). */}+ {!uploadedVideoUrl && (v2vMode || currentModelObj?.inputs?.video_files) && (+ <div className="relative">+ <input+ ref={videoFileInputRef}+ type="file"+ accept="video/*"+ className="hidden"+ onChange={handleVideoFileChange}+ />+ <button+ type="button"+ title="Upload video to remove watermark"+ onClick={() => videoFileInputRef.current?.click()}+ className={promptMediaButtonClassName()}+ >+ {videoUploading ? (+ <div className="flex flex-col items-center justify-center w-full h-full absolute inset-0 bg-black/80 z-20 backdrop-blur-[2px]">+ <svg className="w-8 h-8 -rotate-90">+ <circle cx="16" cy="16" r="14" stroke="currentColor" strokeWidth="2" fill="transparent" className="text-white/10" />+ <circle+ cx="16"+ cy="16"+ r="14"+ stroke="currentColor"+ strokeWidth="2"+ fill="transparent"+ strokeDasharray={88}+ strokeDashoffset={88 - (88 * videoProgress) / 100}+ className="text-[#22d3ee] transition-all duration-300"+ />+ </svg>+ <span className="absolute text-[9px] font-black text-[#22d3ee] leading-none">{videoProgress}%</span>+ </div>+ ) : (+ <svg+ width="16"+ height="16"+ viewBox="0 0 24 24"+ fill="none"+ stroke="currentColor"+ strokeWidth="2.5"+ className="text-white/40 group-hover:text-[#22d3ee] transition-colors"+ >+ <polygon points="23 7 16 12 23 17 23 7" fill="currentColor" />+ <rect x="1" y="5" width="15" height="14" rx="2" ry="2" fill="currentColor" />+ </svg>+ )}+ </button>+ </div>+ )}+ </div>++ {/* Prompt textarea */}+ <div className="flex-1 flex flex-col gap-1">+ <PromptTextarea+ ref={textareaRef}+ value={prompt}+ onChange={handlePromptInput}+ placeholder={promptPlaceholder}+ disabled={promptDisabled}+ />+ </div>+ </div>++ {/* Extend banner */}+ {isExtendMode && (+ <div className="flex items-center gap-2 px-3 py-1.5 mx-3 bg-primary/5 border border-primary/10 rounded-lg text-[10px] text-primary/80 font-medium tracking-tight">+ <svg+ width="13"+ height="13"+ viewBox="0 0 24 24"+ fill="none"+ stroke="currentColor"+ strokeWidth="2.5"+ >+ <path d="M5 12h14M12 5l7 7-7 7" />+ </svg>+ <span>Extending previous Seedance 2.0 generation</span>+ </div>+ )}++ {/* Bottom row: controls + generate */}+ <PromptFooter>+ <PromptControls ref={dropdownRef}>+ {/* Model btn */}+ <div className="relative">+ <button+ type="button"+ onClick={toggleDropdown("model")}+ className={promptControlClassName({+ active: openDropdown === "model",+ })}+ >+ <div className="w-4 h-4 rounded overflow-hidden shrink-0 flex items-center justify-center bg-white/5">+ {(() => {+ const allCurrentModels = [...t2vModels, ...i2vModels, ...v2vModels];+ const selectedModelObj = allCurrentModels.find(m => m.id === selectedModel);+ const selectedModelProvider = selectedModelObj?.provider || 'muapi';+ return PROVIDER_LOGOS[selectedModelProvider] ? (+ <img+ src={PROVIDER_LOGOS[selectedModelProvider]}+ alt=""+ className={`w-full h-full object-contain ${invertLogos.includes(selectedModelProvider) ? "invert" : ""}`}+ />+ ) : (+ <span className="text-[9px] font-bold text-black uppercase">V</span>+ );+ })()}+ </div>+ <span className={PROMPT_CONTROL_LABEL_CLASS}>+ {selectedModelName}+ </span>+ <PromptChevronIcon />+ </button>+ {openDropdown === "model" && (+ <PromptPopover+ onClick={(e) => e.stopPropagation()}+ className="w-[calc(100vw-2rem)] md:w-[480px] max-w-md md:max-w-none max-h-[70vh]"+ >+ <PromptPopoverHeader>Model</PromptPopoverHeader>+ <ModelDropdown+ imageMode={imageMode}+ selectedModel={selectedModel}+ onSelect={handleModelSelect}+ onClose={() => setOpenDropdown(null)}+ />+ </PromptPopover>+ )}+ </div>++ {/* Aspect ratio btn */}+ {showAr && (+ <div className="relative">+ <button+ type="button"+ onClick={toggleDropdown("ar")}+ className={promptControlClassName({+ active: openDropdown === "ar",+ })}+ >+ <PromptAspectRatioIcon />+ <span className={PROMPT_CONTROL_LABEL_CLASS}>+ {selectedAr}+ </span>+ </button>+ {openDropdown === "ar" && (+ <PromptPopover+ onClick={(e) => e.stopPropagation()}+ >+ <PromptPopoverHeader>+ Aspect Ratio+ </PromptPopoverHeader>+ <PromptMenuList>+ {getCurrentAspectRatios(selectedModel).map((r) => (+ <PromptMenuItem+ key={r}+ selected={selectedAr === r}+ onClick={(e) => {+ e.stopPropagation();+ setSelectedAr(r);+ setOpenDropdown(null);+ }}+ >+ {r}+ </PromptMenuItem>+ ))}+ </PromptMenuList>+ </PromptPopover>+ )}+ </div>+ )}++ {/* Effect btn */}+ {showEffect && (+ <div className="relative">+ <button+ type="button"+ onClick={toggleDropdown("effect")}+ className={promptControlClassName({+ active: openDropdown === "effect",+ })}+ >+ <svg+ width="16"+ height="16"+ viewBox="0 0 24 24"+ fill="none"+ stroke="currentColor"+ strokeWidth="2"+ className="opacity-40 text-white"+ >+ <path d="M5 3l14 9-14 9V3z" />+ </svg>+ <span className={`${PROMPT_CONTROL_LABEL_CLASS} max-w-[140px] truncate`}>+ {selectedEffect || "Effect"}+ </span>+ </button>+ {openDropdown === "effect" && (+ <PromptPopover+ onClick={(e) => e.stopPropagation()}+ className="min-w-[200px]"+ >+ <PromptPopoverHeader>+ Effect Type+ </PromptPopoverHeader>+ <PromptMenuList>+ {getEffectsForI2VModel(selectedModel).map((eff) => (+ <PromptMenuItem+ key={eff}+ selected={selectedEffect === eff}+ onClick={(e) => {+ e.stopPropagation();+ setSelectedEffect(eff);+ setOpenDropdown(null);+ }}+ >+ {eff}+ </PromptMenuItem>+ ))}+ </PromptMenuList>+ </PromptPopover>+ )}+ </div>+ )}++ {/* Duration btn */}+ {showDuration && (+ <div className="relative">+ <button+ type="button"+ onClick={toggleDropdown("duration")}+ className={promptControlClassName({+ active: openDropdown === "duration",+ })}+ >+ <PromptDurationIcon />+ <span className={PROMPT_CONTROL_LABEL_CLASS}>+ {selectedDuration}s+ </span>+ </button>+ {openDropdown === "duration" && (+ <PromptPopover+ onClick={(e) => e.stopPropagation()}+ >+ <PromptPopoverHeader>+ Duration+ </PromptPopoverHeader>+ <PromptMenuList>+ {getCurrentDurations(selectedModel).map((d) => (+ <PromptMenuItem+ key={d}+ selected={selectedDuration === d}+ onClick={(e) => {+ e.stopPropagation();+ setSelectedDuration(d);+ setOpenDropdown(null);+ }}+ >+ {d}s+ </PromptMenuItem>+ ))}+ </PromptMenuList>+ </PromptPopover>+ )}+ </div>+ )}++ {/* Resolution btn */}+ {showResolution && (+ <div className="relative">+ <button+ type="button"+ onClick={toggleDropdown("resolution")}+ className={promptControlClassName({+ active: openDropdown === "resolution",+ })}+ >+ <PromptQualityIcon />+ <span className={PROMPT_CONTROL_LABEL_CLASS}>+ {selectedResolution || "720p"}+ </span>+ </button>+ {openDropdown === "resolution" && (+ <PromptPopover+ onClick={(e) => e.stopPropagation()}+ >+ <PromptPopoverHeader>+ Resolution+ </PromptPopoverHeader>+ <PromptMenuList>+ {getCurrentResolutions(selectedModel).map((r) => (+ <PromptMenuItem+ key={r}+ selected={selectedResolution === r}+ onClick={(e) => {+ e.stopPropagation();+ setSelectedResolution(r);+ setOpenDropdown(null);+ }}+ >+ {r}+ </PromptMenuItem>+ ))}+ </PromptMenuList>+ </PromptPopover>+ )}+ </div>+ )}++ {canUploadImageReference && (+ <button+ type="button"+ className={promptControlClassName()}+ onClick={() => setIsDrawModalOpen(true)}+ >+ <svg+ width="16"+ height="16"+ viewBox="0 0 24 24"+ fill="none"+ stroke="currentColor"+ strokeWidth="2.5"+ className="opacity-40 text-white group-hover:text-[#22d3ee] transition-colors"+ >+ <path d="M12 20h9" />+ <path d="M16.5 3.5a2.121 2.121 0 013 3L7 19l-4 1 1-4L16.5 3.5z" />+ </svg>+ <span className={PROMPT_CONTROL_LABEL_CLASS}>Draw</span>+ </button>+ )}+ </PromptControls>++ {/* Generate button */}+ <PromptAction+ onClick={handleGenerate}+ disabled={generating}+ >+ {generating ? (+ <>+ <span className="animate-spin inline-block text-black">+ ◌+ </span>{" "}+ Generating...+ </>+ ) : (+ <>+ <span>Generate</span>+ </>+ )}+ </PromptAction>+ </PromptFooter>+ </PromptComposer>++ {/* ── FULLSCREEN VIDEO MODAL ── */}+ {fullscreenUrl && (+ <div+ className="fixed inset-0 z-[100] flex items-center justify-center bg-black/95 backdrop-blur-sm animate-fade-in"+ onClick={() => setFullscreenUrl(null)}+ >+ <button+ type="button"+ className="absolute top-6 right-6 p-3 bg-white/10 hover:bg-white/20 rounded-full text-white transition-colors border border-white/10"+ onClick={(e) => {+ e.stopPropagation();+ setFullscreenUrl(null);+ }}+ >+ <svg width="24" height="24" viewBox="0 0 24 24" fill="none" stroke="currentColor" strokeWidth="2.5" strokeLinecap="round" strokeLinejoin="round">+ <line x1="18" y1="6" x2="6" y2="18" />+ <line x1="6" y1="6" x2="18" y2="18" />+ </svg>+ </button>+ <video+ src={fullscreenUrl}+ controls+ autoPlay+ loop+ className="max-w-[95vw] max-h-[95vh] rounded-2xl shadow-2xl object-contain animate-scale-up"+ onClick={(e) => e.stopPropagation()}+ />+ </div>+ )}++ <DrawModal+ isOpen={isDrawModalOpen}+ onClose={() => setIsDrawModalOpen(false)}+ apiKey={apiKey}+ batchSize={1}+ onAddHistoryItem={handleDrawReference}+ />+ <Toaster position="top-right" containerStyle={{ zIndex: 99999 }} toastOptions={{ duration: 5000, style: { background: '#18181b', color: '#ffffff', border: '1px solid rgba(255,255,255,0.15)', fontSize: '13px', borderRadius: '12px', boxShadow: '0 10px 30px rgba(0,0,0,0.6)', maxWidth: '440px', wordBreak: 'break-word', whiteSpace: 'pre-wrap', padding: '12px 16px' } }} />+ </div>+ );+}diff --git a/packages/studio/src/components/WorkflowStudio.jsx b/packages/studio/src/components/WorkflowStudio.jsxindex 88f1e2a1..82917fb7 100644--- a/packages/studio/src/components/WorkflowStudio.jsx+++ b/packages/studio/src/components/WorkflowStudio.jsx@@ -406,4 +406,595 @@ export default function WorkflowStudio({e.preventDefault();if (isExecuting) return;- onGeneratio�n}����k�w��U٥�܁A��������(��������������������9�����ā�ٕə��ܵ䵅�Ѽ�����������ȁ���l�������t�������ѕ�̵���ѕȁ���ѥ�䵍��ѕȁ������l�����t��(������������������ɽȀ����(������������������������9����ܵ�ձ�����ܵ��������ɕ�����������ɑ�ȁ��ɑ�ȵɕ���������ɽչ�����ᰁ��������്����ѕ�̵���ѕȁ����Ё�����є�͡�����(��������������������������9����ܴ�ȁ���ȁ���ɕ���������ɽչ�����ձ��������ѕ�̵���ѕȁ���ѥ�䵍��ѕȁѕ�еɕ�������(������������������������ٜ(������������������������ݥ�Ѡ��Ј(��������������������������������Ј(������������������������٥�� ��������Ѐ�Ј(�������������������������������(��������������������������ɽ�����ɕ�� ���Ȉ(��������������������������ɽ��]��Ѡ�ȸԈ(�����������������������(�������������������������ɍ�������Ȉ�����Ȉ���������(������������������������������Ȉ�����������Ȉ�����Ȉ���(������������������������������Ȉ�����؈�����ȸ�Ĉ�����؈���(������������������������ٜ�(����������������������(��������������������������9����ѕ�е���ѕȈ�(���������������������������������9����ѕ�еl����t����е������ѕ�еɕ����������ɍ�͔��Ʌ������ݥ���Ё���������Ĉ�(������������������������ᕍ�ѥ����ɽ�(����������������������������(������������������������������9����ѕ�еݡ�є����ѕ�еʹ���������ɕ��ᕐ��(��������������������������ɽ��(�������������������������(����������������������(��������������������(������������������((����������������셥�ᕍ�ѥ�������ɕ�ձЀ������ɽȀ����(������������������������9���������്����ѕ�̵���ѕȁ���������������(��������������������������9����ܴ�����������ݡ�є�ԁɽչ�����ᰁ������ѕ�̵���ѕȁ���ѥ�䵍��ѕȁѕ�еݡ�є�����(������������������������ٜ(������������������������ݥ�Ѡ����(����������������������������������(������������������������٥�� ��������Ѐ�Ј(�������������������������������(��������������������������ɽ�����ɕ�� ���Ȉ(��������������������������ɽ��]��Ѡ�ĸԈ(�����������������������(���������������������������Ѡ���4�Ȁ�0Ȁݰ���Ԁ���Դ�����4Ȁ�ݰ���Ԁ����4Ȁ�ɰ���Ԁ���Ԉ���(������������������������ٜ�(����������������������(����������������������������9����ѕ�е�́ѕ�еݡ�є�������ܵl�����t���Ѽ�ѕ�е���ѕȁ���е����մ��(���������������������� ������ɔ���Ʌ��ѕ�́�����ո�ѡ��ݽɭ���܁Ѽ�͕��ɕ�ձ�̸(�����������������������(��������������������(������������������((�������������������ᕍ�ѥ�������(������������������������9���������്����ѕ�̵���ѕȁ���������є����������(��������������������������9����ɕ��ѥٔ��(����������������������������9����ܴ�Ё���Ё��ɑ�ȵl���t���ɑ�ȵݡ�є�ԁ��ɑ�ȵеl��ɐ͕�t�ɽչ�����ձ�������є������͡���ܵl�|�|����}ɝ����а���İ������ĥt����(����������������������������9���ͽ��є���͕д��������ѕ�̵���ѕȁ���ѥ�䵍��ѕȁѕ�еl��ɐ͕�t��(��������������������������ٜ(��������������������������ݥ�Ѡ��Ȉ(����������������������������������Ȉ(��������������������������٥�� ��������Ѐ�Ј(���������������������������������(����������������������������ɽ�����ɕ�� ���Ȉ(����������������������������ɽ��]��Ѡ�ȸԈ(�������������������������������9������є��ձ͔�(�������������������������(������������������������������履�����������Ȁ�Ȁ����Ȁ�Ԁ�Ā�̀�ȀȀ�Ȉ���(��������������������������ٜ�(������������������������(����������������������(��������������������������9����ѕ�е���ѕȁ�������Ȉ�(����������������������������9����ѕ�еl����t����е������ѕ�еl��ɐ͕�t�����ɍ�͔��Ʌ������l��͕�t������є��ձ͔��(������������������������Iչ�����A�������(������������������������(����������������������������9����ѕ�еl����t�ѕ�еݡ�є�������е����մ��(������������������������Aɽ���ͥ�������́��������Ʌѥ�����͕�̸��(������������������������(����������������������(��������������������(������������������((�����������������ɕ�ձЀ����(������������������������9����ܵ�ձ�����ܴ�ᰁ��������������є�������������(��������������������������9�������ѕ�̵���ѕȁ���ѥ�䵉��ݕ������Ȉ�(�����������������������́�����9����ѕ�е�́���е������ѕ�еݡ�є��������ɍ�͔��Ʌ������ݥ���Ј�(������������������������]�ɭ���܁I��ձ��(�������������������������(����������������������������9�������ѕ�̵���ѕȁ����ȁ��́��ā����ɕ����������ѕ�е�ɕ�������ɽչ�����ձ��ѕ�еl����t����е�������ɑ�ȁ��ɑ�ȵ�ɕ�����������(������������������������������9����ܴā��ā����ɕ�������ɽչ�����ձ�������є��ձ͔����숀��(������������������������ =5A1Q(������������������������(����������������������((��������������������������9����ɥ���ɥ�����̴ā���ɥ�����̴ȁ����؈�(�����������������������ɕ�ձй����������������а���ऀ����(��������������������������(�����������������������������������(�������������������������������9����ɽ���ɕ��ѥٔ����ݡ�є�ԁ��ɑ�ȁ��ɑ�ȵݡ�є����ɽչ�����ᰁ�ٕə��ܵ���������ٕ�鉽ɑ�ȵl��ɐ͕�t�����Ʌ�ͥѥ�������͡���ܴ�ᰈ(�������������������������(�����������������������������й�����������}�ɰ�����(����������������������������(�������������������������������Ɍ����йم�Օ�(�����������������������������������9����ܵ�ձ�������е��Յɔ������е��ٕȈ(����������������������������������=����Ј(������������������������������(����������������������������聽�й��������٥���}�ɰ�����(�����������������������������٥���(�������������������������������Ɍ����йم�Օ�(����������������������������������ɽ��(�����������������������������������9����ܵ�ձ�������е��Յɔ������е��ٕȈ(������������������������������(����������������������������耠(����������������������������������9������������l�����t�������ѕ�̵���ѕȁ���ѥ�䵍��ѕȁ�х����ѕ�еݡ�є�����(���������������������������������йم�Օ�(������������������������������(����������������������������((��������������������������������9���ͽ��є���͕е������ѽ������Ё����Ʌ����еѼ�Ё�ɽ�����������Ѽ��Ʌ����ɕ�Ё�Ʌ�ͱ�є�䵙ձ���ɽ�����ٕ���Ʌ�ͱ�є�����Ʌ�ͥѥ����Ʌ�͙�ɴ��(����������������������������������9�������ѕ�̵���ѕȁ���ѥ�䵉��ݕ����(�����������������������������������������9����ѕ�еl����t����е������ѕ�еl��ɐ͕�t�����ɍ�͔��Ʌ������ݥ���Ј�(�����������������������������������й���(������������������������������������(�������������������������������(���������������������������������ɕ�����йم�Օ�(��������������������������������хɝ���}������(��������������������������������ɕ�ɕ���ɕȈ(�������������������������������������9����ܴ������ɽչ����������ݡ�є����������ѕ�̵���ѕȁ���ѥ�䵍��ѕȁ��ٕ�鉜�l��ɐ͕�t���ٕ��ѕ�е�������Ʌ�ͥѥ��������̈(�������������������������������(����������������������������������ٜ(����������������������������������ݥ�Ѡ��Ј(������������������������������������������Ј(����������������������������������٥�� ��������Ѐ�Ј(�����������������������������������������(������������������������������������ɽ�����ɕ�� ���Ȉ(������������������������������������ɽ��]��Ѡ�ȸԈ(���������������������������������(�������������������������������������Ѡ���4������لȀȀ���ĴȀ� ՄȀȀ���Ĵȴ�X�ȀȀ����ȴɠ�4�Ԁ͠���4�����0�Ā̈���(����������������������������������ٜ�(��������������������������������(������������������������������(����������������������������(��������������������������(�������������������������(����������������������(��������������������(������������������(����������������(��������������(������������耠(������������������9�����āɕ��ѥٔ����l�������t��(�������������������M�����̀���ݽɭ����������(�����������������]�ɭ����U$(������������������ݽɭ����%���͕���ѕ�]�ɭ���������(���������������������ѥ��9���M������������M�������(���������������������ѥ��]�ɭ�����ф���(�����������������������ݽɭ�������(�����������������������%����Ё%�Ѽ��ɕٕ�Ё�ե���ȁ�ɽ�����յ����ѡ�́�́����܁չٕͅ������(��������������������ݽɭ����}���͕���ѕ�]�ɭ��������(��������������������(�����������������������Ʌѥ��Mх���������Ʌѥ��Mх���(�����������������������Ʌѥ�����������Ʌѥ�����(�����������������������Ʌѥ�� �����є�������Ʌѥ�� �����ѕ�(�����������������������Ʌѥ���ɽ��������Ʌѥ���ɽ��(������������������(����������������耠(����������������������9���ͽ��є���͕д��������ѕ�̵���ѕȁ���ѥ�䵍��ѕȈ�(������������������������9���������്����ѕ�̵���ѕȁ����Ј�(��������������������������9����ܴ�ȁ���ȁ��ɑ�ȴЁ��ɑ�ȵݡ�є�ԁ��ɑ�ȵеl��ɐ͕�t�ɽչ�����ձ�������є���������(��������������������������9����ѕ�еl����t����е������ѕ�еݡ�є��������ɍ�͔��Ʌ������ݥ���Ј�(����������������������1������� ե���ȸ��(����������������������(��������������������(������������������(����������������(��������������(������������(����������(��������(������(���((�����I����ȁ�����ݽɭ���܁����(��ɕ��ɸ��(����������9����ձ��ܵ�ձ����������്��������ٕə��ܵ䵅�Ѽ����ѽ��͍ɽ����Ȉ�(������������9����ܴ�ᰁ��Ѽ�ܵ�ձ���(��������������9���������്�����������Ȉ�(����������������9�������ѕ�̵�������ѥ�䵉��ݕ����(���������������(���������������ā�����9����ѕ�д�ᰁ���е�����ѕ�еݡ�є����ȁ�Ʌ������ѥ��Ј�(����������������]�ɭ�����(�����������������(����������������������9����ѕ�еݡ�є����ѕ�еʹ����е����մ��(���������������� ɕ�є��������������ȁ��幍�ɽ���́$��ɽ���ͥ������������(�����������������(��������������(���������������ѽ�(���������������� �����젤���������� ɕ�ѕ]�ɭ���ܠ��(�������������������9��������́���l��ɐ͕�t�ѕ�е������ѕ�е�́���е����������ɍ�͔��Ʌ������ݥ���Ёɽչ���������ٕ�鉜�ݡ�є��Ʌ�ͥѥ��������Ʌ�͙�ɴ���ٕ��͍������ԁ��ѥٔ�͍�����ԁ͡���ܵl�|�|����}ɝ����а���İ������̥t�������ѕ�̵���ѕȁ����Ȉ(�������������(����������������ٜ(����������������ݥ�Ѡ��Ј(������������������������Ј(����������������٥�� ��������Ѐ�Ј(�����������������������(������������������ɽ�����ɕ�� ���Ȉ(������������������ɽ��]��Ѡ�̈(������������������ɽ��1�������ɽչ��(������������������ɽ��1��������ɽչ��(���������������(����������������������Ȉ����Ԉ�����Ȉ����������(���������������������Ԉ�����Ȉ�����䈁����Ȉ����(����������������ٜ�(�������������� ɕ�є�]�ɭ����(���������������ѽ��(������������((����������������9�������ѕ�̵���ѕȁ����ȁ��ɑ�ȵ����ɑ�ȵݡ�є�Ԉ�(���������������ѽ�(���������������� �����젤����͕��ѥٕ5���Q����ѕ����ѕ̈��(�������������������9���������Ёѕ�е�́���е����������ɍ�͔��Ʌ������l��ɕ�t��Ʌ�ͥѥ���������ɑ�ȵ��Ȁ��(������������������ѥٕ5���Q������ѕ����ѕ̈(���������������������ѕ�еl��ɐ͕�t���ɑ�ȵl��ɐ͕�t�(������������������耉ѕ�еݡ�є������ɑ�ȵ�Ʌ����ɕ�Ё��ٕ��ѕ�еݡ�є�(�����������������(�������������(��������������Q�����ѕ�(���������������ѽ��(���������������ѽ�(���������������� �����젤����͕��ѥٕ5���Q������ݽɭ����̈��(�������������������9���������Ёѕ�е�́���е����������ɍ�͔��Ʌ������l��ɕ�t��Ʌ�ͥѥ���������ɑ�ȵ��Ȁ��(������������������ѥٕ5���Q������ݽɭ����̈(���������������������ѕ�еl��ɐ͕�t���ɑ�ȵl��ɐ͕�t�(������������������耉ѕ�еݡ�є������ɑ�ȵ�Ʌ����ɕ�Ё��ٕ��ѕ�еݡ�є�(�����������������(�������������(��������������5�]�ɭ�����(���������������ѽ��(���������������ѽ�(���������������� �����젤����͕��ѥٕ5���Q�����Չ��͡�����(�������������������9���������Ёѕ�е�́���е����������ɍ�͔��Ʌ������l��ɕ�t��Ʌ�ͥѥ���������ɑ�ȵ��Ȁ��(������������������ѥٕ5���Q�������Չ��͡���(���������������������ѕ�еl��ɐ͕�t���ɑ�ȵl��ɐ͕�t�(������������������耉ѕ�еݡ�є������ɑ�ȵ�Ʌ����ɕ�Ё��ٕ��ѕ�еݡ�є�(�����������������(�������������(�������������� ���չ���(���������������ѽ��(������������(����������((��������������������(����������������9���������������ѕ�̵���ѕȁ���ѥ�䵍��ѕȈ�(������������������9����ܴ����������ɑ�ȴЁ��ɑ�ȵݡ�є�ԁ��ɑ�ȵеl��ɐ͕�t�ɽչ�����ձ�������є���������(������������(����������耠(����������������9����ɥ���ɥ�����̴ȁ���ɥ�����̴́���ɥ�����̴Ё��ɥ�����̴Ԁ���ɥ�����̴����؈�(�������������ݽɭ����̹�����ݘ������(���������������]�ɭ���� �ɐ(���������������������ݘ����(����������������ݽɭ������ݙ�(������������������ ������������M�����]�ɭ�����(������������������ѥٕQ���텍ѥٕ5���Q���(������������������I�������ݘ������(�������������������͕�I�������]�ɭ���ܡݘ��(�������������������͕�9��]�ɭ����9����ݘ�������(������������������(���������������������є�����������ѕ]�ɭ�����(����������������(���������������(������������셱����������ݽɭ����̹����Ѡ����������(��������������������9�����������ձ�����Ёѕ�е���ѕȁ��ɑ�ȴȁ��ɑ�ȵ��͡�����ɑ�ȵݡ�є�ԁɽչ�����ᰁ���ݡ�є�l����t��(����������������������9����ѕ�еݡ�є����ѕ�еʹ����е����մ��х�����(������������������9��ݽɭ����́��չ�����ѡ�͕́�ѥ���(������������������(����������������(��������������(������������(����������(��������((������켨�I������5��������(�������ɕ������]�ɭ���܀����(��������������9���ᕐ���͕д���l���t�������ѕ�̵���ѕȁ���ѥ�䵍��ѕȁ��؈�(����������������9���ͽ��є���͕д�������������������ɽ�����ȵ������ �����젤����͕�I�������]�ɭ���ܡ�ձ����(�����������ɴ�(��������������MՉ�����������I�����]�ɭ�����(�����������������9����ɕ��ѥٔ�ܵ�ձ�����ܵʹ����l�������t���ɑ�ȁ��ɑ�ȵݡ�є����ɽչ�����ᰁ����͡���ܴ�ᰁ�����є������������齽�������Ʌѥ�������(�����������(�������������́�����9����ѕ�еᰁ���е�����ѕ�еݡ�є����Ȉ�I������]�ɭ�������(��������������������9����ѕ�еݡ�є����ѕ�еʹ����؈��ѕȁ����܁��͍ɥ�ѥٔ��������ȁ��ȁ������������(������������(������������������9�����������Ј�(��������������������9�����������Ȉ�(������������������������9����ѕ�еl����t����е������ѕ�еl��ɐ͕�t�����ɍ�͔��Ʌ������ݥ���Ј�]�ɭ���܁9�������(��������������������(��������������������ѽ����(�����������������������ѕ�Ј(������������������م�Ք�����]�ɭ����9����(�������������������� ������졔�����͕�9��]�ɭ����9������хɝ�йم�Ք��(�������������������������������� �����ѥ��Y�������܈(�����������������������9����ܵ�ձ�����ݡ�є�ԁ��ɑ�ȁ��ɑ�ȵݡ�є����ɽչ����ᰁ��Ё��́ѕ�еʹ�ѕ�еݡ�є��������ѱ��������������鉽ɑ�ȵl��ɐ͕�t�����Ʌ�ͥѥ��������̈(������������������(����������������(��������������(��������������������9����������́�дЈ�(�������������������ѽ�(�������������������������ѽ��(�������������������� �����젤����͕�I�������]�ɭ���ܡ�ձ���(�����������������������9�����ā��Ё��́ѕ�е�́���е������ѕ�еݡ�є��������ɍ�͔��Ʌ������ݥ���Ё��ٕ��ѕ�еݡ�є��Ʌ�ͥѥ��������̈(�����������������(������������������ �����(�������������������ѽ��(�������������������ѽ�(������������������������Չ��Ј(�����������������������9�����ā���l��ɐ͕�t�ѕ�е��������Ё��́ɽչ����ᰁѕ�е�́���е����������ɍ�͔��Ʌ������ݥ���Ё��ٕ�鉜�ݡ�є��Ʌ�ͥѥ��������Ʌ�͙�ɴ���ٕ��͍������ԁ��ѥٔ�͍�����Ԉ(�����������������(������������������M�ٔ�9���(�������������������ѽ��(����������������(��������������(����������ɴ�(����������(��������(������(����)�(\ No newline at end of file+ onGenerationStart?.();+ setIsExecuting(true);+ setError(null);+ setResult(null);++ try {+ const inputs = {};+ Object.entries(formData).forEach(([key, value]) => {+ if (!value) return;+ if (key.startsWith("text")) inputs[key] = { prompt: value };+ else if (key.startsWith("image")) inputs[key] = { image_url: value };+ else if (key.startsWith("video")) inputs[key] = { video_url: value };+ else inputs[key] = value;+ });++ const data = await executeWorkflow(apiKey, selectedWorkflow.id, inputs);+ setResult(data);+ onGenerationComplete?.({+ url: data?.url || data?.output?.url || data?.outputs?.[0]?.url || null,+ type: "workflow",+ });+ } catch (err) {+ console.error("Execution failed:", err);+ const message = err.message || "Execution failed";+ setError(message);+ onGenerationError?.(message);+ } finally {+ setIsExecuting(false);+ onGenerationEnd?.();+ }+ };++ if (loading && !selectedWorkflow) {+ return (+ <div className="h-full flex items-center justify-center">+ <div className="animate-spin text-[#22d3ee] text-3xl">◌</div>+ </div>+ );+ }++ if (selectedWorkflow) {+ return (+ <div className="h-full flex flex-col bg-[#030303] text-white">+ {/* Immersive Sub-header / Floating Toggle */}+ {isHeaderVisible ? (+ <div className="flex-shrink-0 h-14 border-b border-white/5 flex items-center justify-between px-6 bg-black/40 z-30">+ <div className="flex items-center gap-8 h-full">+ <button+ onClick={() => router.push("/studio/workflows")}+ className="flex items-center gap-2 text-xs font-bold text-white/50 hover:text-white transition-colors"+ type="button"+ >+ <svg width="14" height="14" viewBox="0 0 24 24" fill="none" stroke="currentColor" strokeWidth="2.5" strokeLinecap="round" strokeLinejoin="round">+ <path d="M19 12H5M12 19l-7-7 7-7" />+ </svg>+ All Workflows+ </button>++ <div className="h-4 w-[1px] bg-white/10" />++ <div className="flex h-full">+ <div className="flex bg-white/5 p-1 rounded-lg my-auto">+ <button+ onClick={() => {+ setActiveSubTab("playground");+ if (selectedWorkflow?.id) router.push(`/workflow/${selectedWorkflow.id}/playground`);+ }}+ type="button"+ className={`px-4 py-1.5 text-[10px] font-black uppercase tracking-widest rounded-md transition-all ${+ activeSubTab === "playground"+ ? "bg-[#22d3ee] text-black shadow-[0_0_15px_rgba(34, 211, 238,0.2)]"+ : "text-white/40 hover:text-white"+ }`}+ >+ Playground+ </button>+ <button+ onClick={() => {+ setActiveSubTab("builder");+ if (selectedWorkflow?.id) router.push(`/workflow/${selectedWorkflow.id}/builder`);+ }}+ type="button"+ className={`px-4 py-1.5 text-[10px] font-black uppercase tracking-widest rounded-md transition-all ${+ activeSubTab === "builder"+ ? "bg-[#22d3ee] text-black shadow-[0_0_15px_rgba(34, 211, 238,0.2)]"+ : "text-white/40 hover:text-white"+ }`}+ >+ Full Workflow+ </button>+ </div>+ </div>+ </div>++ <div className="flex items-center gap-3">+ <span className="text-[11px] font-black text-[#22d3ee] uppercase tracking-widest">+ {selectedWorkflow.name}+ </span>+ <button+ onClick={() => onToggleHeader?.(false)}+ className="p-1.5 bg-white/5 hover:bg-white/10 rounded-md transition-colors text-white/40 hover:text-white"+ title="Enter Zen Mode"+ type="button"+ >+ <svg width="14" height="14" viewBox="0 0 24 24" fill="none" stroke="currentColor" strokeWidth="2.5">+ <path d="M15 3h6v6M9 21H3v-6M21 3l-7 7M3 21l7-7" />+ </svg>+ </button>+ </div>+ </div>+ ) : (+ /* Floating Immersive Mode Controller */+ <div className="absolute top-4 left-1/2 -translate-x-1/2 z-[100] flex items-center gap-4 px-4 py-2 bg-black/60 backdrop-blur-xl border border-white/10 rounded-full shadow-2xl animate-fade-in-down">+ <button+ onClick={() => router.push("/studio/workflows")}+ className="p-1.5 text-white/40 hover:text-white transition-colors"+ title="Back to All Workflows"+ type="button"+ >+ <svg width="14" height="14" viewBox="0 0 24 24" fill="none" stroke="currentColor" strokeWidth="2.5"><path d="M19 12H5M12 19l-7-7 7-7"/></svg>+ </button>++ <div className="h-4 w-[1px] bg-white/10" />++ <div className="flex bg-white/5 p-1 rounded-lg">+ <button+ onClick={() => setActiveSubTab("playground")}+ type="button"+ className={`px-3 py-1 text-[9px] font-black uppercase tracking-widest rounded-md transition-all ${+ activeSubTab === "playground" ? "bg-[#22d3ee] text-black" : "text-white/40"+ }`}+ >+ Play+ </button>+ <button+ onClick={() => setActiveSubTab("builder")}+ type="button"+ className={`px-3 py-1 text-[9px] font-black uppercase tracking-widest rounded-md transition-all ${+ activeSubTab === "builder" ? "bg-[#22d3ee] text-black" : "text-white/40"+ }`}+ >+ Builder+ </button>+ </div>++ <div className="h-4 w-[1px] bg-white/10" />++ <button+ onClick={() => onToggleHeader?.(true)}+ className="px-3 py-1 bg-white/10 hover:bg-white/20 text-[9px] font-black text-white uppercase tracking-widest rounded-lg transition-colors flex items-center gap-2"+ type="button"+ >+ <svg width="10" height="10" viewBox="0 0 24 24" fill="none" stroke="currentColor" strokeWidth="3"><path d="M4 14h6v6M20 10h-6V4M10 20l-7-7M14 4l7 7"/></svg>+ Exit Zen+ </button>+ </div>+ )}++ <div className="flex-1 overflow-hidden flex flex-col lg:flex-row">+ {activeSubTab === "playground" ? (+ <>+ {/* Controls Panel */}+ <div className="w-full lg:w-[400px] border-r border-white/5 flex flex-col bg-black/20">+ <div className="p-6 overflow-y-auto flex-1 custom-scrollbar">+ <form onSubmit={handleRun} className="space-y-6">+ <div>+ <h3 className="text-xs font-black text-white/30 uppercase tracking-widest mb-4">+ Configuration+ </h3>+ <div className="space-y-4">+ {inputSchema &&+ Object.entries(inputSchema.properties || {}).map(+ ([key, prop]) => (+ <div key={key} className="space-y-2">+ <label className="block text-[11px] font-bold text-white/80 uppercase tracking-wider">+ {prop.title || key}+ </label>+ {prop.type === "string" && !prop.enum ? (+ <textarea+ value={formData[key] || ""}+ onChange={(e) =>+ setFormData({+ ...formData,+ [key]: e.target.value,+ })+ }+ className="w-full bg-white/5 border border-white/10 rounded-lg p-3 text-sm text-white focus:outline-none focus:border-[#22d3ee]/50 transition-colors min-h-[80px] resize-none"+ placeholder={+ prop.description || `Enter ${key}...`+ }+ />+ ) : prop.enum ? (+ <select+ value={formData[key] || ""}+ onChange={(e) =>+ setFormData({+ ...formData,+ [key]: e.target.value,+ })+ }+ className="w-full bg-white/5 border border-white/10 rounded-lg p-3 text-sm text-white focus:outline-none focus:border-[#22d3ee]/50 transition-colors"+ >+ {prop.enum.map((opt) => (+ <option+ key={opt}+ value={opt}+ className="bg-black"+ >+ {opt}+ </option>+ ))}+ </select>+ ) : (+ <input+ type="text"+ value={formData[key] || ""}+ onChange={(e) =>+ setFormData({+ ...formData,+ [key]: e.target.value,+ })+ }+ className="w-full bg-white/5 border border-white/10 rounded-lg p-3 text-sm text-white focus:outline-none focus:border-[#22d3ee]/50 transition-colors"+ placeholder={+ prop.description || `Enter ${key}...`+ }+ />+ )}+ </div>+ ),+ )}+ </div>+ </div>++ <button+ type="submit"+ disabled={isExecuting || !selectedWorkflow.id}+ className="w-full py-4 bg-[#22d3ee] text-black text-xs font-black uppercase tracking-[0.2em] rounded-xl hover:bg-white transition-all transform hover:scale-[1.02] active:scale-95 disabled:opacity-50 disabled:grayscale shadow-[0_0_30px_rgba(34, 211, 238,0.15)] flex items-center justify-center gap-3 mt-8"+ >+ {isExecuting ? (+ <>+ <div className="w-4 h-4 border-2 border-black/20 border-t-black rounded-full animate-spin" />+ <span>Generating...</span>+ </>+ ) : (+ <>+ <svg+ width="16"+ height="16"+ viewBox="0 0 24 24"+ fill="none"+ stroke="currentColor"+ strokeWidth="3"+ >+ <path d="M5 3l14 9-14 9V3z" />+ </svg>+ <span>Run Workflow</span>+ </>+ )}+ </button>+ {!selectedWorkflow.id && (+ <p className="text-[10px] text-white/30 text-center mt-4">+ Save your workflow first to enable execution.+ </p>+ )}+ </form>+ </div>+ </div>++ {/* Preview Panel */}+ <div className="flex-1 overflow-y-auto p-8 lg:p-12 bg-[#050505] flex items-center justify-center min-h-[500px]">+ {error && (+ <div className="w-full max-w-md p-6 bg-red-500/10 border border-red-500/20 rounded-2xl flex flex-col items-center gap-4 animate-shake">+ <div className="w-12 h-12 bg-red-500/20 rounded-full flex items-center justify-center text-red-500">+ <svg+ width="24"+ height="24"+ viewBox="0 0 24 24"+ fill="none"+ stroke="currentColor"+ strokeWidth="2.5"+ >+ <circle cx="12" cy="12" r="10" />+ <line x1="12" y1="8" x2="12" y2="12" />+ <line x1="12" y1="16" x2="12.01" y2="16" />+ </svg>+ </div>+ <div className="text-center">+ <span className="text-[10px] font-black text-red-500 uppercase tracking-widest block mb-1">+ Execution Error+ </span>+ <p className="text-white/60 text-sm leading-relaxed">+ {error}+ </p>+ </div>+ </div>+ )}++ {!isExecuting && !result && !error && (+ <div className="flex flex-col items-center gap-6 opacity-40">+ <div className="w-20 h-20 bg-white/5 rounded-3xl flex items-center justify-center text-white/20">+ <svg+ width="40"+ height="40"+ viewBox="0 0 24 24"+ fill="none"+ stroke="currentColor"+ strokeWidth="1.5"+ >+ <path d="M12 2L2 7l10 5 10-5-10-5zM2 17l10 5 10-5M2 12l10 5 10-5" />+ </svg>+ </div>+ <p className="text-xs text-white/40 max-w-[200px] mx-auto text-center font-medium">+ Configure parameters and run the workflow to see results.+ </p>+ </div>+ )}++ {isExecuting && (+ <div className="flex flex-col items-center gap-6 animate-fade-in">+ <div className="relative">+ <div className="w-24 h-24 border-[3px] border-white/5 border-t-[#22d3ee] rounded-full animate-spin shadow-[0_0_40px_rgba(34, 211, 238,0.1)]" />+ <div className="absolute inset-0 flex items-center justify-center text-[#22d3ee]">+ <svg+ width="32"+ height="32"+ viewBox="0 0 24 24"+ fill="none"+ stroke="currentColor"+ strokeWidth="2.5"+ className="animate-pulse"+ >+ <polyline points="22 12 18 12 15 21 9 3 6 12 2 12" />+ </svg>+ </div>+ </div>+ <div className="text-center space-y-2">+ <div className="text-[10px] font-black text-[#22d3ee] uppercase tracking-[0.3em] animate-pulse">+ Running Pipeline+ </div>+ <div className="text-[13px] text-white/40 font-medium">+ Processing nodes and generating assets...+ </div>+ </div>+ </div>+ )}++ {result && (+ <div className="w-full max-w-4xl space-y-8 animate-fade-in-up">+ <div className="flex items-center justify-between mb-2">+ <h3 className="text-xs font-black text-white/30 uppercase tracking-widest">+ Workflow Results+ </h3>+ <div className="flex items-center gap-2 px-3 py-1 bg-green-500/10 text-green-500 rounded-full text-[10px] font-bold border border-green-500/20">+ <div className="w-1 h-1 bg-green-500 rounded-full animate-pulse" />{" "}+ COMPLETED+ </div>+ </div>++ <div className="grid grid-cols-1 md:grid-cols-2 gap-6">+ {result.outputs?.map((out, idx) => (+ <div+ key={idx}+ className="group relative bg-white/5 border border-white/10 rounded-2xl overflow-hidden hover:border-[#22d3ee]/30 transition-all shadow-2xl"+ >+ {out.type === "image_url" ? (+ <img+ src={out.value}+ className="w-full aspect-square object-cover"+ alt="Output"+ />+ ) : out.type === "video_url" ? (+ <video+ src={out.value}+ controls+ className="w-full aspect-square object-cover"+ />+ ) : (+ <div className="p-6 min-h-[200px] flex items-center justify-center italic text-white/60">+ {out.value}+ </div>+ )}++ <div className="absolute inset-x-0 bottom-0 p-4 bg-gradient-to-t from-black/80 to-transparent translate-y-full group-hover:translate-y-0 transition-transform">+ <div className="flex items-center justify-between">+ <span className="text-[10px] font-black text-[#22d3ee] uppercase tracking-widest">+ {out.id}+ </span>+ <a+ href={out.value}+ target="_blank"+ rel="noreferrer"+ className="w-8 h-8 rounded-lg bg-white/10 flex items-center justify-center hover:bg-[#22d3ee] hover:text-black transition-colors"+ >+ <svg+ width="14"+ height="14"+ viewBox="0 0 24 24"+ fill="none"+ stroke="currentColor"+ strokeWidth="2.5"+ >+ <path d="M18 13v6a2 2 0 01-2 2H5a2 2 0 01-2-2V8a2 2 0 012-2h6M15 3h6v6M10 14L21 3" />+ </svg>+ </a>+ </div>+ </div>+ </div>+ ))}+ </div>+ </div>+ )}+ </div>+ </>+ ) : (+ <div className="flex-1 relative bg-[#050505]">+ {nodeSchemas && workflowDef ? (+ <WorkflowUI+ workflowId={selectedWorkflow?.id}+ initialNodeSchemas={nodeSchemas}+ initialWorkflowData={{+ ...workflowDef,+ // Inject ID to prevent builder from assuming this is a new unsaved flow+ workflow_id: selectedWorkflow?.id+ }}+ onGenerationStart={onGenerationStart}+ onGenerationEnd={onGenerationEnd}+ onGenerationComplete={onGenerationComplete}+ onGenerationError={onGenerationError}+ />+ ) : (+ <div className="absolute inset-0 flex items-center justify-center">+ <div className="flex flex-col items-center gap-4">+ <div className="w-12 h-12 border-4 border-white/5 border-t-[#22d3ee] rounded-full animate-spin" />+ <div className="text-[10px] font-black text-white/20 uppercase tracking-widest">+ Loading Builder...+ </div>+ </div>+ </div>+ )}+ </div>+ )}+ </div>+ </div>+ );+ }++ // Render main workflow list+ return (+ <div className="h-full w-full flex flex-col p-8 overflow-y-auto custom-scrollbar">+ <div className="max-w-7xl mx-auto w-full">+ <div className="flex flex-col gap-6 mb-12">+ <div className="flex items-end justify-between">+ <div>+ <h1 className="text-3xl font-bold text-white mb-2 tracking-tight">+ Workflows+ </h1>+ <p className="text-white/40 text-sm font-medium">+ Create and manage your asynchronous AI processing pipelines+ </p>+ </div>+ <button+ onClick={() => handleCreateWorkflow()}+ className="px-6 py-3 bg-[#22d3ee] text-black text-xs font-black uppercase tracking-widest rounded-lg hover:bg-white transition-all transform hover:scale-105 active:scale-95 shadow-[0_0_20px_rgba(34, 211, 238,0.3)] flex items-center gap-2"+ >+ <svg+ width="14"+ height="14"+ viewBox="0 0 24 24"+ fill="none"+ stroke="currentColor"+ strokeWidth="3"+ strokeLinecap="round"+ strokeLinejoin="round"+ >+ <line x1="12" y1="5" x2="12" y2="19"></line>+ <line x1="5" y1="12" x2="19" y2="12"></line>+ </svg>+ Create Workflow+ </button>+ </div>++ <div className="flex items-center gap-2 border-b border-white/5">+ <button+ onClick={() => setActiveMainTab("templates")}+ className={`px-6 py-4 text-xs font-black uppercase tracking-[0.2em] transition-all border-b-2 ${+ activeMainTab === "templates"+ ? "text-[#22d3ee] border-[#22d3ee]"+ : "text-white/30 border-transparent hover:text-white"+ }`}+ >+ Templates+ </button>+ <button+ onClick={() => setActiveMainTab("my-workflows")}+ className={`px-6 py-4 text-xs font-black uppercase tracking-[0.2em] transition-all border-b-2 ${+ activeMainTab === "my-workflows"+ ? "text-[#22d3ee] border-[#22d3ee]"+ : "text-white/30 border-transparent hover:text-white"+ }`}+ >+ My Workflows+ </button>+ <button+ onClick={() => setActiveMainTab("published")}+ className={`px-6 py-4 text-xs font-black uppercase tracking-[0.2em] transition-all border-b-2 ${+ activeMainTab === "published"+ ? "text-[#22d3ee] border-[#22d3ee]"+ : "text-white/30 border-transparent hover:text-white"+ }`}+ >+ Community+ </button>+ </div>+ </div>++ {loading ? (+ <div className="py-20 flex items-center justify-center">+ <div className="w-10 h-10 border-4 border-white/5 border-t-[#22d3ee] rounded-full animate-spin" />+ </div>+ ) : (+ <div className="grid grid-cols-2 md:grid-cols-3 lg:grid-cols-4 xl:grid-cols-5 2xl:grid-cols-6 gap-6">+ {workflows.map((wf) => (+ <WorkflowCard+ key={wf.id}+ workflow={wf}+ onClick={handleSelectWorkflow}+ activeTab={activeMainTab}+ onRename={(wf) => {+ setRenamingWorkflow(wf);+ setNewWorkflowName(wf.name);+ }}+ onDelete={handleDeleteWorkflow}+ />+ ))}+ {!loading && workflows.length === 0 && (+ <div className="col-span-full py-24 text-center border-2 border-dashed border-white/5 rounded-2xl bg-white/[0.02]">+ <div className="text-white/20 text-sm font-medium italic">+ No workflows found in this section.+ </div>+ </div>+ )}+ </div>+ )}+ </div>++ {/* Rename Modal */}+ {renamingWorkflow && (+ <div className="fixed inset-0 z-[100] flex items-center justify-center p-6">+ <div className="absolute inset-0 bg-black/80 backdrop-blur-md" onClick={() => setRenamingWorkflow(null)} />+ <form+ onSubmit={handleRenameWorkflow}+ className="relative w-full max-w-sm bg-[#0a0a0a] border border-white/10 rounded-2xl p-8 shadow-2xl animate-in fade-in zoom-in duration-300"+ >+ <h3 className="text-xl font-bold text-white mb-2">Rename Workflow</h3>+ <p className="text-white/40 text-sm mb-6">Enter a new descriptive name for your pipeline.</p>++ <div className="space-y-4">+ <div className="space-y-2">+ <label className="text-[10px] font-black text-[#22d3ee] uppercase tracking-widest">Workflow Name</label>+ <input+ autoFocus+ type="text"+ value={newWorkflowName}+ onChange={(e) => setNewWorkflowName(e.target.value)}+ placeholder="e.g. Cinematic Video Flow"+ className="w-full bg-white/5 border border-white/10 rounded-xl px-4 py-3 text-sm text-white focus:outline-none focus:border-[#22d3ee]/50 transition-colors"+ />+ </div>++ <div className="flex gap-3 pt-4">+ <button+ type="button"+ onClick={() => setRenamingWorkflow(null)}+ className="flex-1 px-4 py-3 text-xs font-black text-white/40 uppercase tracking-widest hover:text-white transition-colors"+ >+ Cancel+ </button>+ <button+ type="submit"+ className="flex-1 bg-[#22d3ee] text-black px-4 py-3 rounded-xl text-xs font-black uppercase tracking-widest hover:bg-white transition-all transform hover:scale-105 active:scale-95"+ >+ Save Name+ </button>+ </div>+ </div>+ </form>+ </div>+ )}+ </div>+ );+}