@chaibuilder/sdk 4.0.0-beta.4 → 4.0.0-beta.7

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (123) hide show
  1. package/README.md +75 -50
  2. package/dist/{2SSKDMRQ-CopJgtZb.cjs → 2SSKDMRQ-DDOgISWg.cjs} +1 -1
  3. package/dist/{2SSKDMRQ-Difo_1pg.js → 2SSKDMRQ-hL7THuKW.js} +2 -2
  4. package/dist/{AP7HFJJL-BPuPBqj4.js → AP7HFJJL-BsLQ13V_.js} +1 -1
  5. package/dist/{AP7HFJJL-DYxDgaOs.cjs → AP7HFJJL-tcAhVllC.cjs} +1 -1
  6. package/dist/{IconPicker-B2-oriq2.js → IconPicker-FLSVAZxx.js} +1 -1
  7. package/dist/{IconPicker-C0oycHbs.cjs → IconPicker-J1KLNrSB.cjs} +1 -1
  8. package/dist/{WDYDFRGG-DbejaRPK.cjs → WDYDFRGG-BTj8AXV6.cjs} +1 -1
  9. package/dist/{WDYDFRGG-KK8pkcW1.js → WDYDFRGG-Yi0eNS2V.js} +2 -2
  10. package/dist/{actions-registery-JdxhXhT6.cjs → actions-registery-CtQSSexG.cjs} +31 -31
  11. package/dist/{actions-registery-y_ENc8zj.js → actions-registery-DqrFhSMp.js} +2414 -2418
  12. package/dist/actions.cjs +1 -1
  13. package/dist/actions.d.ts +0 -34
  14. package/dist/actions.js +3 -3
  15. package/dist/{active-in-another-tab-Cu_ASKtx.cjs → active-in-another-tab-BtAiatqq.cjs} +1 -1
  16. package/dist/{active-in-another-tab-DkR2HWI4.js → active-in-another-tab-Dozn833d.js} +2 -2
  17. package/dist/{add-new-language-page-BXuwluuU.cjs → add-new-language-page-9AMizlES.cjs} +1 -1
  18. package/dist/{add-new-language-page-CBY0RR6q.js → add-new-language-page-DD-CAoAQ.js} +3 -3
  19. package/dist/{add-new-page-C_PzKby8.cjs → add-new-page-BS9vPnFG.cjs} +1 -1
  20. package/dist/{add-new-page-DJLJFLAd.js → add-new-page-uZKCk9eB.js} +2 -2
  21. package/dist/{ai-panel-content--YM01Aly.js → ai-panel-content-CK4XOkEh.js} +3 -3
  22. package/dist/{ai-panel-content-rRmJdH7L.cjs → ai-panel-content-PovaKJaj.cjs} +1 -1
  23. package/dist/{ai-panel-default-lang-D2zhXvKP.cjs → ai-panel-default-lang-B37k5ADH.cjs} +2 -2
  24. package/dist/{ai-panel-default-lang-BZl0tPYo.js → ai-panel-default-lang-BtLjUl9d.js} +3 -3
  25. package/dist/{ai-panel-other-lang-Y4bEKHoG.cjs → ai-panel-other-lang-CdQmASqv.cjs} +1 -1
  26. package/dist/{ai-panel-other-lang-Bfjk2CYZ.js → ai-panel-other-lang-Dp1MNaLi.js} +3 -3
  27. package/dist/{ai-prompt-input-DueQYNf-.js → ai-prompt-input-BT-mEdTX.js} +1 -1
  28. package/dist/{ai-prompt-input-N9PcYCFa.cjs → ai-prompt-input-Dtym4w8J.cjs} +1 -1
  29. package/dist/{ai-translation-prompt-IAdWMNZb.cjs → ai-translation-prompt-B-lH7emI.cjs} +1 -1
  30. package/dist/{ai-translation-prompt-B36F3d7K.js → ai-translation-prompt-B17GK1QR.js} +1 -1
  31. package/dist/{code-editor-DQB8lAOk.cjs → code-editor-CUeNiMzA.cjs} +1 -1
  32. package/dist/{code-editor-Bb7JumZy.js → code-editor-EZT2pMsU.js} +1 -1
  33. package/dist/{continue-editing-in-this-client-Dm9cCj7K.js → continue-editing-in-this-client-CS7C6h9Q.js} +2 -2
  34. package/dist/{continue-editing-in-this-client-DmGFLHXw.cjs → continue-editing-in-this-client-DMZOc36k.cjs} +1 -1
  35. package/dist/core.cjs +1 -1
  36. package/dist/core.js +41 -42
  37. package/dist/css-import-modal-kHB0ramf.cjs +13 -0
  38. package/dist/{css-import-modal-9P_0uNa4.js → css-import-modal-s7t5gZQo.js} +3 -4
  39. package/dist/{delete-design-token-COvR4G1S.js → delete-design-token-C1smbx4E.js} +1 -1
  40. package/dist/{delete-design-token-BG8yHcS5.cjs → delete-design-token-Mbw_6sYI.cjs} +1 -1
  41. package/dist/{delete-page-CNucxe4P.js → delete-page-2GfBi8Iv.js} +2 -2
  42. package/dist/{delete-page-DAvEjHwF.cjs → delete-page-B7J3t0FN.cjs} +1 -1
  43. package/dist/{design-token-usage-CXglXgcJ.cjs → design-token-usage-BoGOULG8.cjs} +1 -1
  44. package/dist/{design-token-usage-MNYsFlPG.js → design-token-usage-DyO3xM-F.js} +1 -1
  45. package/dist/{digital-asset-manager-CqCWBO0s.js → digital-asset-manager-Cz3Nlrzl.js} +3 -3
  46. package/dist/{digital-asset-manager-CB5MRBcW.cjs → digital-asset-manager-DDk2ucTE.cjs} +1 -1
  47. package/dist/{duplicate-page-BknLfqr0.js → duplicate-page-BwAY4Ssm.js} +3 -3
  48. package/dist/{duplicate-page-DzZByALW.cjs → duplicate-page-Dw3U4wTT.cjs} +1 -1
  49. package/dist/{dynamic-page-selector-WA007Sni.cjs → dynamic-page-selector-CvBFyX2F.cjs} +1 -1
  50. package/dist/{dynamic-page-selector-DoW7OyUB.js → dynamic-page-selector-sViJuQlU.js} +2 -2
  51. package/dist/{get-chai-builder-tailwind-config-BFePCEIS.cjs → get-chai-builder-tailwind-config-DNp8Vhme.cjs} +1 -1
  52. package/dist/{get-chai-builder-tailwind-config-BXf_xLHk.js → get-chai-builder-tailwind-config-k8l5sdcw.js} +2 -2
  53. package/dist/{image-editor-CqwaVxO2.cjs → image-editor-AIsccrqC.cjs} +1 -1
  54. package/dist/{image-editor-CQnNtak2.js → image-editor-BgGQuESa.js} +1 -1
  55. package/dist/{index-Dno42B0a.js → index-B7eWP_hB.js} +539 -528
  56. package/dist/index-BwH1mRm_.cjs +5 -0
  57. package/dist/{index-rAcNbjk_.js → index-RYr8kQdI.js} +2132 -2130
  58. package/dist/{index-C99FhuF1.cjs → index-xYnNKovy.cjs} +15 -15
  59. package/dist/{json-diff-viewer-CLuUHiPU.cjs → json-diff-viewer-B2A78udz.cjs} +1 -1
  60. package/dist/{json-diff-viewer-CMvGUvJ2.js → json-diff-viewer-Svw-kbhe.js} +2 -2
  61. package/dist/{lang-panel-fDCYm5Jm.cjs → lang-panel-AmEkoWid.cjs} +1 -1
  62. package/dist/{lang-panel-CnwTb05j.js → lang-panel-Bnc-9wkM.js} +3 -3
  63. package/dist/{manage-design-tokens-BvH5KTJX.cjs → manage-design-tokens-B2fG80bi.cjs} +1 -1
  64. package/dist/{manage-design-tokens-BsSZE9Vs.js → manage-design-tokens-BBkh1t4w.js} +2 -2
  65. package/dist/{mark-as-template-DBLshWb5.js → mark-as-template-0CPzZnk-.js} +2 -2
  66. package/dist/{mark-as-template-CpWEBJGd.cjs → mark-as-template-CE6tRoQy.cjs} +1 -1
  67. package/dist/{nested-path-selector-content-C2sD9dkq.cjs → nested-path-selector-content-SmfjElr-.cjs} +1 -1
  68. package/dist/{nested-path-selector-content-6OBJ8LG8.js → nested-path-selector-content-kGznHufl.js} +1 -1
  69. package/dist/{no-language-page-content-BvPDdccK.cjs → no-language-page-content-B4bQLc4K.cjs} +1 -1
  70. package/dist/{no-language-page-content-CzENgtnu.js → no-language-page-content-DXsAPDZd.js} +2 -2
  71. package/dist/{no-language-page-dialog-CgW4yJBC.cjs → no-language-page-dialog-BC8NHzK2.cjs} +1 -1
  72. package/dist/{no-language-page-dialog-CbYI2cVg.js → no-language-page-dialog-BpPqmw9a.js} +2 -2
  73. package/dist/{page-creator-g8GqgcKH.cjs → page-creator-82qTbBj4.cjs} +1 -1
  74. package/dist/{page-creator-Cc83uQqw.js → page-creator-Bazn6yH4.js} +14 -14
  75. package/dist/{page-lock-BJUkyxdh.js → page-lock-CRFyqKZE.js} +2 -2
  76. package/dist/{page-lock-CT7SmQqp.cjs → page-lock-D2iFZDUK.cjs} +1 -1
  77. package/dist/{page-locked-dialog-DsEbWRed.js → page-locked-dialog-GKfQEOmk.js} +2 -2
  78. package/dist/{page-locked-dialog-Co5b9XIZ.cjs → page-locked-dialog-xLqvKzax.cjs} +1 -1
  79. package/dist/{page-manager-new-BOkJImo2.cjs → page-manager-new-Bn2QKjbf.cjs} +1 -1
  80. package/dist/{page-manager-new-5rFP5DyQ.js → page-manager-new-DItY2hjd.js} +3 -3
  81. package/dist/{page-manager-search-and-filter-zq-LfhQ1.js → page-manager-search-and-filter-CPa8IXdd.js} +2 -2
  82. package/dist/{page-manager-search-and-filter-Bfm0j1gg.cjs → page-manager-search-and-filter-Dc4ky-qV.cjs} +1 -1
  83. package/dist/{page-revisions-content-D38G2tJM.js → page-revisions-content-CH-PZK0O.js} +3 -3
  84. package/dist/{page-revisions-content-ag-MHBGr.cjs → page-revisions-content-CcLFI4YK.cjs} +1 -1
  85. package/dist/pages.cjs +1 -1
  86. package/dist/pages.js +1 -1
  87. package/dist/{publish-pages-content-BiX-GMLw.cjs → publish-pages-content-BzJDObqr.cjs} +1 -1
  88. package/dist/{publish-pages-content-CS7f41Ac.js → publish-pages-content-CSJCFElu.js} +3 -3
  89. package/dist/{rte-widget-modal-D6Zik0Ta.js → rte-widget-modal-5T81P_hg.js} +1 -1
  90. package/dist/{rte-widget-modal-BKNx2wln.cjs → rte-widget-modal-BfXcA7OP.cjs} +1 -1
  91. package/dist/{save-to-lib-ffjCZYJ5.cjs → save-to-lib-DGAdSa-0.cjs} +1 -1
  92. package/dist/{save-to-lib-WwOzbgiF.js → save-to-lib-MtWKSVeN.js} +2 -2
  93. package/dist/{selected-block-display-B1SG_UXw.js → selected-block-display-CB1-hVR5.js} +2 -2
  94. package/dist/{selected-block-display-BOgnQRLF.cjs → selected-block-display-DLt_nMn9.cjs} +1 -1
  95. package/dist/{seo-panel-BkOgRoWd.js → seo-panel-CRzzw4FW.js} +2 -2
  96. package/dist/{seo-panel-FjS1UF_y.cjs → seo-panel-_kGXE9MC.cjs} +1 -1
  97. package/dist/{shared-json-ld-uka9TOgA.js → shared-json-ld-CXukkDeS.js} +2 -2
  98. package/dist/{shared-json-ld-yJkXjENy.cjs → shared-json-ld-DoRgzDPC.cjs} +1 -1
  99. package/dist/{slug-input-DHLmUNrH.js → slug-input-CeEQ0zyv.js} +1 -1
  100. package/dist/{slug-input-Cyd6NR6J.cjs → slug-input-Dp187Tiy.cjs} +1 -1
  101. package/dist/supabase-actions.cjs +1 -1
  102. package/dist/supabase-actions.d.ts +5 -0
  103. package/dist/supabase-actions.js +1 -1
  104. package/dist/{take-over-request-Ca0X-qyf.js → take-over-request-C9J3_rev.js} +2 -2
  105. package/dist/{take-over-request-CmpJVe9T.cjs → take-over-request-CXuakFBm.cjs} +1 -1
  106. package/dist/{theme-panel-footer-CKO9YYwZ.cjs → theme-panel-footer-CWZ0qs13.cjs} +1 -1
  107. package/dist/{theme-panel-footer-BUXIu252.js → theme-panel-footer-DvwsyHNQ.js} +2 -2
  108. package/dist/{translation-warning-modal-pSZVKcNW.cjs → translation-warning-modal-DEt_ExQp.cjs} +1 -1
  109. package/dist/{translation-warning-modal-DrpFeI83.js → translation-warning-modal-_aBp5ZZQ.js} +1 -1
  110. package/dist/{unmark-as-template-DF1Ms4VN.cjs → unmark-as-template-BYL5naYx.cjs} +1 -1
  111. package/dist/{unmark-as-template-BMqgelv-.js → unmark-as-template-JN-cDUV_.js} +2 -2
  112. package/dist/{unpublish-page-Bsq2yEqQ.cjs → unpublish-page-B06iZEIO.cjs} +1 -1
  113. package/dist/{unpublish-page-BJ0Bsvt2.js → unpublish-page-DqwBY2yI.js} +2 -2
  114. package/dist/utils.cjs +1 -1
  115. package/dist/utils.d.ts +1 -1
  116. package/dist/utils.js +1 -1
  117. package/dist/web-blocks.cjs +1 -1
  118. package/dist/web-blocks.js +42 -42
  119. package/dist/{web-preview-D6h1L2nV.js → web-preview-h39D3TUh.js} +1 -1
  120. package/dist/{web-preview-kres0aG7.cjs → web-preview-wRgRY3Tv.cjs} +1 -1
  121. package/package.json +22 -24
  122. package/dist/css-import-modal-Rh1QAVxo.cjs +0 -13
  123. package/dist/index-C0-pgg_p.cjs +0 -5
package/dist/actions.cjs CHANGED
@@ -1 +1 @@
1
- "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const a=require("./actions-registery-JdxhXhT6.cjs"),l=s=>async o=>{const{apiKey:t,userId:u}=s;try{const i=o,{action:r,data:e}=i,n=a.getChaiAction(r);return n?n.validate(e)?(n.setContext({appId:t,userId:u}),await n.execute(e)):{error:`Validation failed: ${n.getValidationErrors(e)}`,code:"INVALID_REQUEST_DATA",status:400}:{error:`Action ${r} not found`,code:"ACTION_NOT_FOUND",status:404}}catch(i){return console.log("Error in builderApiHandler:",i),i instanceof a.ActionError?{error:i.message,code:i.code,status:400}:{error:"Something went wrong.",status:500}}},h={ab:"Abkhazian",aa:"Afar",af:"Afrikaans",ak:"Akan",sq:"Albanian",am:"Amharic",ar:"Arabic",an:"Aragonese",hy:"Armenian",as:"Assamese",av:"Avaric",ae:"Avestan",ay:"Aymara",az:"Azerbaijani",bm:"Bambara",ba:"Bashkir",eu:"Basque",be:"Belarusian",bn:"Bengali",bh:"Bihari",bi:"Bislama",bs:"Bosnian",br:"Breton",bg:"Bulgarian",my:"Burmese",ca:"Catalan",ch:"Chamorro",ce:"Chechen",ny:"Chichewa",zh:"Chinese","zh-Hans":"Chinese (Simplified)","zh-Hant":"Chinese (Traditional)",cv:"Chuvash",kw:"Cornish",co:"Corsican",cr:"Cree",hr:"Croatian",cs:"Czech",da:"Danish",dv:"Maldivian",nl:"Dutch",dz:"Dzongkha",en:"English",eo:"Esperanto",et:"Estonian",ee:"Ewe",fo:"Faroese",fj:"Fijian",fi:"Finnish",fr:"French",ff:"Fula, Pular",gl:"Galician",gd:"Gaelic (Scottish)",gv:"Manx",ka:"Georgian",de:"German",el:"Greek",kl:"Kalaallisut",gn:"Guarani",gu:"Gujarati",ht:"Haitian Creole",ha:"Hausa",he:"Hebrew",hz:"Herero",hi:"Hindi",ho:"Hiri Motu",hu:"Hungarian",is:"Icelandic",io:"Ido",ig:"Igbo",id:"Indonesian",ia:"Interlingua",ie:"Interlingue",iu:"Inuktitut",ik:"Inupiak",ga:"Irish",it:"Italian",ja:"Japanese",jv:"Javanese",kn:"Kannada",kr:"Kanuri",ks:"Kashmiri",kk:"Kazakh",km:"Khmer",ki:"Kikuyu",rw:"Kinyarwanda",rn:"Kirundi",ky:"Kyrgyz",kv:"Komi",kg:"Kongo",ko:"Korean",ku:"Kurdish",kj:"Kwanyama",lo:"Lao",la:"Latin",lv:"Latvian",li:"Limburgish",ln:"Lingala",lt:"Lithuanian",lu:"Luga-Katanga",lg:"Luganda, Ganda",lb:"Luxembourgish",mk:"Macedonian",mg:"Malagasy",ms:"Malay",ml:"Malayalam",mt:"Maltese",mi:"Maori",mr:"Marathi",mh:"Marshallese",mo:"Moldavian",mn:"Mongolian",na:"Nauru",nv:"Navajo",ng:"Ndonga",nd:"Northern Ndebele",ne:"Nepali",no:"Norwegian",nb:"Norwegian bokmål",nn:"Norwegian nynorsk",ii:"Sichuan Yi",oc:"Occitan",oj:"Ojibwe",cu:"Old Church Slavonic",or:"Oriya",om:"Oromo",os:"Ossetian",pi:"Pāli",ps:"Pashto, Pushto",fa:"Persian (Farsi)",pl:"Polish",pt:"Portuguese",pa:"Punjabi (Eastern)",qu:"Quechua",rm:"Romansh",ro:"Romanian",ru:"Russian",se:"Sami",sm:"Samoan",sg:"Sango",sa:"Sanskrit",sr:"Serbian",sh:"Serbo-Croatian",st:"Sesotho",tn:"Setswana",sn:"Shona",sd:"Sindhi",si:"Sinhalese",ss:"Swati",sk:"Slovak",sl:"Slovenian",so:"Somali",nr:"Southern Ndebele",es:"Spanish",su:"Sundanese",sw:"Swahili (Kiswahili)",sv:"Swedish",tl:"Tagalog",ty:"Tahitian",tg:"Tajik",ta:"Tamil",tt:"Tatar",te:"Telugu",th:"Thai",bo:"Tibetan",ti:"Tigrinya",to:"Tonga",ts:"Tsonga",tr:"Turkish",tk:"Turkmen",tw:"Twi",ug:"Uyghur",uk:"Ukrainian",ur:"Urdu",uz:"Uzbek",ve:"Venda",vi:"Vietnamese",vo:"Volapük",wa:"Wallon",cy:"Welsh",wo:"Wolof",fy:"Western Frisian",xh:"Xhosa",yi:"Yiddish",yo:"Yoruba",za:"Zhuang, Chuang",zu:"Zulu"};exports.ChaiActionsRegistry=a.actionsRegistery;exports.db=a.db;exports.getAskAiSystemPrompt=a.getAskAiSystemPrompt;exports.safeQuery=a.safeQuery;exports.schema=a.schema;exports.LANGUAGES=h;exports.initChaiBuilderActionHandler=l;
1
+ "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const i=require("./actions-registery-CtQSSexG.cjs"),l=s=>async o=>{const{apiKey:t,userId:u}=s;try{const a=o,{action:r,data:e}=a,n=i.getChaiAction(r);return n?n.validate(e)?(n.setContext({appId:t,userId:u}),await n.execute(e)):{error:`Validation failed: ${n.getValidationErrors(e)}`,code:"INVALID_REQUEST_DATA",status:400}:{error:`Action ${r} not found`,code:"ACTION_NOT_FOUND",status:404}}catch(a){return console.log("Error in builderApiHandler:",a),a instanceof i.ActionError?{error:a.message,code:a.code,status:a.status||400}:{error:"Something went wrong.",status:500}}},h={ab:"Abkhazian",aa:"Afar",af:"Afrikaans",ak:"Akan",sq:"Albanian",am:"Amharic",ar:"Arabic",an:"Aragonese",hy:"Armenian",as:"Assamese",av:"Avaric",ae:"Avestan",ay:"Aymara",az:"Azerbaijani",bm:"Bambara",ba:"Bashkir",eu:"Basque",be:"Belarusian",bn:"Bengali",bh:"Bihari",bi:"Bislama",bs:"Bosnian",br:"Breton",bg:"Bulgarian",my:"Burmese",ca:"Catalan",ch:"Chamorro",ce:"Chechen",ny:"Chichewa",zh:"Chinese","zh-Hans":"Chinese (Simplified)","zh-Hant":"Chinese (Traditional)",cv:"Chuvash",kw:"Cornish",co:"Corsican",cr:"Cree",hr:"Croatian",cs:"Czech",da:"Danish",dv:"Maldivian",nl:"Dutch",dz:"Dzongkha",en:"English",eo:"Esperanto",et:"Estonian",ee:"Ewe",fo:"Faroese",fj:"Fijian",fi:"Finnish",fr:"French",ff:"Fula, Pular",gl:"Galician",gd:"Gaelic (Scottish)",gv:"Manx",ka:"Georgian",de:"German",el:"Greek",kl:"Kalaallisut",gn:"Guarani",gu:"Gujarati",ht:"Haitian Creole",ha:"Hausa",he:"Hebrew",hz:"Herero",hi:"Hindi",ho:"Hiri Motu",hu:"Hungarian",is:"Icelandic",io:"Ido",ig:"Igbo",id:"Indonesian",ia:"Interlingua",ie:"Interlingue",iu:"Inuktitut",ik:"Inupiak",ga:"Irish",it:"Italian",ja:"Japanese",jv:"Javanese",kn:"Kannada",kr:"Kanuri",ks:"Kashmiri",kk:"Kazakh",km:"Khmer",ki:"Kikuyu",rw:"Kinyarwanda",rn:"Kirundi",ky:"Kyrgyz",kv:"Komi",kg:"Kongo",ko:"Korean",ku:"Kurdish",kj:"Kwanyama",lo:"Lao",la:"Latin",lv:"Latvian",li:"Limburgish",ln:"Lingala",lt:"Lithuanian",lu:"Luga-Katanga",lg:"Luganda, Ganda",lb:"Luxembourgish",mk:"Macedonian",mg:"Malagasy",ms:"Malay",ml:"Malayalam",mt:"Maltese",mi:"Maori",mr:"Marathi",mh:"Marshallese",mo:"Moldavian",mn:"Mongolian",na:"Nauru",nv:"Navajo",ng:"Ndonga",nd:"Northern Ndebele",ne:"Nepali",no:"Norwegian",nb:"Norwegian bokmål",nn:"Norwegian nynorsk",ii:"Sichuan Yi",oc:"Occitan",oj:"Ojibwe",cu:"Old Church Slavonic",or:"Oriya",om:"Oromo",os:"Ossetian",pi:"Pāli",ps:"Pashto, Pushto",fa:"Persian (Farsi)",pl:"Polish",pt:"Portuguese",pa:"Punjabi (Eastern)",qu:"Quechua",rm:"Romansh",ro:"Romanian",ru:"Russian",se:"Sami",sm:"Samoan",sg:"Sango",sa:"Sanskrit",sr:"Serbian",sh:"Serbo-Croatian",st:"Sesotho",tn:"Setswana",sn:"Shona",sd:"Sindhi",si:"Sinhalese",ss:"Swati",sk:"Slovak",sl:"Slovenian",so:"Somali",nr:"Southern Ndebele",es:"Spanish",su:"Sundanese",sw:"Swahili (Kiswahili)",sv:"Swedish",tl:"Tagalog",ty:"Tahitian",tg:"Tajik",ta:"Tamil",tt:"Tatar",te:"Telugu",th:"Thai",bo:"Tibetan",ti:"Tigrinya",to:"Tonga",ts:"Tsonga",tr:"Turkish",tk:"Turkmen",tw:"Twi",ug:"Uyghur",uk:"Ukrainian",ur:"Urdu",uz:"Uzbek",ve:"Venda",vi:"Vietnamese",vo:"Volapük",wa:"Wallon",cy:"Welsh",wo:"Wolof",fy:"Western Frisian",xh:"Xhosa",yi:"Yiddish",yo:"Yoruba",za:"Zhuang, Chuang",zu:"Zulu"};exports.ChaiActionsRegistry=i.actionsRegistery;exports.db=i.db;exports.getAskAiSystemPrompt=i.getAskAiSystemPrompt;exports.safeQuery=i.safeQuery;exports.schema=i.schema;exports.LANGUAGES=h;exports.initChaiBuilderActionHandler=l;
package/dist/actions.d.ts CHANGED
@@ -2072,23 +2072,6 @@ baseColumn: never;
2072
2072
  identity: undefined;
2073
2073
  generated: undefined;
2074
2074
  }, {}, {}>;
2075
- configData: PgColumn< {
2076
- name: "configData";
2077
- tableName: "apps";
2078
- dataType: "json";
2079
- columnType: "PgJsonb";
2080
- data: unknown;
2081
- driverParam: unknown;
2082
- notNull: false;
2083
- hasDefault: false;
2084
- isPrimaryKey: false;
2085
- isAutoincrement: false;
2086
- hasRuntimeDefault: false;
2087
- enumValues: undefined;
2088
- baseColumn: never;
2089
- identity: undefined;
2090
- generated: undefined;
2091
- }, {}, {}>;
2092
2075
  deletedAt: PgColumn< {
2093
2076
  name: "deletedAt";
2094
2077
  tableName: "apps";
@@ -2301,23 +2284,6 @@ baseColumn: never;
2301
2284
  identity: undefined;
2302
2285
  generated: undefined;
2303
2286
  }, {}, {}>;
2304
- configData: PgColumn< {
2305
- name: "configData";
2306
- tableName: "apps_online";
2307
- dataType: "json";
2308
- columnType: "PgJsonb";
2309
- data: unknown;
2310
- driverParam: unknown;
2311
- notNull: false;
2312
- hasDefault: false;
2313
- isPrimaryKey: false;
2314
- isAutoincrement: false;
2315
- hasRuntimeDefault: false;
2316
- enumValues: undefined;
2317
- baseColumn: never;
2318
- identity: undefined;
2319
- generated: undefined;
2320
- }, {}, {}>;
2321
2287
  apiKey: PgColumn< {
2322
2288
  name: "apiKey";
2323
2289
  tableName: "apps_online";
package/dist/actions.js CHANGED
@@ -1,5 +1,5 @@
1
- import { g as u, A as h } from "./actions-registery-y_ENc8zj.js";
2
- import { a as b, d as y, b as A, s as S, c as v } from "./actions-registery-y_ENc8zj.js";
1
+ import { g as u, A as h } from "./actions-registery-DqrFhSMp.js";
2
+ import { a as b, d as y, b as A, s as S, c as v } from "./actions-registery-DqrFhSMp.js";
3
3
  const c = (r) => async (s) => {
4
4
  const { apiKey: o, userId: t } = r;
5
5
  try {
@@ -14,7 +14,7 @@ const c = (r) => async (s) => {
14
14
  status: 404
15
15
  };
16
16
  } catch (a) {
17
- return console.log("Error in builderApiHandler:", a), a instanceof h ? { error: a.message, code: a.code, status: 400 } : { error: "Something went wrong.", status: 500 };
17
+ return console.log("Error in builderApiHandler:", a), a instanceof h ? { error: a.message, code: a.code, status: a.status || 400 } : { error: "Something went wrong.", status: 500 };
18
18
  }
19
19
  }, d = {
20
20
  ab: "Abkhazian",
@@ -1 +1 @@
1
- "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const e=require("react/jsx-runtime"),c=require("./register-chai-top-bar-BqwKw4uy.cjs"),t=require("./index-C99FhuF1.cjs"),s=require("./index-C0-pgg_p.cjs"),n=require("lucide-react"),l=require("react-i18next"),o=()=>{const r=s.useSendRealtimeEvent(),{setPageStatus:i}=s.usePageLockStatus(),{t:a}=l.useTranslation();return e.jsx(s.BlurContainer,{children:e.jsxs(t.Card,{className:"mx-auto w-full max-w-md",children:[e.jsx(t.CardHeader,{className:"space-y-1",children:e.jsxs(t.CardTitle,{className:"flex items-center gap-2 text-xl font-medium",children:[e.jsx(n.TableIcon,{className:"h-6 w-6 text-green-500"}),e.jsx("span",{children:a("Active in Another Tab")})]})}),e.jsx(t.CardContent,{className:"space-y-4",children:e.jsx("p",{className:"text-sm text-muted-foreground",children:a("This page is currently being edited in another tab. You can continue editing here, which will close the editor in the other tab.")})}),e.jsx(t.CardFooter,{className:"flex justify-end gap-2",children:e.jsxs(c.Button,{variant:"default",onClick:()=>{r(s.EVENT.CONTINUE_EDITING_IN_THIS_TAB_REQUEST),i(s.PAGE_STATUS.CHECKING)},className:"gap-2",children:[e.jsx(n.Edit,{className:"h-4 w-4"}),a("Continue Editing Here")]})})]})})};exports.default=o;
1
+ "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const e=require("react/jsx-runtime"),c=require("./register-chai-top-bar-BqwKw4uy.cjs"),t=require("./index-xYnNKovy.cjs"),s=require("./index-BwH1mRm_.cjs"),n=require("lucide-react"),l=require("react-i18next"),o=()=>{const r=s.useSendRealtimeEvent(),{setPageStatus:i}=s.usePageLockStatus(),{t:a}=l.useTranslation();return e.jsx(s.BlurContainer,{children:e.jsxs(t.Card,{className:"mx-auto w-full max-w-md",children:[e.jsx(t.CardHeader,{className:"space-y-1",children:e.jsxs(t.CardTitle,{className:"flex items-center gap-2 text-xl font-medium",children:[e.jsx(n.TableIcon,{className:"h-6 w-6 text-green-500"}),e.jsx("span",{children:a("Active in Another Tab")})]})}),e.jsx(t.CardContent,{className:"space-y-4",children:e.jsx("p",{className:"text-sm text-muted-foreground",children:a("This page is currently being edited in another tab. You can continue editing here, which will close the editor in the other tab.")})}),e.jsx(t.CardFooter,{className:"flex justify-end gap-2",children:e.jsxs(c.Button,{variant:"default",onClick:()=>{r(s.EVENT.CONTINUE_EDITING_IN_THIS_TAB_REQUEST),i(s.PAGE_STATUS.CHECKING)},className:"gap-2",children:[e.jsx(n.Edit,{className:"h-4 w-4"}),a("Continue Editing Here")]})})]})})};exports.default=o;
@@ -1,7 +1,7 @@
1
1
  import { jsx as e, jsxs as t } from "react/jsx-runtime";
2
2
  import { B as r } from "./register-chai-top-bar-ESJHs5s-.js";
3
- import { R as i, U as o, V as l, W as c, X as d } from "./index-rAcNbjk_.js";
4
- import { ao as m, a as h, B as u, E as p, P as N } from "./index-Dno42B0a.js";
3
+ import { R as i, U as o, V as l, W as c, X as d } from "./index-RYr8kQdI.js";
4
+ import { ao as m, a as h, B as u, E as p, P as N } from "./index-B7eWP_hB.js";
5
5
  import { TableIcon as f, Edit as T } from "lucide-react";
6
6
  import { useTranslation as E } from "react-i18next";
7
7
  const b = () => {
@@ -1 +1 @@
1
- "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const e=require("react/jsx-runtime"),k=require("./register-chai-top-bar-BqwKw4uy.cjs"),N=require("./index-C99FhuF1.cjs"),Y=require("./slug-input-Cyd6NR6J.cjs"),g=require("./index-C0-pgg_p.cjs"),j=require("lodash-es"),ds=require("lucide-react"),v=require("react"),U=require("react-i18next"),Z=({edit:c,lang:h,languages:a,name:u,setLang:t,setName:i,primaryPageObject:o})=>{const{t:s}=U.useTranslation();return e.jsxs("div",{className:"space-y-1",children:[e.jsx(N.Label,{htmlFor:"lang",children:s("Language")}),e.jsxs("select",{value:c?"":h,disabled:c||!a.length,onChange:l=>{const x=l.target.value;t(x),!c&&(j.startsWith(u,o==null?void 0:o.name)||u.length===0)&&i(`${o==null?void 0:o.name} - ${g.LANGUAGES[x]}`)},className:"col-span-3 flex h-9 w-full rounded-md border border-border bg-background px-3 py-1 text-sm shadow-sm transition-colors file:border-0 file:bg-transparent file:text-sm file:font-medium placeholder:text-muted-foreground focus-visible:outline-none focus-visible:ring-1 focus-visible:ring-ring disabled:cursor-not-allowed disabled:opacity-50",children:[e.jsx("option",{value:"",disabled:!0,children:c?g.LANGUAGES[h]||h:a.length?s("Choose language"):s("All available language page is created.")}),a.map(l=>e.jsx("option",{value:l,children:g.LANGUAGES[l]||l},l))]})]})},_=({lang:c,name:h,setName:a,parentHasSelectedLanguagePage:u})=>{const{t}=U.useTranslation();return e.jsxs("div",{className:"space-y-1",children:[e.jsx(N.Label,{htmlFor:"name",children:t("Page Name")}),e.jsx(k.Input,{id:"name",value:c?h:"",onChange:i=>a(i.target.value),required:!0,placeholder:t(c?"Enter page name":"Choose language to add slug"),disabled:!u||!c})]})},cs=({dynamic:c,isNonSlugPageType:h,isRootPage:a,lang:u,useLanguagePrefix:t,setUseLanguagePrefix:i,isHomePage:o,parentSlug:s,parentHasSelectedLanguagePage:l,slug:x,setSlug:d,setIsSlugValid:S,getSlug:f})=>{const{t:r}=U.useTranslation();return h?null:e.jsxs("div",{className:"space-y-1",children:[a&&u&&e.jsxs("div",{className:"flex items-center space-x-2 pb-1",children:[e.jsx("input",{type:"checkbox",id:"useLanguagePrefix",checked:t,onChange:A=>i(A.target.checked),className:"rounded border-gray-300"}),e.jsxs(N.Label,{htmlFor:"useLanguagePrefix",className:"text-sm font-normal leading-tight",children:["Add language code (",e.jsxs("span",{className:"font-mono text-gray-900",children:["/",u]}),") as slug prefix"]})]}),e.jsx(N.Label,{htmlFor:"slug",children:r("Slug")}),c?e.jsx(k.Alert,{variant:"default",className:"p-2 text-xs font-medium italic text-muted-foreground",children:r("This page will use dynamic slug as defined in primary page")}):e.jsx(Y.SlugInput,{disabled:!u||!l,value:x,onChange:d,placeholder:r(u?o&&t?"Leave empty for home page":"Enter page slug":"Choose language to add slug"),parentSlug:s,onValidationChange:S,fullSlug:f()})]})},H=({parentHasSelectedLanguagePage:c,name:h,lang:a,slug:u,edit:t,id:i,primaryPageObject:o,pages:s,isNonSlugPageType:l,isHomePage:x,useLanguagePrefix:d,isSlugValid:S,isPending:f})=>{const{t:r}=U.useTranslation(),A=f||!h||!a||s.some(m=>(t?m.id!==i:!0)&&m.parent===(o==null?void 0:o.id)&&m.lang===a)||!l&&!(x&&d)&&(!S||!u);return e.jsx(N.DialogFooter,{children:c?e.jsxs(e.Fragment,{children:[e.jsx(k.Button,{type:"submit",disabled:A&&!o.dynamic,children:f?e.jsxs("span",{className:"flex items-center gap-2",children:[e.jsx("span",{className:"loader mr-2"}),r(t?"Updating...":"Adding...")]}):r(t?"Update":"Add new language page")}),s.some(m=>(t?m.id!==i:!0)&&m.parent===(o==null?void 0:o.id)&&m.lang===a)&&e.jsx("p",{className:"mt-2 text-xs text-red-500",children:r("A page for this language already exists.")})]}):a&&e.jsx(k.Alert,{variant:"destructive",children:e.jsxs("p",{className:"mx-auto w-5/6 text-center",children:[r("You need to create the")," ",e.jsx("span",{className:"font-medium",children:g.LANGUAGES[a]})," ",r("page in the parent to add here.")]})})})},rs=({onSubmit:c,edit:h,lang:a,languages:u,name:t,setLang:i,setName:o,primaryPageObject:s,parentHasSelectedLanguagePage:l,id:x,pages:d,isNonSlugPageType:S,isHomePage:f,useLanguagePrefix:r,slug:A,isSlugValid:m,isPending:p})=>e.jsxs("form",{onSubmit:c,children:[e.jsxs("div",{className:"grid gap-4 py-4",children:[e.jsx(Z,{edit:h,lang:a,languages:u,name:t,setLang:i,setName:o,primaryPageObject:s}),e.jsx(_,{lang:a,name:t,setName:o,parentHasSelectedLanguagePage:l})]}),e.jsx(H,{parentHasSelectedLanguagePage:l,name:t,lang:a,slug:A,edit:h,id:x,primaryPageObject:s,pages:d,isNonSlugPageType:S,isHomePage:f,useLanguagePrefix:r,isSlugValid:m,isPending:p})]}),hs=({loading:c,onSubmit:h,edit:a,lang:u,languages:t,name:i,setLang:o,setName:s,primaryPageObject:l,parentHasSelectedLanguagePage:x,isNonSlugPageType:d,isRootPage:S,useLanguagePrefix:f,setUseLanguagePrefix:r,isHomePage:A,parentSlug:m,slug:p,setSlug:C,isSlugValid:T,setIsSlugValid:I,getSlug:M,isPending:$,id:q,pages:L})=>c?e.jsx("div",{className:"flex h-80 items-center justify-center",children:e.jsx(ds.Loader,{className:"animate-spin"})}):d?e.jsx(rs,{onSubmit:h,edit:a,lang:u,languages:t,name:i,setLang:o,setName:s,primaryPageObject:l,parentHasSelectedLanguagePage:x,id:q,pages:L,isNonSlugPageType:d,isHomePage:A,useLanguagePrefix:f,slug:p,isSlugValid:T,isPending:$}):e.jsxs("form",{onSubmit:h,children:[e.jsxs("div",{className:"grid gap-4 py-4",children:[e.jsx(Z,{edit:a,lang:u,languages:t,name:i,setLang:o,setName:s,primaryPageObject:l}),e.jsx(_,{lang:u,name:i,setName:s,parentHasSelectedLanguagePage:x}),e.jsx(cs,{dynamic:l==null?void 0:l.dynamic,isNonSlugPageType:d,isRootPage:S,lang:u,useLanguagePrefix:f,setUseLanguagePrefix:r,isHomePage:A,parentSlug:m,parentHasSelectedLanguagePage:x,slug:p,setSlug:C,isSlugValid:T,setIsSlugValid:I,getSlug:M})]}),e.jsx(H,{parentHasSelectedLanguagePage:x,name:i,lang:u,slug:p,edit:a,id:q,primaryPageObject:l,pages:L,isNonSlugPageType:d,isHomePage:A,useLanguagePrefix:f,isSlugValid:T,isPending:$})]}),xs=({id:c,isOpen:h,onClose:a,primaryPage:u,edit:t=!1,preselectedLang:i})=>{const{data:o=[]}=g.useWebsitePages(),s=v.useMemo(()=>o.find(n=>n.id===u),[o,u]),[l,x]=v.useState(""),[d,S]=v.useState(""),[f,r]=v.useState(""),[A,m]=v.useState(!0),[p,C]=v.useState(!0),{mutate:T,isPending:I}=g.useCreatePage(),{mutate:M,isPending:$}=g.useUpdatePage(),q=I||$,{data:L,isFetching:b}=g.useWebsiteSetting(),z=g.useFallbackLang(),{data:w,isFetching:y}=g.useLanguagePages(u),{data:F=[],isFetching:P}=g.useLanguagePages(s==null?void 0:s.parent),{data:J=[],isFetching:O}=g.usePageTypes(),{setSelectedLang:ss}=N.useLanguages(),{t:B}=U.useTranslation(),[,es]=g.useSearchParams(),[,ns]=N.useSidebarActivePanel(),ts=b||y||P||O,G=v.useMemo(()=>j.filter(L==null?void 0:L.languages,n=>!j.find(w,{lang:n})),[L,w]),W=v.useMemo(()=>J.find(n=>n.key===(s==null?void 0:s.pageType)),[J,s==null?void 0:s.pageType]),K=!(W!=null&&W.hasSlug),V=(s==null?void 0:s.slug)==="/";v.useEffect(()=>{if(!t&&s&&i&&(S(i),x(`${s.name} - ${g.LANGUAGES[i]}`)),!t||!s)return;const n=w==null?void 0:w.find(is=>is.id===c);if(!n)return;x(n.name),S(n.lang);const E=n.slug||"",{initSlug:R,prefix:us}=Y.parseSlugForEdit(E,s);r(R),C(us)},[t,c,w,s,i]),v.useEffect(()=>{if(i)S(i);else if((G==null?void 0:G.length)===1&&!t){const n=G[0];if(!n||!g.LANGUAGES[n])return;S(n),(!l||l===(s==null?void 0:s.name))&&x(`${s==null?void 0:s.name} - ${g.LANGUAGES[n]}`)}},[i,G,t,l,s]);const{parentSlug:Q,isRootPage:D}=v.useMemo(()=>{if(V||!d)return{parentSlug:void 0,isRootPage:!(s!=null&&s.parent)};if(!(s!=null&&s.parent))return{parentSlug:p?`/${d}`:void 0,isRootPage:!0};const n=F==null?void 0:F.find(E=>E.lang===d);return{parentSlug:n==null?void 0:n.slug,isRootPage:!1}},[s==null?void 0:s.parent,F,p,d,V]),os=v.useMemo(()=>D?!0:!!(F!=null&&F.some(n=>(n==null?void 0:n.lang)===d)),[d,F,D]),X=()=>{let n="";return D?n=`/${p?[d,f].filter(Boolean).join("/"):f}`:n=`${Y.removeSlugExtension(Q)}/${f}`,n.replace(/\/{2,}/g,"/").replace(/\/$/,"")},ls=n=>{const E=new URLSearchParams(window.location.search);z&&n===z?E.delete("lang"):E.set("lang",n),es(E),window.dispatchEvent(new PopStateEvent("popstate"))},as=n=>{n.preventDefault();const E={name:l,lang:d,primaryPage:s==null?void 0:s.id,slug:K?"":X(),pageType:s==null?void 0:s.pageType,...t&&{id:c}},R=()=>{!t&&d&&(ss(d),ls(d)),ns("outline"),a()};t?M(E,{onSuccess:R}):T(E,{onSuccess:R})};return e.jsx(N.Dialog,{open:h,onOpenChange:a,children:h&&e.jsxs(N.DialogContent,{className:"text-slate-600 sm:max-w-[425px]",children:[e.jsxs(N.DialogHeader,{children:[e.jsx(N.DialogTitle,{children:B(t?"Edit language":"Add new language page")}),e.jsx(N.DialogDescription,{className:"font-light",children:B("Enter the details for the language")})]}),e.jsx(hs,{id:c,pages:o,loading:ts,onSubmit:as,edit:t,lang:d,languages:G,name:l,setLang:S,setName:x,primaryPageObject:s,parentHasSelectedLanguagePage:os,isNonSlugPageType:K,isRootPage:D,useLanguagePrefix:p,setUseLanguagePrefix:C,isHomePage:V,parentSlug:Q,slug:f,setSlug:r,isSlugValid:A,setIsSlugValid:m,getSlug:X,isPending:q})]})})};exports.default=xs;
1
+ "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const e=require("react/jsx-runtime"),k=require("./register-chai-top-bar-BqwKw4uy.cjs"),N=require("./index-xYnNKovy.cjs"),Y=require("./slug-input-Dp187Tiy.cjs"),g=require("./index-BwH1mRm_.cjs"),j=require("lodash-es"),ds=require("lucide-react"),v=require("react"),U=require("react-i18next"),Z=({edit:c,lang:h,languages:a,name:u,setLang:t,setName:i,primaryPageObject:o})=>{const{t:s}=U.useTranslation();return e.jsxs("div",{className:"space-y-1",children:[e.jsx(N.Label,{htmlFor:"lang",children:s("Language")}),e.jsxs("select",{value:c?"":h,disabled:c||!a.length,onChange:l=>{const x=l.target.value;t(x),!c&&(j.startsWith(u,o==null?void 0:o.name)||u.length===0)&&i(`${o==null?void 0:o.name} - ${g.LANGUAGES[x]}`)},className:"col-span-3 flex h-9 w-full rounded-md border border-border bg-background px-3 py-1 text-sm shadow-sm transition-colors file:border-0 file:bg-transparent file:text-sm file:font-medium placeholder:text-muted-foreground focus-visible:outline-none focus-visible:ring-1 focus-visible:ring-ring disabled:cursor-not-allowed disabled:opacity-50",children:[e.jsx("option",{value:"",disabled:!0,children:c?g.LANGUAGES[h]||h:a.length?s("Choose language"):s("All available language page is created.")}),a.map(l=>e.jsx("option",{value:l,children:g.LANGUAGES[l]||l},l))]})]})},_=({lang:c,name:h,setName:a,parentHasSelectedLanguagePage:u})=>{const{t}=U.useTranslation();return e.jsxs("div",{className:"space-y-1",children:[e.jsx(N.Label,{htmlFor:"name",children:t("Page Name")}),e.jsx(k.Input,{id:"name",value:c?h:"",onChange:i=>a(i.target.value),required:!0,placeholder:t(c?"Enter page name":"Choose language to add slug"),disabled:!u||!c})]})},cs=({dynamic:c,isNonSlugPageType:h,isRootPage:a,lang:u,useLanguagePrefix:t,setUseLanguagePrefix:i,isHomePage:o,parentSlug:s,parentHasSelectedLanguagePage:l,slug:x,setSlug:d,setIsSlugValid:S,getSlug:f})=>{const{t:r}=U.useTranslation();return h?null:e.jsxs("div",{className:"space-y-1",children:[a&&u&&e.jsxs("div",{className:"flex items-center space-x-2 pb-1",children:[e.jsx("input",{type:"checkbox",id:"useLanguagePrefix",checked:t,onChange:A=>i(A.target.checked),className:"rounded border-gray-300"}),e.jsxs(N.Label,{htmlFor:"useLanguagePrefix",className:"text-sm font-normal leading-tight",children:["Add language code (",e.jsxs("span",{className:"font-mono text-gray-900",children:["/",u]}),") as slug prefix"]})]}),e.jsx(N.Label,{htmlFor:"slug",children:r("Slug")}),c?e.jsx(k.Alert,{variant:"default",className:"p-2 text-xs font-medium italic text-muted-foreground",children:r("This page will use dynamic slug as defined in primary page")}):e.jsx(Y.SlugInput,{disabled:!u||!l,value:x,onChange:d,placeholder:r(u?o&&t?"Leave empty for home page":"Enter page slug":"Choose language to add slug"),parentSlug:s,onValidationChange:S,fullSlug:f()})]})},H=({parentHasSelectedLanguagePage:c,name:h,lang:a,slug:u,edit:t,id:i,primaryPageObject:o,pages:s,isNonSlugPageType:l,isHomePage:x,useLanguagePrefix:d,isSlugValid:S,isPending:f})=>{const{t:r}=U.useTranslation(),A=f||!h||!a||s.some(m=>(t?m.id!==i:!0)&&m.parent===(o==null?void 0:o.id)&&m.lang===a)||!l&&!(x&&d)&&(!S||!u);return e.jsx(N.DialogFooter,{children:c?e.jsxs(e.Fragment,{children:[e.jsx(k.Button,{type:"submit",disabled:A&&!o.dynamic,children:f?e.jsxs("span",{className:"flex items-center gap-2",children:[e.jsx("span",{className:"loader mr-2"}),r(t?"Updating...":"Adding...")]}):r(t?"Update":"Add new language page")}),s.some(m=>(t?m.id!==i:!0)&&m.parent===(o==null?void 0:o.id)&&m.lang===a)&&e.jsx("p",{className:"mt-2 text-xs text-red-500",children:r("A page for this language already exists.")})]}):a&&e.jsx(k.Alert,{variant:"destructive",children:e.jsxs("p",{className:"mx-auto w-5/6 text-center",children:[r("You need to create the")," ",e.jsx("span",{className:"font-medium",children:g.LANGUAGES[a]})," ",r("page in the parent to add here.")]})})})},rs=({onSubmit:c,edit:h,lang:a,languages:u,name:t,setLang:i,setName:o,primaryPageObject:s,parentHasSelectedLanguagePage:l,id:x,pages:d,isNonSlugPageType:S,isHomePage:f,useLanguagePrefix:r,slug:A,isSlugValid:m,isPending:p})=>e.jsxs("form",{onSubmit:c,children:[e.jsxs("div",{className:"grid gap-4 py-4",children:[e.jsx(Z,{edit:h,lang:a,languages:u,name:t,setLang:i,setName:o,primaryPageObject:s}),e.jsx(_,{lang:a,name:t,setName:o,parentHasSelectedLanguagePage:l})]}),e.jsx(H,{parentHasSelectedLanguagePage:l,name:t,lang:a,slug:A,edit:h,id:x,primaryPageObject:s,pages:d,isNonSlugPageType:S,isHomePage:f,useLanguagePrefix:r,isSlugValid:m,isPending:p})]}),hs=({loading:c,onSubmit:h,edit:a,lang:u,languages:t,name:i,setLang:o,setName:s,primaryPageObject:l,parentHasSelectedLanguagePage:x,isNonSlugPageType:d,isRootPage:S,useLanguagePrefix:f,setUseLanguagePrefix:r,isHomePage:A,parentSlug:m,slug:p,setSlug:C,isSlugValid:T,setIsSlugValid:I,getSlug:M,isPending:$,id:q,pages:L})=>c?e.jsx("div",{className:"flex h-80 items-center justify-center",children:e.jsx(ds.Loader,{className:"animate-spin"})}):d?e.jsx(rs,{onSubmit:h,edit:a,lang:u,languages:t,name:i,setLang:o,setName:s,primaryPageObject:l,parentHasSelectedLanguagePage:x,id:q,pages:L,isNonSlugPageType:d,isHomePage:A,useLanguagePrefix:f,slug:p,isSlugValid:T,isPending:$}):e.jsxs("form",{onSubmit:h,children:[e.jsxs("div",{className:"grid gap-4 py-4",children:[e.jsx(Z,{edit:a,lang:u,languages:t,name:i,setLang:o,setName:s,primaryPageObject:l}),e.jsx(_,{lang:u,name:i,setName:s,parentHasSelectedLanguagePage:x}),e.jsx(cs,{dynamic:l==null?void 0:l.dynamic,isNonSlugPageType:d,isRootPage:S,lang:u,useLanguagePrefix:f,setUseLanguagePrefix:r,isHomePage:A,parentSlug:m,parentHasSelectedLanguagePage:x,slug:p,setSlug:C,isSlugValid:T,setIsSlugValid:I,getSlug:M})]}),e.jsx(H,{parentHasSelectedLanguagePage:x,name:i,lang:u,slug:p,edit:a,id:q,primaryPageObject:l,pages:L,isNonSlugPageType:d,isHomePage:A,useLanguagePrefix:f,isSlugValid:T,isPending:$})]}),xs=({id:c,isOpen:h,onClose:a,primaryPage:u,edit:t=!1,preselectedLang:i})=>{const{data:o=[]}=g.useWebsitePages(),s=v.useMemo(()=>o.find(n=>n.id===u),[o,u]),[l,x]=v.useState(""),[d,S]=v.useState(""),[f,r]=v.useState(""),[A,m]=v.useState(!0),[p,C]=v.useState(!0),{mutate:T,isPending:I}=g.useCreatePage(),{mutate:M,isPending:$}=g.useUpdatePage(),q=I||$,{data:L,isFetching:b}=g.useWebsiteSetting(),z=g.useFallbackLang(),{data:w,isFetching:y}=g.useLanguagePages(u),{data:F=[],isFetching:P}=g.useLanguagePages(s==null?void 0:s.parent),{data:J=[],isFetching:O}=g.usePageTypes(),{setSelectedLang:ss}=N.useLanguages(),{t:B}=U.useTranslation(),[,es]=g.useSearchParams(),[,ns]=N.useSidebarActivePanel(),ts=b||y||P||O,G=v.useMemo(()=>j.filter(L==null?void 0:L.languages,n=>!j.find(w,{lang:n})),[L,w]),W=v.useMemo(()=>J.find(n=>n.key===(s==null?void 0:s.pageType)),[J,s==null?void 0:s.pageType]),K=!(W!=null&&W.hasSlug),V=(s==null?void 0:s.slug)==="/";v.useEffect(()=>{if(!t&&s&&i&&(S(i),x(`${s.name} - ${g.LANGUAGES[i]}`)),!t||!s)return;const n=w==null?void 0:w.find(is=>is.id===c);if(!n)return;x(n.name),S(n.lang);const E=n.slug||"",{initSlug:R,prefix:us}=Y.parseSlugForEdit(E,s);r(R),C(us)},[t,c,w,s,i]),v.useEffect(()=>{if(i)S(i);else if((G==null?void 0:G.length)===1&&!t){const n=G[0];if(!n||!g.LANGUAGES[n])return;S(n),(!l||l===(s==null?void 0:s.name))&&x(`${s==null?void 0:s.name} - ${g.LANGUAGES[n]}`)}},[i,G,t,l,s]);const{parentSlug:Q,isRootPage:D}=v.useMemo(()=>{if(V||!d)return{parentSlug:void 0,isRootPage:!(s!=null&&s.parent)};if(!(s!=null&&s.parent))return{parentSlug:p?`/${d}`:void 0,isRootPage:!0};const n=F==null?void 0:F.find(E=>E.lang===d);return{parentSlug:n==null?void 0:n.slug,isRootPage:!1}},[s==null?void 0:s.parent,F,p,d,V]),os=v.useMemo(()=>D?!0:!!(F!=null&&F.some(n=>(n==null?void 0:n.lang)===d)),[d,F,D]),X=()=>{let n="";return D?n=`/${p?[d,f].filter(Boolean).join("/"):f}`:n=`${Y.removeSlugExtension(Q)}/${f}`,n.replace(/\/{2,}/g,"/").replace(/\/$/,"")},ls=n=>{const E=new URLSearchParams(window.location.search);z&&n===z?E.delete("lang"):E.set("lang",n),es(E),window.dispatchEvent(new PopStateEvent("popstate"))},as=n=>{n.preventDefault();const E={name:l,lang:d,primaryPage:s==null?void 0:s.id,slug:K?"":X(),pageType:s==null?void 0:s.pageType,...t&&{id:c}},R=()=>{!t&&d&&(ss(d),ls(d)),ns("outline"),a()};t?M(E,{onSuccess:R}):T(E,{onSuccess:R})};return e.jsx(N.Dialog,{open:h,onOpenChange:a,children:h&&e.jsxs(N.DialogContent,{className:"text-slate-600 sm:max-w-[425px]",children:[e.jsxs(N.DialogHeader,{children:[e.jsx(N.DialogTitle,{children:B(t?"Edit language":"Add new language page")}),e.jsx(N.DialogDescription,{className:"font-light",children:B("Enter the details for the language")})]}),e.jsx(hs,{id:c,pages:o,loading:ts,onSubmit:as,edit:t,lang:d,languages:G,name:l,setLang:S,setName:x,primaryPageObject:s,parentHasSelectedLanguagePage:os,isNonSlugPageType:K,isRootPage:D,useLanguagePrefix:p,setUseLanguagePrefix:C,isHomePage:V,parentSlug:Q,slug:f,setSlug:r,isSlugValid:A,setIsSlugValid:m,getSlug:X,isPending:q})]})})};exports.default=xs;
@@ -1,8 +1,8 @@
1
1
  import { jsx as t, jsxs as g, Fragment as hn } from "react/jsx-runtime";
2
2
  import { z as fn, D as H, B as gn } from "./register-chai-top-bar-ESJHs5s-.js";
3
- import { n as mn, o as xn, D as vn, d as pn, e as Sn, f as Nn, p as Fn, L as I, q as wn } from "./index-rAcNbjk_.js";
4
- import { p as An, r as Cn, S as Dn } from "./slug-input-DHLmUNrH.js";
5
- import { g as En, h as $n, i as Ln, j as kn, k as Tn, l as Z, m as Un, c as Bn, L as A } from "./index-Dno42B0a.js";
3
+ import { n as mn, o as xn, D as vn, d as pn, e as Sn, f as Nn, p as Fn, L as I, q as wn } from "./index-RYr8kQdI.js";
4
+ import { p as An, r as Cn, S as Dn } from "./slug-input-CeEQ0zyv.js";
5
+ import { g as En, h as $n, i as Ln, j as kn, k as Tn, l as Z, m as Un, c as Bn, L as A } from "./index-B7eWP_hB.js";
6
6
  import { filter as Rn, find as Wn, startsWith as In } from "lodash-es";
7
7
  import { Loader as qn } from "lucide-react";
8
8
  import { useMemo as $, useState as L, useEffect as _ } from "react";
@@ -1 +1 @@
1
- "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const e=require("react/jsx-runtime"),s=require("./index-C99FhuF1.cjs"),c=require("react"),a=require("react-i18next"),u=c.lazy(()=>Promise.resolve().then(()=>require("./page-creator-g8GqgcKH.cjs"))),x=({addEditPage:n,setAddEditPage:r,closePanel:l})=>{const{t:o}=a.useTranslation(),t=!!(n!=null&&n.id),i=!!n;return e.jsx(s.Dialog,{open:i,onOpenChange:()=>r(void 0),children:i&&e.jsxs(s.DialogContent,{className:"sm:max-w-[425px]",children:[e.jsxs(s.DialogHeader,{children:[e.jsxs(s.DialogTitle,{children:[o(t?"Edit":"Add New")," "]}),e.jsx(s.DialogDescription,{children:o(t?"Update your page name":"Enter details to create a new page")})]}),e.jsx(c.Suspense,{fallback:e.jsx("div",{className:"min-h-40"}),children:e.jsx(u,{closePanel:l,addEditPage:n,close:()=>r(void 0)})})]})})};exports.default=x;
1
+ "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const e=require("react/jsx-runtime"),s=require("./index-xYnNKovy.cjs"),c=require("react"),a=require("react-i18next"),u=c.lazy(()=>Promise.resolve().then(()=>require("./page-creator-82qTbBj4.cjs"))),x=({addEditPage:n,setAddEditPage:r,closePanel:l})=>{const{t:o}=a.useTranslation(),t=!!(n!=null&&n.id),i=!!n;return e.jsx(s.Dialog,{open:i,onOpenChange:()=>r(void 0),children:i&&e.jsxs(s.DialogContent,{className:"sm:max-w-[425px]",children:[e.jsxs(s.DialogHeader,{children:[e.jsxs(s.DialogTitle,{children:[o(t?"Edit":"Add New")," "]}),e.jsx(s.DialogDescription,{children:o(t?"Update your page name":"Enter details to create a new page")})]}),e.jsx(c.Suspense,{fallback:e.jsx("div",{className:"min-h-40"}),children:e.jsx(u,{closePanel:l,addEditPage:n,close:()=>r(void 0)})})]})})};exports.default=x;
@@ -1,8 +1,8 @@
1
1
  import { jsx as o, jsxs as r } from "react/jsx-runtime";
2
- import { D as t, d as c, e as p, f as m, p as h } from "./index-rAcNbjk_.js";
2
+ import { D as t, d as c, e as p, f as m, p as h } from "./index-RYr8kQdI.js";
3
3
  import { Suspense as f, lazy as D } from "react";
4
4
  import { useTranslation as u } from "react-i18next";
5
- const x = D(() => import("./page-creator-Cc83uQqw.js")), C = ({
5
+ const x = D(() => import("./page-creator-Bazn6yH4.js")), C = ({
6
6
  addEditPage: e,
7
7
  setAddEditPage: s,
8
8
  closePanel: l
@@ -1,13 +1,13 @@
1
1
  import { jsxs as h, Fragment as k, jsx as n } from "react/jsx-runtime";
2
2
  import { B as y } from "./register-chai-top-bar-ESJHs5s-.js";
3
- import { n as A } from "./index-rAcNbjk_.js";
4
- import { v as B, c as F } from "./index-Dno42B0a.js";
3
+ import { n as A } from "./index-RYr8kQdI.js";
4
+ import { v as B, c as F } from "./index-B7eWP_hB.js";
5
5
  import { Plus as z } from "lucide-react";
6
6
  import { useState as l, useEffect as I, Suspense as D, lazy as x } from "react";
7
7
  import { useTranslation as R } from "react-i18next";
8
8
  import { toast as E } from "sonner";
9
9
  import { g as G } from "./models-D95ZYr_x.js";
10
- const O = x(() => import("./ai-panel-default-lang-BZl0tPYo.js")), T = x(() => import("./ai-panel-other-lang-Bfjk2CYZ.js")), Z = () => {
10
+ const O = x(() => import("./ai-panel-default-lang-BtLjUl9d.js")), T = x(() => import("./ai-panel-other-lang-Dp1MNaLi.js")), Z = () => {
11
11
  const { t: r } = R(), [b, a] = l(""), [e, s] = l([]), [i, c] = l(!1), [f, u] = l(null), [w, d] = l(null), [C, L] = l(G().id), { selectedLang: m, fallbackLang: N } = A(), P = B(), [v] = F(), S = v.get("page"), M = (e == null ? void 0 : e.filter((t) => t.role === "user").length) >= 4, j = (e == null ? void 0 : e.filter((t) => t.role === "user").length) >= 10;
12
12
  I(() => {
13
13
  s([]);
@@ -1 +1 @@
1
- "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const e=require("react/jsx-runtime"),L=require("./register-chai-top-bar-BqwKw4uy.cjs"),N=require("./index-C99FhuF1.cjs"),j=require("./index-C0-pgg_p.cjs"),M=require("lucide-react"),s=require("react"),k=require("react-i18next"),A=require("sonner"),B=require("./models-5gOsRC56.cjs"),R=s.lazy(()=>Promise.resolve().then(()=>require("./ai-panel-default-lang-D2zhXvKP.cjs"))),z=s.lazy(()=>Promise.resolve().then(()=>require("./ai-panel-other-lang-Y4bEKHoG.cjs"))),F=()=>{const{t:o}=k.useTranslation(),[m,a]=s.useState(""),[t,l]=s.useState([]),[c,i]=s.useState(!1),[u,d]=s.useState(null),[S,f]=s.useState(null),[p,b]=s.useState(B.getDefaultModel().id),{selectedLang:h,fallbackLang:q}=N.useLanguages(),P=j.useBuilderFetch(),[v]=j.useSearchParams(),w=v.get("page"),C=(t==null?void 0:t.filter(n=>n.role==="user").length)>=4,y=(t==null?void 0:t.filter(n=>n.role==="user").length)>=10;s.useEffect(()=>{l([])},[h,w]);const g=()=>{l([]),a(""),f(null),d(null),i(!1)},x={t:o,fetch:P,input:m,messages:t,setInput:a,isLoading:c,handleStop:()=>{u&&(u.abort(),d(null)),i(!1),a(""),f(null),l(n=>{const r=n[n.length-1];return r&&r.role==="assistant"&&r.isReasoning&&r.isStreaming?n.slice(0,-1):n}),A.toast.info(o("Generation stopped"))},handleReset:g,setMessages:l,setIsLoading:i,currentBlock:S,fallbackLang:q,abortController:u,setCurrentBlock:f,setAbortController:d,forceNewConversation:y,suggestNewConversation:C,selectedModel:p,onModelChange:b};return e.jsxs(e.Fragment,{children:[c&&e.jsx("div",{className:"fixed inset-0 left-0 top-0 z-40 flex h-screen w-screen flex-col items-center justify-center bg-transparent"}),e.jsxs("div",{className:"flex h-full w-full flex-col",children:[e.jsxs("div",{className:"flex w-full items-center justify-between",children:[e.jsx("p",{className:"text-xs text-gray-500",children:o("Your conversation will not be saved")}),(t==null?void 0:t.length)>0&&e.jsx(L.Button,{variant:"outline",size:"icon",onClick:g,className:"h-6 w-6",disabled:c,children:e.jsx(M.Plus,{})})]}),e.jsx(s.Suspense,{fallback:e.jsx("div",{className:"flex h-full w-full items-center justify-center text-xs",children:"Loading AI Panel"}),children:h?e.jsx(z,{...x,selectedLang:h}):e.jsx(R,{...x})})]})]})};exports.default=F;
1
+ "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const e=require("react/jsx-runtime"),L=require("./register-chai-top-bar-BqwKw4uy.cjs"),N=require("./index-xYnNKovy.cjs"),j=require("./index-BwH1mRm_.cjs"),M=require("lucide-react"),s=require("react"),k=require("react-i18next"),A=require("sonner"),B=require("./models-5gOsRC56.cjs"),R=s.lazy(()=>Promise.resolve().then(()=>require("./ai-panel-default-lang-B37k5ADH.cjs"))),z=s.lazy(()=>Promise.resolve().then(()=>require("./ai-panel-other-lang-CdQmASqv.cjs"))),F=()=>{const{t:o}=k.useTranslation(),[m,a]=s.useState(""),[t,l]=s.useState([]),[c,i]=s.useState(!1),[u,d]=s.useState(null),[S,f]=s.useState(null),[p,b]=s.useState(B.getDefaultModel().id),{selectedLang:h,fallbackLang:q}=N.useLanguages(),P=j.useBuilderFetch(),[v]=j.useSearchParams(),w=v.get("page"),C=(t==null?void 0:t.filter(n=>n.role==="user").length)>=4,y=(t==null?void 0:t.filter(n=>n.role==="user").length)>=10;s.useEffect(()=>{l([])},[h,w]);const g=()=>{l([]),a(""),f(null),d(null),i(!1)},x={t:o,fetch:P,input:m,messages:t,setInput:a,isLoading:c,handleStop:()=>{u&&(u.abort(),d(null)),i(!1),a(""),f(null),l(n=>{const r=n[n.length-1];return r&&r.role==="assistant"&&r.isReasoning&&r.isStreaming?n.slice(0,-1):n}),A.toast.info(o("Generation stopped"))},handleReset:g,setMessages:l,setIsLoading:i,currentBlock:S,fallbackLang:q,abortController:u,setCurrentBlock:f,setAbortController:d,forceNewConversation:y,suggestNewConversation:C,selectedModel:p,onModelChange:b};return e.jsxs(e.Fragment,{children:[c&&e.jsx("div",{className:"fixed inset-0 left-0 top-0 z-40 flex h-screen w-screen flex-col items-center justify-center bg-transparent"}),e.jsxs("div",{className:"flex h-full w-full flex-col",children:[e.jsxs("div",{className:"flex w-full items-center justify-between",children:[e.jsx("p",{className:"text-xs text-gray-500",children:o("Your conversation will not be saved")}),(t==null?void 0:t.length)>0&&e.jsx(L.Button,{variant:"outline",size:"icon",onClick:g,className:"h-6 w-6",disabled:c,children:e.jsx(M.Plus,{})})]}),e.jsx(s.Suspense,{fallback:e.jsx("div",{className:"flex h-full w-full items-center justify-center text-xs",children:"Loading AI Panel"}),children:h?e.jsx(z,{...x,selectedLang:h}):e.jsx(R,{...x})})]})]})};exports.default=F;
@@ -1,3 +1,3 @@
1
- "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const c=require("react/jsx-runtime"),v=require("./index-C99FhuF1.cjs"),S=require("./selected-block-display-BOgnQRLF.cjs"),P=require("lucide-react"),j=require("react"),O=require("sonner"),W=require("./models-5gOsRC56.cjs"),F=require("lodash-es"),q=require("./apply-binding-IsUf6UWJ.cjs"),$=require("@tanstack/react-query"),_=(a,k)=>{const h=a.filter(p=>p._parent===k),I=h.map(p=>p._id),A=h.flatMap(p=>_(a,p._id));return[...I,...A]},V=(a,k,h)=>{const I=F.find(a,{_id:k});if(!I)return a;const A=a.findIndex(g=>g._id===k),p=_(a,k),C=new Set([k,...p]),u=a.filter(g=>!C.has(g._id)),w=new Set(h.map(g=>g._id)),R=h.map(g=>!g._parent||!w.has(g._parent)?{...g,_parent:I._parent}:g);return[...u.slice(0,A),...R,...u.slice(A)]},K=()=>{const[,a]=v.useSelectedBlockIds(),{setNewBlocks:k}=v.useBlocksStoreUndoableActions(),{hasPermission:h}=v.usePermissions();return j.useCallback((I,A)=>{if(!h(v.PERMISSIONS.EDIT_BLOCK))return;const p=v.builderStore.get(v.presentBlocksAtom),C=I?V(p,I,A):A;k(C),A.length>0&&setTimeout(()=>a([A[0]._id]),200)},[a,k,h])},U=()=>{const{addPredefinedBlock:a}=v.useAddBlock(),k=K(),h=v.useRemoveBlocks(),I=$.useQueryClient(),A=async(s,e)=>{if(!e)return;const r=q.getBlocksFromHTML(e);await a(r,s.parentId,s.position)},p=async(s,e)=>{if(!s.blockId||!e)return;const r=q.getBlocksFromHTML(e);await k(s.blockId,r)},C=async s=>{!s.ids||s.ids.length===0||await h(s.ids)};let u=null;const w=(s,e)=>{const r=document.getElementById("canvas-iframe");if(!r)return null;const d=r==null?void 0:r.contentDocument;if(!d)return null;d.querySelectorAll("[data-stream-canvas]").forEach(m=>m.remove());let n=null;if(s&&s!=="undefined"&&(n=d.querySelector(`[data-block-id="${s}"]`)),n||(n=d.body),!n)return null;if(u=d.createElement("div"),u.setAttribute("data-stream-canvas","true"),e!==void 0&&e>=0&&n.children){const m=Math.min(e,n.children.length);m<n.children.length?n.insertBefore(u,n.children[m]):n.appendChild(u)}else n.appendChild(u);return u},R=s=>{var n;const e=document.getElementById("canvas-iframe");if(!e)return null;const r=e==null?void 0:e.contentDocument;if(!r)return null;r.querySelectorAll("[data-stream-canvas]").forEach(m=>m.remove());const f=r.querySelector(`[data-block-id="${s}"]`);return f?(u=r.createElement("div"),u.setAttribute("data-stream-canvas","true"),(n=f.parentNode)==null||n.insertBefore(u,f.nextSibling),f.style.display="none",u):null},M=(s,e,r)=>{const d=w(e,r);if(d){d.innerHTML=s;const f=d.getBoundingClientRect(),n=document.getElementById("canvas-iframe"),m=n==null?void 0:n.contentWindow;m&&(f.top>=0&&f.bottom<=m.innerHeight||d.scrollIntoView({behavior:"smooth",block:"nearest"}))}},g=(s,e)=>{const r=R(e);r&&(r.innerHTML=s)},D=s=>{const e=s.match(/^--ACTION=(.+)--$/);if(!e)return null;let d=e[1].replace(/--/g,"").split("|");const n={type:d[0]};return d.forEach(m=>{const t=m.trim();if(t.startsWith("PARENT=")){const T=t.substring(7);n.parentId=T==="undefined"?void 0:T}else t.startsWith("POS=")?n.position=parseInt(t.substring(4)):t.startsWith("ID=")?n.blockId=t.substring(3):t.startsWith("IDS=")&&(n.ids=t.substring(4).split(",").map(T=>T.trim()))}),n};return j.useCallback(async(s,e)=>{const r=new TextDecoder;let d="",f="",n=!1,m=null;const t={isInAction:!1,currentAction:null,htmlBuffer:"",isCapturingHtml:!1},T=async y=>{const o=y.trim();if(o==="--START--"){n=!0;return}if(n){if(o==="--END--"){t.currentAction&&(t.htmlBuffer||t.currentAction.type==="REMOVE")&&await E(t.currentAction,t.htmlBuffer),u&&(u.remove(),u=null);return}if(o.startsWith("--THINKING=")){const i=o.substring(11);e(l=>{const B=[...l],x=B[B.length-1];if(x&&x.role==="assistant"&&x.isReasoning)x.content=i,x.isStreaming=!1;else{const b={id:Date.now().toString(),role:"assistant",content:i,isReasoning:!0,isStreaming:!1};B.push(b)}return B});return}if(o.startsWith("--TASK=")){const i=o.substring(7),l=`task-${Date.now()}-${Math.random().toString(36).substr(2,9)}`,B={id:l,role:"assistant",content:i.replace(/--$/,""),isTask:!0,isTaskLoading:!0,isTaskCompleted:!1};m=l,e(x=>[...x,B]);return}if(o.startsWith("--MSG=")){const i=o.substring(6),l={id:Date.now().toString(),role:"assistant",content:i.replace(/--$/g,""),isReasoning:!1,isStreaming:!1};e(B=>[...B,l]);return}if(o.startsWith("--ACTION=")){t.currentAction&&(t.htmlBuffer||t.currentAction.type==="REMOVE")&&await E(t.currentAction,t.htmlBuffer),t.currentAction=D(o),t.htmlBuffer="",t.isInAction=!0;return}if(o==="--ENDACTION--"){t.currentAction&&(t.htmlBuffer||t.currentAction.type==="REMOVE")&&await E(t.currentAction,t.htmlBuffer),m&&(e(i=>i.map(l=>l.isTask?{...l,isTaskCompleted:!0}:l)),m=null),t.currentAction=null,t.htmlBuffer="",t.isInAction=!1;return}if(o==="--HTML--"){t.isCapturingHtml=!0;return}if(o==="--ENDHTML--"){t.isCapturingHtml=!1;return}if(o.startsWith("--HTML--")&&o.includes("--ENDHTML--")){const i=o.match(/^--HTML--(.+?)--ENDHTML--$/);if(i&&t.currentAction){const l=i[1];t.htmlBuffer+=l,t.currentAction.type==="ADD"?M(t.htmlBuffer,t.currentAction.parentId,t.currentAction.position):t.currentAction.type==="EDIT"&&t.currentAction.blockId&&g(t.htmlBuffer,t.currentAction.blockId)}return}t.isCapturingHtml&&t.currentAction&&(t.htmlBuffer+=y+`
1
+ "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const c=require("react/jsx-runtime"),v=require("./index-xYnNKovy.cjs"),S=require("./selected-block-display-DLt_nMn9.cjs"),P=require("lucide-react"),j=require("react"),O=require("sonner"),W=require("./models-5gOsRC56.cjs"),F=require("lodash-es"),q=require("./apply-binding-IsUf6UWJ.cjs"),$=require("@tanstack/react-query"),_=(a,k)=>{const h=a.filter(p=>p._parent===k),I=h.map(p=>p._id),A=h.flatMap(p=>_(a,p._id));return[...I,...A]},V=(a,k,h)=>{const I=F.find(a,{_id:k});if(!I)return a;const A=a.findIndex(g=>g._id===k),p=_(a,k),C=new Set([k,...p]),u=a.filter(g=>!C.has(g._id)),w=new Set(h.map(g=>g._id)),R=h.map(g=>!g._parent||!w.has(g._parent)?{...g,_parent:I._parent}:g);return[...u.slice(0,A),...R,...u.slice(A)]},K=()=>{const[,a]=v.useSelectedBlockIds(),{setNewBlocks:k}=v.useBlocksStoreUndoableActions(),{hasPermission:h}=v.usePermissions();return j.useCallback((I,A)=>{if(!h(v.PERMISSIONS.EDIT_BLOCK))return;const p=v.builderStore.get(v.presentBlocksAtom),C=I?V(p,I,A):A;k(C),A.length>0&&setTimeout(()=>a([A[0]._id]),200)},[a,k,h])},U=()=>{const{addPredefinedBlock:a}=v.useAddBlock(),k=K(),h=v.useRemoveBlocks(),I=$.useQueryClient(),A=async(s,e)=>{if(!e)return;const r=q.getBlocksFromHTML(e);await a(r,s.parentId,s.position)},p=async(s,e)=>{if(!s.blockId||!e)return;const r=q.getBlocksFromHTML(e);await k(s.blockId,r)},C=async s=>{!s.ids||s.ids.length===0||await h(s.ids)};let u=null;const w=(s,e)=>{const r=document.getElementById("canvas-iframe");if(!r)return null;const d=r==null?void 0:r.contentDocument;if(!d)return null;d.querySelectorAll("[data-stream-canvas]").forEach(m=>m.remove());let n=null;if(s&&s!=="undefined"&&(n=d.querySelector(`[data-block-id="${s}"]`)),n||(n=d.body),!n)return null;if(u=d.createElement("div"),u.setAttribute("data-stream-canvas","true"),e!==void 0&&e>=0&&n.children){const m=Math.min(e,n.children.length);m<n.children.length?n.insertBefore(u,n.children[m]):n.appendChild(u)}else n.appendChild(u);return u},R=s=>{var n;const e=document.getElementById("canvas-iframe");if(!e)return null;const r=e==null?void 0:e.contentDocument;if(!r)return null;r.querySelectorAll("[data-stream-canvas]").forEach(m=>m.remove());const f=r.querySelector(`[data-block-id="${s}"]`);return f?(u=r.createElement("div"),u.setAttribute("data-stream-canvas","true"),(n=f.parentNode)==null||n.insertBefore(u,f.nextSibling),f.style.display="none",u):null},M=(s,e,r)=>{const d=w(e,r);if(d){d.innerHTML=s;const f=d.getBoundingClientRect(),n=document.getElementById("canvas-iframe"),m=n==null?void 0:n.contentWindow;m&&(f.top>=0&&f.bottom<=m.innerHeight||d.scrollIntoView({behavior:"smooth",block:"nearest"}))}},g=(s,e)=>{const r=R(e);r&&(r.innerHTML=s)},D=s=>{const e=s.match(/^--ACTION=(.+)--$/);if(!e)return null;let d=e[1].replace(/--/g,"").split("|");const n={type:d[0]};return d.forEach(m=>{const t=m.trim();if(t.startsWith("PARENT=")){const T=t.substring(7);n.parentId=T==="undefined"?void 0:T}else t.startsWith("POS=")?n.position=parseInt(t.substring(4)):t.startsWith("ID=")?n.blockId=t.substring(3):t.startsWith("IDS=")&&(n.ids=t.substring(4).split(",").map(T=>T.trim()))}),n};return j.useCallback(async(s,e)=>{const r=new TextDecoder;let d="",f="",n=!1,m=null;const t={isInAction:!1,currentAction:null,htmlBuffer:"",isCapturingHtml:!1},T=async y=>{const o=y.trim();if(o==="--START--"){n=!0;return}if(n){if(o==="--END--"){t.currentAction&&(t.htmlBuffer||t.currentAction.type==="REMOVE")&&await E(t.currentAction,t.htmlBuffer),u&&(u.remove(),u=null);return}if(o.startsWith("--THINKING=")){const i=o.substring(11);e(l=>{const B=[...l],x=B[B.length-1];if(x&&x.role==="assistant"&&x.isReasoning)x.content=i,x.isStreaming=!1;else{const b={id:Date.now().toString(),role:"assistant",content:i,isReasoning:!0,isStreaming:!1};B.push(b)}return B});return}if(o.startsWith("--TASK=")){const i=o.substring(7),l=`task-${Date.now()}-${Math.random().toString(36).substr(2,9)}`,B={id:l,role:"assistant",content:i.replace(/--$/,""),isTask:!0,isTaskLoading:!0,isTaskCompleted:!1};m=l,e(x=>[...x,B]);return}if(o.startsWith("--MSG=")){const i=o.substring(6),l={id:Date.now().toString(),role:"assistant",content:i.replace(/--$/g,""),isReasoning:!1,isStreaming:!1};e(B=>[...B,l]);return}if(o.startsWith("--ACTION=")){t.currentAction&&(t.htmlBuffer||t.currentAction.type==="REMOVE")&&await E(t.currentAction,t.htmlBuffer),t.currentAction=D(o),t.htmlBuffer="",t.isInAction=!0;return}if(o==="--ENDACTION--"){t.currentAction&&(t.htmlBuffer||t.currentAction.type==="REMOVE")&&await E(t.currentAction,t.htmlBuffer),m&&(e(i=>i.map(l=>l.isTask?{...l,isTaskCompleted:!0}:l)),m=null),t.currentAction=null,t.htmlBuffer="",t.isInAction=!1;return}if(o==="--HTML--"){t.isCapturingHtml=!0;return}if(o==="--ENDHTML--"){t.isCapturingHtml=!1;return}if(o.startsWith("--HTML--")&&o.includes("--ENDHTML--")){const i=o.match(/^--HTML--(.+?)--ENDHTML--$/);if(i&&t.currentAction){const l=i[1];t.htmlBuffer+=l,t.currentAction.type==="ADD"?M(t.htmlBuffer,t.currentAction.parentId,t.currentAction.position):t.currentAction.type==="EDIT"&&t.currentAction.blockId&&g(t.htmlBuffer,t.currentAction.blockId)}return}t.isCapturingHtml&&t.currentAction&&(t.htmlBuffer+=y+`
2
2
  `,t.currentAction.type==="ADD"?M(t.htmlBuffer,t.currentAction.parentId,t.currentAction.position):t.currentAction.type==="EDIT"&&t.currentAction.blockId&&g(t.htmlBuffer,t.currentAction.blockId))}},E=async(y,o)=>{try{switch(y.type){case"ADD":await A(y,o);break;case"EDIT":await p(y,o);break;case"REMOVE":await C(y);break}e(i=>i.filter(l=>!l.isTask))}catch(i){console.log(i)}};try{for(;;){const{done:y,value:o}=await s.read();if(y)break;const i=r.decode(o,{stream:!0});d+=i,f+=i;const l=f.split(`
3
- `);f=l.pop()||"";for(const B of l)await T(B)}f&&await T(f),I.invalidateQueries({queryKey:["AI_USAGE"]})}catch(y){console.log(y)}},[h])},G=j.lazy(()=>Promise.resolve().then(()=>require("./ai-prompt-input-N9PcYCFa.cjs"))),Q=({t:a,fetch:k,input:h,messages:I,setInput:A,isLoading:p,setMessages:C,handleStop:u,setIsLoading:w,currentBlock:R,fallbackLang:M,setCurrentBlock:g,setAbortController:D,selectedModel:s=W.getDefaultModel().id,onModelChange:e})=>{const r=v.useSelectedBlock(),[,d]=v.useSelectedBlockIds(),f=v.useBlocksHtmlForAi(),n=U(),m=async(t,T,E,y)=>{var x;if(!t||p)return;g(r);const o=f(r?{blockId:r._id,additionalCoreBlocks:["Icon"]}:{additionalCoreBlocks:["Icon"]});if(r&&!o){O.toast.error(a("Something went wrong. Please try again."));return}const i={id:Date.now().toString(),role:"user",content:S.getUserPrompt({language:M,userInput:T||t,currentHtml:o}),userMessage:t},l={id:(Date.now()+1).toString(),role:"assistant",content:"",isReasoning:!0,isStreaming:!0};C(b=>[...b,i,l]),w(!0);const B=new AbortController;D(B);try{const b={messages:[i].map(L=>({role:L.role,content:L.content})),model:y||s};E&&(b.image=E);const N=await k({body:{action:"ASK_AI",data:b},streamResponse:!0});if(!N.ok)throw new Error(a("Failed to get AI response"));const H=(x=N.body)==null?void 0:x.getReader();if(!H)throw new Error(a("Response body is not readable"));await n(H,C)}catch(b){if(b.name!=="AbortError"){const N={id:(Date.now()+1).toString(),role:"assistant",content:a("Sorry, I encountered an error. Please try again.")};C(H=>[...H,N])}}finally{A(""),w(!1),g(null),D(null)}};return c.jsxs(c.Fragment,{children:[c.jsxs(S.Conversation,{className:"no-scrollbar",children:[c.jsxs(S.ConversationContent,{className:"gap-2 px-0",children:[I.length===0&&c.jsx(S.ConversationEmptyState,{icon:c.jsx(P.Bot,{size:48,className:"text-gray-300"}),title:"Start a conversation",description:a("Start a conversation with the AI assistant to add/edit current page")}),I.map(t=>t.role!=="system"&&c.jsx(j.Fragment,{children:t.isReasoning?c.jsxs(S.Reasoning,{isStreaming:t.isStreaming,defaultOpen:!0,children:[c.jsx(S.ReasoningTrigger,{className:"text-xs [&_p]:text-muted-foreground"}),c.jsx(S.ReasoningContent,{className:"p-0 text-xs",children:t.content})]}):t.isTask&&!t.isTaskCompleted?c.jsx(S.TaskMessage,{content:t.content,isLoading:t.isTaskLoading}):c.jsx(S.Message,{from:t.role,children:c.jsx(S.MessageContent,{className:"p-0",children:t.role==="assistant"?c.jsx(S.MessageResponse,{className:"p-0 text-xs",children:t.content}):c.jsx("div",{className:"p-0 text-xs",children:t.userMessage||t.content})})})},t.id))]}),c.jsx(S.ConversationScrollButton,{})]}),c.jsxs("div",{className:"border-gray-200 pb-2",children:[c.jsx(S.SelectedBlockDisplay,{onRemove:()=>d([]),isLoading:p}),c.jsx(j.Suspense,{fallback:c.jsx("div",{children:"Loading..."}),children:c.jsx(G,{input:h,setInput:A,onSend:m,onStop:u,isLoading:p,selectedLang:"",currentBlock:r||R,disabled:(h==null?void 0:h.length)===0,selectedModel:s,onModelChange:e})})]})]})};exports.default=Q;
3
+ `);f=l.pop()||"";for(const B of l)await T(B)}f&&await T(f),I.invalidateQueries({queryKey:["AI_USAGE"]})}catch(y){console.log(y)}},[h])},G=j.lazy(()=>Promise.resolve().then(()=>require("./ai-prompt-input-Dtym4w8J.cjs"))),Q=({t:a,fetch:k,input:h,messages:I,setInput:A,isLoading:p,setMessages:C,handleStop:u,setIsLoading:w,currentBlock:R,fallbackLang:M,setCurrentBlock:g,setAbortController:D,selectedModel:s=W.getDefaultModel().id,onModelChange:e})=>{const r=v.useSelectedBlock(),[,d]=v.useSelectedBlockIds(),f=v.useBlocksHtmlForAi(),n=U(),m=async(t,T,E,y)=>{var x;if(!t||p)return;g(r);const o=f(r?{blockId:r._id,additionalCoreBlocks:["Icon"]}:{additionalCoreBlocks:["Icon"]});if(r&&!o){O.toast.error(a("Something went wrong. Please try again."));return}const i={id:Date.now().toString(),role:"user",content:S.getUserPrompt({language:M,userInput:T||t,currentHtml:o}),userMessage:t},l={id:(Date.now()+1).toString(),role:"assistant",content:"",isReasoning:!0,isStreaming:!0};C(b=>[...b,i,l]),w(!0);const B=new AbortController;D(B);try{const b={messages:[i].map(L=>({role:L.role,content:L.content})),model:y||s};E&&(b.image=E);const N=await k({body:{action:"ASK_AI",data:b},streamResponse:!0});if(!N.ok)throw new Error(a("Failed to get AI response"));const H=(x=N.body)==null?void 0:x.getReader();if(!H)throw new Error(a("Response body is not readable"));await n(H,C)}catch(b){if(b.name!=="AbortError"){const N={id:(Date.now()+1).toString(),role:"assistant",content:a("Sorry, I encountered an error. Please try again.")};C(H=>[...H,N])}}finally{A(""),w(!1),g(null),D(null)}};return c.jsxs(c.Fragment,{children:[c.jsxs(S.Conversation,{className:"no-scrollbar",children:[c.jsxs(S.ConversationContent,{className:"gap-2 px-0",children:[I.length===0&&c.jsx(S.ConversationEmptyState,{icon:c.jsx(P.Bot,{size:48,className:"text-gray-300"}),title:"Start a conversation",description:a("Start a conversation with the AI assistant to add/edit current page")}),I.map(t=>t.role!=="system"&&c.jsx(j.Fragment,{children:t.isReasoning?c.jsxs(S.Reasoning,{isStreaming:t.isStreaming,defaultOpen:!0,children:[c.jsx(S.ReasoningTrigger,{className:"text-xs [&_p]:text-muted-foreground"}),c.jsx(S.ReasoningContent,{className:"p-0 text-xs",children:t.content})]}):t.isTask&&!t.isTaskCompleted?c.jsx(S.TaskMessage,{content:t.content,isLoading:t.isTaskLoading}):c.jsx(S.Message,{from:t.role,children:c.jsx(S.MessageContent,{className:"p-0",children:t.role==="assistant"?c.jsx(S.MessageResponse,{className:"p-0 text-xs",children:t.content}):c.jsx("div",{className:"p-0 text-xs",children:t.userMessage||t.content})})})},t.id))]}),c.jsx(S.ConversationScrollButton,{})]}),c.jsxs("div",{className:"border-gray-200 pb-2",children:[c.jsx(S.SelectedBlockDisplay,{onRemove:()=>d([]),isLoading:p}),c.jsx(j.Suspense,{fallback:c.jsx("div",{children:"Loading..."}),children:c.jsx(G,{input:h,setInput:A,onSend:m,onStop:u,isLoading:p,selectedLang:"",currentBlock:r||R,disabled:(h==null?void 0:h.length)===0,selectedModel:s,onModelChange:e})})]})]})};exports.default=Q;
@@ -1,6 +1,6 @@
1
1
  import { jsxs as D, Fragment as W, jsx as g } from "react/jsx-runtime";
2
- import { a as _, ah as F, ai as $, aj as q, ak as V, al as K, am as j, an as U, ao as G, ap as z } from "./index-rAcNbjk_.js";
3
- import { C as Q, a as J, b as X, R as Y, c as Z, d as tt, T as et, M as nt, e as rt, f as st, g as ot, S as at, h as it } from "./selected-block-display-B1SG_UXw.js";
2
+ import { a as _, ah as F, ai as $, aj as q, ak as V, al as K, am as j, an as U, ao as G, ap as z } from "./index-RYr8kQdI.js";
3
+ import { C as Q, a as J, b as X, R as Y, c as Z, d as tt, T as et, M as nt, e as rt, f as st, g as ot, S as at, h as it } from "./selected-block-display-CB1-hVR5.js";
4
4
  import { Bot as ct } from "lucide-react";
5
5
  import { useCallback as P, Fragment as lt, Suspense as ut, lazy as dt } from "react";
6
6
  import { toast as ft } from "sonner";
@@ -223,7 +223,7 @@ const O = (i, k) => {
223
223
  },
224
224
  [m]
225
225
  );
226
- }, It = dt(() => import("./ai-prompt-input-DueQYNf-.js")), Mt = ({
226
+ }, It = dt(() => import("./ai-prompt-input-BT-mEdTX.js")), Mt = ({
227
227
  t: i,
228
228
  fetch: k,
229
229
  input: m,
@@ -1 +1 @@
1
- "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const e=require("react/jsx-runtime"),p=require("./index-C99FhuF1.cjs"),f=require("lodash-es"),l=require("react"),G=require("./core-Y0lXLwkq.cjs"),c=require("./selected-block-display-BOgnQRLF.cjs"),H=require("lucide-react"),Q=require("react-i18next"),X=require("./models-5gOsRC56.cjs"),C=(s,o)=>{const r=s.filter(n=>n._parent===o),i=r.flatMap(n=>C(s,n._id));return[...r,...i]},Y=(s,o)=>{const r=o.find(n=>n._id===s);if(!r)return[];const i=C(o,s);return[r,...i]},Z=()=>{const s=p.useSelectedBlock(),[o]=p.useBlocksStore();return l.useCallback((r="")=>{const i=s!=null&&s._id?Y(s._id,o):o;return i?f.compact(i.map(n=>{const h=G.getRegisteredChaiBlock(n._type);if(!h)return null;const x=(h==null?void 0:h.i18nProps)??[];if(x.length===0)return null;const g=r==="ALL"?Object.keys(n).filter(a=>x.find(S=>a.startsWith(S))):x.map(a=>r?`${a}-${r}`:a),d=f.pick(n,["_id"]);return f.each(g,a=>{d[a]=f.get(n,a,f.get(n,a.replace(`-${r}`,"")))}),d})):[]},[s==null?void 0:s._id,o])},ee=l.lazy(()=>Promise.resolve().then(()=>require("./ai-translation-prompt-IAdWMNZb.cjs"))),te=l.lazy(()=>Promise.resolve().then(()=>require("./ai-prompt-input-N9PcYCFa.cjs"))),ne=({fetch:s,input:o,messages:r,setInput:i,isLoading:n,handleStop:h,setMessages:x,setIsLoading:g,selectedLang:d,currentBlock:a,fallbackLang:S,abortController:k,setAbortController:E,setCurrentBlock:T,selectedModel:B=X.getDefaultModel().id,onModelChange:M})=>{const{t:u}=Q.useTranslation(),O=l.useRef(null),y=p.useSelectedBlock(),[,D]=p.useSelectedBlockIds(),R=Z(),I=p.useStreamMultipleBlocksProps(),F=()=>{var t;(t=O.current)==null||t.scrollIntoView({behavior:"smooth"})};l.useEffect(()=>{F()},[r,n]);const N=async(t,w,$)=>{var P;y&&T(y);const q=(t==null?void 0:t.toLowerCase())==="translate",v={id:Date.now().toString(),role:"user",content:c.getTranslationUserPrompt({fallbackLang:S,userInput:w||t,language:d,blocks:q?R():R(d)}),userMessage:w||t||u("Translate the content")},z={id:(Date.now()+1).toString(),role:"assistant",content:"Thinking...",isReasoning:!0,isStreaming:!0};g(!0);const W=new AbortController;E(W),x(b=>[...b,v,z]),g(!0);try{const A=await s({body:{action:"ASK_AI",data:{messages:[v],initiator:q?"TRANSLATE_CONTENT":"UPDATE_CONTENT",model:$||B}},streamResponse:!0});if(!A.ok)throw new Error(u("Failed to get AI response"));const _=(P=A.body)==null?void 0:P.getReader(),U=new TextDecoder;let j="";if(!_)throw new Error(u("Response body is not readable"));for(;;){const{done:K,value:L}=await _.read();if(K)break;const V=U.decode(L,{stream:!0});j+=V,x(m=>(m[m.length-1].content=j,[...m]))}const J=JSON.parse(j==null?void 0:j.replace("```json","").replace("```",""));I(J)}catch{k==null||k.abort()}finally{g(!1),i(""),T(null)}};return e.jsxs(e.Fragment,{children:[e.jsx("div",{className:"py-2",children:e.jsx(l.Suspense,{fallback:e.jsx("div",{children:u("Loading...")}),children:e.jsx(ee,{isLoading:n,selectedBlock:y,selectedLang:d,onClick:N})})}),e.jsx(c.Conversation,{children:e.jsxs(c.ConversationContent,{className:"gap-4 px-0",children:[r.length===0&&e.jsx(c.ConversationEmptyState,{icon:e.jsx(H.Bot,{size:48,className:"text-gray-300"}),title:u("Start a conversation with the AI assistant to translate/edit your content"),description:u("Only content can be edited in secondary languages. To edit layout, styles and more, switch to the default language.")}),r.map(t=>t.role!=="system"&&e.jsx(l.Fragment,{children:t.isReasoning?e.jsxs(c.Reasoning,{isStreaming:t.isStreaming,defaultOpen:!0,children:[e.jsx(c.ReasoningTrigger,{className:"text-xs [&_p]:text-muted-foreground"}),e.jsx(c.ReasoningContent,{className:"p-0 text-xs",children:t.content})]}):t.isTask?e.jsx(c.TaskMessage,{content:t.content,isLoading:t.isTaskLoading}):e.jsx(c.Message,{from:t.role,children:e.jsx(c.MessageContent,{className:"p-0",children:t.role==="assistant"?e.jsx(c.MessageResponse,{className:"p-0 text-xs",children:t.content}):e.jsx("div",{className:"p-0 text-xs",children:t.userMessage||t.content})})})},t.id))]})}),e.jsxs("div",{className:"border-gray-200 pb-2",children:[e.jsx(c.SelectedBlockDisplay,{onRemove:()=>D([]),isLoading:n}),e.jsx(l.Suspense,{fallback:e.jsx("div",{children:u("Loading...")}),children:e.jsx(te,{input:o,setInput:i,onSend:N,onStop:h,isLoading:n,selectedLang:d,currentBlock:y||a,disabled:(o==null?void 0:o.length)===0,selectedModel:B,onModelChange:M})})]})]})};exports.default=ne;
1
+ "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const e=require("react/jsx-runtime"),p=require("./index-xYnNKovy.cjs"),f=require("lodash-es"),l=require("react"),G=require("./core-Y0lXLwkq.cjs"),c=require("./selected-block-display-DLt_nMn9.cjs"),H=require("lucide-react"),Q=require("react-i18next"),X=require("./models-5gOsRC56.cjs"),C=(s,o)=>{const r=s.filter(n=>n._parent===o),i=r.flatMap(n=>C(s,n._id));return[...r,...i]},Y=(s,o)=>{const r=o.find(n=>n._id===s);if(!r)return[];const i=C(o,s);return[r,...i]},Z=()=>{const s=p.useSelectedBlock(),[o]=p.useBlocksStore();return l.useCallback((r="")=>{const i=s!=null&&s._id?Y(s._id,o):o;return i?f.compact(i.map(n=>{const h=G.getRegisteredChaiBlock(n._type);if(!h)return null;const x=(h==null?void 0:h.i18nProps)??[];if(x.length===0)return null;const g=r==="ALL"?Object.keys(n).filter(a=>x.find(S=>a.startsWith(S))):x.map(a=>r?`${a}-${r}`:a),d=f.pick(n,["_id"]);return f.each(g,a=>{d[a]=f.get(n,a,f.get(n,a.replace(`-${r}`,"")))}),d})):[]},[s==null?void 0:s._id,o])},ee=l.lazy(()=>Promise.resolve().then(()=>require("./ai-translation-prompt-B-lH7emI.cjs"))),te=l.lazy(()=>Promise.resolve().then(()=>require("./ai-prompt-input-Dtym4w8J.cjs"))),ne=({fetch:s,input:o,messages:r,setInput:i,isLoading:n,handleStop:h,setMessages:x,setIsLoading:g,selectedLang:d,currentBlock:a,fallbackLang:S,abortController:k,setAbortController:E,setCurrentBlock:T,selectedModel:B=X.getDefaultModel().id,onModelChange:M})=>{const{t:u}=Q.useTranslation(),O=l.useRef(null),y=p.useSelectedBlock(),[,D]=p.useSelectedBlockIds(),R=Z(),I=p.useStreamMultipleBlocksProps(),F=()=>{var t;(t=O.current)==null||t.scrollIntoView({behavior:"smooth"})};l.useEffect(()=>{F()},[r,n]);const N=async(t,w,$)=>{var P;y&&T(y);const q=(t==null?void 0:t.toLowerCase())==="translate",v={id:Date.now().toString(),role:"user",content:c.getTranslationUserPrompt({fallbackLang:S,userInput:w||t,language:d,blocks:q?R():R(d)}),userMessage:w||t||u("Translate the content")},z={id:(Date.now()+1).toString(),role:"assistant",content:"Thinking...",isReasoning:!0,isStreaming:!0};g(!0);const W=new AbortController;E(W),x(b=>[...b,v,z]),g(!0);try{const A=await s({body:{action:"ASK_AI",data:{messages:[v],initiator:q?"TRANSLATE_CONTENT":"UPDATE_CONTENT",model:$||B}},streamResponse:!0});if(!A.ok)throw new Error(u("Failed to get AI response"));const _=(P=A.body)==null?void 0:P.getReader(),U=new TextDecoder;let j="";if(!_)throw new Error(u("Response body is not readable"));for(;;){const{done:K,value:L}=await _.read();if(K)break;const V=U.decode(L,{stream:!0});j+=V,x(m=>(m[m.length-1].content=j,[...m]))}const J=JSON.parse(j==null?void 0:j.replace("```json","").replace("```",""));I(J)}catch{k==null||k.abort()}finally{g(!1),i(""),T(null)}};return e.jsxs(e.Fragment,{children:[e.jsx("div",{className:"py-2",children:e.jsx(l.Suspense,{fallback:e.jsx("div",{children:u("Loading...")}),children:e.jsx(ee,{isLoading:n,selectedBlock:y,selectedLang:d,onClick:N})})}),e.jsx(c.Conversation,{children:e.jsxs(c.ConversationContent,{className:"gap-4 px-0",children:[r.length===0&&e.jsx(c.ConversationEmptyState,{icon:e.jsx(H.Bot,{size:48,className:"text-gray-300"}),title:u("Start a conversation with the AI assistant to translate/edit your content"),description:u("Only content can be edited in secondary languages. To edit layout, styles and more, switch to the default language.")}),r.map(t=>t.role!=="system"&&e.jsx(l.Fragment,{children:t.isReasoning?e.jsxs(c.Reasoning,{isStreaming:t.isStreaming,defaultOpen:!0,children:[e.jsx(c.ReasoningTrigger,{className:"text-xs [&_p]:text-muted-foreground"}),e.jsx(c.ReasoningContent,{className:"p-0 text-xs",children:t.content})]}):t.isTask?e.jsx(c.TaskMessage,{content:t.content,isLoading:t.isTaskLoading}):e.jsx(c.Message,{from:t.role,children:e.jsx(c.MessageContent,{className:"p-0",children:t.role==="assistant"?e.jsx(c.MessageResponse,{className:"p-0 text-xs",children:t.content}):e.jsx("div",{className:"p-0 text-xs",children:t.userMessage||t.content})})})},t.id))]})}),e.jsxs("div",{className:"border-gray-200 pb-2",children:[e.jsx(c.SelectedBlockDisplay,{onRemove:()=>D([]),isLoading:n}),e.jsx(l.Suspense,{fallback:e.jsx("div",{children:u("Loading...")}),children:e.jsx(te,{input:o,setInput:i,onSend:N,onStop:h,isLoading:n,selectedLang:d,currentBlock:y||a,disabled:(o==null?void 0:o.length)===0,selectedModel:B,onModelChange:M})})]})]})};exports.default=ne;
@@ -1,9 +1,9 @@
1
1
  import { jsxs as p, Fragment as H, jsx as t } from "react/jsx-runtime";
2
- import { ao as P, ad as Q, a as X, aq as Y } from "./index-rAcNbjk_.js";
2
+ import { ao as P, ad as Q, a as X, aq as Y } from "./index-RYr8kQdI.js";
3
3
  import { compact as Z, pick as ee, each as te, get as v } from "lodash-es";
4
4
  import { useCallback as ne, useRef as se, useEffect as oe, Suspense as M, lazy as E, Fragment as re } from "react";
5
5
  import { e as ae } from "./core-Dr7QYemB.js";
6
- import { C as ie, a as ce, b as le, R as de, c as ue, d as he, T as me, M as fe, e as pe, f as ge, S as ye, i as Se } from "./selected-block-display-B1SG_UXw.js";
6
+ import { C as ie, a as ce, b as le, R as de, c as ue, d as he, T as me, M as fe, e as pe, f as ge, S as ye, i as Se } from "./selected-block-display-CB1-hVR5.js";
7
7
  import { Bot as Te } from "lucide-react";
8
8
  import { useTranslation as ke } from "react-i18next";
9
9
  import { g as Ne } from "./models-D95ZYr_x.js";
@@ -35,7 +35,7 @@ const O = (s, r) => {
35
35
  },
36
36
  [s == null ? void 0 : s._id, r]
37
37
  );
38
- }, Re = E(() => import("./ai-translation-prompt-B36F3d7K.js")), xe = E(() => import("./ai-prompt-input-DueQYNf-.js")), De = ({
38
+ }, Re = E(() => import("./ai-translation-prompt-B17GK1QR.js")), xe = E(() => import("./ai-prompt-input-BT-mEdTX.js")), De = ({
39
39
  fetch: s,
40
40
  input: r,
41
41
  messages: o,
@@ -1,6 +1,6 @@
1
1
  import { jsx as e, jsxs as w, Fragment as ie } from "react/jsx-runtime";
2
2
  import { E as N, B as E } from "./register-chai-top-bar-ESJHs5s-.js";
3
- import { T as le, av as ce, r as ue, s as de, t as pe, v as me, aw as fe, ax as he, D as ge, ay as ve, d as be, f as xe, C as we, i as Ne, j as Ie, l as ye, m as Se } from "./index-rAcNbjk_.js";
3
+ import { T as le, av as ce, r as ue, s as de, t as pe, v as me, aw as fe, ax as he, D as ge, ay as ve, d as be, f as xe, C as we, i as Ne, j as Ie, l as ye, m as Se } from "./index-RYr8kQdI.js";
4
4
  import { cva as Y } from "class-variance-authority";
5
5
  import { PaperclipIcon as ke, XIcon as J, PlusIcon as De, ImageIcon as ze, MicIcon as Pe, CornerDownLeftIcon as Te, Loader2Icon as Ae, SquareIcon as Le, Cpu as Ce, Paperclip as Re, GlobeIcon as Me, Square as je, Send as Ue } from "lucide-react";
6
6
  import { nanoid as Oe } from "nanoid";
@@ -1 +1 @@
1
- "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const e=require("react/jsx-runtime"),g=require("./register-chai-top-bar-BqwKw4uy.cjs"),N=require("./index-C99FhuF1.cjs"),W=require("class-variance-authority"),S=require("lucide-react"),te=require("nanoid"),c=require("react"),se=require("react-i18next"),R=require("./models-5gOsRC56.cjs");function ne({className:t,...s}){return e.jsx("div",{"data-slot":"input-group",role:"group",className:g.cn("group/input-group shadow-xs relative flex w-full items-center rounded-md border border-input outline-none transition-[color,box-shadow] dark:bg-input/30","h-9 has-[>textarea]:h-auto","has-[>[data-align=inline-start]]:[&>input]:pl-2","has-[>[data-align=inline-end]]:[&>input]:pr-2","has-[>[data-align=block-start]]:h-auto has-[>[data-align=block-start]]:flex-col has-[>[data-align=block-start]]:[&>input]:pb-3","has-[>[data-align=block-end]]:h-auto has-[>[data-align=block-end]]:flex-col has-[>[data-align=block-end]]:[&>input]:pt-3","has-[[data-slot=input-group-control]:focus-visible]:ring-1 has-[[data-slot=input-group-control]:focus-visible]:ring-ring","has-[[data-slot][aria-invalid=true]]:border-destructive has-[[data-slot][aria-invalid=true]]:ring-destructive/20 dark:has-[[data-slot][aria-invalid=true]]:ring-destructive/40",t),...s})}const re=W.cva("text-muted-foreground flex h-auto cursor-text select-none items-center justify-center gap-2 py-1.5 text-sm font-medium group-data-[disabled=true]/input-group:opacity-50 [&>kbd]:rounded-[calc(var(--radius)-5px)] [&>svg:not([class*='size-'])]:size-4",{variants:{align:{"inline-start":"order-first pl-3 has-[>button]:ml-[-0.45rem] has-[>kbd]:ml-[-0.35rem]","inline-end":"order-last pr-3 has-[>button]:mr-[-0.4rem] has-[>kbd]:mr-[-0.35rem]","block-start":"[.border-b]:pb-3 order-first w-full justify-start px-3 pt-3 group-has-[>input]/input-group:pt-2.5","block-end":"[.border-t]:pt-3 order-last w-full justify-start px-3 pb-3 group-has-[>input]/input-group:pb-2.5"}},defaultVariants:{align:"inline-start"}});function H({className:t,align:s="inline-start",...o}){return e.jsx("div",{role:"group","data-slot":"input-group-addon","data-align":s,className:g.cn(re({align:s}),t),onClick:l=>{var i,m;l.target.closest("button")||(m=(i=l.currentTarget.parentElement)==null?void 0:i.querySelector("input"))==null||m.focus()},...o})}const ae=W.cva("flex items-center gap-2 text-sm shadow-none",{variants:{size:{xs:"h-6 gap-1 rounded-[calc(var(--radius)-5px)] px-2 has-[>svg]:px-2 [&>svg:not([class*='size-'])]:size-3.5",sm:"h-8 gap-1.5 rounded-md px-2.5 has-[>svg]:px-2.5","icon-xs":"size-6 rounded-[calc(var(--radius)-5px)] p-0 has-[>svg]:p-0","icon-sm":"size-8 p-0 has-[>svg]:p-0"}},defaultVariants:{size:"xs"}});function K({className:t,type:s="button",variant:o="ghost",size:l="xs",...i}){return e.jsx(g.Button,{type:s,"data-size":l,variant:o,className:g.cn(ae({size:l}),t),...i})}function oe({className:t,...s}){return e.jsx(N.Textarea,{"data-slot":"input-group-control",className:g.cn("flex-1 resize-none rounded-none border-0 bg-transparent py-3 shadow-none focus-visible:ring-0 dark:bg-transparent",t),...s})}const ie=c.createContext(null),ce=c.createContext(null),X=()=>c.useContext(ie),le=()=>c.useContext(ce),$=c.createContext(null),q=()=>{const t=le(),s=c.useContext($),o=t??s;if(!o)throw new Error("usePromptInputAttachments must be used within a PromptInput or PromptInputProvider");return o};function ue({data:t,className:s,...o}){var h;const l=q(),i=t.filename||"",d=((h=t.mediaType)!=null&&h.startsWith("image/")&&t.url?"image":"file")==="image",v=i||(d?"Image":"Attachment");return e.jsxs(Ie,{children:[e.jsx(N.HoverCardTrigger,{asChild:!0,children:e.jsxs("div",{className:g.cn("group relative flex h-8 cursor-default select-none items-center gap-1.5 rounded-md border border-border px-1.5 text-sm font-medium transition-all hover:bg-accent hover:text-accent-foreground dark:hover:bg-accent/50",s),...o,children:[e.jsxs("div",{className:"relative size-5 shrink-0",children:[e.jsx("div",{className:"absolute inset-0 flex size-5 items-center justify-center overflow-hidden rounded bg-background transition-opacity group-hover:opacity-0",children:d?e.jsx("img",{alt:i||"attachment",className:"size-5 object-cover",height:20,src:t.url,width:20}):e.jsx("div",{className:"flex size-5 items-center justify-center text-muted-foreground",children:e.jsx(S.PaperclipIcon,{className:"size-3"})})}),e.jsxs(g.Button,{"aria-label":"Remove attachment",className:"absolute inset-0 size-5 cursor-pointer rounded p-0 opacity-0 transition-opacity group-hover:pointer-events-auto group-hover:opacity-100 [&>svg]:size-2.5",onClick:y=>{y.stopPropagation(),l.remove(t.id)},type:"button",variant:"ghost",children:[e.jsx(S.XIcon,{}),e.jsx("span",{className:"sr-only",children:"Remove"})]})]}),e.jsx("span",{className:"flex-1 truncate",children:v})]},t.id)}),e.jsx(ye,{className:"w-auto p-2",children:e.jsxs("div",{className:"w-auto space-y-3",children:[d&&e.jsx("div",{className:"flex max-h-96 w-96 items-center justify-center overflow-hidden rounded-md border",children:e.jsx("img",{alt:i||"attachment preview",className:"max-h-full max-w-full object-contain",height:384,src:t.url,width:448})}),e.jsx("div",{className:"flex items-center gap-2.5",children:e.jsxs("div",{className:"min-w-0 flex-1 space-y-1 px-0.5",children:[e.jsx("h4",{className:"truncate text-sm font-semibold leading-none",children:i||(d?"Image":"Attachment")}),t.mediaType&&e.jsx("p",{className:"truncate font-mono text-xs text-muted-foreground",children:t.mediaType})]})})]})})]})}function de({children:t,className:s,...o}){const l=q();return l.files.length?e.jsx("div",{className:g.cn("flex flex-wrap items-center gap-2 p-3",s),...o,children:l.files.map(i=>e.jsx(c.Fragment,{children:t(i)},i.id))}):null}const pe=({label:t="Add photos or files",...s})=>{const o=q();return e.jsxs(N.DropdownMenuItem,{...s,onSelect:l=>{l.preventDefault(),o.openFileDialog()},children:[e.jsx(S.ImageIcon,{className:"mr-2 size-4"})," ",t]})},me=({className:t,accept:s,multiple:o,globalDrop:l,syncHiddenInput:i,maxFiles:m,maxFileSize:d,onError:v,onSubmit:h,children:y,...P})=>{const n=X(),a=!!n,p=c.useRef(null),D=c.useRef(null),I=c.useRef(null);c.useEffect(()=>{var j;const r=(j=D.current)==null?void 0:j.closest("form");r instanceof HTMLFormElement&&(I.current=r)},[]);const[k,z]=c.useState([]),x=a?n.attachments.files:k,C=c.useCallback(()=>{var r;(r=p.current)==null||r.click()},[]),M=c.useCallback(r=>!s||s.trim()===""?!0:s.includes("image/*")?r.type.startsWith("image/"):!0,[s]),U=c.useCallback(r=>{const j=Array.from(r),f=j.filter(w=>M(w));if(j.length&&f.length===0){v==null||v({code:"accept",message:"No files match the accepted types."});return}const u=w=>d?w.size<=d:!0,b=f.filter(u);if(f.length>0&&b.length===0){v==null||v({code:"max_file_size",message:"All files exceed the maximum size."});return}z(w=>{const A=typeof m=="number"?Math.max(0,m-w.length):void 0,ee=typeof A=="number"?b.slice(0,A):b;typeof A=="number"&&b.length>A&&(v==null||v({code:"max_files",message:"Too many files. Some were not added."}));const V=[];for(const E of ee)V.push({id:te.nanoid(),type:"file",url:URL.createObjectURL(E),mediaType:E.type,filename:E.name});return w.concat(V)})},[M,m,d,v]),T=a?r=>n.attachments.add(r):U,L=a?r=>n.attachments.remove(r):r=>z(j=>{const f=j.find(u=>u.id===r);return f!=null&&f.url&&URL.revokeObjectURL(f.url),j.filter(u=>u.id!==r)}),O=a?()=>n.attachments.clear():()=>z(r=>{for(const j of r)j.url&&URL.revokeObjectURL(j.url);return[]}),B=a?()=>n.attachments.openFileDialog():C;c.useEffect(()=>{a&&n.__registerFileInput(p,()=>{var r;return(r=p.current)==null?void 0:r.click()})},[a,n]),c.useEffect(()=>{i&&p.current&&x.length===0&&(p.current.value="")},[x,i]),c.useEffect(()=>{const r=I.current;if(!r)return;const j=u=>{var b,w;(w=(b=u.dataTransfer)==null?void 0:b.types)!=null&&w.includes("Files")&&u.preventDefault()},f=u=>{var b,w,A;(w=(b=u.dataTransfer)==null?void 0:b.types)!=null&&w.includes("Files")&&u.preventDefault(),(A=u.dataTransfer)!=null&&A.files&&u.dataTransfer.files.length>0&&T(u.dataTransfer.files)};return r.addEventListener("dragover",j),r.addEventListener("drop",f),()=>{r.removeEventListener("dragover",j),r.removeEventListener("drop",f)}},[T]),c.useEffect(()=>{if(!l)return;const r=f=>{var u,b;(b=(u=f.dataTransfer)==null?void 0:u.types)!=null&&b.includes("Files")&&f.preventDefault()},j=f=>{var u,b,w;(b=(u=f.dataTransfer)==null?void 0:u.types)!=null&&b.includes("Files")&&f.preventDefault(),(w=f.dataTransfer)!=null&&w.files&&f.dataTransfer.files.length>0&&T(f.dataTransfer.files)};return document.addEventListener("dragover",r),document.addEventListener("drop",j),()=>{document.removeEventListener("dragover",r),document.removeEventListener("drop",j)}},[T,l]),c.useEffect(()=>()=>{if(!a)for(const r of x)r.url&&URL.revokeObjectURL(r.url)},[a,x]);const Y=r=>{r.currentTarget.files&&T(r.currentTarget.files)},J=async r=>{const f=await(await fetch(r)).blob();return new Promise((u,b)=>{const w=new FileReader;w.onloadend=()=>u(w.result),w.onerror=b,w.readAsDataURL(f)})},Q=c.useMemo(()=>({files:x.map(r=>({...r,id:r.id})),add:T,remove:L,clear:O,openFileDialog:B,fileInputRef:p}),[x,T,L,O,B]),Z=r=>{r.preventDefault();const j=r.currentTarget,f=a?n.textInput.value:new FormData(j).get("message")||"";a||j.reset(),Promise.all(x.map(async({...u})=>u.url&&u.url.startsWith("blob:")?{...u,url:await J(u.url)}:u)).then(u=>{try{const b=h({text:f,files:u},r);b instanceof Promise?b.then(()=>{O(),a&&n.textInput.clear()}).catch(()=>{}):(O(),a&&n.textInput.clear())}catch{}})},G=e.jsxs(e.Fragment,{children:[e.jsx("span",{"aria-hidden":"true",className:"hidden",ref:D}),e.jsx("input",{accept:s,"aria-label":"Upload files",className:"hidden",multiple:o,onChange:Y,ref:p,title:"Upload files",type:"file"}),e.jsx("form",{className:g.cn("w-full",t),onSubmit:Z,...P,children:e.jsx(ne,{className:"overflow-hidden",children:y})})]});return a?G:e.jsx($.Provider,{value:Q,children:G})},fe=({onChange:t,className:s,placeholder:o="What would you like to know?",...l})=>{const i=X(),m=q(),[d,v]=c.useState(!1),h=n=>{if(n.key==="Enter"){if(d||n.nativeEvent.isComposing||n.shiftKey)return;n.preventDefault();const a=n.currentTarget.form,p=a==null?void 0:a.querySelector('button[type="submit"]');if(p!=null&&p.disabled)return;a==null||a.requestSubmit()}if(n.key==="Backspace"&&n.currentTarget.value===""&&m.files.length>0){n.preventDefault();const a=m.files.at(-1);a&&m.remove(a.id)}},y=n=>{var D;const a=(D=n.clipboardData)==null?void 0:D.items;if(!a)return;const p=[];for(const I of a)if(I.kind==="file"){const k=I.getAsFile();k&&p.push(k)}p.length>0&&(n.preventDefault(),m.add(p))},P=i?{value:i.textInput.value,onChange:n=>{i.textInput.setInput(n.currentTarget.value),t==null||t(n)}}:{onChange:t};return e.jsx(oe,{className:g.cn("field-sizing-content max-h-48 min-h-16",s),name:"message",onCompositionEnd:()=>v(!1),onCompositionStart:()=>v(!0),onKeyDown:h,onPaste:y,placeholder:o,...l,...P})},he=({className:t,...s})=>e.jsx(H,{align:"block-end",className:g.cn("order-first flex-wrap gap-1",t),...s}),xe=({className:t,...s})=>e.jsx(H,{align:"block-end",className:g.cn("justify-between gap-1",t),...s}),ge=({className:t,...s})=>e.jsx("div",{className:g.cn("flex items-center gap-1",t),...s}),F=({variant:t="ghost",className:s,size:o,...l})=>{const i=o??(c.Children.count(l.children)>1?"sm":"icon-sm");return e.jsx(K,{className:g.cn(s),size:i,type:"button",variant:t,...l})},ve=t=>e.jsx(N.DropdownMenu,{...t}),je=({className:t,children:s,...o})=>e.jsx(N.DropdownMenuTrigger,{asChild:!0,children:e.jsx(F,{className:t,...o,children:s??e.jsx(S.PlusIcon,{className:"size-4"})})}),be=({className:t,...s})=>e.jsx(N.DropdownMenuContent,{align:"start",className:g.cn(t),...s}),we=({className:t,variant:s="default",size:o="icon-sm",status:l,children:i,...m})=>{let d=e.jsx(S.CornerDownLeftIcon,{className:"size-4"});return l==="submitted"?d=e.jsx(S.Loader2Icon,{className:"size-4 animate-spin"}):l==="streaming"?d=e.jsx(S.SquareIcon,{className:"size-4"}):l==="error"&&(d=e.jsx(S.XIcon,{className:"size-4"})),e.jsx(K,{"aria-label":"Submit",className:g.cn(t),size:o,type:"submit",variant:s,...m,children:i??d})},Ne=({className:t,textareaRef:s,onTranscriptionChange:o,...l})=>{const[i,m]=c.useState(!1),[d,v]=c.useState(null),h=c.useRef(null);c.useEffect(()=>{if(typeof window<"u"&&("SpeechRecognition"in window||"webkitSpeechRecognition"in window)){const P=window.SpeechRecognition||window.webkitSpeechRecognition,n=new P;n.continuous=!0,n.interimResults=!0,n.lang="en-US",n.onstart=()=>{m(!0)},n.onend=()=>{m(!1)},n.onresult=a=>{var D;let p="";for(let I=a.resultIndex;I<a.results.length;I++){const k=a.results[I];k.isFinal&&(p+=((D=k[0])==null?void 0:D.transcript)??"")}if(p&&(s!=null&&s.current)){const I=s.current,k=I.value,z=k+(k?" ":"")+p;I.value=z,I.dispatchEvent(new Event("input",{bubbles:!0})),o==null||o(z)}},n.onerror=a=>{console.error("Speech recognition error:",a.error),m(!1)},h.current=n,c.startTransition(()=>v(n))}return()=>{h.current&&h.current.stop()}},[s,o]);const y=c.useCallback(()=>{d&&(i?d.stop():d.start())},[d,i]);return e.jsx(F,{className:g.cn("relative transition-all duration-200",i&&"animate-pulse bg-accent text-accent-foreground",t),disabled:!d,onClick:y,...l,children:e.jsx(S.MicIcon,{className:"size-4"})})},Ie=({openDelay:t=0,closeDelay:s=0,...o})=>e.jsx(N.HoverCard,{closeDelay:s,openDelay:t,...o}),ye=({align:t="start",...s})=>e.jsx(N.HoverCardContent,{align:t,...s}),Se=t=>e.jsx(N.Dialog,{...t}),ke=t=>e.jsx(N.DialogTrigger,{...t}),De=({className:t,children:s,title:o="Model Selector",...l})=>e.jsxs(N.DialogContent,{className:g.cn("p-0",t),...l,children:[e.jsx(N.DialogTitle,{className:"sr-only",children:o}),e.jsx(N.Command,{className:"**:data-[slot=command-input-wrapper]:h-auto",children:s})]}),Pe=({className:t,...s})=>e.jsx(N.CommandInput,{className:g.cn("h-auto py-3.5",t),...s}),Te=t=>e.jsx(N.CommandList,{...t}),ze=t=>e.jsx(N.CommandGroup,{...t}),Ce=t=>e.jsx(N.CommandItem,{...t}),Ae=({provider:t,className:s,...o})=>e.jsx("img",{...o,alt:`${t} logo`,className:g.cn("size-3 dark:invert",s),height:12,src:`https://models.dev/logos/${t}.svg`,width:12}),Le=({className:t,...s})=>e.jsx("span",{className:g.cn("flex-1 truncate text-left",t),...s}),Re=({selectedModel:t,onModelChange:s,disabled:o=!1})=>{const[l,i]=c.useState(!1),[m,d]=c.useState(""),v=R.getModelById(t)||R.getDefaultModel(),y=R.AI_MODELS.filter(n=>n.name.toLowerCase().includes(m.toLowerCase())||n.provider.toLowerCase().includes(m.toLowerCase())).reduce((n,a)=>(n[a.provider]||(n[a.provider]=[]),n[a.provider].push(a),n),{}),P=n=>{s(n),i(!1),d("")};return e.jsxs(Se,{open:l,onOpenChange:i,children:[e.jsx(ke,{asChild:!0,children:e.jsxs(g.Button,{variant:"outline",size:"sm",disabled:o,className:"h-8 gap-1 px-2 text-xs",children:[e.jsx(S.Cpu,{size:14}),e.jsx("span",{className:"max-w-20 truncate",children:v.name})]})}),e.jsxs(De,{className:"w-96 p-0",children:[e.jsx(Pe,{placeholder:"Search models...",value:m,onValueChange:d}),e.jsx(Te,{children:Object.entries(y).map(([n,a])=>e.jsx(ze,{heading:n.charAt(0).toUpperCase()+n.slice(1),children:a.map(p=>e.jsxs(Ce,{value:p.id,onSelect:()=>P(p.id),className:"flex cursor-pointer items-center gap-2 p-2",children:[e.jsx(Ae,{provider:p.provider}),e.jsxs("div",{className:"flex flex-1 flex-col",children:[e.jsx(Le,{children:p.name}),e.jsx("span",{className:"text-xs text-muted-foreground",children:p.description})]}),t===p.id&&e.jsx("div",{className:"h-2 w-2 rounded-full bg-blue-500"})]},p.id))},n))})]})]})},_="chai-ai-selected-model",Me=({input:t,setInput:s,onSend:o,onStop:l,isLoading:i,disabled:m,selectedLang:d,selectedModel:v=R.getDefaultModel().id,onModelChange:h})=>{const{t:y}=se.useTranslation(),[P,n]=c.useState(v),[a,p]=c.useState(null),D=c.useRef(null),[I,k]=c.useState(!1);c.useEffect(()=>{if(!d){const x=localStorage.getItem(_);if(x)n(x),h==null||h(x);else{const C=R.getDefaultModel().id;n(C),h==null||h(C)}}},[d,h]);const z=x=>{var U;const C=x.files.find(T=>{var L;return(L=T.mediaType)==null?void 0:L.startsWith("image/")}),M=(C==null?void 0:C.url)||a;o((U=x.text)==null?void 0:U.trim(),void 0,M,P),p(null)};return e.jsx("div",{className:"relative",children:e.jsx("div",{className:"border-gray-20 rounded-lg border",children:e.jsxs(me,{onSubmit:z,accept:"image/*",className:"flex h-auto w-full flex-col",children:[e.jsx(he,{className:"p-0",children:e.jsx(de,{className:"pb-0",children:x=>e.jsx(ue,{className:"text-xs",data:x})})}),e.jsx(fe,{ref:D,value:t,onChange:x=>s(x.target.value),placeholder:y(d?"Ask to update content":"Ask me anything..."),disabled:i,className:"max-h-[200px] min-h-[60px] w-full",rows:3}),e.jsxs(xe,{children:[d?e.jsx("div",{}):e.jsxs(ge,{children:[e.jsxs(ve,{children:[e.jsx(je,{disabled:i,children:e.jsx(S.Paperclip,{size:16})}),e.jsx(be,{children:e.jsx(pe,{})})]}),e.jsx(Ne,{textareaRef:D,onTranscriptionChange:s,disabled:i}),e.jsx(Re,{selectedModel:P,onModelChange:x=>{n(x),h==null||h(x),localStorage.setItem(_,x)},disabled:i}),e.jsxs(F,{className:"hidden",size:"sm",onClick:()=>k(!I),variant:I?"default":"ghost",children:[e.jsx(S.GlobeIcon,{size:16}),e.jsx("span",{children:"Search"})]})]}),i?e.jsxs("button",{onClick:l,className:"z-50 flex items-center gap-x-1 rounded-md bg-red-500 p-1.5 text-white transition-colors hover:bg-red-600",title:y("Stop generation"),children:[e.jsx(S.Square,{size:16})," ",e.jsx("span",{className:"text-xs",children:y("Stop")})]}):e.jsx(we,{disabled:!t.trim()||m,children:e.jsx(S.Send,{size:16})})]})]})})})};exports.default=Me;
1
+ "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const e=require("react/jsx-runtime"),g=require("./register-chai-top-bar-BqwKw4uy.cjs"),N=require("./index-xYnNKovy.cjs"),W=require("class-variance-authority"),S=require("lucide-react"),te=require("nanoid"),c=require("react"),se=require("react-i18next"),R=require("./models-5gOsRC56.cjs");function ne({className:t,...s}){return e.jsx("div",{"data-slot":"input-group",role:"group",className:g.cn("group/input-group shadow-xs relative flex w-full items-center rounded-md border border-input outline-none transition-[color,box-shadow] dark:bg-input/30","h-9 has-[>textarea]:h-auto","has-[>[data-align=inline-start]]:[&>input]:pl-2","has-[>[data-align=inline-end]]:[&>input]:pr-2","has-[>[data-align=block-start]]:h-auto has-[>[data-align=block-start]]:flex-col has-[>[data-align=block-start]]:[&>input]:pb-3","has-[>[data-align=block-end]]:h-auto has-[>[data-align=block-end]]:flex-col has-[>[data-align=block-end]]:[&>input]:pt-3","has-[[data-slot=input-group-control]:focus-visible]:ring-1 has-[[data-slot=input-group-control]:focus-visible]:ring-ring","has-[[data-slot][aria-invalid=true]]:border-destructive has-[[data-slot][aria-invalid=true]]:ring-destructive/20 dark:has-[[data-slot][aria-invalid=true]]:ring-destructive/40",t),...s})}const re=W.cva("text-muted-foreground flex h-auto cursor-text select-none items-center justify-center gap-2 py-1.5 text-sm font-medium group-data-[disabled=true]/input-group:opacity-50 [&>kbd]:rounded-[calc(var(--radius)-5px)] [&>svg:not([class*='size-'])]:size-4",{variants:{align:{"inline-start":"order-first pl-3 has-[>button]:ml-[-0.45rem] has-[>kbd]:ml-[-0.35rem]","inline-end":"order-last pr-3 has-[>button]:mr-[-0.4rem] has-[>kbd]:mr-[-0.35rem]","block-start":"[.border-b]:pb-3 order-first w-full justify-start px-3 pt-3 group-has-[>input]/input-group:pt-2.5","block-end":"[.border-t]:pt-3 order-last w-full justify-start px-3 pb-3 group-has-[>input]/input-group:pb-2.5"}},defaultVariants:{align:"inline-start"}});function H({className:t,align:s="inline-start",...o}){return e.jsx("div",{role:"group","data-slot":"input-group-addon","data-align":s,className:g.cn(re({align:s}),t),onClick:l=>{var i,m;l.target.closest("button")||(m=(i=l.currentTarget.parentElement)==null?void 0:i.querySelector("input"))==null||m.focus()},...o})}const ae=W.cva("flex items-center gap-2 text-sm shadow-none",{variants:{size:{xs:"h-6 gap-1 rounded-[calc(var(--radius)-5px)] px-2 has-[>svg]:px-2 [&>svg:not([class*='size-'])]:size-3.5",sm:"h-8 gap-1.5 rounded-md px-2.5 has-[>svg]:px-2.5","icon-xs":"size-6 rounded-[calc(var(--radius)-5px)] p-0 has-[>svg]:p-0","icon-sm":"size-8 p-0 has-[>svg]:p-0"}},defaultVariants:{size:"xs"}});function K({className:t,type:s="button",variant:o="ghost",size:l="xs",...i}){return e.jsx(g.Button,{type:s,"data-size":l,variant:o,className:g.cn(ae({size:l}),t),...i})}function oe({className:t,...s}){return e.jsx(N.Textarea,{"data-slot":"input-group-control",className:g.cn("flex-1 resize-none rounded-none border-0 bg-transparent py-3 shadow-none focus-visible:ring-0 dark:bg-transparent",t),...s})}const ie=c.createContext(null),ce=c.createContext(null),X=()=>c.useContext(ie),le=()=>c.useContext(ce),$=c.createContext(null),q=()=>{const t=le(),s=c.useContext($),o=t??s;if(!o)throw new Error("usePromptInputAttachments must be used within a PromptInput or PromptInputProvider");return o};function ue({data:t,className:s,...o}){var h;const l=q(),i=t.filename||"",d=((h=t.mediaType)!=null&&h.startsWith("image/")&&t.url?"image":"file")==="image",v=i||(d?"Image":"Attachment");return e.jsxs(Ie,{children:[e.jsx(N.HoverCardTrigger,{asChild:!0,children:e.jsxs("div",{className:g.cn("group relative flex h-8 cursor-default select-none items-center gap-1.5 rounded-md border border-border px-1.5 text-sm font-medium transition-all hover:bg-accent hover:text-accent-foreground dark:hover:bg-accent/50",s),...o,children:[e.jsxs("div",{className:"relative size-5 shrink-0",children:[e.jsx("div",{className:"absolute inset-0 flex size-5 items-center justify-center overflow-hidden rounded bg-background transition-opacity group-hover:opacity-0",children:d?e.jsx("img",{alt:i||"attachment",className:"size-5 object-cover",height:20,src:t.url,width:20}):e.jsx("div",{className:"flex size-5 items-center justify-center text-muted-foreground",children:e.jsx(S.PaperclipIcon,{className:"size-3"})})}),e.jsxs(g.Button,{"aria-label":"Remove attachment",className:"absolute inset-0 size-5 cursor-pointer rounded p-0 opacity-0 transition-opacity group-hover:pointer-events-auto group-hover:opacity-100 [&>svg]:size-2.5",onClick:y=>{y.stopPropagation(),l.remove(t.id)},type:"button",variant:"ghost",children:[e.jsx(S.XIcon,{}),e.jsx("span",{className:"sr-only",children:"Remove"})]})]}),e.jsx("span",{className:"flex-1 truncate",children:v})]},t.id)}),e.jsx(ye,{className:"w-auto p-2",children:e.jsxs("div",{className:"w-auto space-y-3",children:[d&&e.jsx("div",{className:"flex max-h-96 w-96 items-center justify-center overflow-hidden rounded-md border",children:e.jsx("img",{alt:i||"attachment preview",className:"max-h-full max-w-full object-contain",height:384,src:t.url,width:448})}),e.jsx("div",{className:"flex items-center gap-2.5",children:e.jsxs("div",{className:"min-w-0 flex-1 space-y-1 px-0.5",children:[e.jsx("h4",{className:"truncate text-sm font-semibold leading-none",children:i||(d?"Image":"Attachment")}),t.mediaType&&e.jsx("p",{className:"truncate font-mono text-xs text-muted-foreground",children:t.mediaType})]})})]})})]})}function de({children:t,className:s,...o}){const l=q();return l.files.length?e.jsx("div",{className:g.cn("flex flex-wrap items-center gap-2 p-3",s),...o,children:l.files.map(i=>e.jsx(c.Fragment,{children:t(i)},i.id))}):null}const pe=({label:t="Add photos or files",...s})=>{const o=q();return e.jsxs(N.DropdownMenuItem,{...s,onSelect:l=>{l.preventDefault(),o.openFileDialog()},children:[e.jsx(S.ImageIcon,{className:"mr-2 size-4"})," ",t]})},me=({className:t,accept:s,multiple:o,globalDrop:l,syncHiddenInput:i,maxFiles:m,maxFileSize:d,onError:v,onSubmit:h,children:y,...P})=>{const n=X(),a=!!n,p=c.useRef(null),D=c.useRef(null),I=c.useRef(null);c.useEffect(()=>{var j;const r=(j=D.current)==null?void 0:j.closest("form");r instanceof HTMLFormElement&&(I.current=r)},[]);const[k,z]=c.useState([]),x=a?n.attachments.files:k,C=c.useCallback(()=>{var r;(r=p.current)==null||r.click()},[]),M=c.useCallback(r=>!s||s.trim()===""?!0:s.includes("image/*")?r.type.startsWith("image/"):!0,[s]),U=c.useCallback(r=>{const j=Array.from(r),f=j.filter(w=>M(w));if(j.length&&f.length===0){v==null||v({code:"accept",message:"No files match the accepted types."});return}const u=w=>d?w.size<=d:!0,b=f.filter(u);if(f.length>0&&b.length===0){v==null||v({code:"max_file_size",message:"All files exceed the maximum size."});return}z(w=>{const A=typeof m=="number"?Math.max(0,m-w.length):void 0,ee=typeof A=="number"?b.slice(0,A):b;typeof A=="number"&&b.length>A&&(v==null||v({code:"max_files",message:"Too many files. Some were not added."}));const V=[];for(const E of ee)V.push({id:te.nanoid(),type:"file",url:URL.createObjectURL(E),mediaType:E.type,filename:E.name});return w.concat(V)})},[M,m,d,v]),T=a?r=>n.attachments.add(r):U,L=a?r=>n.attachments.remove(r):r=>z(j=>{const f=j.find(u=>u.id===r);return f!=null&&f.url&&URL.revokeObjectURL(f.url),j.filter(u=>u.id!==r)}),O=a?()=>n.attachments.clear():()=>z(r=>{for(const j of r)j.url&&URL.revokeObjectURL(j.url);return[]}),B=a?()=>n.attachments.openFileDialog():C;c.useEffect(()=>{a&&n.__registerFileInput(p,()=>{var r;return(r=p.current)==null?void 0:r.click()})},[a,n]),c.useEffect(()=>{i&&p.current&&x.length===0&&(p.current.value="")},[x,i]),c.useEffect(()=>{const r=I.current;if(!r)return;const j=u=>{var b,w;(w=(b=u.dataTransfer)==null?void 0:b.types)!=null&&w.includes("Files")&&u.preventDefault()},f=u=>{var b,w,A;(w=(b=u.dataTransfer)==null?void 0:b.types)!=null&&w.includes("Files")&&u.preventDefault(),(A=u.dataTransfer)!=null&&A.files&&u.dataTransfer.files.length>0&&T(u.dataTransfer.files)};return r.addEventListener("dragover",j),r.addEventListener("drop",f),()=>{r.removeEventListener("dragover",j),r.removeEventListener("drop",f)}},[T]),c.useEffect(()=>{if(!l)return;const r=f=>{var u,b;(b=(u=f.dataTransfer)==null?void 0:u.types)!=null&&b.includes("Files")&&f.preventDefault()},j=f=>{var u,b,w;(b=(u=f.dataTransfer)==null?void 0:u.types)!=null&&b.includes("Files")&&f.preventDefault(),(w=f.dataTransfer)!=null&&w.files&&f.dataTransfer.files.length>0&&T(f.dataTransfer.files)};return document.addEventListener("dragover",r),document.addEventListener("drop",j),()=>{document.removeEventListener("dragover",r),document.removeEventListener("drop",j)}},[T,l]),c.useEffect(()=>()=>{if(!a)for(const r of x)r.url&&URL.revokeObjectURL(r.url)},[a,x]);const Y=r=>{r.currentTarget.files&&T(r.currentTarget.files)},J=async r=>{const f=await(await fetch(r)).blob();return new Promise((u,b)=>{const w=new FileReader;w.onloadend=()=>u(w.result),w.onerror=b,w.readAsDataURL(f)})},Q=c.useMemo(()=>({files:x.map(r=>({...r,id:r.id})),add:T,remove:L,clear:O,openFileDialog:B,fileInputRef:p}),[x,T,L,O,B]),Z=r=>{r.preventDefault();const j=r.currentTarget,f=a?n.textInput.value:new FormData(j).get("message")||"";a||j.reset(),Promise.all(x.map(async({...u})=>u.url&&u.url.startsWith("blob:")?{...u,url:await J(u.url)}:u)).then(u=>{try{const b=h({text:f,files:u},r);b instanceof Promise?b.then(()=>{O(),a&&n.textInput.clear()}).catch(()=>{}):(O(),a&&n.textInput.clear())}catch{}})},G=e.jsxs(e.Fragment,{children:[e.jsx("span",{"aria-hidden":"true",className:"hidden",ref:D}),e.jsx("input",{accept:s,"aria-label":"Upload files",className:"hidden",multiple:o,onChange:Y,ref:p,title:"Upload files",type:"file"}),e.jsx("form",{className:g.cn("w-full",t),onSubmit:Z,...P,children:e.jsx(ne,{className:"overflow-hidden",children:y})})]});return a?G:e.jsx($.Provider,{value:Q,children:G})},fe=({onChange:t,className:s,placeholder:o="What would you like to know?",...l})=>{const i=X(),m=q(),[d,v]=c.useState(!1),h=n=>{if(n.key==="Enter"){if(d||n.nativeEvent.isComposing||n.shiftKey)return;n.preventDefault();const a=n.currentTarget.form,p=a==null?void 0:a.querySelector('button[type="submit"]');if(p!=null&&p.disabled)return;a==null||a.requestSubmit()}if(n.key==="Backspace"&&n.currentTarget.value===""&&m.files.length>0){n.preventDefault();const a=m.files.at(-1);a&&m.remove(a.id)}},y=n=>{var D;const a=(D=n.clipboardData)==null?void 0:D.items;if(!a)return;const p=[];for(const I of a)if(I.kind==="file"){const k=I.getAsFile();k&&p.push(k)}p.length>0&&(n.preventDefault(),m.add(p))},P=i?{value:i.textInput.value,onChange:n=>{i.textInput.setInput(n.currentTarget.value),t==null||t(n)}}:{onChange:t};return e.jsx(oe,{className:g.cn("field-sizing-content max-h-48 min-h-16",s),name:"message",onCompositionEnd:()=>v(!1),onCompositionStart:()=>v(!0),onKeyDown:h,onPaste:y,placeholder:o,...l,...P})},he=({className:t,...s})=>e.jsx(H,{align:"block-end",className:g.cn("order-first flex-wrap gap-1",t),...s}),xe=({className:t,...s})=>e.jsx(H,{align:"block-end",className:g.cn("justify-between gap-1",t),...s}),ge=({className:t,...s})=>e.jsx("div",{className:g.cn("flex items-center gap-1",t),...s}),F=({variant:t="ghost",className:s,size:o,...l})=>{const i=o??(c.Children.count(l.children)>1?"sm":"icon-sm");return e.jsx(K,{className:g.cn(s),size:i,type:"button",variant:t,...l})},ve=t=>e.jsx(N.DropdownMenu,{...t}),je=({className:t,children:s,...o})=>e.jsx(N.DropdownMenuTrigger,{asChild:!0,children:e.jsx(F,{className:t,...o,children:s??e.jsx(S.PlusIcon,{className:"size-4"})})}),be=({className:t,...s})=>e.jsx(N.DropdownMenuContent,{align:"start",className:g.cn(t),...s}),we=({className:t,variant:s="default",size:o="icon-sm",status:l,children:i,...m})=>{let d=e.jsx(S.CornerDownLeftIcon,{className:"size-4"});return l==="submitted"?d=e.jsx(S.Loader2Icon,{className:"size-4 animate-spin"}):l==="streaming"?d=e.jsx(S.SquareIcon,{className:"size-4"}):l==="error"&&(d=e.jsx(S.XIcon,{className:"size-4"})),e.jsx(K,{"aria-label":"Submit",className:g.cn(t),size:o,type:"submit",variant:s,...m,children:i??d})},Ne=({className:t,textareaRef:s,onTranscriptionChange:o,...l})=>{const[i,m]=c.useState(!1),[d,v]=c.useState(null),h=c.useRef(null);c.useEffect(()=>{if(typeof window<"u"&&("SpeechRecognition"in window||"webkitSpeechRecognition"in window)){const P=window.SpeechRecognition||window.webkitSpeechRecognition,n=new P;n.continuous=!0,n.interimResults=!0,n.lang="en-US",n.onstart=()=>{m(!0)},n.onend=()=>{m(!1)},n.onresult=a=>{var D;let p="";for(let I=a.resultIndex;I<a.results.length;I++){const k=a.results[I];k.isFinal&&(p+=((D=k[0])==null?void 0:D.transcript)??"")}if(p&&(s!=null&&s.current)){const I=s.current,k=I.value,z=k+(k?" ":"")+p;I.value=z,I.dispatchEvent(new Event("input",{bubbles:!0})),o==null||o(z)}},n.onerror=a=>{console.error("Speech recognition error:",a.error),m(!1)},h.current=n,c.startTransition(()=>v(n))}return()=>{h.current&&h.current.stop()}},[s,o]);const y=c.useCallback(()=>{d&&(i?d.stop():d.start())},[d,i]);return e.jsx(F,{className:g.cn("relative transition-all duration-200",i&&"animate-pulse bg-accent text-accent-foreground",t),disabled:!d,onClick:y,...l,children:e.jsx(S.MicIcon,{className:"size-4"})})},Ie=({openDelay:t=0,closeDelay:s=0,...o})=>e.jsx(N.HoverCard,{closeDelay:s,openDelay:t,...o}),ye=({align:t="start",...s})=>e.jsx(N.HoverCardContent,{align:t,...s}),Se=t=>e.jsx(N.Dialog,{...t}),ke=t=>e.jsx(N.DialogTrigger,{...t}),De=({className:t,children:s,title:o="Model Selector",...l})=>e.jsxs(N.DialogContent,{className:g.cn("p-0",t),...l,children:[e.jsx(N.DialogTitle,{className:"sr-only",children:o}),e.jsx(N.Command,{className:"**:data-[slot=command-input-wrapper]:h-auto",children:s})]}),Pe=({className:t,...s})=>e.jsx(N.CommandInput,{className:g.cn("h-auto py-3.5",t),...s}),Te=t=>e.jsx(N.CommandList,{...t}),ze=t=>e.jsx(N.CommandGroup,{...t}),Ce=t=>e.jsx(N.CommandItem,{...t}),Ae=({provider:t,className:s,...o})=>e.jsx("img",{...o,alt:`${t} logo`,className:g.cn("size-3 dark:invert",s),height:12,src:`https://models.dev/logos/${t}.svg`,width:12}),Le=({className:t,...s})=>e.jsx("span",{className:g.cn("flex-1 truncate text-left",t),...s}),Re=({selectedModel:t,onModelChange:s,disabled:o=!1})=>{const[l,i]=c.useState(!1),[m,d]=c.useState(""),v=R.getModelById(t)||R.getDefaultModel(),y=R.AI_MODELS.filter(n=>n.name.toLowerCase().includes(m.toLowerCase())||n.provider.toLowerCase().includes(m.toLowerCase())).reduce((n,a)=>(n[a.provider]||(n[a.provider]=[]),n[a.provider].push(a),n),{}),P=n=>{s(n),i(!1),d("")};return e.jsxs(Se,{open:l,onOpenChange:i,children:[e.jsx(ke,{asChild:!0,children:e.jsxs(g.Button,{variant:"outline",size:"sm",disabled:o,className:"h-8 gap-1 px-2 text-xs",children:[e.jsx(S.Cpu,{size:14}),e.jsx("span",{className:"max-w-20 truncate",children:v.name})]})}),e.jsxs(De,{className:"w-96 p-0",children:[e.jsx(Pe,{placeholder:"Search models...",value:m,onValueChange:d}),e.jsx(Te,{children:Object.entries(y).map(([n,a])=>e.jsx(ze,{heading:n.charAt(0).toUpperCase()+n.slice(1),children:a.map(p=>e.jsxs(Ce,{value:p.id,onSelect:()=>P(p.id),className:"flex cursor-pointer items-center gap-2 p-2",children:[e.jsx(Ae,{provider:p.provider}),e.jsxs("div",{className:"flex flex-1 flex-col",children:[e.jsx(Le,{children:p.name}),e.jsx("span",{className:"text-xs text-muted-foreground",children:p.description})]}),t===p.id&&e.jsx("div",{className:"h-2 w-2 rounded-full bg-blue-500"})]},p.id))},n))})]})]})},_="chai-ai-selected-model",Me=({input:t,setInput:s,onSend:o,onStop:l,isLoading:i,disabled:m,selectedLang:d,selectedModel:v=R.getDefaultModel().id,onModelChange:h})=>{const{t:y}=se.useTranslation(),[P,n]=c.useState(v),[a,p]=c.useState(null),D=c.useRef(null),[I,k]=c.useState(!1);c.useEffect(()=>{if(!d){const x=localStorage.getItem(_);if(x)n(x),h==null||h(x);else{const C=R.getDefaultModel().id;n(C),h==null||h(C)}}},[d,h]);const z=x=>{var U;const C=x.files.find(T=>{var L;return(L=T.mediaType)==null?void 0:L.startsWith("image/")}),M=(C==null?void 0:C.url)||a;o((U=x.text)==null?void 0:U.trim(),void 0,M,P),p(null)};return e.jsx("div",{className:"relative",children:e.jsx("div",{className:"border-gray-20 rounded-lg border",children:e.jsxs(me,{onSubmit:z,accept:"image/*",className:"flex h-auto w-full flex-col",children:[e.jsx(he,{className:"p-0",children:e.jsx(de,{className:"pb-0",children:x=>e.jsx(ue,{className:"text-xs",data:x})})}),e.jsx(fe,{ref:D,value:t,onChange:x=>s(x.target.value),placeholder:y(d?"Ask to update content":"Ask me anything..."),disabled:i,className:"max-h-[200px] min-h-[60px] w-full",rows:3}),e.jsxs(xe,{children:[d?e.jsx("div",{}):e.jsxs(ge,{children:[e.jsxs(ve,{children:[e.jsx(je,{disabled:i,children:e.jsx(S.Paperclip,{size:16})}),e.jsx(be,{children:e.jsx(pe,{})})]}),e.jsx(Ne,{textareaRef:D,onTranscriptionChange:s,disabled:i}),e.jsx(Re,{selectedModel:P,onModelChange:x=>{n(x),h==null||h(x),localStorage.setItem(_,x)},disabled:i}),e.jsxs(F,{className:"hidden",size:"sm",onClick:()=>k(!I),variant:I?"default":"ghost",children:[e.jsx(S.GlobeIcon,{size:16}),e.jsx("span",{children:"Search"})]})]}),i?e.jsxs("button",{onClick:l,className:"z-50 flex items-center gap-x-1 rounded-md bg-red-500 p-1.5 text-white transition-colors hover:bg-red-600",title:y("Stop generation"),children:[e.jsx(S.Square,{size:16})," ",e.jsx("span",{className:"text-xs",children:y("Stop")})]}):e.jsx(we,{disabled:!t.trim()||m,children:e.jsx(S.Send,{size:16})})]})]})})})};exports.default=Me;
@@ -1 +1 @@
1
- "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const e=require("react/jsx-runtime"),r=require("./register-chai-top-bar-BqwKw4uy.cjs"),i=require("./index-C0-pgg_p.cjs"),c=require("lucide-react"),o=require("react-i18next"),x=({selectedLang:s,isLoading:n,selectedBlock:a,onClick:l})=>{const{t}=o.useTranslation();return e.jsx("div",{className:"flex flex-col gap-2",children:e.jsx("div",{className:`flex flex-col gap-2 ${n?"pointer-events-none opacity-50":""}`,children:a?e.jsx(r.Button,{variant:"outline",className:"h-auto",onClick:()=>l("TRANSLATE"),children:e.jsxs("div",{className:"flex flex-col",children:[e.jsx("p",{className:"text-left text-xs font-thin",children:t("Quick Action:")}),e.jsxs("span",{className:"flex items-center gap-x-2 text-sm font-medium",children:[t("Translate Content")," ",t("to")," ",i.LANGUAGES[s]," ",e.jsx(c.ArrowRight,{className:"h-4 w-4"})]})]})}):null})})};exports.default=x;
1
+ "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const e=require("react/jsx-runtime"),r=require("./register-chai-top-bar-BqwKw4uy.cjs"),i=require("./index-BwH1mRm_.cjs"),c=require("lucide-react"),o=require("react-i18next"),x=({selectedLang:s,isLoading:n,selectedBlock:a,onClick:l})=>{const{t}=o.useTranslation();return e.jsx("div",{className:"flex flex-col gap-2",children:e.jsx("div",{className:`flex flex-col gap-2 ${n?"pointer-events-none opacity-50":""}`,children:a?e.jsx(r.Button,{variant:"outline",className:"h-auto",onClick:()=>l("TRANSLATE"),children:e.jsxs("div",{className:"flex flex-col",children:[e.jsx("p",{className:"text-left text-xs font-thin",children:t("Quick Action:")}),e.jsxs("span",{className:"flex items-center gap-x-2 text-sm font-medium",children:[t("Translate Content")," ",t("to")," ",i.LANGUAGES[s]," ",e.jsx(c.ArrowRight,{className:"h-4 w-4"})]})]})}):null})})};exports.default=x;
@@ -1,6 +1,6 @@
1
1
  import { jsx as t, jsxs as a } from "react/jsx-runtime";
2
2
  import { B as r } from "./register-chai-top-bar-ESJHs5s-.js";
3
- import { L as i } from "./index-Dno42B0a.js";
3
+ import { L as i } from "./index-B7eWP_hB.js";
4
4
  import { ArrowRight as c } from "lucide-react";
5
5
  import { useTranslation as m } from "react-i18next";
6
6
  const u = ({
@@ -1 +1 @@
1
- "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const t=require("react/jsx-runtime"),o=require("./index-C99FhuF1.cjs"),k=require("@react-hookz/web"),c=require("react"),g=require("react-i18next"),x=l=>{const s=document.createElement("div");return s.innerHTML=l,s.innerHTML};function j(){const{t:l}=g.useTranslation(),[s,m]=c.useState(!1),[a,h]=c.useState(""),[e,i]=o.useCodeEditor(),[d]=o.useSelectedBlockIds(),p=o.useUpdateBlocksProps(),b=o.useUpdateBlocksPropsRealtime(),f=k.useThrottledCallback(n=>{if(!e)return;const r=x(n);b([e.blockId],{[e.blockProp]:r})},[],300),u=c.useCallback(()=>{if(s&&e){const n=x(a);p([e.blockId],{[e.blockProp]:n})}},[s,a,e]);c.useEffect(()=>{e&&!d.includes(e.blockId)&&(u(),i(null))},[d,e]);const C=()=>{u(),i(null)};return t.jsx(o.Dialog,{open:!0,onOpenChange:C,children:t.jsxs(o.DialogContent,{className:"flex max-h-[400px] min-h-[200px] max-w-4xl flex-col border-gray-700 text-black",children:[t.jsx(o.DialogHeader,{className:"shrink-0 border-b border-gray-700 pb-3",children:t.jsx(o.DialogTitle,{className:"flex items-center justify-between text-black",children:t.jsxs("div",{className:"space-x-3 text-sm font-semibold",children:[t.jsx("span",{children:l("HTML Code Editor |")}),t.jsx("span",{className:"text-xs text-gray-400",children:l("Scripts will be only executed in preview and live mode.")})]})})}),t.jsx("div",{className:"min-h-0 flex-1 overflow-hidden",children:t.jsx(o.Textarea,{className:"h-full w-full resize-none font-mono text-xs",value:e?a||e.initialCode:"",onChange:n=>{const r=n.target.value;m(!0),h(r),f(r)},rows:10,placeholder:"Enter your code here..."})})]})})}exports.default=j;
1
+ "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const t=require("react/jsx-runtime"),o=require("./index-xYnNKovy.cjs"),k=require("@react-hookz/web"),c=require("react"),g=require("react-i18next"),x=l=>{const s=document.createElement("div");return s.innerHTML=l,s.innerHTML};function j(){const{t:l}=g.useTranslation(),[s,m]=c.useState(!1),[a,h]=c.useState(""),[e,i]=o.useCodeEditor(),[d]=o.useSelectedBlockIds(),p=o.useUpdateBlocksProps(),b=o.useUpdateBlocksPropsRealtime(),f=k.useThrottledCallback(n=>{if(!e)return;const r=x(n);b([e.blockId],{[e.blockProp]:r})},[],300),u=c.useCallback(()=>{if(s&&e){const n=x(a);p([e.blockId],{[e.blockProp]:n})}},[s,a,e]);c.useEffect(()=>{e&&!d.includes(e.blockId)&&(u(),i(null))},[d,e]);const C=()=>{u(),i(null)};return t.jsx(o.Dialog,{open:!0,onOpenChange:C,children:t.jsxs(o.DialogContent,{className:"flex max-h-[400px] min-h-[200px] max-w-4xl flex-col border-gray-700 text-black",children:[t.jsx(o.DialogHeader,{className:"shrink-0 border-b border-gray-700 pb-3",children:t.jsx(o.DialogTitle,{className:"flex items-center justify-between text-black",children:t.jsxs("div",{className:"space-x-3 text-sm font-semibold",children:[t.jsx("span",{children:l("HTML Code Editor |")}),t.jsx("span",{className:"text-xs text-gray-400",children:l("Scripts will be only executed in preview and live mode.")})]})})}),t.jsx("div",{className:"min-h-0 flex-1 overflow-hidden",children:t.jsx(o.Textarea,{className:"h-full w-full resize-none font-mono text-xs",value:e?a||e.initialCode:"",onChange:n=>{const r=n.target.value;m(!0),h(r),f(r)},rows:10,placeholder:"Enter your code here..."})})]})})}exports.default=j;
@@ -1,5 +1,5 @@
1
1
  import { jsx as o, jsxs as d } from "react/jsx-runtime";
2
- import { u as C, a as k, b as v, c as T, D as g, d as y, e as E, f as w, T as N } from "./index-rAcNbjk_.js";
2
+ import { u as C, a as k, b as v, c as T, D as g, d as y, e as E, f as w, T as N } from "./index-RYr8kQdI.js";
3
3
  import { useThrottledCallback as D } from "@react-hookz/web";
4
4
  import { useState as m, useCallback as H, useEffect as P } from "react";
5
5
  import { useTranslation as B } from "react-i18next";
@@ -1,7 +1,7 @@
1
1
  import { jsx as e, jsxs as t } from "react/jsx-runtime";
2
2
  import { B as r } from "./register-chai-top-bar-ESJHs5s-.js";
3
- import { R as o, U as c, V as i, W as l, X as m } from "./index-rAcNbjk_.js";
4
- import { b as d, B as h } from "./index-Dno42B0a.js";
3
+ import { R as o, U as c, V as i, W as l, X as m } from "./index-RYr8kQdI.js";
4
+ import { b as d, B as h } from "./index-B7eWP_hB.js";
5
5
  import { CheckCircle as u, Check as p } from "lucide-react";
6
6
  import { useTranslation as C } from "react-i18next";
7
7
  const y = () => {
@@ -1 +1 @@
1
- "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const e=require("react/jsx-runtime"),i=require("./register-chai-top-bar-BqwKw4uy.cjs"),s=require("./index-C99FhuF1.cjs"),a=require("./index-C0-pgg_p.cjs"),n=require("lucide-react"),l=require("react-i18next"),o=()=>{const{setPageLockMeta:r}=a.usePageLockMeta(),{t}=l.useTranslation(),c=async()=>{r({})};return e.jsx(a.BlurContainer,{children:e.jsxs(s.Card,{className:"mx-auto w-full max-w-md",children:[e.jsx(s.CardHeader,{className:"space-y-1",children:e.jsxs(s.CardTitle,{className:"flex items-center gap-2 text-xl",children:[e.jsx(n.CheckCircle,{className:"h-6 w-6 text-green-500"}),t("You can edit the page now")]})}),e.jsx(s.CardContent,{className:"space-y-4",children:e.jsx("p",{className:"text-sm text-muted-foreground",children:t("This page is released by other user you can continue editing now")})}),e.jsx(s.CardFooter,{className:"flex gap-2",children:e.jsxs(i.Button,{variant:"default",onClick:c,className:"flex-1 gap-2",children:[e.jsx(n.Check,{className:"h-4 w-4"}),t("Continue Editing")]})})]})})};exports.default=o;
1
+ "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const e=require("react/jsx-runtime"),i=require("./register-chai-top-bar-BqwKw4uy.cjs"),s=require("./index-xYnNKovy.cjs"),a=require("./index-BwH1mRm_.cjs"),n=require("lucide-react"),l=require("react-i18next"),o=()=>{const{setPageLockMeta:r}=a.usePageLockMeta(),{t}=l.useTranslation(),c=async()=>{r({})};return e.jsx(a.BlurContainer,{children:e.jsxs(s.Card,{className:"mx-auto w-full max-w-md",children:[e.jsx(s.CardHeader,{className:"space-y-1",children:e.jsxs(s.CardTitle,{className:"flex items-center gap-2 text-xl",children:[e.jsx(n.CheckCircle,{className:"h-6 w-6 text-green-500"}),t("You can edit the page now")]})}),e.jsx(s.CardContent,{className:"space-y-4",children:e.jsx("p",{className:"text-sm text-muted-foreground",children:t("This page is released by other user you can continue editing now")})}),e.jsx(s.CardFooter,{className:"flex gap-2",children:e.jsxs(i.Button,{variant:"default",onClick:c,className:"flex-1 gap-2",children:[e.jsx(n.Check,{className:"h-4 w-4"}),t("Continue Editing")]})})]})})};exports.default=o;
package/dist/core.cjs CHANGED
@@ -1 +1 @@
1
- "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const e=require("./index-C99FhuF1.cjs"),r=require("./common-functions-B3a4xKt_.cjs"),a=require("./apply-binding-IsUf6UWJ.cjs");require("lodash-es");const i=require("./register-chai-top-bar-BqwKw4uy.cjs"),t=require("i18next");exports.ChaiAddBlocksDialog=e.AddBlocksDialog;exports.ChaiAddBlocksPanel=e.AddBlocksPanel;exports.ChaiAskAiUserPrompt=e.AIUserPrompt;exports.ChaiBlockAttributesEditor=e.BlockAttributesEditor;exports.ChaiBlockPropsEditor=e.BlockSettings;exports.ChaiBlockStyleEditor=e.BlockStyling;exports.ChaiBuilderCanvas=e.CanvasArea;exports.ChaiBuilderEditor=e.ChaiBuilderEditor;exports.ChaiDarkModeSwitcher=e.DarkMode;exports.ChaiDefaultBlocks=e.DefaultChaiBlocks;exports.ChaiDraggableBlock=e.ChaiDraggableBlock;exports.ChaiExportCodeModal=e.ExportCodeModal;exports.ChaiImportHTML=e.ImportHTML;exports.ChaiOutline=e.ListTree;exports.ChaiScreenSizes=e.Breakpoints;exports.ChaiThemeConfigPanel=e.ThemeConfigPanel;exports.ChaiUILibrariesPanel=e.UILibrariesPanel;exports.ChaiUndoRedo=e.UndoRedo;exports.PERMISSIONS=e.PERMISSIONS;exports.getClassValueAndUnit=e.getClassValueAndUnit;exports.generateBlockId=r.generateUUID;exports.mergeClasses=r.cn;exports.convertHTMLToChaiBlocks=a.getBlocksFromHTML;exports.getBlocksFromHTML=a.getBlocksFromHTML;exports.registerBlockSettingField=i.registerBlockSettingField;exports.registerBlockSettingTemplate=i.registerBlockSettingTemplate;exports.registerBlockSettingWidget=i.registerBlockSettingWidget;exports.registerChaiAddBlockTab=i.registerChaiAddBlockTab;exports.registerChaiLibrary=i.registerChaiLibrary;exports.registerChaiMediaManager=i.registerChaiMediaManager;exports.registerChaiPreImportHTMLHook=i.registerChaiPreImportHTMLHook;exports.registerChaiSaveToLibrary=i.registerChaiSaveToLibrary;exports.registerChaiSidebarPanel=i.registerChaiSidebarPanel;exports.registerChaiTopBar=i.registerChaiTopBar;exports.useMediaManagerComponent=i.useMediaManagerComponent;exports.i18n=t;
1
+ "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const e=require("./index-xYnNKovy.cjs"),r=require("./common-functions-B3a4xKt_.cjs"),a=require("./apply-binding-IsUf6UWJ.cjs"),i=require("./register-chai-top-bar-BqwKw4uy.cjs"),t=require("i18next");exports.ChaiAddBlocksDialog=e.AddBlocksDialog;exports.ChaiAddBlocksPanel=e.AddBlocksPanel;exports.ChaiAskAiUserPrompt=e.AIUserPrompt;exports.ChaiBlockAttributesEditor=e.BlockAttributesEditor;exports.ChaiBlockPropsEditor=e.BlockSettings;exports.ChaiBlockStyleEditor=e.BlockStyling;exports.ChaiBuilderCanvas=e.CanvasArea;exports.ChaiBuilderEditor=e.ChaiBuilderEditor;exports.ChaiDarkModeSwitcher=e.DarkMode;exports.ChaiDefaultBlocks=e.DefaultChaiBlocks;exports.ChaiDraggableBlock=e.ChaiDraggableBlock;exports.ChaiExportCodeModal=e.ExportCodeModal;exports.ChaiImportHTML=e.ImportHTML;exports.ChaiOutline=e.ListTree;exports.ChaiScreenSizes=e.Breakpoints;exports.ChaiThemeConfigPanel=e.ThemeConfigPanel;exports.ChaiUILibrariesPanel=e.UILibrariesPanel;exports.ChaiUndoRedo=e.UndoRedo;exports.PERMISSIONS=e.PERMISSIONS;exports.getClassValueAndUnit=e.getClassValueAndUnit;exports.generateBlockId=r.generateUUID;exports.mergeClasses=r.cn;exports.convertHTMLToChaiBlocks=a.getBlocksFromHTML;exports.getBlocksFromHTML=a.getBlocksFromHTML;exports.registerBlockSettingField=i.registerBlockSettingField;exports.registerBlockSettingTemplate=i.registerBlockSettingTemplate;exports.registerBlockSettingWidget=i.registerBlockSettingWidget;exports.registerChaiAddBlockTab=i.registerChaiAddBlockTab;exports.registerChaiLibrary=i.registerChaiLibrary;exports.registerChaiMediaManager=i.registerChaiMediaManager;exports.registerChaiPreImportHTMLHook=i.registerChaiPreImportHTMLHook;exports.registerChaiSaveToLibrary=i.registerChaiSaveToLibrary;exports.registerChaiSidebarPanel=i.registerChaiSidebarPanel;exports.registerChaiTopBar=i.registerChaiTopBar;exports.useMediaManagerComponent=i.useMediaManagerComponent;exports.i18n=t;