@chaibuilder/sdk 4.0.0-beta.2 → 4.0.0-beta.3

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 (111) hide show
  1. package/dist/{2SSKDMRQ-C4VFVd-q.cjs → 2SSKDMRQ-BnsZi3K3.cjs} +1 -1
  2. package/dist/{2SSKDMRQ-DSnzF_1o.js → 2SSKDMRQ-CnSDkQcy.js} +2 -2
  3. package/dist/{AP7HFJJL-B7YYCY9q.cjs → AP7HFJJL-B31839PG.cjs} +1 -1
  4. package/dist/{AP7HFJJL-Cxwj01Aq.js → AP7HFJJL-CymCmW14.js} +1 -1
  5. package/dist/{IconPicker-RqVvq6G2.js → IconPicker-B1rWC-Ex.js} +1 -1
  6. package/dist/{IconPicker-C9-ieDWm.cjs → IconPicker-DREyo007.cjs} +1 -1
  7. package/dist/{WDYDFRGG-C7aSUcjs.js → WDYDFRGG-BUVnbAci.js} +2 -2
  8. package/dist/{WDYDFRGG-b3T2SQbz.cjs → WDYDFRGG-BxhOCHc3.cjs} +1 -1
  9. package/dist/{active-in-another-tab-Clng6zpY.cjs → active-in-another-tab-B47YjQGN.cjs} +1 -1
  10. package/dist/{active-in-another-tab-wb8qolB8.js → active-in-another-tab-CyjngVA6.js} +2 -2
  11. package/dist/{add-new-language-page-C4BuMTaN.cjs → add-new-language-page-88xzrUy8.cjs} +1 -1
  12. package/dist/{add-new-language-page-D7NDABl1.js → add-new-language-page-WmlCnytQ.js} +3 -3
  13. package/dist/{add-new-page-B4hc0B-g.js → add-new-page-VW2wAYZp.js} +2 -2
  14. package/dist/{add-new-page-BNfwKjRd.cjs → add-new-page-soZ8GAkN.cjs} +1 -1
  15. package/dist/{ai-panel-content-DPy2jgKw.cjs → ai-panel-content-7zCil042.cjs} +1 -1
  16. package/dist/{ai-panel-content-BnbURb7j.js → ai-panel-content-D_o7Q_A-.js} +3 -3
  17. package/dist/{ai-panel-default-lang-3tCHzab5.cjs → ai-panel-default-lang-COYaxNwn.cjs} +2 -2
  18. package/dist/{ai-panel-default-lang-oVk4TDeb.js → ai-panel-default-lang-DnElspF0.js} +3 -3
  19. package/dist/{ai-panel-other-lang-BBHCCSen.cjs → ai-panel-other-lang-CkynNlAU.cjs} +1 -1
  20. package/dist/{ai-panel-other-lang-DmQ3QMDD.js → ai-panel-other-lang-Dp0E9_Hx.js} +3 -3
  21. package/dist/{ai-prompt-input-DaTyfib-.js → ai-prompt-input-Bhc0ds7X.js} +1 -1
  22. package/dist/{ai-prompt-input-b5ty81RB.cjs → ai-prompt-input-CThbVp0_.cjs} +1 -1
  23. package/dist/{ai-translation-prompt-c0Q3zkT2.cjs → ai-translation-prompt-C2kJQFDX.cjs} +1 -1
  24. package/dist/{ai-translation-prompt-DJPe2O-n.js → ai-translation-prompt-CZ55HQmo.js} +2 -2
  25. package/dist/{code-display-Q3_sK_Ta.cjs → code-display-BnqzqzoP.cjs} +1 -1
  26. package/dist/{code-display-BzBq5xSn.js → code-display-DhD_RBcg.js} +1 -1
  27. package/dist/{code-editor-DWWnphW9.js → code-editor-DRIAnNbb.js} +1 -1
  28. package/dist/{code-editor-BQZi6-FB.cjs → code-editor-o3___nu2.cjs} +1 -1
  29. package/dist/{continue-editing-in-this-client-BllU94XG.js → continue-editing-in-this-client-CS2aQ7yY.js} +2 -2
  30. package/dist/{continue-editing-in-this-client-D9HyD4GP.cjs → continue-editing-in-this-client-CtMYsk-A.cjs} +1 -1
  31. package/dist/core.cjs +1 -1
  32. package/dist/core.js +1 -1
  33. package/dist/{css-import-modal-D72a-16X.js → css-import-modal-Byg6wV0O.js} +3 -4
  34. package/dist/css-import-modal-CyqkXWCO.cjs +13 -0
  35. package/dist/{delete-design-token-Cd1ZDtqT.js → delete-design-token-BRZZiWtQ.js} +1 -1
  36. package/dist/{delete-design-token-D_TLlO3I.cjs → delete-design-token-DkVs1oBf.cjs} +1 -1
  37. package/dist/{delete-page-DC8pzvWW.js → delete-page-BzyX9TN-.js} +2 -2
  38. package/dist/{delete-page-ByQwBupJ.cjs → delete-page-DxX7PFIE.cjs} +1 -1
  39. package/dist/{design-token-usage-BqZeR1sT.cjs → design-token-usage-CAHzEGgJ.cjs} +1 -1
  40. package/dist/{design-token-usage-DE4XCDdn.js → design-token-usage-xQs6SlaJ.js} +1 -1
  41. package/dist/{digital-asset-manager-BYLKFEYi.cjs → digital-asset-manager--uO8Agia.cjs} +1 -1
  42. package/dist/{digital-asset-manager-C_gL_0YY.js → digital-asset-manager-DbtwzxRz.js} +3 -3
  43. package/dist/{duplicate-page-BoVhko2q.js → duplicate-page-BR7Dlo9d.js} +3 -3
  44. package/dist/{duplicate-page-vdvwLQLo.cjs → duplicate-page-CaNAbXwV.cjs} +1 -1
  45. package/dist/{dynamic-page-selector-CSndg2-y.js → dynamic-page-selector-Cb5r_W8s.js} +2 -2
  46. package/dist/{dynamic-page-selector-DdnbCuQZ.cjs → dynamic-page-selector-Cxk_gjni.cjs} +1 -1
  47. package/dist/{image-editor-oypq8asR.js → image-editor-DV8kUKhl.js} +1 -1
  48. package/dist/{image-editor-DTspjj_c.cjs → image-editor-G-K28aTS.cjs} +1 -1
  49. package/dist/{index-S8ibZk9Q.js → index-Ct7ElCGK.js} +6 -6
  50. package/dist/{index-CnSjWE1P.cjs → index-DF5DEvqb.cjs} +2 -2
  51. package/dist/{index-CbwxUFy_.cjs → index-WQwzsC7A.cjs} +3 -3
  52. package/dist/{index-BDnwJqMw.js → index-ZuacEL1j.js} +122 -122
  53. package/dist/{json-diff-viewer-XX1pgabt.cjs → json-diff-viewer-D7z4zNvv.cjs} +1 -1
  54. package/dist/{json-diff-viewer-B5dr-Y_L.js → json-diff-viewer-krslPepD.js} +2 -2
  55. package/dist/{lang-panel-Cn83SRzd.js → lang-panel-BwIewMyw.js} +3 -3
  56. package/dist/{lang-panel-BPxex-M2.cjs → lang-panel-DT96k1xg.cjs} +1 -1
  57. package/dist/{manage-design-tokens-lP4HLS0P.js → manage-design-tokens-Caz_20VK.js} +2 -2
  58. package/dist/{manage-design-tokens-ConiyuPr.cjs → manage-design-tokens-CrmLe7UT.cjs} +1 -1
  59. package/dist/{mark-as-template-jncsjfHm.js → mark-as-template-D295ZQtU.js} +2 -2
  60. package/dist/{mark-as-template-DYRxre1f.cjs → mark-as-template-W3LmpiqN.cjs} +1 -1
  61. package/dist/{nested-path-selector-content-B-8LqhXI.js → nested-path-selector-content-CKYYK-C5.js} +1 -1
  62. package/dist/{nested-path-selector-content-BYtLi7mC.cjs → nested-path-selector-content-CoS_d3dc.cjs} +1 -1
  63. package/dist/{no-language-page-content-D_zd9Rb0.js → no-language-page-content-BvqRBP6y.js} +2 -2
  64. package/dist/{no-language-page-content-DAbLq0gX.cjs → no-language-page-content-DkfeMl90.cjs} +1 -1
  65. package/dist/{no-language-page-dialog-fXmbQO7L.cjs → no-language-page-dialog-BcEoqyQB.cjs} +1 -1
  66. package/dist/{no-language-page-dialog-C5Ps6YYL.js → no-language-page-dialog-PjNqTUpl.js} +2 -2
  67. package/dist/{page-creator-VWIB2VAs.cjs → page-creator-C4gc5NSC.cjs} +1 -1
  68. package/dist/{page-creator-wCMtlE6Z.js → page-creator-DiOITEMw.js} +3 -3
  69. package/dist/{page-lock-DweiYy1w.cjs → page-lock-BdYmCks0.cjs} +1 -1
  70. package/dist/{page-lock-BPCxfv9J.js → page-lock-Bfbs6RgL.js} +2 -2
  71. package/dist/{page-locked-dialog-BlbgvaG2.cjs → page-locked-dialog-B1FAtK92.cjs} +1 -1
  72. package/dist/{page-locked-dialog-ByGl18_m.js → page-locked-dialog-B6MKTRfY.js} +2 -2
  73. package/dist/{page-manager-new-D0lGfNnS.cjs → page-manager-new-CHDueBDk.cjs} +1 -1
  74. package/dist/{page-manager-new-BWFE-S-O.js → page-manager-new-CzX22g2n.js} +3 -3
  75. package/dist/{page-manager-search-and-filter-kNJFWJ86.js → page-manager-search-and-filter-CM0UMb6U.js} +2 -2
  76. package/dist/{page-manager-search-and-filter-DpGMoOII.cjs → page-manager-search-and-filter-DkkRIH86.cjs} +1 -1
  77. package/dist/{page-revisions-content-DYxXZqmh.cjs → page-revisions-content-ChY-4f2V.cjs} +1 -1
  78. package/dist/{page-revisions-content-Ulr8slUN.js → page-revisions-content-NH9JK4Ey.js} +3 -3
  79. package/dist/pages.cjs +1 -1
  80. package/dist/pages.d.ts +18 -19
  81. package/dist/pages.js +12 -12
  82. package/dist/{publish-pages-content-BTPzt_m4.js → publish-pages-content-D9aixMN5.js} +3 -3
  83. package/dist/{publish-pages-content-D6g8GAsd.cjs → publish-pages-content-x-JuSFJ9.cjs} +1 -1
  84. package/dist/{rte-widget-modal-DrMzWWjw.cjs → rte-widget-modal-BaHIuEjF.cjs} +1 -1
  85. package/dist/{rte-widget-modal-Rk_NW3KU.js → rte-widget-modal-DOJEXLIf.js} +1 -1
  86. package/dist/{save-to-lib-DHHUO12i.cjs → save-to-lib-Cgpxw8-g.cjs} +1 -1
  87. package/dist/{save-to-lib-BK3uTFss.js → save-to-lib-eiOc_SSN.js} +2 -2
  88. package/dist/{selected-block-display-DSFhddPj.cjs → selected-block-display-BgRY82CT.cjs} +1 -1
  89. package/dist/{selected-block-display-CU3TwIMA.js → selected-block-display-CBFePS19.js} +2 -2
  90. package/dist/{seo-panel-jbzxFioc.js → seo-panel-C1-iMOR1.js} +2 -2
  91. package/dist/{seo-panel-Dl0IDV09.cjs → seo-panel-DfAb8U7W.cjs} +1 -1
  92. package/dist/{shared-json-ld-BL_dv3_q.js → shared-json-ld-B4PxAM_0.js} +2 -2
  93. package/dist/{shared-json-ld-DPNkqDC1.cjs → shared-json-ld-DzG398hr.cjs} +1 -1
  94. package/dist/{slug-input-1qwKkXhA.js → slug-input-AwNJs9im.js} +1 -1
  95. package/dist/{slug-input-YVLjtTI3.cjs → slug-input-C_ijLQ_X.cjs} +1 -1
  96. package/dist/{take-over-request-DvMIg_cZ.cjs → take-over-request-BNxcjY2j.cjs} +1 -1
  97. package/dist/{take-over-request-DKvKi3mM.js → take-over-request-C4FeDtN_.js} +2 -2
  98. package/dist/{theme-panel-footer-BMOaPLWc.cjs → theme-panel-footer-Cq9pljro.cjs} +1 -1
  99. package/dist/{theme-panel-footer-DbMDLYGI.js → theme-panel-footer-uBQqSJXm.js} +2 -2
  100. package/dist/{translation-warning-modal-9wTwIy_9.js → translation-warning-modal-B64YqlbI.js} +1 -1
  101. package/dist/{translation-warning-modal-DjTwz75c.cjs → translation-warning-modal-BZAcwM2_.cjs} +1 -1
  102. package/dist/{unmark-as-template-Dulvf7Zw.js → unmark-as-template-CZ9sQp_P.js} +2 -2
  103. package/dist/{unmark-as-template-CdqIJJER.cjs → unmark-as-template-EVvk0vmp.cjs} +1 -1
  104. package/dist/{unpublish-page-Degu5Cy9.js → unpublish-page-D4VwOlxc.js} +2 -2
  105. package/dist/{unpublish-page-BwSVBf0_.cjs → unpublish-page-bdSmwAVQ.cjs} +1 -1
  106. package/dist/web-blocks.cjs +1 -1
  107. package/dist/web-blocks.js +42 -42
  108. package/dist/{web-preview-YzKxyXft.cjs → web-preview-Cio70gk5.cjs} +1 -1
  109. package/dist/{web-preview-DXE4Jnf5.js → web-preview-Djy6WIyj.js} +2 -2
  110. package/package.json +1 -1
  111. package/dist/css-import-modal-BSMGKA2T.cjs +0 -13
@@ -132,7 +132,7 @@
132
132
  `),n)}ignoreFallback(e,n){e.nodeName=="BR"&&(!this.top.type||!this.top.type.inlineContent)&&this.findPlace(this.parser.schema.text("-"),n,!0)}readStyles(e,n){let s=e.style;if(s&&s.length)for(let r=0;r<this.parser.matchedStyles.length;r++){let o=this.parser.matchedStyles[r],a=s.getPropertyValue(o);if(a)for(let l=void 0;;){let c=this.parser.matchStyle(o,a,this,l);if(!c)break;if(c.ignore)return null;if(c.clearMark?n=n.filter(d=>!c.clearMark(d)):n=n.concat(this.parser.schema.marks[c.mark].create(c.attrs)),c.consuming===!1)l=c;else break}}return n}addElementByRule(e,n,s,r){let o,a;if(n.node)if(a=this.parser.schema.nodes[n.node],a.isLeaf)this.insertNode(a.create(n.attrs),s,e.nodeName=="BR")||this.leafFallback(e,s);else{let c=this.enter(a,n.attrs||null,s,n.preserveWhitespace);c&&(o=!0,s=c)}else{let c=this.parser.schema.marks[n.mark];s=s.concat(c.create(n.attrs))}let l=this.top;if(a&&a.isLeaf)this.findInside(e);else if(r)this.addElement(e,s,r);else if(n.getContent)this.findInside(e),n.getContent(e,this.parser.schema).forEach(c=>this.insertNode(c,s,!1));else{let c=e;typeof n.contentElement=="string"?c=e.querySelector(n.contentElement):typeof n.contentElement=="function"?c=n.contentElement(e):n.contentElement&&(c=n.contentElement),this.findAround(e,c,!0),this.addAll(c,s),this.findAround(e,c,!1)}o&&this.sync(l)&&this.open--}addAll(e,n,s,r){let o=s||0;for(let a=s?e.childNodes[s]:e.firstChild,l=r==null?null:e.childNodes[r];a!=l;a=a.nextSibling,++o)this.findAtPoint(e,o),this.addDOM(a,n);this.findAtPoint(e,o)}findPlace(e,n,s){let r,o;for(let a=this.open,l=0;a>=0;a--){let c=this.nodes[a],d=c.findWrapping(e);if(d&&(!r||r.length>d.length+l)&&(r=d,o=c,!d.length))break;if(c.solid){if(s)break;l+=2}}if(!r)return null;this.sync(o);for(let a=0;a<r.length;a++)n=this.enterInner(r[a],null,n,!1);return n}insertNode(e,n,s){if(e.isInline&&this.needsBlock&&!this.top.type){let o=this.textblockFromContext();o&&(n=this.enterInner(o,null,n))}let r=this.findPlace(e,n,s);if(r){this.closeExtra();let o=this.top;o.match&&(o.match=o.match.matchType(e.type));let a=Q.none;for(let l of r.concat(e.marks))(o.type?o.type.allowsMarkType(l.type):Ni(l.type,e.type))&&(a=l.addToSet(a));return o.content.push(e.mark(a)),!0}return!1}enter(e,n,s,r){let o=this.findPlace(e.create(n),s,!1);return o&&(o=this.enterInner(e,n,s,!0,r)),o}enterInner(e,n,s,r=!1,o){this.closeExtra();let a=this.top;a.match=a.match&&a.match.matchType(e);let l=Ci(e,o,a.options);a.options&yn&&a.content.length==0&&(l|=yn);let c=Q.none;return s=s.filter(d=>(a.type?a.type.allowsMarkType(d.type):Ni(d.type,e))?(c=d.addToSet(c),!1):!0),this.nodes.push(new Yn(e,n,c,r,null,l)),this.open++,s}closeExtra(e=!1){let n=this.nodes.length-1;if(n>this.open){for(;n>this.open;n--)this.nodes[n-1].content.push(this.nodes[n].finish(e));this.nodes.length=this.open+1}}finish(){return this.open=0,this.closeExtra(this.isOpen),this.nodes[0].finish(!!(this.isOpen||this.options.topOpen))}sync(e){for(let n=this.open;n>=0;n--){if(this.nodes[n]==e)return this.open=n,!0;this.localPreserveWS&&(this.nodes[n].options|=jn)}return!1}get currentPos(){this.closeExtra();let e=0;for(let n=this.open;n>=0;n--){let s=this.nodes[n].content;for(let r=s.length-1;r>=0;r--)e+=s[r].nodeSize;n&&e++}return e}findAtPoint(e,n){if(this.find)for(let s=0;s<this.find.length;s++)this.find[s].node==e&&this.find[s].offset==n&&(this.find[s].pos=this.currentPos)}findInside(e){if(this.find)for(let n=0;n<this.find.length;n++)this.find[n].pos==null&&e.nodeType==1&&e.contains(this.find[n].node)&&(this.find[n].pos=this.currentPos)}findAround(e,n,s){if(e!=n&&this.find)for(let r=0;r<this.find.length;r++)this.find[r].pos==null&&e.nodeType==1&&e.contains(this.find[r].node)&&n.compareDocumentPosition(this.find[r].node)&(s?2:4)&&(this.find[r].pos=this.currentPos)}findInText(e){if(this.find)for(let n=0;n<this.find.length;n++)this.find[n].node==e&&(this.find[n].pos=this.currentPos-(e.nodeValue.length-this.find[n].offset))}matchesContext(e){if(e.indexOf("|")>-1)return e.split(/\s*\|\s*/).some(this.matchesContext,this);let n=e.split("/"),s=this.options.context,r=!this.isOpen&&(!s||s.parent.type==this.nodes[0].type),o=-(s?s.depth+1:0)+(r?0:1),a=(l,c)=>{for(;l>=0;l--){let d=n[l];if(d==""){if(l==n.length-1||l==0)continue;for(;c>=o;c--)if(a(l-1,c))return!0;return!1}else{let p=c>0||c==0&&r?this.nodes[c].type:s&&c>=o?s.node(c-o).type:null;if(!p||p.name!=d&&!p.isInGroup(d))return!1;c--}}return!0};return a(n.length-1,this.open)}textblockFromContext(){let e=this.options.context;if(e)for(let n=e.depth;n>=0;n--){let s=e.node(n).contentMatchAt(e.indexAfter(n)).defaultType;if(s&&s.isTextblock&&s.defaultAttrs)return s}for(let n in this.parser.schema.nodes){let s=this.parser.schema.nodes[n];if(s.isTextblock&&s.defaultAttrs)return s}}}function qf(t){for(let e=t.firstChild,n=null;e;e=e.nextSibling){let s=e.nodeType==1?e.nodeName.toLowerCase():null;s&&yl.hasOwnProperty(s)&&n?(n.appendChild(e),e=n):s=="li"?n=e:s&&(n=null)}}function Kf(t,e){return(t.matches||t.msMatchesSelector||t.webkitMatchesSelector||t.mozMatchesSelector).call(t,e)}function Si(t){let e={};for(let n in t)e[n]=t[n];return e}function Ni(t,e){let n=e.schema.nodes;for(let s in n){let r=n[s];if(!r.allowsMarkType(t))continue;let o=[],a=l=>{o.push(l);for(let c=0;c<l.edgeCount;c++){let{type:d,next:p}=l.edge(c);if(d==e||o.indexOf(p)<0&&a(p))return!0}};if(a(r.contentMatch))return!0}}const vl=65535,kl=Math.pow(2,16);function Yf(t,e){return t+e*kl}function Ei(t){return t&vl}function Xf(t){return(t-(t&vl))/kl}const wl=1,Cl=2,ts=4,jl=8;class Ai{constructor(e,n,s){this.pos=e,this.delInfo=n,this.recover=s}get deleted(){return(this.delInfo&jl)>0}get deletedBefore(){return(this.delInfo&(wl|ts))>0}get deletedAfter(){return(this.delInfo&(Cl|ts))>0}get deletedAcross(){return(this.delInfo&ts)>0}}class ze{constructor(e,n=!1){if(this.ranges=e,this.inverted=n,!e.length&&ze.empty)return ze.empty}recover(e){let n=0,s=Ei(e);if(!this.inverted)for(let r=0;r<s;r++)n+=this.ranges[r*3+2]-this.ranges[r*3+1];return this.ranges[s*3]+n+Xf(e)}mapResult(e,n=1){return this._map(e,n,!1)}map(e,n=1){return this._map(e,n,!0)}_map(e,n,s){let r=0,o=this.inverted?2:1,a=this.inverted?1:2;for(let l=0;l<this.ranges.length;l+=3){let c=this.ranges[l]-(this.inverted?r:0);if(c>e)break;let d=this.ranges[l+o],p=this.ranges[l+a],f=c+d;if(e<=f){let m=d?e==c?-1:e==f?1:n:n,h=c+r+(m<0?0:p);if(s)return h;let b=e==(n<0?c:f)?null:Yf(l/3,e-c),x=e==c?Cl:e==f?wl:ts;return(n<0?e!=c:e!=f)&&(x|=jl),new Ai(h,x,b)}r+=p-d}return s?e+r:new Ai(e+r,0,null)}touches(e,n){let s=0,r=Ei(n),o=this.inverted?2:1,a=this.inverted?1:2;for(let l=0;l<this.ranges.length;l+=3){let c=this.ranges[l]-(this.inverted?s:0);if(c>e)break;let d=this.ranges[l+o],p=c+d;if(e<=p&&l==r*3)return!0;s+=this.ranges[l+a]-d}return!1}forEach(e){let n=this.inverted?2:1,s=this.inverted?1:2;for(let r=0,o=0;r<this.ranges.length;r+=3){let a=this.ranges[r],l=a-(this.inverted?o:0),c=a+(this.inverted?0:o),d=this.ranges[r+n],p=this.ranges[r+s];e(l,l+d,c,c+p),o+=p-d}}invert(){return new ze(this.ranges,!this.inverted)}toString(){return(this.inverted?"-":"")+JSON.stringify(this.ranges)}static offset(e){return e==0?ze.empty:new ze(e<0?[0,-e,0]:[0,0,e])}}ze.empty=new ze([]);const sr=Object.create(null);class Te{getMap(){return ze.empty}merge(e){return null}static fromJSON(e,n){if(!n||!n.stepType)throw new RangeError("Invalid input for Step.fromJSON");let s=sr[n.stepType];if(!s)throw new RangeError(`No step type ${n.stepType} defined`);return s.fromJSON(e,n)}static jsonID(e,n){if(e in sr)throw new RangeError("Duplicate use of step JSON ID "+e);return sr[e]=n,n.prototype.jsonID=e,n}}class ye{constructor(e,n){this.doc=e,this.failed=n}static ok(e){return new ye(e,null)}static fail(e){return new ye(null,e)}static fromReplace(e,n,s,r){try{return ye.ok(e.replace(n,s,r))}catch(o){if(o instanceof ds)return ye.fail(o.message);throw o}}}function xo(t,e,n){let s=[];for(let r=0;r<t.childCount;r++){let o=t.child(r);o.content.size&&(o=o.copy(xo(o.content,e,o))),o.isInline&&(o=e(o,n,r)),s.push(o)}return D.fromArray(s)}class jt extends Te{constructor(e,n,s){super(),this.from=e,this.to=n,this.mark=s}apply(e){let n=e.slice(this.from,this.to),s=e.resolve(this.from),r=s.node(s.sharedDepth(this.to)),o=new V(xo(n.content,(a,l)=>!a.isAtom||!l.type.allowsMarkType(this.mark.type)?a:a.mark(this.mark.addToSet(a.marks)),r),n.openStart,n.openEnd);return ye.fromReplace(e,this.from,this.to,o)}invert(){return new St(this.from,this.to,this.mark)}map(e){let n=e.mapResult(this.from,1),s=e.mapResult(this.to,-1);return n.deleted&&s.deleted||n.pos>=s.pos?null:new jt(n.pos,s.pos,this.mark)}merge(e){return e instanceof jt&&e.mark.eq(this.mark)&&this.from<=e.to&&this.to>=e.from?new jt(Math.min(this.from,e.from),Math.max(this.to,e.to),this.mark):null}toJSON(){return{stepType:"addMark",mark:this.mark.toJSON(),from:this.from,to:this.to}}static fromJSON(e,n){if(typeof n.from!="number"||typeof n.to!="number")throw new RangeError("Invalid input for AddMarkStep.fromJSON");return new jt(n.from,n.to,e.markFromJSON(n.mark))}}Te.jsonID("addMark",jt);class St extends Te{constructor(e,n,s){super(),this.from=e,this.to=n,this.mark=s}apply(e){let n=e.slice(this.from,this.to),s=new V(xo(n.content,r=>r.mark(this.mark.removeFromSet(r.marks)),e),n.openStart,n.openEnd);return ye.fromReplace(e,this.from,this.to,s)}invert(){return new jt(this.from,this.to,this.mark)}map(e){let n=e.mapResult(this.from,1),s=e.mapResult(this.to,-1);return n.deleted&&s.deleted||n.pos>=s.pos?null:new St(n.pos,s.pos,this.mark)}merge(e){return e instanceof St&&e.mark.eq(this.mark)&&this.from<=e.to&&this.to>=e.from?new St(Math.min(this.from,e.from),Math.max(this.to,e.to),this.mark):null}toJSON(){return{stepType:"removeMark",mark:this.mark.toJSON(),from:this.from,to:this.to}}static fromJSON(e,n){if(typeof n.from!="number"||typeof n.to!="number")throw new RangeError("Invalid input for RemoveMarkStep.fromJSON");return new St(n.from,n.to,e.markFromJSON(n.mark))}}Te.jsonID("removeMark",St);class Nt extends Te{constructor(e,n){super(),this.pos=e,this.mark=n}apply(e){let n=e.nodeAt(this.pos);if(!n)return ye.fail("No node at mark step's position");let s=n.type.create(n.attrs,null,this.mark.addToSet(n.marks));return ye.fromReplace(e,this.pos,this.pos+1,new V(D.from(s),0,n.isLeaf?0:1))}invert(e){let n=e.nodeAt(this.pos);if(n){let s=this.mark.addToSet(n.marks);if(s.length==n.marks.length){for(let r=0;r<n.marks.length;r++)if(!n.marks[r].isInSet(s))return new Nt(this.pos,n.marks[r]);return new Nt(this.pos,this.mark)}}return new Sn(this.pos,this.mark)}map(e){let n=e.mapResult(this.pos,1);return n.deletedAfter?null:new Nt(n.pos,this.mark)}toJSON(){return{stepType:"addNodeMark",pos:this.pos,mark:this.mark.toJSON()}}static fromJSON(e,n){if(typeof n.pos!="number")throw new RangeError("Invalid input for AddNodeMarkStep.fromJSON");return new Nt(n.pos,e.markFromJSON(n.mark))}}Te.jsonID("addNodeMark",Nt);class Sn extends Te{constructor(e,n){super(),this.pos=e,this.mark=n}apply(e){let n=e.nodeAt(this.pos);if(!n)return ye.fail("No node at mark step's position");let s=n.type.create(n.attrs,null,this.mark.removeFromSet(n.marks));return ye.fromReplace(e,this.pos,this.pos+1,new V(D.from(s),0,n.isLeaf?0:1))}invert(e){let n=e.nodeAt(this.pos);return!n||!this.mark.isInSet(n.marks)?this:new Nt(this.pos,this.mark)}map(e){let n=e.mapResult(this.pos,1);return n.deletedAfter?null:new Sn(n.pos,this.mark)}toJSON(){return{stepType:"removeNodeMark",pos:this.pos,mark:this.mark.toJSON()}}static fromJSON(e,n){if(typeof n.pos!="number")throw new RangeError("Invalid input for RemoveNodeMarkStep.fromJSON");return new Sn(n.pos,e.markFromJSON(n.mark))}}Te.jsonID("removeNodeMark",Sn);class $e extends Te{constructor(e,n,s,r=!1){super(),this.from=e,this.to=n,this.slice=s,this.structure=r}apply(e){return this.structure&&Sr(e,this.from,this.to)?ye.fail("Structure replace would overwrite content"):ye.fromReplace(e,this.from,this.to,this.slice)}getMap(){return new ze([this.from,this.to-this.from,this.slice.size])}invert(e){return new $e(this.from,this.from+this.slice.size,e.slice(this.from,this.to))}map(e){let n=e.mapResult(this.from,1),s=e.mapResult(this.to,-1);return n.deletedAcross&&s.deletedAcross?null:new $e(n.pos,Math.max(n.pos,s.pos),this.slice,this.structure)}merge(e){if(!(e instanceof $e)||e.structure||this.structure)return null;if(this.from+this.slice.size==e.from&&!this.slice.openEnd&&!e.slice.openStart){let n=this.slice.size+e.slice.size==0?V.empty:new V(this.slice.content.append(e.slice.content),this.slice.openStart,e.slice.openEnd);return new $e(this.from,this.to+(e.to-e.from),n,this.structure)}else if(e.to==this.from&&!this.slice.openStart&&!e.slice.openEnd){let n=this.slice.size+e.slice.size==0?V.empty:new V(e.slice.content.append(this.slice.content),e.slice.openStart,this.slice.openEnd);return new $e(e.from,this.to,n,this.structure)}else return null}toJSON(){let e={stepType:"replace",from:this.from,to:this.to};return this.slice.size&&(e.slice=this.slice.toJSON()),this.structure&&(e.structure=!0),e}static fromJSON(e,n){if(typeof n.from!="number"||typeof n.to!="number")throw new RangeError("Invalid input for ReplaceStep.fromJSON");return new $e(n.from,n.to,V.fromJSON(e,n.slice),!!n.structure)}}Te.jsonID("replace",$e);class Oe extends Te{constructor(e,n,s,r,o,a,l=!1){super(),this.from=e,this.to=n,this.gapFrom=s,this.gapTo=r,this.slice=o,this.insert=a,this.structure=l}apply(e){if(this.structure&&(Sr(e,this.from,this.gapFrom)||Sr(e,this.gapTo,this.to)))return ye.fail("Structure gap-replace would overwrite content");let n=e.slice(this.gapFrom,this.gapTo);if(n.openStart||n.openEnd)return ye.fail("Gap is not a flat range");let s=this.slice.insertAt(this.insert,n.content);return s?ye.fromReplace(e,this.from,this.to,s):ye.fail("Content does not fit in gap")}getMap(){return new ze([this.from,this.gapFrom-this.from,this.insert,this.gapTo,this.to-this.gapTo,this.slice.size-this.insert])}invert(e){let n=this.gapTo-this.gapFrom;return new Oe(this.from,this.from+this.slice.size+n,this.from+this.insert,this.from+this.insert+n,e.slice(this.from,this.to).removeBetween(this.gapFrom-this.from,this.gapTo-this.from),this.gapFrom-this.from,this.structure)}map(e){let n=e.mapResult(this.from,1),s=e.mapResult(this.to,-1),r=this.from==this.gapFrom?n.pos:e.map(this.gapFrom,-1),o=this.to==this.gapTo?s.pos:e.map(this.gapTo,1);return n.deletedAcross&&s.deletedAcross||r<n.pos||o>s.pos?null:new Oe(n.pos,s.pos,r,o,this.slice,this.insert,this.structure)}toJSON(){let e={stepType:"replaceAround",from:this.from,to:this.to,gapFrom:this.gapFrom,gapTo:this.gapTo,insert:this.insert};return this.slice.size&&(e.slice=this.slice.toJSON()),this.structure&&(e.structure=!0),e}static fromJSON(e,n){if(typeof n.from!="number"||typeof n.to!="number"||typeof n.gapFrom!="number"||typeof n.gapTo!="number"||typeof n.insert!="number")throw new RangeError("Invalid input for ReplaceAroundStep.fromJSON");return new Oe(n.from,n.to,n.gapFrom,n.gapTo,V.fromJSON(e,n.slice),n.insert,!!n.structure)}}Te.jsonID("replaceAround",Oe);function Sr(t,e,n){let s=t.resolve(e),r=n-e,o=s.depth;for(;r>0&&o>0&&s.indexAfter(o)==s.node(o).childCount;)o--,r--;if(r>0){let a=s.node(o).maybeChild(s.indexAfter(o));for(;r>0;){if(!a||a.isLeaf)return!0;a=a.firstChild,r--}}return!1}function Jf(t,e,n){return(e==0||t.canReplace(e,t.childCount))&&(n==t.childCount||t.canReplace(0,n))}function an(t){let n=t.parent.content.cutByIndex(t.startIndex,t.endIndex);for(let s=t.depth,r=0,o=0;;--s){let a=t.$from.node(s),l=t.$from.index(s)+r,c=t.$to.indexAfter(s)-o;if(s<t.depth&&a.canReplace(l,c,n))return s;if(s==0||a.type.spec.isolating||!Jf(a,l,c))break;l&&(r=1),c<a.childCount&&(o=1)}return null}function Sl(t,e,n=null,s=t){let r=Zf(t,e),o=r&&Qf(s,e);return o?r.map(_i).concat({type:e,attrs:n}).concat(o.map(_i)):null}function _i(t){return{type:t,attrs:null}}function Zf(t,e){let{parent:n,startIndex:s,endIndex:r}=t,o=n.contentMatchAt(s).findWrapping(e);if(!o)return null;let a=o.length?o[0]:e;return n.canReplaceWith(s,r,a)?o:null}function Qf(t,e){let{parent:n,startIndex:s,endIndex:r}=t,o=n.child(s),a=e.contentMatch.findWrapping(o.type);if(!a)return null;let c=(a.length?a[a.length-1]:e).contentMatch;for(let d=s;c&&d<r;d++)c=c.matchType(n.child(d).type);return!c||!c.validEnd?null:a}function ct(t,e,n=1,s){let r=t.resolve(e),o=r.depth-n,a=s&&s[s.length-1]||r.parent;if(o<0||r.parent.type.spec.isolating||!r.parent.canReplace(r.index(),r.parent.childCount)||!a.type.validContent(r.parent.content.cutByIndex(r.index(),r.parent.childCount)))return!1;for(let d=r.depth-1,p=n-2;d>o;d--,p--){let f=r.node(d),m=r.index(d);if(f.type.spec.isolating)return!1;let h=f.content.cutByIndex(m,f.childCount),b=s&&s[p+1];b&&(h=h.replaceChild(0,b.type.create(b.attrs)));let x=s&&s[p]||f;if(!f.canReplace(m+1,f.childCount)||!x.type.validContent(h))return!1}let l=r.indexAfter(o),c=s&&s[0];return r.node(o).canReplaceWith(l,l,c?c.type:r.node(o+1).type)}function zt(t,e){let n=t.resolve(e),s=n.index();return Nl(n.nodeBefore,n.nodeAfter)&&n.parent.canReplace(s,s+1)}function eh(t,e){e.content.size||t.type.compatibleContent(e.type);let n=t.contentMatchAt(t.childCount),{linebreakReplacement:s}=t.type.schema;for(let r=0;r<e.childCount;r++){let o=e.child(r),a=o.type==s?t.type.schema.nodes.text:o.type;if(n=n.matchType(a),!n||!t.type.allowsMarks(o.marks))return!1}return n.validEnd}function Nl(t,e){return!!(t&&e&&!t.isLeaf&&eh(t,e))}function Os(t,e,n=-1){let s=t.resolve(e);for(let r=s.depth;;r--){let o,a,l=s.index(r);if(r==s.depth?(o=s.nodeBefore,a=s.nodeAfter):n>0?(o=s.node(r+1),l++,a=s.node(r).maybeChild(l)):(o=s.node(r).maybeChild(l-1),a=s.node(r+1)),o&&!o.isTextblock&&Nl(o,a)&&s.node(r).canReplace(l,l+1))return e;if(r==0)break;e=n<0?s.before(r):s.after(r)}}function bo(t,e,n=e,s=V.empty){if(e==n&&!s.size)return null;let r=t.resolve(e),o=t.resolve(n);return th(r,o,s)?new $e(e,n,s):new nh(r,o,s).fit()}function th(t,e,n){return!n.openStart&&!n.openEnd&&t.start()==e.start()&&t.parent.canReplace(t.index(),e.index(),n.content)}class nh{constructor(e,n,s){this.$from=e,this.$to=n,this.unplaced=s,this.frontier=[],this.placed=D.empty;for(let r=0;r<=e.depth;r++){let o=e.node(r);this.frontier.push({type:o.type,match:o.contentMatchAt(e.indexAfter(r))})}for(let r=e.depth;r>0;r--)this.placed=D.from(e.node(r).copy(this.placed))}get depth(){return this.frontier.length-1}fit(){for(;this.unplaced.size;){let d=this.findFittable();d?this.placeNodes(d):this.openMore()||this.dropNode()}let e=this.mustMoveInline(),n=this.placed.size-this.depth-this.$from.depth,s=this.$from,r=this.close(e<0?this.$to:s.doc.resolve(e));if(!r)return null;let o=this.placed,a=s.depth,l=r.depth;for(;a&&l&&o.childCount==1;)o=o.firstChild.content,a--,l--;let c=new V(o,a,l);return e>-1?new Oe(s.pos,e,this.$to.pos,this.$to.end(),c,n):c.size||s.pos!=this.$to.pos?new $e(s.pos,r.pos,c):null}findFittable(){let e=this.unplaced.openStart;for(let n=this.unplaced.content,s=0,r=this.unplaced.openEnd;s<e;s++){let o=n.firstChild;if(n.childCount>1&&(r=0),o.type.spec.isolating&&r<=s){e=s;break}n=o.content}for(let n=1;n<=2;n++)for(let s=n==1?e:this.unplaced.openStart;s>=0;s--){let r,o=null;s?(o=rr(this.unplaced.content,s-1).firstChild,r=o.content):r=this.unplaced.content;let a=r.firstChild;for(let l=this.depth;l>=0;l--){let{type:c,match:d}=this.frontier[l],p,f=null;if(n==1&&(a?d.matchType(a.type)||(f=d.fillBefore(D.from(a),!1)):o&&c.compatibleContent(o.type)))return{sliceDepth:s,frontierDepth:l,parent:o,inject:f};if(n==2&&a&&(p=d.findWrapping(a.type)))return{sliceDepth:s,frontierDepth:l,parent:o,wrap:p};if(o&&d.matchType(o.type))break}}}openMore(){let{content:e,openStart:n,openEnd:s}=this.unplaced,r=rr(e,n);return!r.childCount||r.firstChild.isLeaf?!1:(this.unplaced=new V(e,n+1,Math.max(s,r.size+n>=e.size-s?n+1:0)),!0)}dropNode(){let{content:e,openStart:n,openEnd:s}=this.unplaced,r=rr(e,n);if(r.childCount<=1&&n>0){let o=e.size-n<=n+r.size;this.unplaced=new V(mn(e,n-1,1),n-1,o?n-1:s)}else this.unplaced=new V(mn(e,n,1),n,s)}placeNodes({sliceDepth:e,frontierDepth:n,parent:s,inject:r,wrap:o}){for(;this.depth>n;)this.closeFrontierNode();if(o)for(let x=0;x<o.length;x++)this.openFrontierNode(o[x]);let a=this.unplaced,l=s?s.content:a.content,c=a.openStart-e,d=0,p=[],{match:f,type:m}=this.frontier[n];if(r){for(let x=0;x<r.childCount;x++)p.push(r.child(x));f=f.matchFragment(r)}let h=l.size+e-(a.content.size-a.openEnd);for(;d<l.childCount;){let x=l.child(d),y=f.matchType(x.type);if(!y)break;d++,(d>1||c==0||x.content.size)&&(f=y,p.push(El(x.mark(m.allowedMarks(x.marks)),d==1?c:0,d==l.childCount?h:-1)))}let b=d==l.childCount;b||(h=-1),this.placed=gn(this.placed,n,D.from(p)),this.frontier[n].match=f,b&&h<0&&s&&s.type==this.frontier[this.depth].type&&this.frontier.length>1&&this.closeFrontierNode();for(let x=0,y=l;x<h;x++){let k=y.lastChild;this.frontier.push({type:k.type,match:k.contentMatchAt(k.childCount)}),y=k.content}this.unplaced=b?e==0?V.empty:new V(mn(a.content,e-1,1),e-1,h<0?a.openEnd:e-1):new V(mn(a.content,e,d),a.openStart,a.openEnd)}mustMoveInline(){if(!this.$to.parent.isTextblock)return-1;let e=this.frontier[this.depth],n;if(!e.type.isTextblock||!or(this.$to,this.$to.depth,e.type,e.match,!1)||this.$to.depth==this.depth&&(n=this.findCloseLevel(this.$to))&&n.depth==this.depth)return-1;let{depth:s}=this.$to,r=this.$to.after(s);for(;s>1&&r==this.$to.end(--s);)++r;return r}findCloseLevel(e){e:for(let n=Math.min(this.depth,e.depth);n>=0;n--){let{match:s,type:r}=this.frontier[n],o=n<e.depth&&e.end(n+1)==e.pos+(e.depth-(n+1)),a=or(e,n,r,s,o);if(a){for(let l=n-1;l>=0;l--){let{match:c,type:d}=this.frontier[l],p=or(e,l,d,c,!0);if(!p||p.childCount)continue e}return{depth:n,fit:a,move:o?e.doc.resolve(e.after(n+1)):e}}}}close(e){let n=this.findCloseLevel(e);if(!n)return null;for(;this.depth>n.depth;)this.closeFrontierNode();n.fit.childCount&&(this.placed=gn(this.placed,n.depth,n.fit)),e=n.move;for(let s=n.depth+1;s<=e.depth;s++){let r=e.node(s),o=r.type.contentMatch.fillBefore(r.content,!0,e.index(s));this.openFrontierNode(r.type,r.attrs,o)}return e}openFrontierNode(e,n=null,s){let r=this.frontier[this.depth];r.match=r.match.matchType(e),this.placed=gn(this.placed,this.depth,D.from(e.create(n,s))),this.frontier.push({type:e,match:e.contentMatch})}closeFrontierNode(){let n=this.frontier.pop().match.fillBefore(D.empty,!0);n.childCount&&(this.placed=gn(this.placed,this.frontier.length,n))}}function mn(t,e,n){return e==0?t.cutByIndex(n,t.childCount):t.replaceChild(0,t.firstChild.copy(mn(t.firstChild.content,e-1,n)))}function gn(t,e,n){return e==0?t.append(n):t.replaceChild(t.childCount-1,t.lastChild.copy(gn(t.lastChild.content,e-1,n)))}function rr(t,e){for(let n=0;n<e;n++)t=t.firstChild.content;return t}function El(t,e,n){if(e<=0)return t;let s=t.content;return e>1&&(s=s.replaceChild(0,El(s.firstChild,e-1,s.childCount==1?n-1:0))),e>0&&(s=t.type.contentMatch.fillBefore(s).append(s),n<=0&&(s=s.append(t.type.contentMatch.matchFragment(s).fillBefore(D.empty,!0)))),t.copy(s)}function or(t,e,n,s,r){let o=t.node(e),a=r?t.indexAfter(e):t.index(e);if(a==o.childCount&&!n.compatibleContent(o.type))return null;let l=s.fillBefore(o.content,!0,a);return l&&!sh(n,o.content,a)?l:null}function sh(t,e,n){for(let s=n;s<e.childCount;s++)if(!t.allowsMarks(e.child(s).marks))return!0;return!1}class vn extends Te{constructor(e,n,s){super(),this.pos=e,this.attr=n,this.value=s}apply(e){let n=e.nodeAt(this.pos);if(!n)return ye.fail("No node at attribute step's position");let s=Object.create(null);for(let o in n.attrs)s[o]=n.attrs[o];s[this.attr]=this.value;let r=n.type.create(s,null,n.marks);return ye.fromReplace(e,this.pos,this.pos+1,new V(D.from(r),0,n.isLeaf?0:1))}getMap(){return ze.empty}invert(e){return new vn(this.pos,this.attr,e.nodeAt(this.pos).attrs[this.attr])}map(e){let n=e.mapResult(this.pos,1);return n.deletedAfter?null:new vn(n.pos,this.attr,this.value)}toJSON(){return{stepType:"attr",pos:this.pos,attr:this.attr,value:this.value}}static fromJSON(e,n){if(typeof n.pos!="number"||typeof n.attr!="string")throw new RangeError("Invalid input for AttrStep.fromJSON");return new vn(n.pos,n.attr,n.value)}}Te.jsonID("attr",vn);class ms extends Te{constructor(e,n){super(),this.attr=e,this.value=n}apply(e){let n=Object.create(null);for(let r in e.attrs)n[r]=e.attrs[r];n[this.attr]=this.value;let s=e.type.create(n,e.content,e.marks);return ye.ok(s)}getMap(){return ze.empty}invert(e){return new ms(this.attr,e.attrs[this.attr])}map(e){return this}toJSON(){return{stepType:"docAttr",attr:this.attr,value:this.value}}static fromJSON(e,n){if(typeof n.attr!="string")throw new RangeError("Invalid input for DocAttrStep.fromJSON");return new ms(n.attr,n.value)}}Te.jsonID("docAttr",ms);let Nn=class extends Error{};Nn=function t(e){let n=Error.call(this,e);return n.__proto__=t.prototype,n};Nn.prototype=Object.create(Error.prototype);Nn.prototype.constructor=Nn;Nn.prototype.name="TransformError";const ir=Object.create(null);class X{constructor(e,n,s){this.$anchor=e,this.$head=n,this.ranges=s||[new rh(e.min(n),e.max(n))]}get anchor(){return this.$anchor.pos}get head(){return this.$head.pos}get from(){return this.$from.pos}get to(){return this.$to.pos}get $from(){return this.ranges[0].$from}get $to(){return this.ranges[0].$to}get empty(){let e=this.ranges;for(let n=0;n<e.length;n++)if(e[n].$from.pos!=e[n].$to.pos)return!1;return!0}content(){return this.$from.doc.slice(this.from,this.to,!0)}replace(e,n=V.empty){let s=n.content.lastChild,r=null;for(let l=0;l<n.openEnd;l++)r=s,s=s.lastChild;let o=e.steps.length,a=this.ranges;for(let l=0;l<a.length;l++){let{$from:c,$to:d}=a[l],p=e.mapping.slice(o);e.replaceRange(p.map(c.pos),p.map(d.pos),l?V.empty:n),l==0&&Bi(e,o,(s?s.isInline:r&&r.isTextblock)?-1:1)}}replaceWith(e,n){let s=e.steps.length,r=this.ranges;for(let o=0;o<r.length;o++){let{$from:a,$to:l}=r[o],c=e.mapping.slice(s),d=c.map(a.pos),p=c.map(l.pos);o?e.deleteRange(d,p):(e.replaceRangeWith(d,p,n),Bi(e,s,n.isInline?-1:1))}}static findFrom(e,n,s=!1){let r=e.parent.inlineContent?new oe(e):Gt(e.node(0),e.parent,e.pos,e.index(),n,s);if(r)return r;for(let o=e.depth-1;o>=0;o--){let a=n<0?Gt(e.node(0),e.node(o),e.before(o+1),e.index(o),n,s):Gt(e.node(0),e.node(o),e.after(o+1),e.index(o)+1,n,s);if(a)return a}return null}static near(e,n=1){return this.findFrom(e,n)||this.findFrom(e,-n)||new We(e.node(0))}static atStart(e){return Gt(e,e,0,0,1)||new We(e)}static atEnd(e){return Gt(e,e,e.content.size,e.childCount,-1)||new We(e)}static fromJSON(e,n){if(!n||!n.type)throw new RangeError("Invalid input for Selection.fromJSON");let s=ir[n.type];if(!s)throw new RangeError(`No selection type ${n.type} defined`);return s.fromJSON(e,n)}static jsonID(e,n){if(e in ir)throw new RangeError("Duplicate use of selection JSON ID "+e);return ir[e]=n,n.prototype.jsonID=e,n}getBookmark(){return oe.between(this.$anchor,this.$head).getBookmark()}}X.prototype.visible=!0;class rh{constructor(e,n){this.$from=e,this.$to=n}}let Ii=!1;function Ti(t){!Ii&&!t.parent.inlineContent&&(Ii=!0,console.warn("TextSelection endpoint not pointing into a node with inline content ("+t.parent.type.name+")"))}class oe extends X{constructor(e,n=e){Ti(e),Ti(n),super(e,n)}get $cursor(){return this.$anchor.pos==this.$head.pos?this.$head:null}map(e,n){let s=e.resolve(n.map(this.head));if(!s.parent.inlineContent)return X.near(s);let r=e.resolve(n.map(this.anchor));return new oe(r.parent.inlineContent?r:s,s)}replace(e,n=V.empty){if(super.replace(e,n),n==V.empty){let s=this.$from.marksAcross(this.$to);s&&e.ensureMarks(s)}}eq(e){return e instanceof oe&&e.anchor==this.anchor&&e.head==this.head}getBookmark(){return new Fs(this.anchor,this.head)}toJSON(){return{type:"text",anchor:this.anchor,head:this.head}}static fromJSON(e,n){if(typeof n.anchor!="number"||typeof n.head!="number")throw new RangeError("Invalid input for TextSelection.fromJSON");return new oe(e.resolve(n.anchor),e.resolve(n.head))}static create(e,n,s=n){let r=e.resolve(n);return new this(r,s==n?r:e.resolve(s))}static between(e,n,s){let r=e.pos-n.pos;if((!s||r)&&(s=r>=0?1:-1),!n.parent.inlineContent){let o=X.findFrom(n,s,!0)||X.findFrom(n,-s,!0);if(o)n=o.$head;else return X.near(n,s)}return e.parent.inlineContent||(r==0?e=n:(e=(X.findFrom(e,-s,!0)||X.findFrom(e,s,!0)).$anchor,e.pos<n.pos!=r<0&&(e=n))),new oe(e,n)}}X.jsonID("text",oe);class Fs{constructor(e,n){this.anchor=e,this.head=n}map(e){return new Fs(e.map(this.anchor),e.map(this.head))}resolve(e){return oe.between(e.resolve(this.anchor),e.resolve(this.head))}}class ee extends X{constructor(e){let n=e.nodeAfter,s=e.node(0).resolve(e.pos+n.nodeSize);super(e,s),this.node=n}map(e,n){let{deleted:s,pos:r}=n.mapResult(this.anchor),o=e.resolve(r);return s?X.near(o):new ee(o)}content(){return new V(D.from(this.node),0,0)}eq(e){return e instanceof ee&&e.anchor==this.anchor}toJSON(){return{type:"node",anchor:this.anchor}}getBookmark(){return new yo(this.anchor)}static fromJSON(e,n){if(typeof n.anchor!="number")throw new RangeError("Invalid input for NodeSelection.fromJSON");return new ee(e.resolve(n.anchor))}static create(e,n){return new ee(e.resolve(n))}static isSelectable(e){return!e.isText&&e.type.spec.selectable!==!1}}ee.prototype.visible=!1;X.jsonID("node",ee);class yo{constructor(e){this.anchor=e}map(e){let{deleted:n,pos:s}=e.mapResult(this.anchor);return n?new Fs(s,s):new yo(s)}resolve(e){let n=e.resolve(this.anchor),s=n.nodeAfter;return s&&ee.isSelectable(s)?new ee(n):X.near(n)}}class We extends X{constructor(e){super(e.resolve(0),e.resolve(e.content.size))}replace(e,n=V.empty){if(n==V.empty){e.delete(0,e.doc.content.size);let s=X.atStart(e.doc);s.eq(e.selection)||e.setSelection(s)}else super.replace(e,n)}toJSON(){return{type:"all"}}static fromJSON(e){return new We(e)}map(e){return new We(e)}eq(e){return e instanceof We}getBookmark(){return oh}}X.jsonID("all",We);const oh={map(){return this},resolve(t){return new We(t)}};function Gt(t,e,n,s,r,o=!1){if(e.inlineContent)return oe.create(t,n);for(let a=s-(r>0?0:1);r>0?a<e.childCount:a>=0;a+=r){let l=e.child(a);if(l.isAtom){if(!o&&ee.isSelectable(l))return ee.create(t,n-(r<0?l.nodeSize:0))}else{let c=Gt(t,l,n+r,r<0?l.childCount:0,r,o);if(c)return c}n+=l.nodeSize*r}return null}function Bi(t,e,n){let s=t.steps.length-1;if(s<e)return;let r=t.steps[s];if(!(r instanceof $e||r instanceof Oe))return;let o=t.mapping.maps[s],a;o.forEach((l,c,d,p)=>{a==null&&(a=p)}),t.setSelection(X.near(t.doc.resolve(a),n))}function Ri(t,e){return!e||!t?t:t.bind(e)}class Xn{constructor(e,n,s){this.name=e,this.init=Ri(n.init,s),this.apply=Ri(n.apply,s)}}new Xn("doc",{init(t){return t.doc||t.schema.topNodeType.createAndFill()},apply(t){return t.doc}}),new Xn("selection",{init(t,e){return t.selection||X.atStart(e.doc)},apply(t){return t.selection}}),new Xn("storedMarks",{init(t){return t.storedMarks||null},apply(t,e,n,s){return s.selection.$cursor?t.storedMarks:null}}),new Xn("scrollToSelection",{init(){return 0},apply(t,e){return t.scrolledIntoView?e+1:e}});function Al(t,e,n){for(let s in t){let r=t[s];r instanceof Function?r=r.bind(e):s=="handleDOMEvents"&&(r=Al(r,e,{})),n[s]=r}return n}class Ht{constructor(e){this.spec=e,this.props={},e.props&&Al(e.props,this,this.props),this.key=e.key?e.key.key:_l("plugin")}getState(e){return e[this.key]}}const ar=Object.create(null);function _l(t){return t in ar?t+"$"+ ++ar[t]:(ar[t]=0,t+"$")}class Vt{constructor(e="key"){this.key=_l(e)}get(e){return e.config.pluginsByKey[this.key]}getState(e){return e[this.key]}}const vo=(t,e)=>t.selection.empty?!1:(e&&e(t.tr.deleteSelection().scrollIntoView()),!0);function Il(t,e){let{$cursor:n}=t.selection;return!n||(e?!e.endOfTextblock("backward",t):n.parentOffset>0)?null:n}const Tl=(t,e,n)=>{let s=Il(t,n);if(!s)return!1;let r=ko(s);if(!r){let a=s.blockRange(),l=a&&an(a);return l==null?!1:(e&&e(t.tr.lift(a,l).scrollIntoView()),!0)}let o=r.nodeBefore;if($l(t,r,e,-1))return!0;if(s.parent.content.size==0&&(Zt(o,"end")||ee.isSelectable(o)))for(let a=s.depth;;a--){let l=bo(t.doc,s.before(a),s.after(a),V.empty);if(l&&l.slice.size<l.to-l.from){if(e){let c=t.tr.step(l);c.setSelection(Zt(o,"end")?X.findFrom(c.doc.resolve(c.mapping.map(r.pos,-1)),-1):ee.create(c.doc,r.pos-o.nodeSize)),e(c.scrollIntoView())}return!0}if(a==1||s.node(a-1).childCount>1)break}return o.isAtom&&r.depth==s.depth-1?(e&&e(t.tr.delete(r.pos-o.nodeSize,r.pos).scrollIntoView()),!0):!1},ih=(t,e,n)=>{let s=Il(t,n);if(!s)return!1;let r=ko(s);return r?Bl(t,r,e):!1},ah=(t,e,n)=>{let s=Pl(t,n);if(!s)return!1;let r=wo(s);return r?Bl(t,r,e):!1};function Bl(t,e,n){let s=e.nodeBefore,r=s,o=e.pos-1;for(;!r.isTextblock;o--){if(r.type.spec.isolating)return!1;let p=r.lastChild;if(!p)return!1;r=p}let a=e.nodeAfter,l=a,c=e.pos+1;for(;!l.isTextblock;c++){if(l.type.spec.isolating)return!1;let p=l.firstChild;if(!p)return!1;l=p}let d=bo(t.doc,o,c,V.empty);if(!d||d.from!=o||d instanceof $e&&d.slice.size>=c-o)return!1;if(n){let p=t.tr.step(d);p.setSelection(oe.create(p.doc,o)),n(p.scrollIntoView())}return!0}function Zt(t,e,n=!1){for(let s=t;s;s=e=="start"?s.firstChild:s.lastChild){if(s.isTextblock)return!0;if(n&&s.childCount!=1)return!1}return!1}const Rl=(t,e,n)=>{let{$head:s,empty:r}=t.selection,o=s;if(!r)return!1;if(s.parent.isTextblock){if(n?!n.endOfTextblock("backward",t):s.parentOffset>0)return!1;o=ko(s)}let a=o&&o.nodeBefore;return!a||!ee.isSelectable(a)?!1:(e&&e(t.tr.setSelection(ee.create(t.doc,o.pos-a.nodeSize)).scrollIntoView()),!0)};function ko(t){if(!t.parent.type.spec.isolating)for(let e=t.depth-1;e>=0;e--){if(t.index(e)>0)return t.doc.resolve(t.before(e+1));if(t.node(e).type.spec.isolating)break}return null}function Pl(t,e){let{$cursor:n}=t.selection;return!n||(e?!e.endOfTextblock("forward",t):n.parentOffset<n.parent.content.size)?null:n}const Ll=(t,e,n)=>{let s=Pl(t,n);if(!s)return!1;let r=wo(s);if(!r)return!1;let o=r.nodeAfter;if($l(t,r,e,1))return!0;if(s.parent.content.size==0&&(Zt(o,"start")||ee.isSelectable(o))){let a=bo(t.doc,s.before(),s.after(),V.empty);if(a&&a.slice.size<a.to-a.from){if(e){let l=t.tr.step(a);l.setSelection(Zt(o,"start")?X.findFrom(l.doc.resolve(l.mapping.map(r.pos)),1):ee.create(l.doc,l.mapping.map(r.pos))),e(l.scrollIntoView())}return!0}}return o.isAtom&&r.depth==s.depth-1?(e&&e(t.tr.delete(r.pos,r.pos+o.nodeSize).scrollIntoView()),!0):!1},Ml=(t,e,n)=>{let{$head:s,empty:r}=t.selection,o=s;if(!r)return!1;if(s.parent.isTextblock){if(n?!n.endOfTextblock("forward",t):s.parentOffset<s.parent.content.size)return!1;o=wo(s)}let a=o&&o.nodeAfter;return!a||!ee.isSelectable(a)?!1:(e&&e(t.tr.setSelection(ee.create(t.doc,o.pos)).scrollIntoView()),!0)};function wo(t){if(!t.parent.type.spec.isolating)for(let e=t.depth-1;e>=0;e--){let n=t.node(e);if(t.index(e)+1<n.childCount)return t.doc.resolve(t.after(e+1));if(n.type.spec.isolating)break}return null}const lh=(t,e)=>{let n=t.selection,s=n instanceof ee,r;if(s){if(n.node.isTextblock||!zt(t.doc,n.from))return!1;r=n.from}else if(r=Os(t.doc,n.from,-1),r==null)return!1;if(e){let o=t.tr.join(r);s&&o.setSelection(ee.create(o.doc,r-t.doc.resolve(r).nodeBefore.nodeSize)),e(o.scrollIntoView())}return!0},ch=(t,e)=>{let n=t.selection,s;if(n instanceof ee){if(n.node.isTextblock||!zt(t.doc,n.to))return!1;s=n.to}else if(s=Os(t.doc,n.to,1),s==null)return!1;return e&&e(t.tr.join(s).scrollIntoView()),!0},dh=(t,e)=>{let{$from:n,$to:s}=t.selection,r=n.blockRange(s),o=r&&an(r);return o==null?!1:(e&&e(t.tr.lift(r,o).scrollIntoView()),!0)},Dl=(t,e)=>{let{$head:n,$anchor:s}=t.selection;return!n.parent.type.spec.code||!n.sameParent(s)?!1:(e&&e(t.tr.insertText(`
133
133
  `).scrollIntoView()),!0)};function Co(t){for(let e=0;e<t.edgeCount;e++){let{type:n}=t.edge(e);if(n.isTextblock&&!n.hasRequiredAttrs())return n}return null}const uh=(t,e)=>{let{$head:n,$anchor:s}=t.selection;if(!n.parent.type.spec.code||!n.sameParent(s))return!1;let r=n.node(-1),o=n.indexAfter(-1),a=Co(r.contentMatchAt(o));if(!a||!r.canReplaceWith(o,o,a))return!1;if(e){let l=n.after(),c=t.tr.replaceWith(l,l,a.createAndFill());c.setSelection(X.near(c.doc.resolve(l),1)),e(c.scrollIntoView())}return!0},Ol=(t,e)=>{let n=t.selection,{$from:s,$to:r}=n;if(n instanceof We||s.parent.inlineContent||r.parent.inlineContent)return!1;let o=Co(r.parent.contentMatchAt(r.indexAfter()));if(!o||!o.isTextblock)return!1;if(e){let a=(!s.parentOffset&&r.index()<r.parent.childCount?s:r).pos,l=t.tr.insert(a,o.createAndFill());l.setSelection(oe.create(l.doc,a+1)),e(l.scrollIntoView())}return!0},Fl=(t,e)=>{let{$cursor:n}=t.selection;if(!n||n.parent.content.size)return!1;if(n.depth>1&&n.after()!=n.end(-1)){let o=n.before();if(ct(t.doc,o))return e&&e(t.tr.split(o).scrollIntoView()),!0}let s=n.blockRange(),r=s&&an(s);return r==null?!1:(e&&e(t.tr.lift(s,r).scrollIntoView()),!0)};function ph(t){return(e,n)=>{let{$from:s,$to:r}=e.selection;if(e.selection instanceof ee&&e.selection.node.isBlock)return!s.parentOffset||!ct(e.doc,s.pos)?!1:(n&&n(e.tr.split(s.pos).scrollIntoView()),!0);if(!s.depth)return!1;let o=[],a,l,c=!1,d=!1;for(let h=s.depth;;h--)if(s.node(h).isBlock){c=s.end(h)==s.pos+(s.depth-h),d=s.start(h)==s.pos-(s.depth-h),l=Co(s.node(h-1).contentMatchAt(s.indexAfter(h-1))),o.unshift(c&&l?{type:l}:null),a=h;break}else{if(h==1)return!1;o.unshift(null)}let p=e.tr;(e.selection instanceof oe||e.selection instanceof We)&&p.deleteSelection();let f=p.mapping.map(s.pos),m=ct(p.doc,f,o.length,o);if(m||(o[0]=l?{type:l}:null,m=ct(p.doc,f,o.length,o)),!m)return!1;if(p.split(f,o.length,o),!c&&d&&s.node(a).type!=l){let h=p.mapping.map(s.before(a)),b=p.doc.resolve(h);l&&s.node(a-1).canReplaceWith(b.index(),b.index()+1,l)&&p.setNodeMarkup(p.mapping.map(s.before(a)),l)}return n&&n(p.scrollIntoView()),!0}}const fh=ph(),hh=(t,e)=>{let{$from:n,to:s}=t.selection,r,o=n.sharedDepth(s);return o==0?!1:(r=n.before(o),e&&e(t.tr.setSelection(ee.create(t.doc,r))),!0)};function mh(t,e,n){let s=e.nodeBefore,r=e.nodeAfter,o=e.index();return!s||!r||!s.type.compatibleContent(r.type)?!1:!s.content.size&&e.parent.canReplace(o-1,o)?(n&&n(t.tr.delete(e.pos-s.nodeSize,e.pos).scrollIntoView()),!0):!e.parent.canReplace(o,o+1)||!(r.isTextblock||zt(t.doc,e.pos))?!1:(n&&n(t.tr.join(e.pos).scrollIntoView()),!0)}function $l(t,e,n,s){let r=e.nodeBefore,o=e.nodeAfter,a,l,c=r.type.spec.isolating||o.type.spec.isolating;if(!c&&mh(t,e,n))return!0;let d=!c&&e.parent.canReplace(e.index(),e.index()+1);if(d&&(a=(l=r.contentMatchAt(r.childCount)).findWrapping(o.type))&&l.matchType(a[0]||o.type).validEnd){if(n){let h=e.pos+o.nodeSize,b=D.empty;for(let k=a.length-1;k>=0;k--)b=D.from(a[k].create(null,b));b=D.from(r.copy(b));let x=t.tr.step(new Oe(e.pos-1,h,e.pos,h,new V(b,1,0),a.length,!0)),y=x.doc.resolve(h+2*a.length);y.nodeAfter&&y.nodeAfter.type==r.type&&zt(x.doc,y.pos)&&x.join(y.pos),n(x.scrollIntoView())}return!0}let p=o.type.spec.isolating||s>0&&c?null:X.findFrom(e,1),f=p&&p.$from.blockRange(p.$to),m=f&&an(f);if(m!=null&&m>=e.depth)return n&&n(t.tr.lift(f,m).scrollIntoView()),!0;if(d&&Zt(o,"start",!0)&&Zt(r,"end")){let h=r,b=[];for(;b.push(h),!h.isTextblock;)h=h.lastChild;let x=o,y=1;for(;!x.isTextblock;x=x.firstChild)y++;if(h.canReplace(h.childCount,h.childCount,x.content)){if(n){let k=D.empty;for(let E=b.length-1;E>=0;E--)k=D.from(b[E].copy(k));let w=t.tr.step(new Oe(e.pos-b.length,e.pos+o.nodeSize,e.pos+y,e.pos+o.nodeSize-y,new V(k,b.length,0),0,!0));n(w.scrollIntoView())}return!0}}return!1}function zl(t){return function(e,n){let s=e.selection,r=t<0?s.$from:s.$to,o=r.depth;for(;r.node(o).isInline;){if(!o)return!1;o--}return r.node(o).isTextblock?(n&&n(e.tr.setSelection(oe.create(e.doc,t<0?r.start(o):r.end(o)))),!0):!1}}const gh=zl(-1),xh=zl(1);function bh(t,e=null){return function(n,s){let{$from:r,$to:o}=n.selection,a=r.blockRange(o),l=a&&Sl(a,t,e);return l?(s&&s(n.tr.wrap(a,l).scrollIntoView()),!0):!1}}function Pi(t,e=null){return function(n,s){let r=!1;for(let o=0;o<n.selection.ranges.length&&!r;o++){let{$from:{pos:a},$to:{pos:l}}=n.selection.ranges[o];n.doc.nodesBetween(a,l,(c,d)=>{if(r)return!1;if(!(!c.isTextblock||c.hasMarkup(t,e)))if(c.type==t)r=!0;else{let p=n.doc.resolve(d),f=p.index();r=p.parent.canReplaceWith(f,f+1,t)}})}if(!r)return!1;if(s){let o=n.tr;for(let a=0;a<n.selection.ranges.length;a++){let{$from:{pos:l},$to:{pos:c}}=n.selection.ranges[a];o.setBlockType(l,c,t,e)}s(o.scrollIntoView())}return!0}}function jo(...t){return function(e,n,s){for(let r=0;r<t.length;r++)if(t[r](e,n,s))return!0;return!1}}jo(vo,Tl,Rl);jo(vo,Ll,Ml);jo(Dl,Ol,Fl,fh);typeof navigator<"u"?/Mac|iP(hone|[oa]d)/.test(navigator.platform):typeof os<"u"&&os.platform&&os.platform()=="darwin";function yh(t,e=null){return function(n,s){let{$from:r,$to:o}=n.selection,a=r.blockRange(o);if(!a)return!1;let l=s?n.tr:null;return vh(l,a,t,e)?(s&&s(l.scrollIntoView()),!0):!1}}function vh(t,e,n,s=null){let r=!1,o=e,a=e.$from.doc;if(e.depth>=2&&e.$from.node(e.depth-1).type.compatibleContent(n)&&e.startIndex==0){if(e.$from.index(e.depth-1)==0)return!1;let c=a.resolve(e.start-2);o=new ps(c,c,e.depth),e.endIndex<e.parent.childCount&&(e=new ps(e.$from,a.resolve(e.$to.end(e.depth)),e.depth)),r=!0}let l=Sl(o,n,s,e);return l?(t&&kh(t,e,l,r,n),!0):!1}function kh(t,e,n,s,r){let o=D.empty;for(let p=n.length-1;p>=0;p--)o=D.from(n[p].type.create(n[p].attrs,o));t.step(new Oe(e.start-(s?2:0),e.end,e.start,e.end,new V(o,0,0),n.length,!0));let a=0;for(let p=0;p<n.length;p++)n[p].type==r&&(a=p+1);let l=n.length-a,c=e.start+n.length-(s?2:0),d=e.parent;for(let p=e.startIndex,f=e.endIndex,m=!0;p<f;p++,m=!1)!m&&ct(t.doc,c,l)&&(t.split(c,l),c+=2*l),c+=d.child(p).nodeSize;return t}function wh(t){return function(e,n){let{$from:s,$to:r}=e.selection,o=s.blockRange(r,a=>a.childCount>0&&a.firstChild.type==t);return o?n?s.node(o.depth-1).type==t?Ch(e,n,t,o):jh(e,n,o):!0:!1}}function Ch(t,e,n,s){let r=t.tr,o=s.end,a=s.$to.end(s.depth);o<a&&(r.step(new Oe(o-1,a,o,a,new V(D.from(n.create(null,s.parent.copy())),1,0),1,!0)),s=new ps(r.doc.resolve(s.$from.pos),r.doc.resolve(a),s.depth));const l=an(s);if(l==null)return!1;r.lift(s,l);let c=r.doc.resolve(r.mapping.map(o,-1)-1);return zt(r.doc,c.pos)&&c.nodeBefore.type==c.nodeAfter.type&&r.join(c.pos),e(r.scrollIntoView()),!0}function jh(t,e,n){let s=t.tr,r=n.parent;for(let h=n.end,b=n.endIndex-1,x=n.startIndex;b>x;b--)h-=r.child(b).nodeSize,s.delete(h-1,h+1);let o=s.doc.resolve(n.start),a=o.nodeAfter;if(s.mapping.map(n.end)!=n.start+o.nodeAfter.nodeSize)return!1;let l=n.startIndex==0,c=n.endIndex==r.childCount,d=o.node(-1),p=o.index(-1);if(!d.canReplace(p+(l?0:1),p+1,a.content.append(c?D.empty:D.from(r))))return!1;let f=o.pos,m=f+a.nodeSize;return s.step(new Oe(f-(l?1:0),m+(c?1:0),f+1,m-1,new V((l?D.empty:D.from(r.copy(D.empty))).append(c?D.empty:D.from(r.copy(D.empty))),l?0:1,c?0:1),l?0:1)),e(s.scrollIntoView()),!0}function Sh(t){return function(e,n){let{$from:s,$to:r}=e.selection,o=s.blockRange(r,d=>d.childCount>0&&d.firstChild.type==t);if(!o)return!1;let a=o.startIndex;if(a==0)return!1;let l=o.parent,c=l.child(a-1);if(c.type!=t)return!1;if(n){let d=c.lastChild&&c.lastChild.type==l.type,p=D.from(d?t.create():null),f=new V(D.from(t.create(null,D.from(l.type.create(null,p)))),d?3:1,0),m=o.start,h=o.end;n(e.tr.step(new Oe(m-(d?3:1),h,m,h,f,1,!0)).scrollIntoView())}return!0}}function Hl(t){const{state:e,transaction:n}=t;let{selection:s}=n,{doc:r}=n,{storedMarks:o}=n;return{...e,apply:e.apply.bind(e),applyTransaction:e.applyTransaction.bind(e),plugins:e.plugins,schema:e.schema,reconfigure:e.reconfigure.bind(e),toJSON:e.toJSON.bind(e),get storedMarks(){return o},get selection(){return s},get doc(){return r},get tr(){return s=n.selection,r=n.doc,o=n.storedMarks,n}}}class Nh{constructor(e){this.editor=e.editor,this.rawCommands=this.editor.extensionManager.commands,this.customState=e.state}get hasCustomState(){return!!this.customState}get state(){return this.customState||this.editor.state}get commands(){const{rawCommands:e,editor:n,state:s}=this,{view:r}=n,{tr:o}=s,a=this.buildProps(o);return Object.fromEntries(Object.entries(e).map(([l,c])=>[l,(...p)=>{const f=c(...p)(a);return!o.getMeta("preventDispatch")&&!this.hasCustomState&&r.dispatch(o),f}]))}get chain(){return()=>this.createChain()}get can(){return()=>this.createCan()}createChain(e,n=!0){const{rawCommands:s,editor:r,state:o}=this,{view:a}=r,l=[],c=!!e,d=e||o.tr,p=()=>(!c&&n&&!d.getMeta("preventDispatch")&&!this.hasCustomState&&a.dispatch(d),l.every(m=>m===!0)),f={...Object.fromEntries(Object.entries(s).map(([m,h])=>[m,(...x)=>{const y=this.buildProps(d,n),k=h(...x)(y);return l.push(k),f}])),run:p};return f}createCan(e){const{rawCommands:n,state:s}=this,r=!1,o=e||s.tr,a=this.buildProps(o,r);return{...Object.fromEntries(Object.entries(n).map(([c,d])=>[c,(...p)=>d(...p)({...a,dispatch:void 0})])),chain:()=>this.createChain(o,r)}}buildProps(e,n=!0){const{rawCommands:s,editor:r,state:o}=this,{view:a}=r,l={tr:e,editor:r,view:a,state:Hl({state:o,transaction:e}),dispatch:n?()=>{}:void 0,chain:()=>this.createChain(e,n),can:()=>this.createCan(e),get commands(){return Object.fromEntries(Object.entries(s).map(([c,d])=>[c,(...p)=>d(...p)(l)]))}};return l}}function Et(t,e,n){return t.config[e]===void 0&&t.parent?Et(t.parent,e,n):typeof t.config[e]=="function"?t.config[e].bind({...n,parent:t.parent?Et(t.parent,e,n):null}):t.config[e]}function Eh(t){const e=t.filter(r=>r.type==="extension"),n=t.filter(r=>r.type==="node"),s=t.filter(r=>r.type==="mark");return{baseExtensions:e,nodeExtensions:n,markExtensions:s}}function Ie(t,e){if(typeof t=="string"){if(!e.nodes[t])throw Error(`There is no node type named '${t}'. Maybe you forgot to add the extension?`);return e.nodes[t]}return t}function Ah(t){return typeof t=="function"}function xn(t,e=void 0,...n){return Ah(t)?e?t.bind(e)(...n):t(...n):t}function _h(t){return Object.prototype.toString.call(t)==="[object RegExp]"}function Ih(t){return Object.prototype.toString.call(t).slice(8,-1)}function Jn(t){return Ih(t)!=="Object"?!1:t.constructor===Object&&Object.getPrototypeOf(t)===Object.prototype}function Vl(t,e){const n={...t};return Jn(t)&&Jn(e)&&Object.keys(e).forEach(s=>{Jn(e[s])&&Jn(t[s])?n[s]=Vl(t[s],e[s]):n[s]=e[s]}),n}class Ge{constructor(e={}){this.type="extension",this.name="extension",this.parent=null,this.child=null,this.config={name:this.name,defaultOptions:{}},this.config={...this.config,...e},this.name=this.config.name,e.defaultOptions&&Object.keys(e.defaultOptions).length>0&&console.warn(`[tiptap warn]: BREAKING CHANGE: "defaultOptions" is deprecated. Please use "addOptions" instead. Found in extension: "${this.name}".`),this.options=this.config.defaultOptions,this.config.addOptions&&(this.options=xn(Et(this,"addOptions",{name:this.name}))),this.storage=xn(Et(this,"addStorage",{name:this.name,options:this.options}))||{}}static create(e={}){return new Ge(e)}configure(e={}){const n=this.extend({...this.config,addOptions:()=>Vl(this.options,e)});return n.name=this.name,n.parent=this.parent,n}extend(e={}){const n=new Ge({...this.config,...e});return n.parent=this,this.child=n,n.name=e.name?e.name:n.parent.name,e.defaultOptions&&Object.keys(e.defaultOptions).length>0&&console.warn(`[tiptap warn]: BREAKING CHANGE: "defaultOptions" is deprecated. Please use "addOptions" instead. Found in extension: "${n.name}".`),n.options=xn(Et(n,"addOptions",{name:n.name})),n.storage=xn(Et(n,"addStorage",{name:n.name,options:n.options})),n}}function Th(t,e,n){const{from:s,to:r}=e,{blockSeparator:o=`
134
134
 
135
- `,textSerializers:a={}}=n||{};let l="";return t.nodesBetween(s,r,(c,d,p,f)=>{var m;c.isBlock&&d>s&&(l+=o);const h=a==null?void 0:a[c.type.name];if(h)return p&&(l+=h({node:c,pos:d,parent:p,index:f,range:e})),!1;c.isText&&(l+=(m=c==null?void 0:c.text)===null||m===void 0?void 0:m.slice(Math.max(s,d)-d,r-d))}),l}function Bh(t){return Object.fromEntries(Object.entries(t.nodes).filter(([,e])=>e.spec.toText).map(([e,n])=>[e,n.spec.toText]))}Ge.create({name:"clipboardTextSerializer",addOptions(){return{blockSeparator:void 0}},addProseMirrorPlugins(){return[new Ht({key:new Vt("clipboardTextSerializer"),props:{clipboardTextSerializer:()=>{const{editor:t}=this,{state:e,schema:n}=t,{doc:s,selection:r}=e,{ranges:o}=r,a=Math.min(...o.map(p=>p.$from.pos)),l=Math.max(...o.map(p=>p.$to.pos)),c=Bh(n);return Th(s,{from:a,to:l},{...this.options.blockSeparator!==void 0?{blockSeparator:this.options.blockSeparator}:{},textSerializers:c})}}})]}});const Rh=()=>({editor:t,view:e})=>(requestAnimationFrame(()=>{var n;t.isDestroyed||(e.dom.blur(),(n=window==null?void 0:window.getSelection())===null||n===void 0||n.removeAllRanges())}),!0),Ph=(t=!1)=>({commands:e})=>e.setContent("",t),Lh=()=>({state:t,tr:e,dispatch:n})=>{const{selection:s}=e,{ranges:r}=s;return n&&r.forEach(({$from:o,$to:a})=>{t.doc.nodesBetween(o.pos,a.pos,(l,c)=>{if(l.type.isText)return;const{doc:d,mapping:p}=e,f=d.resolve(p.map(c)),m=d.resolve(p.map(c+l.nodeSize)),h=f.blockRange(m);if(!h)return;const b=an(h);if(l.type.isTextblock){const{defaultType:x}=f.parent.contentMatchAt(f.index());e.setNodeMarkup(h.start,x)}(b||b===0)&&e.lift(h,b)})}),!0},Mh=t=>e=>t(e),Dh=()=>({state:t,dispatch:e})=>Ol(t,e),Oh=(t,e)=>({editor:n,tr:s})=>{const{state:r}=n,o=r.doc.slice(t.from,t.to);s.deleteRange(t.from,t.to);const a=s.mapping.map(e);return s.insert(a,o.content),s.setSelection(new oe(s.doc.resolve(Math.max(a-1,0)))),!0},Fh=()=>({tr:t,dispatch:e})=>{const{selection:n}=t,s=n.$anchor.node();if(s.content.size>0)return!1;const r=t.selection.$anchor;for(let o=r.depth;o>0;o-=1)if(r.node(o).type===s.type){if(e){const l=r.before(o),c=r.after(o);t.delete(l,c).scrollIntoView()}return!0}return!1},$h=t=>({tr:e,state:n,dispatch:s})=>{const r=Ie(t,n.schema),o=e.selection.$anchor;for(let a=o.depth;a>0;a-=1)if(o.node(a).type===r){if(s){const c=o.before(a),d=o.after(a);e.delete(c,d).scrollIntoView()}return!0}return!1},zh=t=>({tr:e,dispatch:n})=>{const{from:s,to:r}=t;return n&&e.delete(s,r),!0},Hh=()=>({state:t,dispatch:e})=>vo(t,e),Vh=()=>({commands:t})=>t.keyboardShortcut("Enter"),Wh=()=>({state:t,dispatch:e})=>uh(t,e);function gs(t,e,n={strict:!0}){const s=Object.keys(e);return s.length?s.every(r=>n.strict?e[r]===t[r]:_h(e[r])?e[r].test(t[r]):e[r]===t[r]):!0}function Wl(t,e,n={}){return t.find(s=>s.type===e&&gs(Object.fromEntries(Object.keys(n).map(r=>[r,s.attrs[r]])),n))}function Li(t,e,n={}){return!!Wl(t,e,n)}function Ul(t,e,n){var s;if(!t||!e)return;let r=t.parent.childAfter(t.parentOffset);if((!r.node||!r.node.marks.some(p=>p.type===e))&&(r=t.parent.childBefore(t.parentOffset)),!r.node||!r.node.marks.some(p=>p.type===e)||(n=n||((s=r.node.marks[0])===null||s===void 0?void 0:s.attrs),!Wl([...r.node.marks],e,n)))return;let a=r.index,l=t.start()+r.offset,c=a+1,d=l+r.node.nodeSize;for(;a>0&&Li([...t.parent.child(a-1).marks],e,n);)a-=1,l-=t.parent.child(a).nodeSize;for(;c<t.parent.childCount&&Li([...t.parent.child(c).marks],e,n);)d+=t.parent.child(c).nodeSize,c+=1;return{from:l,to:d}}function kt(t,e){if(typeof t=="string"){if(!e.marks[t])throw Error(`There is no mark type named '${t}'. Maybe you forgot to add the extension?`);return e.marks[t]}return t}const Uh=(t,e={})=>({tr:n,state:s,dispatch:r})=>{const o=kt(t,s.schema),{doc:a,selection:l}=n,{$from:c,from:d,to:p}=l;if(r){const f=Ul(c,o,e);if(f&&f.from<=d&&f.to>=p){const m=oe.create(a,f.from,f.to);n.setSelection(m)}}return!0},Gh=t=>e=>{const n=typeof t=="function"?t(e):t;for(let s=0;s<n.length;s+=1)if(n[s](e))return!0;return!1};function Gl(t){return t instanceof oe}function At(t=0,e=0,n=0){return Math.min(Math.max(t,e),n)}function qh(t,e=null){if(!e)return null;const n=X.atStart(t),s=X.atEnd(t);if(e==="start"||e===!0)return n;if(e==="end")return s;const r=n.from,o=s.to;return e==="all"?oe.create(t,At(0,r,o),At(t.content.size,r,o)):oe.create(t,At(e,r,o),At(e,r,o))}function Kh(){return navigator.platform==="Android"||/android/i.test(navigator.userAgent)}function So(){return["iPad Simulator","iPhone Simulator","iPod Simulator","iPad","iPhone","iPod"].includes(navigator.platform)||navigator.userAgent.includes("Mac")&&"ontouchend"in document}const Yh=(t=null,e={})=>({editor:n,view:s,tr:r,dispatch:o})=>{e={scrollIntoView:!0,...e};const a=()=>{(So()||Kh())&&s.dom.focus(),requestAnimationFrame(()=>{n.isDestroyed||(s.focus(),e!=null&&e.scrollIntoView&&n.commands.scrollIntoView())})};if(s.hasFocus()&&t===null||t===!1)return!0;if(o&&t===null&&!Gl(n.state.selection))return a(),!0;const l=qh(r.doc,t)||n.state.selection,c=n.state.selection.eq(l);return o&&(c||r.setSelection(l),c&&r.storedMarks&&r.setStoredMarks(r.storedMarks),a()),!0},Xh=(t,e)=>n=>t.every((s,r)=>e(s,{...n,index:r})),Jh=(t,e)=>({tr:n,commands:s})=>s.insertContentAt({from:n.selection.from,to:n.selection.to},t,e),ql=t=>{const e=t.childNodes;for(let n=e.length-1;n>=0;n-=1){const s=e[n];s.nodeType===3&&s.nodeValue&&/^(\n\s\s|\n)$/.test(s.nodeValue)?t.removeChild(s):s.nodeType===1&&ql(s)}return t};function Zn(t){const e=`<body>${t}</body>`,n=new window.DOMParser().parseFromString(e,"text/html").body;return ql(n)}function En(t,e,n){if(t instanceof Rt||t instanceof D)return t;n={slice:!0,parseOptions:{},...n};const s=typeof t=="object"&&t!==null,r=typeof t=="string";if(s)try{if(Array.isArray(t)&&t.length>0)return D.fromArray(t.map(l=>e.nodeFromJSON(l)));const a=e.nodeFromJSON(t);return n.errorOnInvalidContent&&a.check(),a}catch(o){if(n.errorOnInvalidContent)throw new Error("[tiptap error]: Invalid JSON content",{cause:o});return console.warn("[tiptap warn]: Invalid content.","Passed value:",t,"Error:",o),En("",e,n)}if(r){if(n.errorOnInvalidContent){let a=!1,l="";const c=new Vf({topNode:e.spec.topNode,marks:e.spec.marks,nodes:e.spec.nodes.append({__tiptap__private__unknown__catch__all__node:{content:"inline*",group:"block",parseDOM:[{tag:"*",getAttrs:d=>(a=!0,l=typeof d=="string"?d:d.outerHTML,null)}]}})});if(n.slice?Kt.fromSchema(c).parseSlice(Zn(t),n.parseOptions):Kt.fromSchema(c).parse(Zn(t),n.parseOptions),n.errorOnInvalidContent&&a)throw new Error("[tiptap error]: Invalid HTML content",{cause:new Error(`Invalid element found: ${l}`)})}const o=Kt.fromSchema(e);return n.slice?o.parseSlice(Zn(t),n.parseOptions).content:o.parse(Zn(t),n.parseOptions)}return En("",e,n)}function Zh(t,e,n){const s=t.steps.length-1;if(s<e)return;const r=t.steps[s];if(!(r instanceof $e||r instanceof Oe))return;const o=t.mapping.maps[s];let a=0;o.forEach((l,c,d,p)=>{a===0&&(a=p)}),t.setSelection(X.near(t.doc.resolve(a),n))}const Qh=t=>!("type"in t),em=(t,e,n)=>({tr:s,dispatch:r,editor:o})=>{var a;if(r){n={parseOptions:o.options.parseOptions,updateSelection:!0,applyInputRules:!1,applyPasteRules:!1,...n};let l;const c=y=>{o.emit("contentError",{editor:o,error:y,disableCollaboration:()=>{o.storage.collaboration&&(o.storage.collaboration.isDisabled=!0)}})},d={preserveWhitespace:"full",...n.parseOptions};if(!n.errorOnInvalidContent&&!o.options.enableContentCheck&&o.options.emitContentError)try{En(e,o.schema,{parseOptions:d,errorOnInvalidContent:!0})}catch(y){c(y)}try{l=En(e,o.schema,{parseOptions:d,errorOnInvalidContent:(a=n.errorOnInvalidContent)!==null&&a!==void 0?a:o.options.enableContentCheck})}catch(y){return c(y),!1}let{from:p,to:f}=typeof t=="number"?{from:t,to:t}:{from:t.from,to:t.to},m=!0,h=!0;if((Qh(l)?l:[l]).forEach(y=>{y.check(),m=m?y.isText&&y.marks.length===0:!1,h=h?y.isBlock:!1}),p===f&&h){const{parent:y}=s.doc.resolve(p);y.isTextblock&&!y.type.spec.code&&!y.childCount&&(p-=1,f+=1)}let x;if(m){if(Array.isArray(e))x=e.map(y=>y.text||"").join("");else if(e instanceof D){let y="";e.forEach(k=>{k.text&&(y+=k.text)}),x=y}else typeof e=="object"&&e&&e.text?x=e.text:x=e;s.insertText(x,p,f)}else x=l,s.replaceWith(p,f,x);n.updateSelection&&Zh(s,s.steps.length-1,-1),n.applyInputRules&&s.setMeta("applyInputRules",{from:p,text:x}),n.applyPasteRules&&s.setMeta("applyPasteRules",{from:p,text:x})}return!0},tm=()=>({state:t,dispatch:e})=>lh(t,e),nm=()=>({state:t,dispatch:e})=>ch(t,e),sm=()=>({state:t,dispatch:e})=>Tl(t,e),rm=()=>({state:t,dispatch:e})=>Ll(t,e),om=()=>({state:t,dispatch:e,tr:n})=>{try{const s=Os(t.doc,t.selection.$from.pos,-1);return s==null?!1:(n.join(s,2),e&&e(n),!0)}catch{return!1}},im=()=>({state:t,dispatch:e,tr:n})=>{try{const s=Os(t.doc,t.selection.$from.pos,1);return s==null?!1:(n.join(s,2),e&&e(n),!0)}catch{return!1}},am=()=>({state:t,dispatch:e})=>ih(t,e),lm=()=>({state:t,dispatch:e})=>ah(t,e);function Kl(){return typeof navigator<"u"?/Mac/.test(navigator.platform):!1}function cm(t){const e=t.split(/-(?!$)/);let n=e[e.length-1];n==="Space"&&(n=" ");let s,r,o,a;for(let l=0;l<e.length-1;l+=1){const c=e[l];if(/^(cmd|meta|m)$/i.test(c))a=!0;else if(/^a(lt)?$/i.test(c))s=!0;else if(/^(c|ctrl|control)$/i.test(c))r=!0;else if(/^s(hift)?$/i.test(c))o=!0;else if(/^mod$/i.test(c))So()||Kl()?a=!0:r=!0;else throw new Error(`Unrecognized modifier name: ${c}`)}return s&&(n=`Alt-${n}`),r&&(n=`Ctrl-${n}`),a&&(n=`Meta-${n}`),o&&(n=`Shift-${n}`),n}const dm=t=>({editor:e,view:n,tr:s,dispatch:r})=>{const o=cm(t).split(/-(?!$)/),a=o.find(d=>!["Alt","Ctrl","Meta","Shift"].includes(d)),l=new KeyboardEvent("keydown",{key:a==="Space"?" ":a,altKey:o.includes("Alt"),ctrlKey:o.includes("Ctrl"),metaKey:o.includes("Meta"),shiftKey:o.includes("Shift"),bubbles:!0,cancelable:!0}),c=e.captureTransaction(()=>{n.someProp("handleKeyDown",d=>d(n,l))});return c==null||c.steps.forEach(d=>{const p=d.map(s.mapping);p&&r&&s.maybeStep(p)}),!0};function No(t,e,n={}){const{from:s,to:r,empty:o}=t.selection,a=e?Ie(e,t.schema):null,l=[];t.doc.nodesBetween(s,r,(f,m)=>{if(f.isText)return;const h=Math.max(s,m),b=Math.min(r,m+f.nodeSize);l.push({node:f,from:h,to:b})});const c=r-s,d=l.filter(f=>a?a.name===f.node.type.name:!0).filter(f=>gs(f.node.attrs,n,{strict:!1}));return o?!!d.length:d.reduce((f,m)=>f+m.to-m.from,0)>=c}const um=(t,e={})=>({state:n,dispatch:s})=>{const r=Ie(t,n.schema);return No(n,r,e)?dh(n,s):!1},pm=()=>({state:t,dispatch:e})=>Fl(t,e),fm=t=>({state:e,dispatch:n})=>{const s=Ie(t,e.schema);return wh(s)(e,n)},hm=()=>({state:t,dispatch:e})=>Dl(t,e);function Yl(t,e){return e.nodes[t]?"node":e.marks[t]?"mark":null}function Mi(t,e){const n=typeof e=="string"?[e]:e;return Object.keys(t).reduce((s,r)=>(n.includes(r)||(s[r]=t[r]),s),{})}const mm=(t,e)=>({tr:n,state:s,dispatch:r})=>{let o=null,a=null;const l=Yl(typeof t=="string"?t:t.name,s.schema);return l?(l==="node"&&(o=Ie(t,s.schema)),l==="mark"&&(a=kt(t,s.schema)),r&&n.selection.ranges.forEach(c=>{s.doc.nodesBetween(c.$from.pos,c.$to.pos,(d,p)=>{o&&o===d.type&&n.setNodeMarkup(p,void 0,Mi(d.attrs,e)),a&&d.marks.length&&d.marks.forEach(f=>{a===f.type&&n.addMark(p,p+d.nodeSize,a.create(Mi(f.attrs,e)))})})}),!0):!1},gm=()=>({tr:t,dispatch:e})=>(e&&t.scrollIntoView(),!0),xm=()=>({tr:t,dispatch:e})=>{if(e){const n=new We(t.doc);t.setSelection(n)}return!0},bm=()=>({state:t,dispatch:e})=>Rl(t,e),ym=()=>({state:t,dispatch:e})=>Ml(t,e),vm=()=>({state:t,dispatch:e})=>hh(t,e),km=()=>({state:t,dispatch:e})=>xh(t,e),wm=()=>({state:t,dispatch:e})=>gh(t,e);function Cm(t,e,n={},s={}){return En(t,e,{slice:!1,parseOptions:n,errorOnInvalidContent:s.errorOnInvalidContent})}const jm=(t,e=!1,n={},s={})=>({editor:r,tr:o,dispatch:a,commands:l})=>{var c,d;const{doc:p}=o;if(n.preserveWhitespace!=="full"){const f=Cm(t,r.schema,n,{errorOnInvalidContent:(c=s.errorOnInvalidContent)!==null&&c!==void 0?c:r.options.enableContentCheck});return a&&o.replaceWith(0,p.content.size,f).setMeta("preventUpdate",!e),!0}return a&&o.setMeta("preventUpdate",!e),l.insertContentAt({from:0,to:p.content.size},t,{parseOptions:n,errorOnInvalidContent:(d=s.errorOnInvalidContent)!==null&&d!==void 0?d:r.options.enableContentCheck})};function Sm(t,e){const n=kt(e,t.schema),{from:s,to:r,empty:o}=t.selection,a=[];o?(t.storedMarks&&a.push(...t.storedMarks),a.push(...t.selection.$head.marks())):t.doc.nodesBetween(s,r,c=>{a.push(...c.marks)});const l=a.find(c=>c.type.name===n.name);return l?{...l.attrs}:{}}function Nm(t){for(let e=0;e<t.edgeCount;e+=1){const{type:n}=t.edge(e);if(n.isTextblock&&!n.hasRequiredAttrs())return n}return null}function Em(t,e){for(let n=t.depth;n>0;n-=1){const s=t.node(n);if(e(s))return{pos:n>0?t.before(n):0,start:t.start(n),depth:n,node:s}}}function Eo(t){return e=>Em(e.$from,t)}function ns(t,e,n){return Object.fromEntries(Object.entries(n).filter(([s])=>{const r=t.find(o=>o.type===e&&o.name===s);return r?r.attribute.keepOnSplit:!1}))}function Am(t,e,n={}){const{empty:s,ranges:r}=t.selection,o=e?kt(e,t.schema):null;if(s)return!!(t.storedMarks||t.selection.$from.marks()).filter(f=>o?o.name===f.type.name:!0).find(f=>gs(f.attrs,n,{strict:!1}));let a=0;const l=[];if(r.forEach(({$from:f,$to:m})=>{const h=f.pos,b=m.pos;t.doc.nodesBetween(h,b,(x,y)=>{if(!x.isText&&!x.marks.length)return;const k=Math.max(h,y),w=Math.min(b,y+x.nodeSize),E=w-k;a+=E,l.push(...x.marks.map(A=>({mark:A,from:k,to:w})))})}),a===0)return!1;const c=l.filter(f=>o?o.name===f.mark.type.name:!0).filter(f=>gs(f.mark.attrs,n,{strict:!1})).reduce((f,m)=>f+m.to-m.from,0),d=l.filter(f=>o?f.mark.type!==o&&f.mark.type.excludes(o):!0).reduce((f,m)=>f+m.to-m.from,0);return(c>0?c+d:c)>=a}function Di(t,e){const{nodeExtensions:n}=Eh(e),s=n.find(a=>a.name===t);if(!s)return!1;const r={name:s.name,options:s.options,storage:s.storage},o=xn(Et(s,"group",r));return typeof o!="string"?!1:o.split(" ").includes("list")}function Xl(t,{checkChildren:e=!0,ignoreWhitespace:n=!1}={}){var s;if(n){if(t.type.name==="hardBreak")return!0;if(t.isText)return/^\s*$/m.test((s=t.text)!==null&&s!==void 0?s:"")}if(t.isText)return!t.text;if(t.isAtom||t.isLeaf)return!1;if(t.content.childCount===0)return!0;if(e){let r=!0;return t.content.forEach(o=>{r!==!1&&(Xl(o,{ignoreWhitespace:n,checkChildren:e})||(r=!1))}),r}return!1}function _m(t,e,n){var s;const{selection:r}=e;let o=null;if(Gl(r)&&(o=r.$cursor),o){const l=(s=t.storedMarks)!==null&&s!==void 0?s:o.marks();return!!n.isInSet(l)||!l.some(c=>c.type.excludes(n))}const{ranges:a}=r;return a.some(({$from:l,$to:c})=>{let d=l.depth===0?t.doc.inlineContent&&t.doc.type.allowsMarkType(n):!1;return t.doc.nodesBetween(l.pos,c.pos,(p,f,m)=>{if(d)return!1;if(p.isInline){const h=!m||m.type.allowsMarkType(n),b=!!n.isInSet(p.marks)||!p.marks.some(x=>x.type.excludes(n));d=h&&b}return!d}),d})}const Im=(t,e={})=>({tr:n,state:s,dispatch:r})=>{const{selection:o}=n,{empty:a,ranges:l}=o,c=kt(t,s.schema);if(r)if(a){const d=Sm(s,c);n.addStoredMark(c.create({...d,...e}))}else l.forEach(d=>{const p=d.$from.pos,f=d.$to.pos;s.doc.nodesBetween(p,f,(m,h)=>{const b=Math.max(h,p),x=Math.min(h+m.nodeSize,f);m.marks.find(k=>k.type===c)?m.marks.forEach(k=>{c===k.type&&n.addMark(b,x,c.create({...k.attrs,...e}))}):n.addMark(b,x,c.create(e))})});return _m(s,n,c)},Tm=(t,e)=>({tr:n})=>(n.setMeta(t,e),!0),Bm=(t,e={})=>({state:n,dispatch:s,chain:r})=>{const o=Ie(t,n.schema);let a;return n.selection.$anchor.sameParent(n.selection.$head)&&(a=n.selection.$anchor.parent.attrs),o.isTextblock?r().command(({commands:l})=>Pi(o,{...a,...e})(n)?!0:l.clearNodes()).command(({state:l})=>Pi(o,{...a,...e})(l,s)).run():(console.warn('[tiptap warn]: Currently "setNode()" only supports text block nodes.'),!1)},Rm=t=>({tr:e,dispatch:n})=>{if(n){const{doc:s}=e,r=At(t,0,s.content.size),o=ee.create(s,r);e.setSelection(o)}return!0},Pm=t=>({tr:e,dispatch:n})=>{if(n){const{doc:s}=e,{from:r,to:o}=typeof t=="number"?{from:t,to:t}:t,a=oe.atStart(s).from,l=oe.atEnd(s).to,c=At(r,a,l),d=At(o,a,l),p=oe.create(s,c,d);e.setSelection(p)}return!0},Lm=t=>({state:e,dispatch:n})=>{const s=Ie(t,e.schema);return Sh(s)(e,n)};function Oi(t,e){const n=t.storedMarks||t.selection.$to.parentOffset&&t.selection.$from.marks();if(n){const s=n.filter(r=>e==null?void 0:e.includes(r.type.name));t.tr.ensureMarks(s)}}const Mm=({keepMarks:t=!0}={})=>({tr:e,state:n,dispatch:s,editor:r})=>{const{selection:o,doc:a}=e,{$from:l,$to:c}=o,d=r.extensionManager.attributes,p=ns(d,l.node().type.name,l.node().attrs);if(o instanceof ee&&o.node.isBlock)return!l.parentOffset||!ct(a,l.pos)?!1:(s&&(t&&Oi(n,r.extensionManager.splittableMarks),e.split(l.pos).scrollIntoView()),!0);if(!l.parent.isBlock)return!1;const f=c.parentOffset===c.parent.content.size,m=l.depth===0?void 0:Nm(l.node(-1).contentMatchAt(l.indexAfter(-1)));let h=f&&m?[{type:m,attrs:p}]:void 0,b=ct(e.doc,e.mapping.map(l.pos),1,h);if(!h&&!b&&ct(e.doc,e.mapping.map(l.pos),1,m?[{type:m}]:void 0)&&(b=!0,h=m?[{type:m,attrs:p}]:void 0),s){if(b&&(o instanceof oe&&e.deleteSelection(),e.split(e.mapping.map(l.pos),1,h),m&&!f&&!l.parentOffset&&l.parent.type!==m)){const x=e.mapping.map(l.before()),y=e.doc.resolve(x);l.node(-1).canReplaceWith(y.index(),y.index()+1,m)&&e.setNodeMarkup(e.mapping.map(l.before()),m)}t&&Oi(n,r.extensionManager.splittableMarks),e.scrollIntoView()}return b},Dm=(t,e={})=>({tr:n,state:s,dispatch:r,editor:o})=>{var a;const l=Ie(t,s.schema),{$from:c,$to:d}=s.selection,p=s.selection.node;if(p&&p.isBlock||c.depth<2||!c.sameParent(d))return!1;const f=c.node(-1);if(f.type!==l)return!1;const m=o.extensionManager.attributes;if(c.parent.content.size===0&&c.node(-1).childCount===c.indexAfter(-1)){if(c.depth===2||c.node(-3).type!==l||c.index(-2)!==c.node(-2).childCount-1)return!1;if(r){let k=D.empty;const w=c.index(-1)?1:c.index(-2)?2:3;for(let N=c.depth-w;N>=c.depth-3;N-=1)k=D.from(c.node(N).copy(k));const E=c.indexAfter(-1)<c.node(-2).childCount?1:c.indexAfter(-2)<c.node(-3).childCount?2:3,A={...ns(m,c.node().type.name,c.node().attrs),...e},_=((a=l.contentMatch.defaultType)===null||a===void 0?void 0:a.createAndFill(A))||void 0;k=k.append(D.from(l.createAndFill(null,_)||void 0));const I=c.before(c.depth-(w-1));n.replace(I,c.after(-E),new V(k,4-w,0));let j=-1;n.doc.nodesBetween(I,n.doc.content.size,(N,C)=>{if(j>-1)return!1;N.isTextblock&&N.content.size===0&&(j=C+1)}),j>-1&&n.setSelection(oe.near(n.doc.resolve(j))),n.scrollIntoView()}return!0}const h=d.pos===c.end()?f.contentMatchAt(0).defaultType:null,b={...ns(m,f.type.name,f.attrs),...e},x={...ns(m,c.node().type.name,c.node().attrs),...e};n.delete(c.pos,d.pos);const y=h?[{type:l,attrs:b},{type:h,attrs:x}]:[{type:l,attrs:b}];if(!ct(n.doc,c.pos,2))return!1;if(r){const{selection:k,storedMarks:w}=s,{splittableMarks:E}=o.extensionManager,A=w||k.$to.parentOffset&&k.$from.marks();if(n.split(c.pos,2,y).scrollIntoView(),!A||!r)return!0;const _=A.filter(I=>E.includes(I.type.name));n.ensureMarks(_)}return!0},lr=(t,e)=>{const n=Eo(a=>a.type===e)(t.selection);if(!n)return!0;const s=t.doc.resolve(Math.max(0,n.pos-1)).before(n.depth);if(s===void 0)return!0;const r=t.doc.nodeAt(s);return n.node.type===(r==null?void 0:r.type)&&zt(t.doc,n.pos)&&t.join(n.pos),!0},cr=(t,e)=>{const n=Eo(a=>a.type===e)(t.selection);if(!n)return!0;const s=t.doc.resolve(n.start).after(n.depth);if(s===void 0)return!0;const r=t.doc.nodeAt(s);return n.node.type===(r==null?void 0:r.type)&&zt(t.doc,s)&&t.join(s),!0},Om=(t,e,n,s={})=>({editor:r,tr:o,state:a,dispatch:l,chain:c,commands:d,can:p})=>{const{extensions:f,splittableMarks:m}=r.extensionManager,h=Ie(t,a.schema),b=Ie(e,a.schema),{selection:x,storedMarks:y}=a,{$from:k,$to:w}=x,E=k.blockRange(w),A=y||x.$to.parentOffset&&x.$from.marks();if(!E)return!1;const _=Eo(I=>Di(I.type.name,f))(x);if(E.depth>=1&&_&&E.depth-_.depth<=1){if(_.node.type===h)return d.liftListItem(b);if(Di(_.node.type.name,f)&&h.validContent(_.node.content)&&l)return c().command(()=>(o.setNodeMarkup(_.pos,h),!0)).command(()=>lr(o,h)).command(()=>cr(o,h)).run()}return!n||!A||!l?c().command(()=>p().wrapInList(h,s)?!0:d.clearNodes()).wrapInList(h,s).command(()=>lr(o,h)).command(()=>cr(o,h)).run():c().command(()=>{const I=p().wrapInList(h,s),j=A.filter(N=>m.includes(N.type.name));return o.ensureMarks(j),I?!0:d.clearNodes()}).wrapInList(h,s).command(()=>lr(o,h)).command(()=>cr(o,h)).run()},Fm=(t,e={},n={})=>({state:s,commands:r})=>{const{extendEmptyMarkRange:o=!1}=n,a=kt(t,s.schema);return Am(s,a,e)?r.unsetMark(a,{extendEmptyMarkRange:o}):r.setMark(a,e)},$m=(t,e,n={})=>({state:s,commands:r})=>{const o=Ie(t,s.schema),a=Ie(e,s.schema),l=No(s,o,n);let c;return s.selection.$anchor.sameParent(s.selection.$head)&&(c=s.selection.$anchor.parent.attrs),l?r.setNode(a,c):r.setNode(o,{...c,...n})},zm=(t,e={})=>({state:n,commands:s})=>{const r=Ie(t,n.schema);return No(n,r,e)?s.lift(r):s.wrapIn(r,e)},Hm=()=>({state:t,dispatch:e})=>{const n=t.plugins;for(let s=0;s<n.length;s+=1){const r=n[s];let o;if(r.spec.isInputRules&&(o=r.getState(t))){if(e){const a=t.tr,l=o.transform;for(let c=l.steps.length-1;c>=0;c-=1)a.step(l.steps[c].invert(l.docs[c]));if(o.text){const c=a.doc.resolve(o.from).marks();a.replaceWith(o.from,o.to,t.schema.text(o.text,c))}else a.delete(o.from,o.to)}return!0}}return!1},Vm=()=>({tr:t,dispatch:e})=>{const{selection:n}=t,{empty:s,ranges:r}=n;return s||e&&r.forEach(o=>{t.removeMark(o.$from.pos,o.$to.pos)}),!0},Wm=(t,e={})=>({tr:n,state:s,dispatch:r})=>{var o;const{extendEmptyMarkRange:a=!1}=e,{selection:l}=n,c=kt(t,s.schema),{$from:d,empty:p,ranges:f}=l;if(!r)return!0;if(p&&a){let{from:m,to:h}=l;const b=(o=d.marks().find(y=>y.type===c))===null||o===void 0?void 0:o.attrs,x=Ul(d,c,b);x&&(m=x.from,h=x.to),n.removeMark(m,h,c)}else f.forEach(m=>{n.removeMark(m.$from.pos,m.$to.pos,c)});return n.removeStoredMark(c),!0},Um=(t,e={})=>({tr:n,state:s,dispatch:r})=>{let o=null,a=null;const l=Yl(typeof t=="string"?t:t.name,s.schema);return l?(l==="node"&&(o=Ie(t,s.schema)),l==="mark"&&(a=kt(t,s.schema)),r&&n.selection.ranges.forEach(c=>{const d=c.$from.pos,p=c.$to.pos;let f,m,h,b;n.selection.empty?s.doc.nodesBetween(d,p,(x,y)=>{o&&o===x.type&&(h=Math.max(y,d),b=Math.min(y+x.nodeSize,p),f=y,m=x)}):s.doc.nodesBetween(d,p,(x,y)=>{y<d&&o&&o===x.type&&(h=Math.max(y,d),b=Math.min(y+x.nodeSize,p),f=y,m=x),y>=d&&y<=p&&(o&&o===x.type&&n.setNodeMarkup(y,void 0,{...x.attrs,...e}),a&&x.marks.length&&x.marks.forEach(k=>{if(a===k.type){const w=Math.max(y,d),E=Math.min(y+x.nodeSize,p);n.addMark(w,E,a.create({...k.attrs,...e}))}}))}),m&&(f!==void 0&&n.setNodeMarkup(f,void 0,{...m.attrs,...e}),a&&m.marks.length&&m.marks.forEach(x=>{a===x.type&&n.addMark(h,b,a.create({...x.attrs,...e}))}))}),!0):!1},Gm=(t,e={})=>({state:n,dispatch:s})=>{const r=Ie(t,n.schema);return bh(r,e)(n,s)},qm=(t,e={})=>({state:n,dispatch:s})=>{const r=Ie(t,n.schema);return yh(r,e)(n,s)};var Km=Object.freeze({__proto__:null,blur:Rh,clearContent:Ph,clearNodes:Lh,command:Mh,createParagraphNear:Dh,cut:Oh,deleteCurrentNode:Fh,deleteNode:$h,deleteRange:zh,deleteSelection:Hh,enter:Vh,exitCode:Wh,extendMarkRange:Uh,first:Gh,focus:Yh,forEach:Xh,insertContent:Jh,insertContentAt:em,joinBackward:sm,joinDown:nm,joinForward:rm,joinItemBackward:om,joinItemForward:im,joinTextblockBackward:am,joinTextblockForward:lm,joinUp:tm,keyboardShortcut:dm,lift:um,liftEmptyBlock:pm,liftListItem:fm,newlineInCode:hm,resetAttributes:mm,scrollIntoView:gm,selectAll:xm,selectNodeBackward:bm,selectNodeForward:ym,selectParentNode:vm,selectTextblockEnd:km,selectTextblockStart:wm,setContent:jm,setMark:Im,setMeta:Tm,setNode:Bm,setNodeSelection:Rm,setTextSelection:Pm,sinkListItem:Lm,splitBlock:Mm,splitListItem:Dm,toggleList:Om,toggleMark:Fm,toggleNode:$m,toggleWrap:zm,undoInputRule:Hm,unsetAllMarks:Vm,unsetMark:Wm,updateAttributes:Um,wrapIn:Gm,wrapInList:qm});Ge.create({name:"commands",addCommands(){return{...Km}}});Ge.create({name:"drop",addProseMirrorPlugins(){return[new Ht({key:new Vt("tiptapDrop"),props:{handleDrop:(t,e,n,s)=>{this.editor.emit("drop",{editor:this.editor,event:e,slice:n,moved:s})}}})]}});Ge.create({name:"editable",addProseMirrorPlugins(){return[new Ht({key:new Vt("editable"),props:{editable:()=>this.editor.options.editable}})]}});const Ym=new Vt("focusEvents");Ge.create({name:"focusEvents",addProseMirrorPlugins(){const{editor:t}=this;return[new Ht({key:Ym,props:{handleDOMEvents:{focus:(e,n)=>{t.isFocused=!0;const s=t.state.tr.setMeta("focus",{event:n}).setMeta("addToHistory",!1);return e.dispatch(s),!1},blur:(e,n)=>{t.isFocused=!1;const s=t.state.tr.setMeta("blur",{event:n}).setMeta("addToHistory",!1);return e.dispatch(s),!1}}}})]}});Ge.create({name:"keymap",addKeyboardShortcuts(){const t=()=>this.editor.commands.first(({commands:a})=>[()=>a.undoInputRule(),()=>a.command(({tr:l})=>{const{selection:c,doc:d}=l,{empty:p,$anchor:f}=c,{pos:m,parent:h}=f,b=f.parent.isTextblock&&m>0?l.doc.resolve(m-1):f,x=b.parent.type.spec.isolating,y=f.pos-f.parentOffset,k=x&&b.parent.childCount===1?y===f.pos:X.atStart(d).from===m;return!p||!h.type.isTextblock||h.textContent.length||!k||k&&f.parent.type.name==="paragraph"?!1:a.clearNodes()}),()=>a.deleteSelection(),()=>a.joinBackward(),()=>a.selectNodeBackward()]),e=()=>this.editor.commands.first(({commands:a})=>[()=>a.deleteSelection(),()=>a.deleteCurrentNode(),()=>a.joinForward(),()=>a.selectNodeForward()]),s={Enter:()=>this.editor.commands.first(({commands:a})=>[()=>a.newlineInCode(),()=>a.createParagraphNear(),()=>a.liftEmptyBlock(),()=>a.splitBlock()]),"Mod-Enter":()=>this.editor.commands.exitCode(),Backspace:t,"Mod-Backspace":t,"Shift-Backspace":t,Delete:e,"Mod-Delete":e,"Mod-a":()=>this.editor.commands.selectAll()},r={...s},o={...s,"Ctrl-h":t,"Alt-Backspace":t,"Ctrl-d":e,"Ctrl-Alt-Backspace":e,"Alt-Delete":e,"Alt-d":e,"Ctrl-a":()=>this.editor.commands.selectTextblockStart(),"Ctrl-e":()=>this.editor.commands.selectTextblockEnd()};return So()||Kl()?o:r},addProseMirrorPlugins(){return[new Ht({key:new Vt("clearDocument"),appendTransaction:(t,e,n)=>{if(t.some(x=>x.getMeta("composition")))return;const s=t.some(x=>x.docChanged)&&!e.doc.eq(n.doc),r=t.some(x=>x.getMeta("preventClearDocument"));if(!s||r)return;const{empty:o,from:a,to:l}=e.selection,c=X.atStart(e.doc).from,d=X.atEnd(e.doc).to;if(o||!(a===c&&l===d)||!Xl(n.doc))return;const m=n.tr,h=Hl({state:n,transaction:m}),{commands:b}=new Nh({editor:this.editor,state:h});if(b.clearNodes(),!!m.steps.length)return m}})]}});Ge.create({name:"paste",addProseMirrorPlugins(){return[new Ht({key:new Vt("tiptapPaste"),props:{handlePaste:(t,e,n)=>{this.editor.emit("paste",{editor:this.editor,event:e,slice:n})}}})]}});Ge.create({name:"tabindex",addProseMirrorPlugins(){return[new Ht({key:new Vt("tabindex"),props:{attributes:()=>this.editor.isEditable?{tabindex:"0"}:{}}})]}});const Xm=Ge.create({name:"color",addOptions(){return{types:["textStyle"]}},addGlobalAttributes(){return[{types:this.options.types,attributes:{color:{default:null,parseHTML:t=>{var e;return(e=t.style.color)===null||e===void 0?void 0:e.replace(/['"]+/g,"")},renderHTML:t=>t.color?{style:`color: ${t.color}`}:{}}}}]},addCommands(){return{setColor:t=>({chain:e})=>e().setMark("textStyle",{color:t}).run(),unsetColor:()=>({chain:t})=>t().setMark("textStyle",{color:null}).removeEmptyTextStyle().run()}}}),Jl=({blockId:t,value:e="",onUpdate:n=()=>{},onBlur:s=()=>{},placeholder:r="",from:o="settings",style:a={}})=>as.useEditor({extensions:[Od,Bd,Xm.configure({types:["textStyle"]}),Rd.configure({multicolor:!0}),Pd.configure({openOnClick:!1,HTMLAttributes:{class:"underline"}}),Md.configure({types:["heading","paragraph"],alignments:["left","center","right"],defaultAlignment:"left"}),Dd,Ld.configure({placeholder:r||"Enter text here",emptyEditorClass:"cursor-text before:content-[attr(data-placeholder)] before:absolute before:opacity-50 before:pointer-events-none"})],content:e||"",onUpdate:n,onBlur:s,editorProps:{attributes:{...a?{style:a}:{},class:o!=="canvas"?"text-sm p-1 px-2 rte":"rte"}}},[t]);function Jm(t){let e=t;for(;e;){if(e.style&&e.style.textAlign)return e.style.textAlign;const n=window.getComputedStyle(e).textAlign;if(n&&n!=="start"&&n!=="initial"&&n!=="inherit")return n;e=e.parentElement}return null}const Zm=g.memo(({blockContent:t,editingElement:e,onClose:n,onChange:s,onEscape:r})=>{const{document:o}=st(),a=Jl({value:t,blockId:"active-inline-editing-element",placeholder:"Enter text here",onUpdate:({editor:d})=>s((d==null?void 0:d.getHTML())||""),onBlur:({editor:d,event:p})=>{const f=p==null?void 0:p.relatedTarget,m=o.querySelector(".ProseMirror"),h=o.querySelector(".tippy-box"),b=o.querySelector("#chai-rich-text-menu-bar"),x=m==null?void 0:m.contains(f),y=h==null?void 0:h.contains(f),k=b==null?void 0:b.contains(f),w=window.document.getElementById("rte-widget-color-picker");if(!x&&!y&&!k&&!w){const E=(d==null?void 0:d.getHTML())||"";n(E)}},from:"canvas"});g.useEffect(()=>{var p,f;const d=Jm(e);d&&((p=a==null?void 0:a.commands)==null||p.setTextAlign(d)),(f=a==null?void 0:a.commands)==null||f.focus(),a==null||a.emit("focus",{editor:a,event:new FocusEvent("focus"),transaction:[]})},[a]);const l=g.useMemo(()=>{var f;const d="max-w-none shadow-none outline outline-[2px] [&_*]:shadow-none";if(!e)return d;const p=((f=e==null?void 0:e.className)==null?void 0:f.replace("sr-only",""))||"";return`${d} ${p}`},[e]),c=d=>{d.key==="Escape"&&r(d)};return a&&i.jsxs("div",{onKeyDown:c,onClick:d=>d.stopPropagation(),className:"relative",children:[i.jsx(as.BubbleMenu,{editor:a,shouldShow:()=>a&&(a==null?void 0:a.isFocused),tippyOptions:{duration:100,arrow:!0,hideOnClick:!1},className:"w-max",children:i.jsx(sl,{editor:a,from:"canvas"})}),i.jsx(as.EditorContent,{id:"active-inline-editing-element",onKeyDown:c,value:t,editor:a,className:l})]})}),Qm=g.memo(({editingElement:t,blockContent:e,onClose:n,editorRef:s,onChange:r,onEscape:o})=>{const{document:a,window:l}=st();g.useEffect(()=>{if(s.current){s.current.innerHTML=e,s.current.focus();const m=a.createRange(),h=l.getSelection();m.selectNodeContents(s.current),m.collapse(!1),h==null||h.removeAllRanges(),h==null||h.addRange(m),s.current.focus()}else n()},[a,l]);const c=g.useMemo(()=>{var h;const m=((h=t==null?void 0:t.tagName)==null?void 0:h.toLowerCase())||"div";return m==="button"?"div":m},[t]),d=g.useCallback(m=>{(m.key==="Enter"||m.key==="Escape")&&o(m)},[o]),p=g.useCallback(()=>{n()},[n]),f=g.useMemo(()=>{var m;return{id:"active-inline-editing-element",contentEditable:!0,className:`${((m=t==null?void 0:t.className)==null?void 0:m.replace("sr-only",""))||""} outline outline-[2px] outline-green-500 shadow-none empty:before:content-[attr(data-placeholder)] empty:before:text-gray-400 empty:before:absolute empty:before:pointer-events-none empty:before:select-none empty:before:inset-0 empty:before:z-0 relative min-h-[1em]`,style:u.cloneDeep(t==null?void 0:t.style)||{},onInput:h=>{const b=h.target;b&&(b.innerText.trim()===""?(b.setAttribute("data-placeholder","Enter text here"),b.children.length>0&&b.children[0].remove()):h.target.removeAttribute("data-placeholder"),r(h.target.innerText))},onClick:h=>{h.stopPropagation(),h.preventDefault()}}},[t==null?void 0:t.className,t==null?void 0:t.style]);return i.jsx(i.Fragment,{children:g.createElement(c,{ref:s,onBlur:p,onKeyDown:d,...f})})}),eg=g.memo(({block:t,children:e})=>{const n="content",{document:s}=st(),{editingBlockId:r,editingItemIndex:o,setEditingBlockId:a,setEditingItemIndex:l}=$t(),[c,d]=g.useState(null),p=g.useRef(null),{clearHighlight:f}=nt(),m=tt(),{selectedLang:h}=Le(),[,b]=K(),x=g.useRef(null),y=r,{blockContent:k,blockType:w}=g.useMemo(()=>{var R;const j=t._type;let N=t[n];const C=J.getRegisteredChaiBlock(t._type);return h&&((R=C==null?void 0:C.i18nProps)==null?void 0:R.includes(n))&&u.has(t,`${n}-${h}`)&&(N=u.get(t,`${n}-${h}`)),{blockContent:N,blockType:j}},[t,h]),E=g.useCallback(j=>{var C;const N=j||((C=p.current)==null?void 0:C.innerText);m([y],{[n]:N}),d(null),a(null),l(-1),b([]),y&&setTimeout(()=>b([y]),100)},[y,m,a,b,h]),A=ke.useDebouncedCallback(j=>{m([y],{[n]:j})},[y,t,m,h],1e3),_=g.useCallback(j=>{j.preventDefault(),y&&(x.current=y),E(),setTimeout(()=>{const N=x.current;x.current=null,b([N])},100)},[b,y,h]);g.useEffect(()=>{var T;if(!y)return;const j=`[data-block-id="${y}"]`,N=o>=0?`[data-block-index="${o}"]`:"",C=s.querySelector(`${j}${N}`);C&&((T=C==null?void 0:C.classList)==null||T.add("sr-only"),d(C))},[y,w,s,o]);const I=g.useMemo(()=>c?(f(),["RichText","Paragraph"].includes(w)?i.jsx(Zm,{blockContent:k,editingElement:c,onChange:A,onClose:E,onEscape:_}):i.jsx(Qm,{editorRef:p,blockContent:k,editingElement:c,onClose:E,onChange:A,onEscape:_})):null,[c,y,w,k,E,h]);return i.jsxs(i.Fragment,{children:[I,e]})},(t,e)=>t.block._id===e.block._id&&t.block.content===e.block.content),Zl=g.createContext({index:-1,key:""}),tg=["Box","Repeater","GlobalBlock","PartialBlock","Heading","Text","RichText","Span","Image","Button","Paragraph","Link","Video","Audio","Icon","List","ListItem","CustomScript","CustomHTML"],ng=({asyncProps:t,blockAtom:e,children:n})=>{const{editingBlockId:s,editingItemIndex:r}=$t(),[o]=S.useAtom(e),a=g.useMemo(()=>J.getRegisteredChaiBlock(o._type),[o._type]),{selectedLang:l,fallbackLang:c}=Le(),d=yf(),p=sn(),[f]=S.useAtom(ao),m=u.get(a,"component",null),{index:h,key:b}=g.useContext(Zl),{mode:x}=nl(),y=S.useAtomValue(nn),k=Ye(),w=x==="edit",E=bf(),A=g.useMemo(()=>f?$.applyBindingToBlockProps($.applyLanguage(o,l,a),p,{index:h,key:b}):$.applyLanguage(o,l,a),[o,l,a,p,f,h,b]),_=g.useMemo(()=>$.getBlockTagAttributes(o,!0,y),[o,$.getBlockTagAttributes,y]),I=g.useMemo(()=>d(o._id,$.getBlockRuntimeProps(o._type)),[o._id,o._type,d,$.getBlockRuntimeProps]),j=g.useMemo(()=>{const U={"data-block-id":o._id,"data-block-type":o._type,"data-block-index":h};return w&&k?{...U,draggable:!s,onMouseDown:E.onMouseDown,onDragStart:E.onDragStart,onDragEnd:E.onDragEnd}:U},[o._id,o._type,h,w,k,E,s]),N=g.useMemo(()=>({blockProps:j,inBuilder:x==="edit",lang:l||c,pageData:p,...A,..._,...I,...t}),[x,j,l,c,A,_,I,t]),C=g.useMemo(()=>!tg.includes(o._type),[o._type]),T=g.useMemo(()=>u.get(o,"_show",!0),[o]);if(u.isNull(m)||!T)return null;let R=i.jsx(g.Suspense,{children:g.createElement(m,{...N,children:n({_id:o._id,_type:o._type,...u.isArray(A.repeaterItems)?{repeaterItems:$.applyLimit(A.repeaterItems,o),$repeaterItemsKey:A.$repeaterItemsKey}:{},...o.partialBlockId?{partialBlockId:o.partialBlockId}:"",...o.globalBlock?{partialBlockId:o.globalBlock}:""})})});const B=s===o._id&&(r===h||h<0)?i.jsx(eg,{block:o,children:R}):R;return C?i.jsx(_t.ErrorBoundary,{fallbackRender:wf,children:B}):B},sg=({children:t,partialBlockId:e})=>{const n=O("gotoPage",u.noop),{saveState:s}=Rn(),{selectedLang:r,fallbackLang:o}=Le(),a=g.useCallback(l=>{if(l.stopPropagation(),s!=="SAVED"){me.toast.error("You have unsaved changes. Please save the page first.");return}n({pageId:e,lang:r||o})},[s,n,e,r,o]);return i.jsxs(i.Fragment,{children:[t,i.jsx("div",{className:"partial-overlay group absolute inset-0 z-50",children:i.jsx("div",{onDoubleClick:a,className:"flex h-full w-full items-center justify-center bg-black/10 opacity-0 transition-opacity duration-300 ease-in-out group-hover:opacity-100 group-hover:backdrop-opacity-85",children:i.jsx("p",{className:"rounded-md bg-white px-2 py-1 text-xs",children:"Partial block. Double click to edit."})})})]})},rg=({partialBlockId:t})=>{const{getPartailBlocks:e}=Ds(),n=g.useMemo(()=>e(t),[e,t]),s=g.useMemo(()=>we.splitAtom(S.atom(n)),[n]);return u.isEmpty(n)?null:i.jsx(sg,{partialBlockId:t,children:i.jsx(xs,{splitAtoms:s,blocks:n,type:"PartialBlock"})})},xs=({blocks:t,parent:e=null,splitAtoms:n=void 0,type:s=""})=>{const r=Du(n);let o=g.useMemo(()=>u.filter(t,l=>u.has(l,"_id")&&(u.isEmpty(e)?!l._parent:l._parent===e)),[t,e]);const a=g.useCallback(l=>u.filter(t,c=>c._parent===l).length>0,[t]);return a&&(s==="Heading"||s==="Paragraph"||s==="Link")&&(o=$.adjustSpacingInContentBlocks(o)),u.map(o,l=>{const c=r(l._id);return c?i.jsx(kf,{block:l,children:d=>i.jsx(ng,{blockAtom:c,asyncProps:d,children:({_id:p,_type:f,partialBlockId:m,repeaterItems:h,$repeaterItemsKey:b})=>f==="Repeater"?u.isArray(h)&&h.map((x,y)=>i.jsx(Zl.Provider,{value:{index:y,key:b},children:i.jsx(xs,{splitAtoms:n,blocks:t,parent:l._id,type:f})},`${p}-${y}`)):f==="GlobalBlock"||f==="PartialBlock"?i.jsx(S.Provider,{store:Ve,children:i.jsx(rg,{partialBlockId:m})}):a(p)?i.jsx(xs,{splitAtoms:n,blocks:t,parent:l._id,type:f}):null})},l._id):null})},og=()=>{const[t]=te();return i.jsx(xs,{splitAtoms:In,blocks:t})},ig=()=>{const[t]=te(),[e]=S.useAtom(co),n=u.isEmpty(t)?null:i.jsx(og,{},e);return i.jsx(i.Fragment,{children:n})},ag=we.atomWithStorage("canvasZoom",100),Ql=()=>S.useAtom(ag),lg=()=>S.useAtom(ka),ec=we.atomWithStorage("canvasWidth",800),cg=we.atomWithStorage("canvasDisplayWidth",800),tc=S.atom(t=>{const e=t(ec);return ve.getBreakpointValue(e).toLowerCase()}),bs=()=>{const[t,e]=S.useAtom(ec),n=S.useAtomValue(tc),[s,r]=lg();return g.useEffect(()=>{s!=="xs"&&r(n)},[n,s,r]),[t,n,e]},Ao=()=>{const[t,e]=S.useAtom(cg);return[t,e]},dg=t=>{const[e]=Ao(),[,n]=Ql(),s=O("htmlDir","ltr"),[r,o]=g.useState({}),a=g.useCallback(()=>{const{width:l,height:c}=t;if(l<e){const d=parseFloat((l/e).toFixed(2).toString());let p={};const f=c*d,m=l*d;c&&(p={height:100+(c-f)/f*100+"%",width:100+(l-m)/m*100+"%"}),o({position:"relative",top:0,transform:`scale(${d})`,transformOrigin:s==="rtl"?"top right":"top left",...p,maxWidth:"none"}),n(d*100)}else o({}),n(100)},[e,t,s,n]);return g.useEffect(()=>{a()},[e,t,n,a]),r};function Yt(t,e){g.useEffect(()=>{const n=re.subscribe(t,e);return()=>n()},[t,e])}const ug=()=>{const[,t]=K(),[e,n]=Ee(),{document:s}=st(),{clearHighlight:r}=nt(),[o]=K(),[a]=S.useAtom(oo);return g.useEffect(()=>{setTimeout(()=>{if(!u.isEmpty(e))return;const l=Ga(s,u.first(o));if(l){const c=l.getAttribute("data-style-prop");if(c){const d=l.getAttribute("data-style-id"),p=l.getAttribute("data-block-parent");n([{id:d,prop:c,blockId:p}])}}},100)},[s,o,n,e]),g.useEffect(()=>()=>r(),[r]),Yt(Y.CANVAS_BLOCK_SELECTED,l=>{l&&(!u.isEmpty(l)&&!u.includes(o,u.first(l))&&(a==null||a.closeAll()),t(l))}),Yt(Y.CANVAS_BLOCK_STYLE_SELECTED,l=>{if(!l)return;const{blockId:c,styleId:d,styleProp:p}=l;c&&(u.includes(o,c)||a==null||a.closeAll(),n([{id:d,prop:p,blockId:c}]),t([c]))}),Yt(Y.CLEAR_CANVAS_SELECTION,()=>{r(),t([]),n([])}),null},pg=()=>{const[t]=Ao(),[,e]=$a(),n=g.useRef(null),s=g.useRef(null),[r,o]=g.useState({width:0,height:0}),a=dg(r),[,l]=rn(),c=O("loading",!1),d=O("htmlDir","ltr"),{onDragOver:p,onDrop:f,onDragEnd:m}=on(),h=Mp(),b=g.useCallback(y=>{o(k=>({...k,width:y}))},[o]);g.useEffect(()=>{if(!s.current)return;const{clientWidth:y,clientHeight:k}=s.current;o({width:y,height:k})},[s,t]);const x=g.useMemo(()=>{let y=nf;return y=y.replace("__HTML_DIR__",d),y},[d]);return i.jsx(xf,{onMount:b,onResize:b,children:i.jsx("div",{onMouseLeave:()=>setTimeout(()=>e(""),300),className:"relative mx-auto h-full w-full overflow-hidden",onDragOver:p,onDrop:f,onDragEnd:m,ref:s,children:i.jsxs(rf,{contentDidMount:()=>l(n.current),ref:n,id:"canvas-iframe",style:{...a,...u.isEmpty(a)?{width:`${t}px`}:{}},className:"relative mx-auto box-content h-full w-full max-w-full shadow-lg transition-all duration-300 ease-linear",initialContent:x,children:[i.jsx(uf,{}),i.jsx(ef,{}),i.jsx(ff,{}),i.jsxs(iu.Provider,{children:[i.jsxs(Zp,{children:[c?i.jsx("div",{className:"h-full p-4",children:i.jsx(Mt,{className:"h-full"})}):i.jsx(ig,{}),i.jsx(pf,{})]}),i.jsx(ug,{})]}),h.isVisible&&i.jsx("div",{id:"placeholder",className:`pointer-events-none absolute z-[99999] max-w-full transition-all duration-150 ${h.isEmpty?"bg-purple-500/10 outline-dashed outline-2 -outline-offset-2 outline-purple-500":"rounded-full bg-green-500"}`,style:{top:h.top,left:h.left,width:h.width,height:h.height}})]})})})},kn=()=>{const{t}=F.useTranslation();return i.jsx("div",{className:"h-full w-full rounded-md bg-red-200 p-4 text-red-500",children:i.jsxs("div",{className:"flex h-full w-full flex-col items-center justify-center",children:[i.jsx("p",{className:"font-semibold",children:t("Oops! Something went wrong.")}),i.jsx("p",{children:t("Please try again.")})]})})},fg=S.atom(null),_o=()=>S.useAtom(fg),hg=g.lazy(()=>Promise.resolve().then(()=>require("./code-editor-BQZi6-FB.cjs"))),nc=()=>{const[t]=_o(),e=O("onError",u.noop);return i.jsx("div",{className:"flex h-full max-h-full w-full flex-1 flex-col",children:i.jsxs("div",{className:"relative flex h-full max-h-full flex-col overflow-hidden bg-gray-100/40",children:[i.jsx(g.Suspense,{fallback:i.jsx(Mt,{className:"h-full"}),children:i.jsx(_t.ErrorBoundary,{fallback:i.jsx(kn,{}),onError:e,children:i.jsx(pg,{})})}),t?i.jsx(g.Suspense,{fallback:i.jsx(Mt,{className:"h-full"}),children:i.jsx(hg,{})}):null]})})},$s={},mg=(t,e)=>{$s[t]={id:t,component:e,type:"widget"}},gg=(t,e)=>{$s[t]={id:t,component:e,type:"field"}},xg=(t,e)=>{$s[t]={id:t,component:e,type:"template"}},dr=t=>Object.values($s).filter(e=>e.type===t).reduce((e,n)=>(e[n.id]=n.component,e),{}),bg=g.lazy(()=>Promise.resolve().then(()=>require("./IconPicker-C9-ieDWm.cjs")).then(t=>({default:t.IconPicker}))),yg=t=>{try{let e=t.replace(/<svg([^>]*)\sheight="[^"]*"([^>]*)>/gi,"<svg$1$2>").replace(/<svg([^>]*)\swidth="[^"]*"([^>]*)>/gi,"<svg$1$2>");return e=e.replace(/>\s+</g,"><"),e=e.replace(/\n/g,"").replace(/\s{2,}/g," "),e=e.replace(/\s+=/g,"=").replace(/=\s+/g,"="),e=e.replace(/<!--[\s\S]*?-->/g,""),e.trim()}catch{return t}},vg=({value:t,onChange:e,id:n})=>{const{t:s}=F.useTranslation(),[r,o]=g.useState(t||"");g.useEffect(()=>{o(t||"")},[t]);const a=l=>{o(l);const c=yg(l);e(c)};return i.jsxs("div",{className:"mt-1 flex flex-col gap-2",id:"icon-picker-field",children:[i.jsxs("div",{className:"flex items-center gap-x-2",children:[i.jsx("div",{className:"flex h-12 w-12 items-center justify-center overflow-hidden rounded-lg border bg-gray-50",children:r?i.jsx("div",{className:"h-6 w-6",dangerouslySetInnerHTML:{__html:r}}):i.jsx("span",{className:"text-xs text-gray-400",children:"SVG"})}),i.jsx("textarea",{id:n,autoCapitalize:"off",autoCorrect:"off",spellCheck:"false",value:r,onChange:l=>a(l.target.value),placeholder:s("SVG_code"),rows:2,className:"no-scrollbar w-full rounded-md border border-border bg-background px-3 py-1.5 text-xs shadow-sm transition-colors placeholder:text-muted-foreground focus-visible:outline-none focus-visible:ring-1 focus-visible:ring-ring disabled:cursor-not-allowed disabled:opacity-50"})]}),i.jsxs("div",{className:"flex items-center gap-2",children:[i.jsx(g.Suspense,{fallback:i.jsx("div",{className:"text-xs text-muted-foreground",children:"Loading..."}),children:i.jsx(bg,{onSelectIcon:a})}),i.jsx("p",{className:"text-xs text-muted-foreground",children:s("Paste SVG_code")})]})]})},On=ie.Root,sc=ie.Trigger,kg=ie.Portal,rc=M.forwardRef(({className:t,...e},n)=>i.jsx(ie.Overlay,{ref:n,className:L("fixed inset-0 z-50 bg-black/80 data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0",t),...e}));rc.displayName=ie.Overlay.displayName;const ln=M.forwardRef(({className:t,children:e,...n},s)=>i.jsxs(kg,{children:[i.jsx(rc,{}),i.jsxs(ie.Content,{ref:s,className:L("fixed left-[50%] top-[50%] z-50 grid w-full max-w-lg translate-x-[-50%] translate-y-[-50%] gap-4 border bg-background p-6 shadow-lg duration-200 data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0 data-[state=closed]:zoom-out-95 data-[state=open]:zoom-in-95 data-[state=closed]:slide-out-to-left-1/2 data-[state=closed]:slide-out-to-top-[48%] data-[state=open]:slide-in-from-left-1/2 data-[state=open]:slide-in-from-top-[48%] sm:rounded-lg",t),...n,children:[e,i.jsxs(ie.Close,{className:"absolute right-4 top-4 rounded-sm opacity-70 ring-offset-background transition-opacity hover:opacity-100 focus:outline-none focus:ring-2 focus:ring-ring focus:ring-offset-2 disabled:pointer-events-none data-[state=open]:bg-accent data-[state=open]:text-muted-foreground",children:[i.jsx(v.Cross1Icon,{className:"h-4 w-4"}),i.jsx("span",{className:"sr-only",children:"Close"})]})]})]}));ln.displayName=ie.Content.displayName;const Fn=({className:t,...e})=>i.jsx("div",{className:L("flex flex-col space-y-1.5 text-center sm:text-left",t),...e});Fn.displayName="DialogHeader";const oc=({className:t,...e})=>i.jsx("div",{className:L("flex flex-col-reverse sm:flex-row sm:justify-end sm:space-x-2",t),...e});oc.displayName="DialogFooter";const cn=M.forwardRef(({className:t,...e},n)=>i.jsx(ie.Title,{ref:n,className:L("text-lg font-semibold leading-none tracking-tight",t),...e}));cn.displayName=ie.Title.displayName;const ic=M.forwardRef(({className:t,...e},n)=>i.jsx(ie.Description,{ref:n,className:L("text-sm text-muted-foreground",t),...e}));ic.displayName=ie.Description.displayName;const wg=_n.cva("relative w-full rounded-lg border px-4 py-3 text-sm [&>svg+div]:translate-y-[-3px] [&>svg]:absolute [&>svg]:left-4 [&>svg]:top-4 [&>svg]:text-foreground [&>svg~*]:pl-7",{variants:{variant:{default:"bg-background text-foreground",destructive:"border-destructive/50 text-destructive dark:border-destructive [&>svg]:text-destructive"}},defaultVariants:{variant:"default"}}),Io=M.forwardRef(({className:t,variant:e,...n},s)=>i.jsx("div",{ref:s,role:"alert",className:L(wg({variant:e}),t),...n}));Io.displayName="Alert";const Cg=M.forwardRef(({className:t,...e},n)=>i.jsx("h5",{ref:n,className:L("mb-1 font-medium leading-none tracking-tight",t),...e}));Cg.displayName="AlertTitle";const To=M.forwardRef(({className:t,...e},n)=>i.jsx("div",{ref:n,className:L("text-sm [&_p]:leading-relaxed",t),...e}));To.displayName="AlertDescription";const Bo=_n.cva("inline-flex items-center justify-center gap-2 whitespace-nowrap rounded-md text-sm font-medium transition-colors focus-visible:outline-none focus-visible:ring-1 focus-visible:ring-ring disabled:pointer-events-none disabled:opacity-50 [&_svg]:pointer-events-none [&_svg]:size-4 [&_svg]:shrink-0",{variants:{variant:{default:"bg-primary text-primary-foreground shadow hover:bg-primary/90",destructive:"bg-destructive text-destructive-foreground shadow-sm hover:bg-destructive/90",outline:"border border-input bg-background shadow-sm hover:bg-accent hover:text-accent-foreground",secondary:"bg-secondary text-secondary-foreground shadow-sm hover:bg-secondary/80",ghost:"hover:bg-accent hover:text-accent-foreground",link:"text-primary underline-offset-4 hover:underline"},size:{default:"h-9 px-4 py-2",sm:"h-8 rounded-md px-3 text-xs",lg:"h-10 rounded-md px-8",icon:"h-9 w-9"}},defaultVariants:{variant:"default",size:"default"}}),q=M.forwardRef(({className:t,variant:e,size:n,asChild:s=!1,...r},o)=>{const a=s?_d.Slot:"button";return i.jsx(a,{className:L(Bo({variant:e,size:n,className:t})),ref:o,...r})});q.displayName="Button";const jg=({close:t,onSelect:e,mode:n="image"})=>{const[s,r]=g.useState(""),[o,a]=g.useState(!1),[l,c]=g.useState(!1),[d,p]=g.useState(null),f=async h=>{if(!h.trim()){c(!1),p("Please enter a URL");return}try{a(!0),p(null),c(!0),p(null)}catch{c(!1),p("Error validating URL")}finally{a(!1)}},{t:m}=F.useTranslation();return i.jsxs("div",{className:"flex w-96 flex-col gap-4 p-4",children:[i.jsx("h2",{className:"text-xl font-semibold",children:m(`${n.charAt(0).toUpperCase()+n.slice(1)} Manager`)}),d&&i.jsxs(Io,{variant:"destructive",children:[i.jsx(v.ExclamationTriangleIcon,{className:"h-4 w-4"}),i.jsx(To,{children:d})]}),i.jsxs("div",{className:"flex flex-col gap-4",children:[i.jsx(vt,{placeholder:m(`Enter ${n} URL`),value:s,onChange:h=>r(h.target.value),onKeyUp:()=>f(s)}),i.jsxs("div",{className:"flex justify-end gap-2",children:[i.jsx(q,{variant:"outline",onClick:t,children:m("Cancel")}),i.jsx(q,{onClick:()=>e({id:"dam-id",url:s,width:600,height:400,description:"This is image description"}),disabled:!l||o,children:m("Insert")})]})]})]})},ac={component:jg},Sg=t=>{ac.component=t},lc=()=>g.useMemo(()=>ac.component,[]),ss=({assetId:t,children:e,onSelect:n,mode:s="image"})=>{const[r,o]=g.useState(!1),a=lc(),l=(...c)=>{n.call(void 0,...c),o(!1)};return i.jsxs(On,{open:r,onOpenChange:c=>o(c),children:[i.jsx(sc,{asChild:!0,children:e}),i.jsxs(ln,{className:"flex max-h-[90vh] max-w-7xl border-border md:w-fit",children:[i.jsx(cn,{className:"sr-only",children:"Media Manager"}),i.jsx("div",{className:"h-full w-full",children:a?i.jsx(a,{close:()=>o(!1),onSelect:l,mode:s,assetId:t}):null})]})]})};ss.displayName="MediaManagerModal";const Qn="data:image/svg+xml;base64,PHN2ZyB3aWR0aD0iNTAwIiBoZWlnaHQ9IjQwMCIgeG1sbnM9Imh0dHA6Ly93d3cudzMub3JnLzIwMDAvc3ZnIj48cmVjdCB3aWR0aD0iMTAwJSIgaGVpZ2h0PSIxMDAlIiBmaWxsPSIjZjNmNGY2Ii8+PHRleHQgeD0iNTAlIiB5PSI1MCUiIGZvbnQtZmFtaWx5PSJBcmlhbCwgc2Fucy1zZXJpZiIgZm9udC1zaXplPSIxNiIgZmlsbD0iI2Q1ZDdkYSIgdGV4dC1hbmNob3I9Im1pZGRsZSIgZHk9Ii4zZW0iPkltYWdlIFBsYWNlaG9sZGVyPC90ZXh0Pjwvc3ZnPg==",Ng=t=>{var r;if(!t||u.startsWith(t,"data"))return"";const e=((r=t.split("/").pop())==null?void 0:r.split("?")[0])||"";return[".jpg",".jpeg",".png",".gif",".webp",".svg",".bmp",".ico",".avif"].some(o=>e.toLowerCase().endsWith(o))?e:""},Eg=({value:t,onChange:e,id:n,onBlur:s,uiSchema:r})=>{const{t:o}=F.useTranslation(),{selectedLang:a}=Le(),l=Z(),c=tt(),d=sn(),p=(r==null?void 0:r["ui:allowEmpty"])===!0,f=n.split(".").pop()||"",m=a?`_${f}Id-${a}`:`_${f}Id`,h=u.isEmpty(a)&&(l==null?void 0:l._type)==="Image"&&u.has(l,"assetId"),b=u.get(l,m,h?l==null?void 0:l.assetId:""),x=g.useMemo(()=>{if(!t||!l||!/\{\{.*?\}\}/.test(t))return t;const _={...l,[f]:t},I=$.applyBindingToBlockProps(_,d,{index:-1,key:""});return u.get(I,f,t)},[t,l,d,f]),y=!!b||x!==Qn&&x!=="",k=A=>{const _=u.isArray(A)?u.first(A):A;if(_){e(_==null?void 0:_.url);const I=_==null?void 0:_.width,j=_==null?void 0:_.height,N=m.includes("mobile");if(l!=null&&l._id){const C={...I&&{[N?"mobileWidth":"width"]:I},...j&&{[N?"mobileHeight":"height"]:j},..._.description&&{alt:_.description}};if(u.set(C,m,_.id),u.isEmpty(C))return;c([l._id],C)}}},w=g.useCallback(()=>{if(e(p?"":Qn),l!=null&&l._id){const _={},I=m.includes("mobile");u.set(_,m,""),u.set(_,I?"mobileWidth":"width",""),u.set(_,I?"mobileHeight":"height",""),c([l._id],_)}},[e,l==null?void 0:l._id,c,m,p]),E=Ng(x);return i.jsxs("div",{className:"mt-1.5 flex items-start gap-x-3",children:[x?i.jsxs("div",{className:"group relative",children:[i.jsx("img",{src:x,className:"h-14 w-14 overflow-hidden rounded-md border border-border object-cover transition duration-200 "+(b&&b!==""?"cursor-pointer group-hover:blur-sm":""),alt:""}),y&&i.jsx("button",{type:"button",onClick:w,className:"absolute -right-2 -top-2 z-20 rounded-full bg-destructive p-1 text-destructive-foreground hover:bg-destructive/90",children:i.jsx(v.Cross1Icon,{className:"h-3 w-3"})}),b&&b!==""&&i.jsx(ss,{onSelect:k,assetId:b,children:i.jsx("button",{type:"button",className:"absolute inset-0 z-10 flex cursor-pointer items-center justify-center bg-black/10 opacity-0 transition duration-200 group-hover:bg-black/30 group-hover:opacity-100",children:i.jsx(v.Pencil2Icon,{className:"h-4 w-4 text-white"})})})]}):i.jsx(ss,{onSelect:k,mode:"image",assetId:b,children:i.jsx("div",{className:"h-14 w-14 cursor-pointer rounded-md border border-border bg-[radial-gradient(#AAA,transparent_1px)] duration-300 [background-size:10px_10px]"})}),i.jsxs("div",{className:"flex w-3/5 flex-col",children:[i.jsxs(i.Fragment,{children:[i.jsx("p",{className:"max-w-[250px] truncate pr-2 text-xs text-gray-400",children:E}),i.jsx(ss,{onSelect:k,assetId:"",children:i.jsx("small",{className:"mb-1 h-6 w-full cursor-pointer rounded-md bg-secondary px-1 py-1 text-center text-xs text-secondary-foreground hover:bg-secondary/80",children:!u.isEmpty(x)&&x!==Qn?o("Replace image"):o("Choose image")})}),i.jsx("div",{className:"text-center text-xs text-gray-400",children:"OR"})]}),i.jsx("input",{id:n,autoCapitalize:"off",autoCorrect:"off",spellCheck:"false",type:"url",className:"h-6 text-xs",placeholder:o("Enter image URL"),value:t===Qn?"":t,onBlur:({target:{value:A}})=>s(n,A),onChange:A=>e(A.target.value)})]})]})},Qt={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"},Ro=M.forwardRef(({className:t,...e},n)=>i.jsx(Fe.Command,{ref:n,className:L("flex h-full w-full flex-col overflow-hidden rounded-md bg-popover text-popover-foreground",t),...e}));Ro.displayName=Fe.Command.displayName;const Po=M.forwardRef(({className:t,...e},n)=>i.jsxs("div",{className:"flex items-center border-b px-3","cmdk-input-wrapper":"",children:[i.jsx(v.MagnifyingGlassIcon,{className:"mr-2 h-4 w-4 shrink-0 opacity-50"}),i.jsx(Fe.Command.Input,{ref:n,className:L("flex h-10 w-full rounded-md bg-transparent py-3 text-sm outline-none placeholder:text-muted-foreground disabled:cursor-not-allowed disabled:opacity-50",t),...e})]}));Po.displayName=Fe.Command.Input.displayName;const Lo=M.forwardRef(({className:t,...e},n)=>i.jsx(Fe.Command.List,{ref:n,className:L("max-h-[300px] overflow-y-auto overflow-x-hidden",t),...e}));Lo.displayName=Fe.Command.List.displayName;const Mo=M.forwardRef((t,e)=>i.jsx(Fe.Command.Empty,{ref:e,className:"py-6 text-center text-sm",...t}));Mo.displayName=Fe.Command.Empty.displayName;const Do=M.forwardRef(({className:t,...e},n)=>i.jsx(Fe.Command.Group,{ref:n,className:L("overflow-hidden p-1 text-foreground [&_[cmdk-group-heading]]:px-2 [&_[cmdk-group-heading]]:py-1.5 [&_[cmdk-group-heading]]:text-xs [&_[cmdk-group-heading]]:font-medium [&_[cmdk-group-heading]]:text-muted-foreground",t),...e}));Do.displayName=Fe.Command.Group.displayName;const Ag=M.forwardRef(({className:t,...e},n)=>i.jsx(Fe.Command.Separator,{ref:n,className:L("-mx-1 h-px bg-border",t),...e}));Ag.displayName=Fe.Command.Separator.displayName;const ys=M.forwardRef(({className:t,...e},n)=>i.jsx(Fe.Command.Item,{ref:n,className:L("relative flex cursor-default select-none items-center gap-2 rounded-sm px-2 py-1.5 text-sm outline-none data-[disabled=true]:pointer-events-none data-[selected=true]:bg-accent data-[selected=true]:text-accent-foreground data-[disabled=true]:opacity-50 [&_svg]:pointer-events-none [&_svg]:size-4 [&_svg]:shrink-0",t),...e}));ys.displayName=Fe.Command.Item.displayName;const Oo=wn.Root,Fo=wn.Trigger,zs=M.forwardRef(({className:t,align:e="center",sideOffset:n=4,...s},r)=>i.jsx(wn.Portal,{children:i.jsx(wn.Content,{ref:r,align:e,sideOffset:n,className:L("z-50 w-72 origin-[--radix-popover-content-transform-origin] rounded-md border bg-popover p-4 text-popover-foreground shadow-md outline-none data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0 data-[state=closed]:zoom-out-95 data-[state=open]:zoom-in-95 data-[side=bottom]:slide-in-from-top-2 data-[side=left]:slide-in-from-right-2 data-[side=right]:slide-in-from-left-2 data-[side=top]:slide-in-from-bottom-2",t),...s})}));zs.displayName=wn.Content.displayName;const vs=Jt.Provider,pe=Jt.Root,fe=Jt.Trigger,ue=M.forwardRef(({className:t,sideOffset:e=4,...n},s)=>i.jsx(Jt.Portal,{children:i.jsx(Jt.Content,{ref:s,sideOffset:e,className:L("z-50 origin-[--radix-tooltip-content-transform-origin] overflow-hidden rounded-md bg-primary px-3 py-1.5 text-xs text-primary-foreground animate-in fade-in-0 zoom-in-95 data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=closed]:zoom-out-95 data-[side=bottom]:slide-in-from-top-2 data-[side=left]:slide-in-from-right-2 data-[side=right]:slide-in-from-left-2 data-[side=top]:slide-in-from-bottom-2",t),...n})}));ue.displayName=Jt.Content.displayName;const _g=({data:t,onSelect:e,dataType:n})=>{const[s,r]=g.useState([]),[o,a]=g.useState(t),l=f=>Array.isArray(f)?"array":typeof f=="object"&&f!==null?"object":"value",c=g.useCallback(f=>{const m=h=>n==="value"?h==="value"||h==="object":n==="array"?h==="array":h===n;f.type==="object"?(r(h=>[...h,f.key]),a(f.value)):m(f.type)&&e([...s,f.key].join("."),n)},[s,e,n]),d=g.useCallback(()=>{if(s.length>0){const f=s.slice(0,-1);r(f),a(f.reduce((m,h)=>m[h],t))}},[s,t]),p=g.useMemo(()=>o?Object.entries(o).map(([f,m])=>({key:f,value:m,type:l(m)})).filter(f=>!u.startsWith(f.key,$.REPEATER_PREFIX)&&f.key.includes("/")?!1:n==="value"?f.type==="value"||f.type==="object":n==="array"?f.type==="array"||f.type==="object":n==="object"?f.type==="object":!0):[],[o,n]);return i.jsxs(Ro,{className:"fields-command",children:[i.jsx(Po,{className:"border-none",placeholder:"Search..."}),i.jsxs(Lo,{children:[i.jsx(Mo,{children:xt.t("No option found.")}),i.jsxs(Do,{children:[s.length>0&&i.jsxs(ys,{onSelect:d,className:"flex items-center text-sm",children:[i.jsx(v.ChevronLeftIcon,{className:"mr-2 h-4 w-4"}),xt.t("Back")]}),p.map(f=>i.jsxs(ys,{value:f.key,disabled:!1,onSelect:()=>c(f),className:"flex items-center justify-between",children:[i.jsxs("span",{className:"flex items-center gap-x-2",children:[u.startsWith(f.key,$.REPEATER_PREFIX)?i.jsx(v.LoopIcon,{}):u.startsWith(f.key,$.COLLECTION_PREFIX)?i.jsx(v.IdCardIcon,{}):null,u.startsWith(f.key,$.REPEATER_PREFIX)?xt.t("Repeater Data"):u.startsWith(f.key,$.COLLECTION_PREFIX)?f.key.replace($.COLLECTION_PREFIX,""):f.key]}),i.jsxs("div",{className:"flex items-center gap-2",children:[n==="object"&&f.type==="object"&&i.jsx(q,{size:"sm",variant:"ghost",className:"h-6 px-2 hover:bg-primary hover:text-primary-foreground",onClick:m=>{m.stopPropagation(),e([...s,f.key].join("."),n)},children:xt.t("Select")}),f.type==="object"&&i.jsx("div",{className:"cursor-pointer rounded p-1 hover:bg-muted",children:i.jsx(v.ChevronRightIcon,{className:"h-4 w-4 opacity-50"})})]})]},f.key))]})]})]})};function $o({data:t,onSelect:e,dataType:n="value"}){const[s,r]=g.useState(!1),o=O("collections",[]),a=g.useMemo(()=>n==="array"?{...o.map(c=>c.id).reduce((c,d)=>({...c,[$.COLLECTION_PREFIX+d]:[]}),{}),...t}:t,[t,o,n]);return i.jsxs(Oo,{open:s,onOpenChange:r,children:[i.jsxs(pe,{children:[i.jsx(fe,{asChild:!0,children:i.jsx(Fo,{asChild:!0,children:i.jsx(q,{size:"sm",variant:"ghost",className:"h-5 rounded-sm px-1 py-0 text-[9px] text-muted-foreground",role:"combobox","aria-expanded":s,children:i.jsx("svg",{xmlns:"http://www.w3.org/2000/svg",width:"24px",height:"24px",viewBox:"0 0 24 24",fill:"none",children:i.jsx("path",{d:"M9.5 5H9C7.89543 5 7 5.89543 7 7V9C7 10 6.4 12 4 12C5 12 7 12.6 7 15V17.0002C7 18.1048 7.89543 19 9 19H9.5M14.5 5H15C16.1046 5 17 5.89543 17 7V9C17 10 17.6 12 20 12C19 12 17 12.6 17 15V17.0002C17 18.1048 16.1046 19 15 19H14.5",stroke:"#000000",strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:"2"})})})})}),i.jsx(ue,{children:xt.t("Add field")})]}),i.jsx(zs,{className:"z-[1000]! relative mr-3 w-[300px] p-0",children:i.jsx(_g,{data:a,onSelect:(l,c)=>{e(l,c),r(!1)},dataType:n})})]})}const cc=({schema:t,onChange:e,id:n,formData:s})=>{const r=sn(),o=O("flags.dataBinding",!0),a=Nu(),l=Z(),c=g.useMemo(()=>{if(a.length===1)return"";const f=a.find(b=>b._type==="Repeater"),h=u.get(f,"repeaterItems","").replace(/\{\{(.*)\}\}/g,"$1");return`${$.REPEATER_PREFIX}${u.startsWith(h,$.COLLECTION_PREFIX)?`${h}/${f._id}`:h}`},[a]),d=g.useMemo(()=>u.first(u.get(r,c.replace($.REPEATER_PREFIX,""),[])),[c,r]),p=g.useCallback((f,m)=>{if(f=u.isEmpty(c)?f:f.replace(`${c}`,"$index"),m==="array"||m==="object"){e(`{{${f}}}`,{},n);return}const h=k=>/[.,!?;:]/.test(k),b=(k,w,E)=>{let A="",_="";const I=w>0?k[w-1]:"",j=w<k.length?k[w]:"";return w>0&&(I==="."||!h(I)&&I!==" ")&&(A=" "),w<k.length&&!h(j)&&j!==" "&&(_=" "),{text:A+E+_,prefixLength:A.length,suffixLength:_.length}},x=document.getElementById(n);if(!x)return;const y=document.getElementById(`chai-rte-${n}`)||document.getElementById(`chai-rte-modal-${n}`);if(y&&(y.querySelector(".ProseMirror")||y.__chaiRTE)){const k=y.__chaiRTE;if(k){const w=`{{${f}}}`;k.commands.focus();const{from:E,to:A}=k.state.selection;if(E!==A)k.chain().deleteSelection().insertContent(w).run();else{const{state:I}=k,j=I.selection.from,N=I.doc.textBetween(Math.max(0,j-1),j),C=I.doc.textBetween(j,Math.min(j+1,I.doc.content.size));let T="";j>0&&N!==" "&&!h(N)&&(T=" ");let R="";C&&C!==" "&&!h(C)&&(R=" "),k.chain().insertContent(T+w+R).run()}setTimeout(()=>e(k.getHTML(),{},n),100);return}}else{const k=x,w=k.selectionStart||0,E=k.value||"",A=k.selectionEnd||w;if(A>w){const C=`{{${f}}}`,{text:T}=b(E,w,C),R=E.slice(0,w)+T+E.slice(A);e(R,{},n);return}const I=`{{${f}}}`,{text:j}=b(E,w,I),N=E.slice(0,w)+j+E.slice(w);e(N,{},n)}},[n,e,s,l==null?void 0:l._id,c]);return o?i.jsx($o,{data:{...d&&{[c]:d},...r},onSelect:p,dataType:t.binding==="array"?"array":"value"}):null},Ig=({href:t,pageTypes:e,onChange:n})=>{var N;const{t:s}=F.useTranslation(),r=O("searchPageTypeItems",(C,T)=>[]),[o,a]=g.useState(!1),[l,c]=g.useState(!1),[d,p]=g.useState("page"),[f,m]=g.useState(""),[h,b]=g.useState([]),[x,y]=g.useState(-1),k=g.useRef(null),w=(N=e==null?void 0:e.find(C=>C.key===d))==null?void 0:N.name;g.useEffect(()=>{if(m(""),b([]),y(-1),c(!1),!t||o||!u.startsWith(t,"pageType:"))return;const C=u.split(t,":"),T=u.get(C,1,"page")||"page";p(T),(async()=>{const R=await r(T,[u.get(C,2,"page")]);R&&Array.isArray(R)&&m(u.get(R,[0,"name"],""))})()},[t]);const E=ke.useDebouncedCallback(async C=>{if(u.isEmpty(C))b([]);else{const T=await r(d,C);b(T)}a(!1),y(-1)},[d],300),A=C=>{const T=["pageType",d,C.id];T[1]&&(n(T.join(":")),m(C.name),c(!1),b([]),y(-1))},_=C=>{switch(C.key){case"ArrowDown":C.preventDefault(),y(T=>T<h.length-1?T+1:T);break;case"ArrowUp":C.preventDefault(),y(T=>T>0?T-1:T);break;case"Enter":if(C.preventDefault(),h.length===0)return;x>=0&&A(h[x]);break;case"Escape":C.preventDefault(),I();break}};g.useEffect(()=>{if(x>=0&&k.current){const C=k.current.children[x];C==null||C.scrollIntoView({block:"nearest"})}},[x]);const I=()=>{m(""),b([]),y(-1),c(!1),n("")},j=C=>{m(C),c(!u.isEmpty(C)),a(!0),E(C)};return i.jsxs("div",{children:[i.jsx("select",{name:"pageType",value:d,onChange:C=>p(C.target.value),children:u.map(e,C=>i.jsx("option",{value:C.key,children:C.name},C.key))}),d&&i.jsxs("div",{className:"group relative mt-2 flex items-center",children:[i.jsx("input",{type:"text",value:f,onChange:C=>j(C.target.value),onKeyDown:_,placeholder:s(`Search ${w??""}`),className:"w-full rounded-md border border-gray-300 p-2 pr-16"}),i.jsx("div",{className:"absolute bottom-2 right-2 top-3 flex items-center gap-1.5",children:f&&i.jsx("button",{onClick:I,className:"text-gray-400 hover:text-gray-600",title:s("Clear search"),children:i.jsx(v.Cross1Icon,{className:"h-4 w-4"})})})]}),(o||!u.isEmpty(h)||l&&u.isEmpty(h))&&i.jsx("div",{className:"absolute z-40 mt-2 max-h-40 w-full max-w-[250px] overflow-y-auto rounded-md border border-border bg-background shadow-lg",children:o?i.jsxs("div",{className:"space-y-1 p-2",children:[i.jsx("div",{className:"h-6 w-full animate-pulse rounded bg-gray-200"}),i.jsx("div",{className:"h-6 w-full animate-pulse rounded bg-gray-200"})]}):l&&u.isEmpty(h)?i.jsxs("div",{className:"flex items-center justify-center p-4 text-sm text-gray-500",children:[s("No results found for"),' "',f,'"']}):i.jsx("ul",{ref:k,children:u.map(h==null?void 0:h.slice(0,20),(C,T)=>i.jsxs("li",{onClick:()=>A(C),className:`cursor-pointer p-2 text-xs ${t!=null&&t.includes(C.id)?"bg-blue-200":T===x?"bg-gray-100":"hover:bg-gray-100"}`,children:[C.name," ",C.slug&&i.jsxs("small",{className:"font-light text-gray-500",children:["( ",C.slug," )"]})]},C.id))})})]})},Tg=({schema:t,formData:e,onChange:n,name:s})=>{const{t:r}=F.useTranslation(),{type:o="pageType",href:a="",target:l="self"}=e??{},c=O("pageTypes",[]),{selectedLang:d,fallbackLang:p,languages:f}=Le(),m=g.useMemo(()=>u.isEmpty(f)?"":u.isEmpty(d)?p:d,[f,d,p]),h=g.useMemo(()=>u.get(Qt,m,m),[m]),b=o==="pageType"&&u.isEmpty(c)?"url":o;return i.jsxs("div",{children:[i.jsxs("span",{className:"flex items-center justify-between gap-x-2 text-xs font-medium",children:[i.jsxs("span",{children:[(t==null?void 0:t.title)??"Link",i.jsx("span",{className:"pl-1 text-[9px] text-zinc-400",children:h})]}),i.jsx(cc,{schema:t,onChange:x=>{n({...e,href:x,...b==="pageType"?{type:"url"}:{}})},id:`root.${s}.href`,formData:e})]}),i.jsxs("div",{className:"flex flex-col gap-y-1.5",children:[i.jsx("select",{name:"type",value:o,onChange:x=>n({...e,type:x.target.value}),children:u.map([...u.isEmpty(c)?[]:[{const:"pageType",title:r("Goto Page")}],{const:"url",title:r("Open URL")},{const:"email",title:r("Compose Email")},{const:"telephone",title:r("Call Phone")},{const:"scroll",title:r("Scroll to element")}],x=>i.jsx("option",{value:x.const,children:x.title},x.const))}),b==="pageType"&&!u.isEmpty(c)?i.jsx(Ig,{href:a,pageTypes:c,onChange:x=>n({...e,href:x})}):null,i.jsx("input",{id:`root.${s}.href`,autoCapitalize:"off",autoCorrect:"off",spellCheck:"false",name:"href",type:"text",className:b==="pageType"?"!hidden":"",value:a,onChange:x=>n({...e,href:x.target.value}),placeholder:r(o==="url"?"Enter URL":o==="scroll"?"#ElementID":"Enter details")}),b==="url"&&i.jsxs("div",{className:"flex items-center gap-x-2 text-muted-foreground",children:[i.jsx("input",{id:`root.${s}.target`,autoCapitalize:"off",autoCorrect:"off",spellCheck:"false",type:"checkbox",checked:l==="_blank",className:"!w-fit cursor-pointer rounded-md border border-border",onChange:()=>n({...e,target:l==="_blank"?"_self":"_blank"})}),i.jsx("span",{className:"pt-1 text-xs",children:r("Open in new tab")})]})]})]})},dc=S.atom(t=>{var a;const e=t(Se),n=t(As),s=n.length===1?n[0]:null;if(!s)return null;const r=u.find(e,{_id:s});if(!r)return null;let o=r._parent;for(;o;){const l=u.find(e,{_id:o});if(!l)return null;if((a=J.getRegisteredChaiBlock(l._type))!=null&&a.wrapper)return l;o=l._parent}return null});dc.debugLabel="wrapperBlockAtom";const zo=()=>S.useAtomValue(dc),Bg=()=>{const t=Z(),e=zo(),{addCoreBlock:n}=yt();if(!t&&!e)return null;const s=(t==null?void 0:t._type)==="Row"?t:e;return i.jsx("div",{className:"pt-1",children:i.jsxs("button",{type:"button",className:"duratiom-300 flex items-center gap-x-1 rounded border border-gray-400 bg-gray-100 px-4 py-1 text-[11px] font-medium leading-tight hover:bg-slate-200",onClick:()=>n({type:"Column",styles:"#styles:,"},s==null?void 0:s._id),children:[i.jsx(v.PlusIcon,{className:"h-4 w-4"})," Add Column"]})})},Rg=g.lazy(()=>Promise.resolve().then(()=>require("./rte-widget-modal-DrMzWWjw.cjs"))),Pg=({blockId:t,id:e,placeholder:n,value:s,onChange:r,onBlur:o})=>{const a=g.useRef(null),[l,c]=g.useState(!1),d=Jl({blockId:t,value:s,placeholder:n,onBlur:({editor:m})=>{const h=m==null?void 0:m.getHTML();o(e,h)},onUpdate:({editor:m})=>{const h=m==null?void 0:m.getHTML();r(h)}});g.useEffect(()=>{a.current&&d&&(a.current.__chaiRTE=d)},[t,d]);const p=()=>{c(!1)},f=i.jsxs("div",{id:`chai-rte-${e}`,ref:a,className:"mt-1 rounded-md border border-input",children:[i.jsx(sl,{editor:d,onExpand:()=>c(!0)}),i.jsx(as.EditorContent,{editor:d,id:e,placeholder:n,className:`overflow-auto ${l?"max-h-[500px] min-h-[400px]":"max-h-[200px] min-h-[100px]"}`},e)]});return i.jsxs(i.Fragment,{children:[l&&i.jsx(g.Suspense,{fallback:i.jsx("div",{children:"Loading..."}),children:i.jsx(Rg,{isOpen:l,onClose:p,editor:d,rteElement:f})}),l?i.jsx("div",{children:"Open in modal"}):i.jsx("div",{className:"relative",children:f})]})},Lg=t=>{const{editingBlockId:e}=$t(),[n,s]=g.useState(null),r=Z(),o=r==null?void 0:r._id;return g.useEffect(()=>{s(o)},[o]),n&&n!==e?i.jsx(Pg,{...t,blockId:n},n):null},Mg=({formData:t,onChange:e})=>{const[n]=te(),s=Z(),r=zo(),{addCoreBlock:o}=yt(),[,a]=K();if(!s&&!r)return null;const l=(s==null?void 0:s._type)==="Slider"?s:r,c=u.find(n,{_parent:l==null?void 0:l._id,_type:"Slides"});if(!c)return null;const d=u.filter(n,{_parent:c==null?void 0:c._id,_type:"Slide"}),p=(t==null?void 0:t.currentSlide)||u.get(d,"0._id");g.useEffect(()=>{(s==null?void 0:s._type)==="Slide"&&(t==null?void 0:t.currentSlide)!==(s==null?void 0:s._id)&&e({...t,currentSlide:s==null?void 0:s._id})},[s]),g.useEffect(()=>{d!=null&&d.length&&!u.find(d,{_id:t==null?void 0:t.currentSlide})&&e({...t,currentSlide:u.get(d,"0._id")})},[t,d]);const f=()=>{const b=u.findIndex(d,{_id:p});if(b>-1){const x=(b+1)%d.length,y=u.get(d,[x,"_id"]);if(!y)return;e({...t,currentSlide:y}),a([y])}},m=()=>{const b=u.findIndex(d,{_id:p});if(b>-1){const x=(b-1+d.length)%d.length,y=u.get(d,[x,"_id"]);if(!y)return;e({...t,currentSlide:y}),a([y])}},h=()=>{const b=o({styles:"#styles:,h-full w-full min-w-full",type:"Slide"},c==null?void 0:c._id),x=b==null?void 0:b._id;x&&(e({...t,currentSlide:x}),a([x]))};return i.jsxs("div",{className:"space-y-1.5 px-2",children:[i.jsxs("div",{className:"flex items-center gap-x-2 pb-2 text-[12px]",children:[i.jsx("button",{onClick:m,className:"rounded bg-gray-200 p-1.5 hover:opacity-80",children:i.jsx(v.ChevronLeftIcon,{className:"h-3 w-3"})}),i.jsx("div",{className:"whitespace-nowrap text-center text-[10px] text-slate-500",children:p?i.jsxs("span",{className:"",children:[i.jsxs("b",{className:"text-[12px]",children:[" ",u.findIndex(d,{_id:p})+1]}),"/",d.length]}):"-"}),i.jsx("button",{onClick:f,className:"rounded bg-gray-200 p-1.5 hover:opacity-80",children:i.jsx(v.ChevronRightIcon,{className:"h-3 w-3"})}),i.jsxs("button",{onClick:h,className:"flex w-full items-center justify-center gap-x-1 rounded bg-gray-200 p-1.5 text-xs font-medium leading-tight hover:opacity-80",children:[i.jsx(v.PlusCircledIcon,{className:"h-3 w-3"}),"Add Slide"]})]}),i.jsxs("div",{className:"flex items-center gap-x-2 leading-tight",children:[i.jsx("input",{type:"checkbox",checked:!!(t!=null&&t.showSlideButton),onChange:()=>e({...t,showSlideButton:!(t!=null&&t.showSlideButton)}),className:"cursor-pointer"}),i.jsx("label",{htmlFor:"autoplay",className:"mt-0.5 text-[12px]",children:"Show Slide Buttons"})]}),i.jsxs("div",{className:"flex items-center gap-x-2 leading-tight",children:[i.jsx("input",{type:"checkbox",checked:!!(t!=null&&t.showSlideNavbar),onChange:()=>e({...t,showSlideNavbar:!(t!=null&&t.showSlideNavbar)}),className:"cursor-pointer"}),i.jsx("label",{htmlFor:"autoplay",className:"mt-0.5 text-[12px]",children:"Show Slide Navbar"})]}),i.jsx("div",{children:i.jsxs("div",{className:"flex flex-col",children:[i.jsxs("div",{className:"flex items-center gap-x-2 leading-tight",children:[i.jsx("input",{type:"checkbox",checked:!!(t!=null&&t.autoplay),onChange:()=>e({...t,autoplay:!(t!=null&&t.autoplay)}),className:"cursor-pointer"}),i.jsx("label",{htmlFor:"autoplay",className:"mt-0.5 text-[12px]",children:"Autoplay slides"})]}),(t==null?void 0:t.autoplay)&&i.jsxs("div",{className:"pt-0.5 leading-tight",children:[i.jsxs("label",{htmlFor:"interval",className:"whitespace-nowrap text-[9px]",children:["Autoplay Interval ",i.jsx("span",{className:"font-light opacity-80",children:"(in seconds)"})]}),i.jsx("input",{type:"number",id:"interval",name:"interval",placeholder:"0",value:t==null?void 0:t.autoplayInterval,className:"text-xs",pattern:"[0-9]*",onChange:b=>{let x=b.target.value;x.length&&(x=x.replace("-","")),e({...t,autoplayInterval:x})}})]})]})})]})},Dg=({formData:t,onChange:e})=>{const n=u.get(t,"srcsets",[])||[],s=(a,l)=>{const c=a.target.name,d=a.target.value;e({srcsets:u.map(n,(p,f)=>f===l?{...p,[c]:d}:p)})},r=()=>{e({srcsets:[...n,{}]})},o=a=>{e({srcsets:u.reject(n,(l,c)=>c===a)})};return i.jsxs("div",{children:[i.jsxs("div",{className:"flex items-center justify-between pb-2",children:[i.jsx("label",{children:"Responsive Video (optional)"}),i.jsx("button",{type:"button",onClick:r,className:"flex items-center gap-x-1 rounded-md border border-blue-500 bg-blue-100 px-2 py-px text-xs text-blue-600 hover:opacity-80",children:i.jsx(v.PlusIcon,{className:"h-3 w-3"})})]}),i.jsx("div",{className:"space-y-2",children:n.length===0?i.jsx("div",{className:"rounded border border-dashed border-gray-200 p-2 text-xs italic text-gray-500",children:"Add additional sources to create responsive videos"}):u.map(n,(a,l)=>i.jsxs("div",{className:"group relative space-y-1.5 rounded border border-gray-200 px-2 pb-1.5",children:[i.jsx("button",{type:"button",onClick:()=>o(l),className:"absolute -right-px -top-0 -translate-y-1/2 rounded-full bg-red-100 p-1 opacity-0 hover:bg-red-200 group-hover:opacity-100",children:i.jsx(v.Cross1Icon,{className:"h-2.5 w-2.5 text-red-500"})}),i.jsxs("div",{className:"flex items-center gap-x-2 rounded border",children:[i.jsx("label",{className:"flex !h-6 h-full w-1/4 items-center justify-center bg-gray-200 px-2 !text-[10px] !font-medium",children:"Width"}),i.jsx("input",{name:"width",placeholder:"Enter width (in px)",type:"number",value:u.get(a,"width"),onChange:c=>s(c,l),className:"!placeholder:text-gray-100 !mt-0 !rounded-none !border-0 !p-0 !text-xs"})]}),i.jsxs("div",{className:"flex items-center gap-x-2 rounded border",children:[i.jsx("label",{className:"flex !h-6 h-full w-1/4 items-center justify-center bg-gray-200 px-2 !text-[10px] !font-medium",children:"URL"}),i.jsx("input",{name:"url",placeholder:"Enter url",className:"!mt-0 !rounded-none !border-0 !p-0 !text-xs !shadow-none",value:u.get(a,"url",""),onChange:c=>s(c,l)})]})]},l))})]})},Og=({id:t,placeholder:e})=>{const{t:n}=F.useTranslation(),[,s]=_o(),r=Z();if(typeof window>"u")return null;const o=t.replace("root.",""),a=u.get(r,o,""),l=()=>{const c=r==null?void 0:r._id;s({blockId:c,blockProp:o,placeholder:e,initialCode:u.get(r,o,a)})};return i.jsxs("div",{className:"mt-2 flex flex-col gap-y-1",children:[i.jsx("button",{onClick:l,className:"w-[90%] max-w-full cursor-default truncate text-pretty rounded border border-border bg-background p-2 text-left text-[10px]",children:a.trim().length>0?a.substring(0,46):e||"Eg: <script>console.log('Hello, world!');<\/script>"}),i.jsx(q,{onClick:l,size:"sm",variant:"outline",className:"w-fit",children:n("Open code editor")})]})},Fg=({id:t,value:e,onChange:n,onBlur:s})=>{const r=O("collections",[]),o=Z(),a=u.get(o,"repeaterItems","").replace(/\{\{(.*)\}\}/g,"$1").replace($.COLLECTION_PREFIX,""),l=u.find(r,{id:a}),c=t==="root.filter"?"filters":"sorts",d=u.get(l,c,[]);return i.jsx("div",{children:i.jsxs("select",{value:e,onChange:p=>n(p.target.value),onBlur:p=>s(t,p.target.value),children:[i.jsx("option",{value:"",children:"Select"}),d.map(p=>i.jsx("option",{value:p.id,children:p.name},p.id))]})})},$g=_n.cva("inline-flex items-center rounded-md border px-2.5 py-0.5 text-xs font-semibold transition-colors focus:outline-none focus:ring-2 focus:ring-ring focus:ring-offset-2",{variants:{variant:{default:"border-transparent bg-primary text-primary-foreground shadow hover:bg-primary/80",secondary:"border-transparent bg-secondary text-secondary-foreground hover:bg-secondary/80",destructive:"border-transparent bg-destructive text-destructive-foreground shadow hover:bg-destructive/80",outline:"text-foreground"}},defaultVariants:{variant:"default"}});function Hs({className:t,variant:e,...n}){return i.jsx("div",{className:L($g({variant:e}),t),...n})}const zg=t=>{const{id:e,classNames:n,label:s,children:r,errors:o,help:a,hidden:l,required:c,schema:d,formData:p,onChange:f}=t,{selectedLang:m,fallbackLang:h,languages:b}=Le(),x=g.useMemo(()=>u.isEmpty(b)?"":u.isEmpty(m)?h:m,[b,m,h]),y=g.useMemo(()=>u.get(Qt,x,x),[x]),k=sn(),w=Z(),E=J.useRegisteredChaiBlocks(),A=g.useMemo(()=>u.get(E,[w==null?void 0:w._type,"i18nProps"],[]),[E,w==null?void 0:w._type]),[_,I]=g.useState(null);if(l)return null;if(d.type==="boolean")return i.jsx("div",{className:n,children:r});const N=A==null?void 0:A.includes(e.replace("root.",""));if(d.type==="array"){const R=_===e;return i.jsxs("div",{className:`${n} relative`,children:[d.title&&i.jsx("div",{className:"flex items-center justify-between gap-1",children:i.jsxs("label",{htmlFor:e,onClick:()=>I(R?null:e),className:"flex cursor-pointer items-center gap-x-1 py-1 leading-tight duration-200 hover:bg-slate-100",children:[R?i.jsx(v.ChevronDownIcon,{className:"h-3 w-3"}):i.jsx(v.ChevronRightIcon,{className:"h-3 w-3"}),i.jsx(v.ListBulletIcon,{className:"h-3 w-3"}),i.jsx("span",{className:"leading-tight",children:s})," ",i.jsx(Hs,{className:"m-0 bg-gray-200 px-2 leading-tight text-gray-500 hover:bg-gray-200 hover:text-gray-500",children:i.jsx("span",{className:"text-[9px] font-medium text-slate-600",children:p==null?void 0:p.length})}),d.description&&i.jsx(vs,{children:i.jsxs(pe,{children:[i.jsx(fe,{asChild:!0,children:i.jsx(v.InfoCircledIcon,{className:"h-3 w-3 text-muted-foreground/70",onClick:B=>B.stopPropagation(),onMouseDown:B=>B.stopPropagation()})}),i.jsx(ue,{className:"max-w-xs",children:d.description})]})})]})}),(p==null?void 0:p.length)===0?i.jsx("div",{className:"h-0 overflow-hidden",children:r}):i.jsxs("div",{className:`${R?"pt-0.5":"h-0 overflow-hidden"}`,children:[r,o,a]})]})}const C=e.replace("root.",""),T=A.includes(C)&&!u.isEmpty(m)&&u.isEmpty(p);return i.jsxs("div",{className:n,children:[d.title&&i.jsxs("div",{className:"flex items-center justify-between",children:[i.jsxs("div",{className:"flex items-center gap-2",children:[i.jsxs("label",{htmlFor:e,className:d.type==="object"?"pb-2":"",children:[s," ",N&&i.jsxs("small",{className:"text-[9px] text-zinc-400",children:[" ",y]}),c&&d.type!=="object"?" *":null]}),d.description&&i.jsx(vs,{children:i.jsxs(pe,{children:[i.jsx(fe,{asChild:!0,children:i.jsx(v.InfoCircledIcon,{className:"h-3 w-3 text-muted-foreground/70"})}),i.jsx(ue,{className:"max-w-xs",children:d.description})]})})]}),!d.enum&&!d.oneOf&&k&&i.jsxs("span",{className:"flex items-center space-x-1",children:[T?i.jsxs(pe,{children:[i.jsx(fe,{asChild:!0,children:i.jsxs("svg",{xmlns:"http://www.w3.org/2000/svg",width:"24",height:"24",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor","stroke-width":"2","stroke-linecap":"round","stroke-linejoin":"round",className:"lucide lucide-triangle-alert-icon lucide-triangle-alert h-3 w-3 text-orange-400",children:[i.jsx("path",{d:"m21.73 18-8-14a2 2 0 0 0-3.48 0l-8 14A2 2 0 0 0 4 21h16a2 2 0 0 0 1.73-3"}),i.jsx("path",{d:"M12 9v4"}),i.jsx("path",{d:"M12 17h.01"})]})}),i.jsxs(ue,{className:"max-w-xs",children:["No translation provided. ",i.jsx("br",{}),"Using default language value."]})]}):null,i.jsx(cc,{schema:d,onChange:R=>{f(R,p,e)},id:e,formData:p})]})]}),r,o,a]})},Hg=({value:t,onChange:e})=>{var o;if(!t)return i.jsxs("div",{className:"mt-1 flex items-center gap-2 rounded-md border border-gray-200 bg-gray-50 px-2 py-1.5 text-xs text-gray-500 text-gray-600",children:[i.jsx(v.FileIcon,{className:"h-4 w-4"})," Choose a collection"]});const n=`{{${$.COLLECTION_PREFIX}`,s=t==null?void 0:t.startsWith(n);let r=t;return s&&(r=(o=t==null?void 0:t.replace(n,""))==null?void 0:o.replace("}}","")),i.jsx("div",{className:"mt-1 flex flex-col gap-1",children:i.jsxs("div",{className:"flex items-center justify-between gap-2 rounded-md border border-blue-200 bg-blue-50 px-2 py-1 text-xs text-blue-600",children:[i.jsxs("span",{className:"flex max-w-[200px] items-center gap-2",children:[" ",s?i.jsx(v.IdCardIcon,{className:"h-3 min-h-3 w-3 min-w-3"}):null,i.jsxs(pe,{delayDuration:500,children:[i.jsx(fe,{asChild:!0,children:i.jsx("span",{className:"cursor-default truncate",children:r})}),i.jsx(ue,{side:"left",hidden:r.length<50,children:r})]})]}),i.jsxs(pe,{children:[i.jsx(fe,{asChild:!0,children:i.jsx(q,{variant:"ghost",size:"icon",className:"h-5 w-5 rounded-full bg-gray-200 text-gray-900 hover:bg-gray-300",onClick:()=>e(""),children:i.jsx(v.Cross1Icon,{className:"h-4 w-4"})})}),i.jsx(ue,{side:"left",children:"Remove binding"})]})]})})},Vg=t=>i.jsx("button",{...t,className:"duration absolute right-2 top-2 cursor-pointer text-blue-400 hover:text-blue-500",children:i.jsxs("div",{className:"flex items-center gap-x-0.5 text-[11px] leading-tight",children:[i.jsx(v.PlusIcon,{className:"h-3 w-3"})," ",i.jsx("span",{children:"Add"})]})}),Fi=g.memo(({blockId:t,schema:e,uiSchema:n,formData:s,onChange:r})=>{const{selectedLang:o}=Le(),a=dr("widget"),l=dr("field"),c=dr("template"),d=ke.useThrottledCallback(async({formData:p},f)=>{u.get(p,f)===void 0&&u.set(p,f,""),r({formData:p},f)},[r,o],400);return i.jsx($d,{widgets:{richtext:Lg,icon:vg,image:Eg,code:Og,colCount:Bg,collectionSelect:Fg,repeaterBinding:Hg,...a},fields:{link:Tg,slider:Mg,sources:Dg,...l},templates:{FieldTemplate:zg,ButtonTemplates:{AddButton:Vg},...c},idSeparator:".",autoComplete:"off",omitExtraData:!1,liveOmit:!1,liveValidate:!1,validator:zd,uiSchema:n,schema:e,formData:s,onChange:({formData:p},f)=>{if(!f||t!==(p==null?void 0:p._id))return;const m=u.take(f.split("."),2).join(".").replace("root.","");d({formData:p},m)}},o)}),$i=(t,e,n)=>{const s=u.cloneDeep(t);return u.forEach(u.keys(t),r=>{u.includes(u.get(n,"i18nProps",[]),r)&&!u.isEmpty(e)&&(s[r]=u.get(t,`${r}-${e}`))}),s};function Nr(){const{selectedLang:t}=Le(),e=Z(),n=Jr(),s=tt(),r=J.getRegisteredChaiBlock(e==null?void 0:e._type),o=$i(e,t,r),[a,l]=g.useState(o),[c,d]=g.useState(!1),p=zo(),f=J.getRegisteredChaiBlock(p==null?void 0:p._type),m=$i(p,t,f),h=({formData:_},I,j)=>{I&&(a==null?void 0:a._id)===e._id&&s([e._id],{[I]:u.get(_,I)},j)},b=g.useCallback(u.debounce(({formData:_},I,j)=>{h({formData:_},I,j),l(_)},1500),[e==null?void 0:e._id,t]),x=({formData:_},I)=>{I&&(n([e._id],{[I]:u.get(_,I)}),b({formData:_},I,{[I]:u.get(a,I)}))},y=({formData:_},I)=>{I&&(n([p._id],{[I]:u.get(_,I)}),b({formData:_},I,{[I]:u.get(a,I)}))},{schema:k,uiSchema:w}=g.useMemo(()=>{const _=e==null?void 0:e._type;if(!_)return{schema:{},uiSchema:{}};try{const{schema:I,uiSchema:j}=J.getBlockFormSchemas(_);if(_==="Repeater"){const N=u.get(e,"repeaterItems","");u.startsWith(N,`{{${$.COLLECTION_PREFIX}`)?(u.set(j,"filter",{"ui:widget":"collectionSelect"}),u.set(j,"sort",{"ui:widget":"collectionSelect"})):(u.set(j,"filter",{"ui:widget":"hidden"}),u.set(j,"sort",{"ui:widget":"hidden"}))}return{schema:I,uiSchema:j}}catch{return{schema:{},uiSchema:{}}}},[e]),{wrapperSchema:E,wrapperUiSchema:A}=g.useMemo(()=>{if(!p||!(p!=null&&p._type))return{wrapperSchema:{},wrapperUiSchema:{}};const _=p==null?void 0:p._type,{schema:I={},uiSchema:j={}}=J.getBlockFormSchemas(_);return{wrapperSchema:I,wrapperUiSchema:j}},[p]);return i.jsxs("div",{className:"no-scrollbar overflow-x-hidden px-px",children:[!u.isEmpty(p)&&i.jsxs("div",{className:"mb-4 rounded border bg-zinc-100 px-1",children:[i.jsxs("div",{onClick:()=>d(_=>!_),className:"flex cursor-pointer items-center gap-x-1 py-2 text-xs font-medium leading-tight hover:bg-slate-100",children:[c?i.jsx(v.ChevronDownIcon,{className:"h-4 w-4 text-slate-400"}):i.jsx(v.ChevronRightIcon,{className:"h-4 w-4 text-slate-400"}),u.startCase(p._type)," settings"," ",p._name&&i.jsxs("span",{className:"text-[11px] font-light text-slate-400",children:["(",p._name,")"]})]}),i.jsx("div",{className:c?"h-auto":"invisible h-0",children:i.jsx(Fi,{blockId:p==null?void 0:p._id,onChange:y,formData:m,schema:E,uiSchema:A})})]}),u.isEmpty(k)?null:i.jsx(Fi,{blockId:e==null?void 0:e._id,onChange:x,formData:o,schema:k,uiSchema:w})]})}const uc=Lt.Root,Ho=M.forwardRef(({className:t,...e},n)=>i.jsx(Lt.Item,{ref:n,className:L("border-b",t),...e}));Ho.displayName="AccordionItem";const Vo=M.forwardRef(({className:t,children:e,...n},s)=>i.jsx(Lt.Header,{className:"flex",children:i.jsxs(Lt.Trigger,{ref:s,className:L("flex flex-1 items-center justify-between py-4 text-sm font-medium transition-all hover:underline text-left [&[data-state=open]>svg]:rotate-180",t),...n,children:[e,i.jsx(v.ChevronDownIcon,{className:"h-4 w-4 shrink-0 text-muted-foreground transition-transform duration-200"})]})}));Vo.displayName=Lt.Trigger.displayName;const Wo=M.forwardRef(({className:t,children:e,...n},s)=>i.jsx(Lt.Content,{ref:s,className:"overflow-hidden text-sm data-[state=closed]:animate-accordion-up data-[state=open]:animate-accordion-down",...n,children:i.jsx("div",{className:L("pb-4 pt-0",t),children:e})}));Wo.displayName=Lt.Content.displayName;const Wg=S.atom(null,(t,e,{blockIds:n,fullClasses:s})=>{const r=u.first(t(Mn)),o=u.filter(t(In),a=>n.includes(t(a)._id));return u.map(o,a=>{const l=t(a),c=s;let{classes:d,baseClasses:p}=$.getSplitChaiClasses(u.get(l,r.prop,`${$.STYLES_KEY},`));return u.each(c,f=>{const m=f.replace(/[.*+?^${}()|[\]\\]/g,"\\$&"),h=new RegExp(`(^|\\s)${m}(?=\\s|$)`,"g");d=d.replace(h," ").replace(/\s+/g," ").trim();const b=u.first(f.split(":"));u.includes(["2xl","xl","lg","md","sm"],b)&&c.push(f.split(":").pop().trim())}),u.each(c,f=>{const m=f.replace(/[.*+?^${}()|[\]\\]/g,"\\$&"),h=new RegExp(`(^|\\s)${m}(?=\\s|$)`,"g");p=p.replace(h," ").replace(/\s+/g," ").trim()}),{ids:[l._id],props:{[r.prop]:`${$.STYLES_KEY}${p},${d}`}}})}),Ug=t=>{const e=Object.keys(t).filter(s=>typeof t[s]=="string"&&t[s].startsWith($.STYLES_KEY)),n={};return e.forEach(s=>{n[s]=`${$.STYLES_KEY},`}),{ids:[t._id],props:n}},Gg=()=>{const{updateBlocks:t,updateBlocksRuntime:e}=Ne();return g.useCallback((n,s=!1)=>{const{ids:r,props:o}=Ug(n);s?t(r,o):e(r,o)},[t,e])},Uo=()=>{const{updateBlocks:t,updateBlocksRuntime:e}=Ne(),n=S.useSetAtom(Wg);return g.useCallback((s,r,o=!1)=>{const a=n({blockIds:s,fullClasses:r});o?t(s,a[0].props):e(s,a[0].props)},[n])},pc=()=>{const t=Z(),e=tt(),n=g.useCallback(a=>J.getDefaultBlockProps(a)||{},[]),s=g.useCallback(a=>Object.keys(a).filter(l=>typeof a[l]=="string"&&a[l].startsWith("#styles:")),[]),r=g.useCallback(a=>{if(!t)return;const c=n(t._type)[a]??"#styles:,";e([t._id],{[a]:c})},[t,n,e]);return{resetAll:g.useCallback(()=>{if(!t)return;const a=s(t);if(a.length===0)return;const l=n(t._type),c=u.pick(l,a);e([t._id],c)},[t,s,n,e]),reset:r}},qg=()=>{var h;const t=Z(),[e,n]=Ee(),s=Uo(),[r]=K(),{t:o}=F.useTranslation();if(!t)return null;const a=Object.keys(t).filter(b=>typeof t[b]=="string"&&t[b].startsWith("#styles:")),{reset:l}=pc(),c=!u.isEmpty(a)&&a.length>1,d=u.get(t,(h=e[0])==null?void 0:h.prop,""),{classes:p=""}=$.getSplitChaiClasses(d)||{},f=p?p.split(" ").filter(b=>!u.isEmpty(b)):[],m=b=>u.find(e,x=>x.prop===b);return i.jsx(i.Fragment,{children:c&&i.jsxs("div",{className:"flex flex-wrap gap-1",children:[i.jsxs("label",{htmlFor:"block-styling-props",className:"py-1 text-xs",children:[o("Style element"),":"]}),i.jsx("div",{className:"flex flex-wrap gap-2",children:u.map(a,b=>i.jsxs(Hs,{className:"flex cursor-pointer items-center gap-1 pr-1",variant:m(b)?"default":"secondary",onClick:()=>{n([{id:`${b}-${t._id}`,blockId:t._id,prop:b}])},children:[u.startCase(b),i.jsxs(Qe,{children:[i.jsx(et,{asChild:!0,children:i.jsx("button",{type:"button",className:"ml-1 rounded-sm p-0.5 hover:bg-blue-300 hover:text-blue-600",onClick:x=>x.stopPropagation(),children:i.jsx(v.DotsVerticalIcon,{className:"h-3 w-3"})})}),i.jsxs(Ue,{side:"bottom",className:"border-border text-xs",children:[i.jsx(de,{className:"text-xs",onClick:()=>{l(b)},children:o("Reset style")}),i.jsx(de,{className:"text-xs",onClick:()=>{s(r,f,!0)},children:o("Clear styles")})]})]})]},b))}),i.jsx("div",{className:"my-2 h-[1px] w-full bg-border"})]})})},fc=g.createContext({setDragData:()=>{}}),zi=(t,e)=>{t=t.toLowerCase();let n=t.trim().replace(/ |\+/g,"");if((n==="auto"||n==="none")&&e.includes(n))return{value:"",unit:n};const s=e.length?new RegExp(e.join("|"),"g"):/XXXXXX/g;n=n.replace(s,"");const r=t.match(s),o=r&&r.length>1,a=!u.isEmpty(n)&&Number.isNaN(Number(n));return o||a?{error:"Invalid value"}:r&&(r[0]==="auto"||r[0]==="none")?{value:r[0],unit:""}:{value:n,unit:r?r[0]:""}},Kg=t=>{const e=t.startsWith("-")?"-":"",n=t.split("-").pop();if(["auto","none"].includes(n))return{value:"",unit:n};if(n==="px")return{value:"1",unit:"px"};if(n==="screen")return{value:"100",unit:t.indexOf("w-")!==-1?"vw":"vh"};if(n==="full")return{value:"100",unit:"%"};if(u.includes(t,"skew-"))return{value:`${e}${n}`,unit:"deg"};if(u.includes(t,"rotate-"))return{value:`${e}${n}`,unit:"deg"};if(u.includes(t,"opacity-"))return{value:`${n/100}`,unit:"-"};if(u.includes(t,"duration-")||u.includes(t,"delay-"))return{value:`${n}`,unit:"ms"};if(u.includes(t,"translate-")&&!n.includes("/"))return{value:`${e}${`${n/4}`}`,unit:"rem"};if(u.includes(t,"scale-"))return{value:`${e}${`${n/100}`}`,unit:"-"};if(u.startsWith(t,"border")){const s=t.match(/border-?(x|y|t|r|b|l)?\d+/g);if(s)return{value:s[0].split("-").pop(),unit:"px"};if(t.match(/border-?(x|y|t|r|b|l)?/g))return{value:"1",unit:"px"}}if(u.startsWith(t,"max-w-")){if(t==="max-w-screen-sm")return{value:"640",unit:"px"};if(t==="max-w-screen-md")return{value:"768",unit:"px"};if(t==="max-w-screen-lg")return{value:"1024",unit:"px"};if(t==="max-w-screen-xl")return{value:"1280",unit:"px"};if(t==="max-w-screen-2xl")return{value:"1536",unit:"px"};if(n==="xs")return{value:"320",unit:"px"};if(n==="sm")return{value:"384",unit:"px"};if(n==="md")return{value:"448",unit:"px"};if(n==="lg")return{value:"512",unit:"px"};if(n==="xl")return{value:"576",unit:"px"};if(n==="2xl")return{value:"672",unit:"px"};if(n==="3xl")return{value:"768",unit:"px"};if(n==="4xl")return{value:"896",unit:"px"};if(n==="5xl")return{value:"1024",unit:"px"};if(n==="6xl")return{value:"1152",unit:"px"};if(n==="7xl")return{value:"1280",unit:"px"};if(n==="prose")return{value:"65",unit:"ch"}}if(u.startsWith(t,"text-")){if(n==="xs")return{value:"12",unit:"px"};if(n==="sm")return{value:"14",unit:"px"};if(n==="base")return{value:"16",unit:"px"};if(n==="lg")return{value:"18",unit:"px"};if(n==="xl")return{value:"20",unit:"px"};if(n==="2xl")return{value:"24",unit:"px"};if(n==="3xl")return{value:"30",unit:"px"};if(n==="4xl")return{value:"36",unit:"px"};if(n==="5xl")return{value:"48",unit:"px"};if(n==="6xl")return{value:"60",unit:"px"};if(n==="7xl")return{value:"72",unit:"px"};if(n==="8xl")return{value:"96",unit:"px"};if(n==="9xl")return{value:"128",unit:"px"}}if(u.startsWith(t,"leading-")){if(n==="none")return{value:"1",unit:"-"};if(n==="tight")return{value:"1.25",unit:"-"};if(n==="snug")return{value:"1.375",unit:"-"};if(n==="normal")return{value:"1.5",unit:"-"};if(n==="relaxed")return{value:"1.625",unit:"-"};if(n==="loose")return{value:"2",unit:"-"}}if(u.startsWith(t,"tracking-")){if(n==="tighter")return{value:"-0.05",unit:"em"};if(n==="tight")return{value:"-0.025",unit:"em"};if(n==="normal")return{value:"0",unit:"em"};if(n==="wide")return{value:"0.025",unit:"em"};if(n==="wider")return{value:"0.05",unit:"em"};if(n==="widest")return{value:"0.1",unit:"em"}}if(["max","min","fit"].includes(n))return{value:t,unit:"class"};if(n.includes("/")){const[s,r]=u.map(n.split("/"),o=>parseInt(o,10));return{value:e+(s/r*100).toFixed(2).replace(".00",""),unit:"%"}}return u.isNumber(parseFloat(n))?{value:`${e+parseFloat(n)*4}`,unit:"px"}:{value:n,unit:"class"}},hc=t=>{if(u.isEmpty(t))return{value:"",unit:""};const e=t.match(/\[.*\]/g);if(e===null)return Yg(t);const n=u.get(e,"0","").replace(/\[|\]/g,""),s=t.startsWith("-")?"-":"",r=u.first(n.match(/\d+.\d+|\d+/g));return{value:`${s}${r}`,unit:n.replace(r,"")}},Yg=t=>u.isEmpty(t)?{value:"",unit:""}:Kg(t),Xg=({unit:t,currentValue:e,onDrag:n,onDragEnd:s,onDragStart:r,negative:o,cssProperty:a})=>{const{setDragData:l}=g.useContext(fc);return i.jsx("button",{type:"button",onMouseDown:c=>{const d={onDrag:n,onDragEnd:s,dragging:!0,dragStartY:c.pageY,dragStartValue:`${e}`,dragUnit:t,negative:o,cssProperty:a};r(d),l(d)},color:void 0,className:"relative z-50 ml-1 hidden h-6 cursor-row-resize rounded bg-background/70 px-2 group-hover:inline",children:i.jsx(v.RowSpacingIcon,{})})},Jg=({onSelect:t,current:e,units:n})=>i.jsx("div",{"data-theme":"light",className:"-m-[7px] -mx-[13px] flex w-9 flex-col",children:n.map(s=>i.jsx(q,{className:"h-max rounded-none px-1 py-1 text-right text-[11px] hover:bg-blue-400",color:e===s?"primary":void 0,size:"sm",onClick:r=>{r.stopPropagation(),t(s)},children:s},s))}),Hi=50,Zg=t=>{const[e,n]=g.useState(!1),[s,r]=g.useState(""),{currentClass:o,onChange:a,classPrefix:l,cssProperty:c,units:d,negative:p}=t,[f,m]=g.useState(c!=null&&c.toLowerCase().includes("width")?"%":d[0]),[h,b]=g.useState(!1),[x,y]=g.useState(""),[k,w]=g.useState(!1),[E,A]=g.useState(!1);g.useEffect(()=>{const{value:C,unit:T}=hc(o);if(T===""){r(C),m(c!=null&&c.toLowerCase().includes("width")?"%":u.first(d));return}m(T),r(T==="class"||u.isEmpty(C)?"":C)},[o,c,d]);const _=ke.useThrottledCallback(C=>a(C),[a],Hi),I=ke.useThrottledCallback(C=>a(C,!1),[a],Hi),j=g.useCallback((C=!1)=>{const T=zi(`${s}`,d);if(u.get(T,"error",!1)){b(!0);return}const R=u.get(T,"unit")!==""?u.get(T,"unit"):f;if(R==="auto"||R==="none"){_(`${l}${R}`);return}if(u.get(T,"value")==="")return;const U=`${u.get(T,"value","").startsWith("-")?"-":""}${l}[${u.get(T,"value","").replace("-","")}${R==="-"?"":R}]`;C?I(U):_(U)},[_,I,s,f,l,d]),N=g.useCallback(C=>{const T=zi(`${s}`,d);if(u.get(T,"error",!1)){b(!0);return}if(C==="auto"||C==="none"){_(`${l}${C}`);return}if(u.get(T,"value")==="")return;const R=u.get(T,"unit")!==""?u.get(T,"unit"):C,U=`${u.get(T,"value","").startsWith("-")?"-":""}${l}[${u.get(T,"value","").replace("-","")}${R==="-"?"":R}]`;_(U)},[_,s,l,d]);return i.jsx("div",{className:"flex w-full flex-col",children:i.jsx("div",{className:"flex items-center justify-start",children:f==="class"?i.jsxs(i.Fragment,{children:[i.jsx("input",{className:"h-6 w-24 rounded border border-foreground/20 bg-background px-2 py-0.5 text-sm focus-visible:outline-0",readOnly:!0,value:o}),i.jsxs(pe,{children:[i.jsx(fe,{asChild:!0,children:i.jsx("button",{type:"button",className:"invisible ml-3 mt-1 text-blue-600 group-hover:visible",children:i.jsx(v.InfoCircledIcon,{})})}),i.jsx(ue,{children:"Current value is using a Tailwind preset class."})]})]}):i.jsxs("div",{className:`group relative flex items-center ${k?"z-auto":""}`,children:[i.jsxs("div",{className:"flex items-center rounded-md border border-border",children:[["none","auto"].indexOf(f)!==-1?null:i.jsx("input",{readOnly:f==="class",onKeyPress:C=>{C.key==="Enter"&&j()},onKeyDown:C=>{if(C.keyCode!==38&&C.keyCode!==40)return;C.preventDefault(),A(!0);const T=u.parseInt(C.target.value);let R=u.isNaN(T)?0:T;C.keyCode===38&&(R+=1),C.keyCode===40&&(R-=1);const B=`${R}`,z=`${B.startsWith("-")?"-":""}${l}[${B.replace("-","")}${f==="-"?"":f}]`;I(z)},onKeyUp:C=>{E&&(C.preventDefault(),A(!1))},onBlur:()=>j(),onChange:C=>{b(!1),r(C.target.value)},onClick:C=>{var T;(T=C==null?void 0:C.target)==null||T.select(),n(!1)},value:k?x:s,className:"h-6 w-14 rounded rounded-r-none border border-transparent bg-background pl-2 text-sm focus-visible:outline-0".concat(" ",h?"border-red-500 text-red-500":"border-foreground/20")}),i.jsxs(pe,{open:e,delayDuration:100,children:[i.jsx(fe,{asChild:!0,children:i.jsxs("button",{type:"button",onClick:()=>n(!e),className:"flex h-6 cursor-pointer items-center gap-x-1 rounded rounded-l-none bg-background p-px px-1 text-[11px] uppercase",children:[i.jsx("span",{className:`inline-block ${d.length===1?"px-2 font-semibold":""}`,children:f}),d.length>1?i.jsx(v.TriangleDownIcon,{}):null]})}),i.jsx(ue,{className:"bg-background",children:i.jsx(Jg,{units:d,current:f,onSelect:C=>{n(!1),m(C),N(C)}})})]})]}),["none","auto"].indexOf(f)!==-1||k?null:i.jsx(Xg,{onDragStart:()=>w(!0),onDragEnd:C=>{if(y(()=>""),w(!1),u.isEmpty(C))return;const T=`${C}`,B=`${T.startsWith("-")?"-":""}${l}[${T.replace("-","")}${f==="-"?"":f}]`;_(B)},onDrag:C=>{if(u.isEmpty(C))return;y(C);const T=`${C}`,B=`${T.startsWith("-")?"-":""}${l}[${T.replace("-","")}${f==="-"?"":f}]`;I(B)},currentValue:s,unit:f,negative:p,cssProperty:c})]})})})},$n=g.createContext({canReset:!1,canChange:!0}),Qg=({children:t,canReset:e=!1,canChange:n=!0})=>i.jsx($n.Provider,{value:{canReset:e,canChange:n},children:t}),ur=[0,1,2,3,4,5,6,7,8,9,10,11,12,14,16,20,24,28,32,36,40,44,48,52,56,60,64,72,80,96],P={columns:[...u.range(1,13),"auto","3xs","2xs","xs","sm","md","lg","xl",...u.map(u.range(2,8),t=>`${t}xl`)],breakAfter:["auto","avoid","all","avoid-page","page","left","right","column"],breakInside:["auto","avoid","avoid-page","avoid-column"],display:["block","flex","grid","inline-block","inline","hidden"],objectFit:["contain","cover","fill","none","scale-down"],objectPosition:["bottom","center","left","left-bottom","left-top","right","right-bottom","right-top","top"],overflow:["auto","hidden","clip","visible","scroll"],overscroll:["auto","contain","none"],trbl:[0,"px","0.5",1,1.5,2,2.5,3,3.5,...u.range(4,13),14,16,20,24,28,32,36,40,44,48,52,56,60,64,72,80,96,"auto","1/2","1/3","2/3","1/4","2/4","3/4","full"],flexBasis:[...ur,"auto","px","0.5","1.5","2.5","3.5","1/2","1/3","2/3","1/4","2/4","3/4","1/5","2/5","3/5","4/5","1/6","2/6","3/6","4/6","5/6","1/12","2/12","3/12","4/12","5/12","6/12","7/12","8/12","9/12","10/12","11/12","full"],padding:[...ur,"px","0.5","1.5","2.5","3.5"],margin:["auto",...ur,"px","0.5","1.5","2.5","3.5"],scale:[0,50,75,90,95,100,105,110,125,150],origin:["center","top","top-right","right","bottom-right","bottom","bottom-left","left","top-left"],blendEffect:["normal","multiply","screen","overlay","darken","lighten","color-dodge","color-burn","hard-light","soft-light","difference","exclusion","hue","saturation","color","luminosity"],borderWidth:[0,2,4,8],borderRadius:["global","none","sm","md","lg","xl","2xl","3xl","full"],indent:[0,"px","0.5",1,1.5,2,2.5,3,3.5,...u.range(4,13),14,16,20,24,28,32,36,40,44,48,52,56,60,64,72,80,96],maxHeight:[0,"px","0.5",1,1.5,2,2.5,3,3.5,...u.range(4,13),14,16,20,24,28,32,36,40,44,48,52,56,60,64,72,80,96,"full","screen","min","max","fit"],space:[0,"px","0.5",1,1.5,2,2.5,3,3.5,...u.range(4,13),14,16,20,24,28,32,36,40,44,48,52,56,60,64,72,80,96,"px","reverse"],width:["0","px","0.5","1","1.5","2","2.5","3","3.5","4","5","6","7","8","9","10","11","12","14","16","20","24","28","32","36","40","44","48","52","56","60","64","72","80","96","auto","1/2","1/3","2/3","1/4","2/4","3/4","1/5","2/5","3/5","4/5","1/6","2/6","3/6","4/6","5/6","1/12","2/12","3/12","4/12","5/12","6/12","7/12","8/12","9/12","10/12","11/12"],maxWidth:["0","none","xs","sm","md","lg","xl","2xl","3xl","4xl","5xl","6xl","7xl","full","min","max","fit","prose","screen-sm","screen-md","screen-lg","screen-xl","screen-2xl"],height:["0","px","0.5","1","1.5","2","2.5","3","3.5","4","5","6","7","8","9","10","11","12","14","16","20","24","28","32","36","40","44","48","52","56","60","64","72","80","96","auto","1/2","1/3","2/3","1/4","2/4","3/4","1/5","2/5","3/5","4/5","1/6","2/6","3/6","4/6","5/6","full","screen","min","max","fit"]},Xt={textColor:{classes:[],regExp:"text-(black|transparent|current|white|__THEME_COLORS_REGEXP__|\\S+-\\d+)"},aspectRatio:{classes:["aspect-auto","aspect-square","aspect-video"],regExp:"aspect-(auto|square|video)"},container:{classes:["container"],regExp:"container"},columns:{classes:u.map(P.columns,t=>`columns-${t}`),regExp:"columns-(auto|[0-9]xl|[0-9]xs|xs|sm|md|lg|xl|\\d+)"},breakAfter:{classes:u.map(P.breakAfter,t=>`break-after-${t}`),regExp:"break-after-\\S+"},breakBefore:{classes:u.map(P.breakAfter,t=>`break-before-${t}`),regExp:"break-before-\\S+"},breakInside:{classes:u.map(P.breakInside,t=>`break-inside-${t}`),regExp:"break-inside-\\S+"},boxDecoration:{classes:["box-decoration-clone","box-decoration-slice"],regExp:"box-decoration-\\S+"},boxSizing:{classes:["box-border","box-content"],regExp:"box-(border|content)"},flexDirection:{classes:["flex-row","flex-row-reverse","flex-col","flex-col-reverse"],regExp:"flex-(row|row-reverse|col|col-reverse)"},flexWrap:{classes:["flex-wrap","flex-wrap-reverse","flex-nowrap"],regExp:"flex-(wrap|wrap-reverse|nowrap)"},flexGrowShrink:{classes:["flex-1","flex-auto","flex-initial","flex-none"],regExp:"flex-1|flex-auto|flex-initial|flex-none"},gridColumns:{classes:u.map([...u.range(0,13),"none"],t=>`grid-cols-${t}`),regExp:"grid-cols-(\\d+|none)"},gridFlow:{classes:["grid-flow-row","grid-flow-col","grid-flow-row-dense","grid-flow-col-dense"],regExp:"grid-flow-(row|col|row-dense|col-dense)"},outlineStyle:{classes:u.map(["none","dashed","dotted","double","hidden"],t=>`outline-${t}`),regExp:"outline-(none|dashed|dotted|double|hidden)"},borderStyle:{classes:u.map(["solid","dashed","dotted","double","hidden","none"],t=>`border-${t}`),regExp:"border-(solid|dashed|dotted|double|hidden|none)"},overflow:{classes:u.map(P.overflow,t=>`overflow-${t}`),regExp:`overflow-(${P.overflow.join("|")})`},overflowX:{classes:u.map(P.overflow,t=>`overflow-x-${t}`),regExp:`overflow-x-(${P.overflow.join("|")})`},overflowY:{classes:u.map(P.overflow,t=>`overflow-y-${t}`),regExp:`overflow-y-(${P.overflow.join("|")})`},gridRows:{classes:u.map([1,2,3,4,5,6,"none"],t=>`grid-rows-${t}`),regExp:"grid-rows-(\\d|none)"},display:{classes:u.map(P.display,t=>t.toString()),regExp:`(${P.display.join("|")})`},float:{classes:["float-right","float-left","float-none"],regExp:"float-\\S+"},clear:{classes:["clear-right","clear-left","clear-none","clear-both"],regExp:"clear-\\S+"},isolation:{classes:["isolate","isolation-auto"],regExp:"isolate|isolation-auto"},objectFit:{classes:u.map(P.objectFit,t=>`object-${t}`),regExp:"object-(contain|cover|fill|none|scale-down)"},objectPosition:{classes:u.map(P.objectPosition,t=>`object-${t}`),regExp:`object-(${P.objectPosition.join("|")})`},overscroll:{classes:u.map(P.overscroll,t=>`overscroll-${t}`),regExp:`overscroll-(${P.overscroll.join("|")})`},overscrollX:{classes:u.map(P.overscroll,t=>`overscroll-x-${t}`),regExp:`overscroll-x-(${P.overscroll.join("|")})`},overscrollY:{classes:u.map(P.overscroll,t=>`overscroll-y-${t}`),regExp:`overscroll-y-(${P.overscroll.join("|")})`},inset:{classes:u.map(P.trbl,t=>`inset-${t}`),regExp:"-?inset-(px|\\d\\/\\d|\\d\\.\\d|\\d+|full|auto|\\[.*\\])"},insetX:{classes:u.map(P.trbl,t=>`inset-x-${t}`),regExp:"-?inset-x-(px|\\d\\/\\d|\\d\\.\\d|\\d+|full|auto|\\[.*\\])"},insetY:{classes:u.map(P.trbl,t=>`inset-y-${t}`),regExp:"-?inset-y-(px|\\d\\/\\d|\\d\\.\\d|\\d+|full|auto|\\[.*\\])"},top:{classes:u.map(P.trbl,t=>`top-${t}`),regExp:"-?top-(px|\\d\\/\\d|\\d\\.\\d|\\d+|full|auto|\\[.*\\])"},topX:{classes:u.map(P.trbl,t=>`top-x-${t}`),regExp:"-?top-x-(px|\\d\\/\\d|\\d\\.\\d|\\d+|full|auto|\\[.*\\])"},topY:{classes:u.map(P.trbl,t=>`top-y-${t}`),regExp:"-?top-y-(px|\\d\\/\\d|\\d\\.\\d|\\d+|full|auto|\\[.*\\])"},right:{classes:u.map(P.trbl,t=>`right-${t}`),regExp:"-?right-(px|\\d\\/\\d|\\d\\.\\d|\\d+|full|auto|\\[.*\\])"},rightX:{classes:u.map(P.trbl,t=>`right-x-${t}`),regExp:"-?right-x-(px|\\d\\/\\d|\\d\\.\\d|\\d+|full|auto|\\[.*\\])"},rightY:{classes:u.map(P.trbl,t=>`right-y-${t}`),regExp:"-?right-y-(px|\\d\\/\\d|\\d\\.\\d|\\d+|full|auto|\\[.*\\])"},bottom:{classes:u.map(P.trbl,t=>`bottom-${t}`),regExp:"-?bottom-(px|\\d\\/\\d|\\d\\.\\d|\\d+|full|auto|\\[.*\\])"},bottomX:{classes:u.map(P.trbl,t=>`bottom-x-${t}`),regExp:"-?bottom-x-(px|\\d\\/\\d|\\d\\.\\d|\\d+|full|auto|\\[.*\\])"},bottomY:{classes:u.map(P.trbl,t=>`bottom-y-${t}`),regExp:"-?bottom-y-(px|\\d\\/\\d|\\d\\.\\d|\\d+|full|auto|\\[.*\\])"},left:{classes:u.map(P.trbl,t=>`left-${t}`),regExp:"-?left-(px|\\d\\/\\d|\\d\\.\\d|\\d+|full|auto|\\[.*\\])"},leftX:{classes:u.map(P.trbl,t=>`left-x-${t}`),regExp:"-?left-x-(px|\\d\\/\\d|\\d\\.\\d|\\d+|full|auto|\\[.*\\])"},leftY:{classes:u.map(P.trbl,t=>`left-y-${t}`),regExp:"-?left-y-(px|\\d\\/\\d|\\d\\.\\d|\\d+|full|auto|\\[.*\\])"},visibility:{classes:["visible","invisible"],regExp:"invisible|visible"},zIndex:{classes:u.map(["0",10,20,30,40,50,"auto"],t=>`z-${t}`),regExp:"-?z-(\\d+|auto|\\[.*\\])"},flexBasis:{classes:u.map(P.flexBasis,t=>`basis-${t}`),regExp:"basis-(\\d+|\\S+)"},flexGrow:{classes:["grow","grow-0"],regExp:"grow(-0)?"},flexShrink:{classes:["shrink","shrink-0"],regExp:"shrink(-0)?"},gridColSpan:{classes:["col-auto",...u.map(u.range(1,13),t=>`col-span-${t}`),"col-span-full"],regExp:"col-(auto|span-(\\d+|full))"},gridColStart:{classes:[...u.map(u.range(1,14),t=>`col-start-${t}`),"col-start-auto"],regExp:"col-start-(\\d+|auto)"},gridColEnd:{classes:[...u.map(u.range(1,14),t=>`col-end-${t}`),"col-end-auto"],regExp:"col-end-(\\d+|auto)"},gridRowSpan:{classes:["row-auto",...u.map(u.range(1,7),t=>`row-span-${t}`),"row-span-full"],regExp:"row-(auto|span-(\\d+|full))"},gridRowStart:{classes:[...u.map(u.range(1,8),t=>`row-start-${t}`),"row-start-auto"],regExp:"row-start-(\\d+|auto)"},gridRowEnd:{classes:[...u.map(u.range(1,8),t=>`row-end-${t}`),"row-end-auto"],regExp:"row-end-(\\d+|auto)"},gridAutoColumns:{classes:["auto-cols-auto","auto-cols-min","auto-cols-max","auto-cols-fr"],regExp:"auto-cols-(auto|min|max|fr)"},gridAutoRows:{classes:["auto-rows-auto","auto-rows-min","auto-rows-max","auto-rows-fr"],regExp:"auto-rows-(auto|min|max|fr)"},gap:{classes:u.map(P.indent,t=>`gap-${t}`),regExp:"gap-(px|\\d.\\d|\\d|\\[.*\\])"},gapX:{classes:u.map(P.indent,t=>`gap-x-${t}`),regExp:"gap-x-(px|\\d.\\d|\\d|\\[.*\\])"},gapY:{classes:u.map(P.indent,t=>`gap-y-${t}`),regExp:"gap-y-(px|\\d.\\d|\\d|\\[.*\\])"},justifyContent:{classes:["justify-start","justify-end","justify-center","justify-between","justify-around","justify-evenly"],regExp:"justify-(start|end|center|between|around|evenly)"},justifyItems:{classes:["justify-items-start","justify-items-end","justify-items-center","justify-items-stretch"],regExp:"justify-items-(start|end|center|stretch)"},justifySelf:{classes:["justify-self-auto","justify-self-start","justify-self-end","justify-self-center","justify-self-stretch"],regExp:"justify-self-(auto|start|end|center|stretch)"},placeContent:{classes:["place-content-center","place-content-start","place-content-end","place-content-between","place-content-around","place-content-evenly","place-content-stretch"],regExp:"place-content-(center|start|end|between|around|evenly|stretch)"},placeItems:{classes:["place-items-start","place-items-end","place-items-center","place-items-stretch"],regExp:"place-items-(start|end|center|stretch)"},placeSelf:{classes:["place-self-auto","place-self-start","place-self-end","place-self-center","place-self-stretch"],regExp:"place-self-(auto|start|end|center|stretch)"},alignContent:{classes:["content-center","content-start","content-end","content-between","content-around","content-evenly"],regExp:"content-(center|start|end|between|around|evenly)"},alignItems:{classes:["items-start","items-end","items-center","items-baseline","items-stretch"],regExp:"items-(start|end|center|baseline|stretch)"},alignSelf:{classes:["self-auto","self-start","self-end","self-center","self-stretch","self-baseline"],regExp:"self-(auto|start|end|center|stretch|baseline)"},backgroundClip:{classes:["bg-clip-border","bg-clip-padding","bg-clip-content","bg-clip-text"],regExp:"bg-clip-(border|padding|content|text)"},dropShadow:{classes:u.map(["sm","md","lg","xl","2xl","none"],t=>`drop-shadow-${t}`),regExp:"drop-shadow-(sm|md|lg|xl|2xl|none)"},backdropBlur:{classes:u.map(["none","sm","md","lg","xl","2xl","3xl"],t=>`backdrop-blur-${t}`),regExp:"backdrop-blur-(none|sm|md|lg|xl|2xl|3xl)"},backdropBrightness:{classes:u.map([0,50,75,90,95,100,105,110,125,150,200],t=>`backdrop-brightness-${t}`),regExp:"backdrop-brightness-(\\d+)"},backdropContrast:{classes:u.map([0,50,75,100,125,150,200],t=>`backdrop-contrast-${t}`),regExp:"backdrop-contrast-(\\d+)"},backdropGrayScale:{classes:["backdrop-grayscale-0","backdrop-grayscale"],regExp:"backdrop-grayscale(-0)?"},backdropHueRotate:{classes:u.map([0,15,30,60,90,180],t=>`backdrop-hue-rotate-${t}`),regExp:"-?backdrop-hue-rotate-(\\d+)"},backdropInvert:{classes:["backdrop-invert-0","backdrop-invert"],regExp:"backdrop-invert(-0)?"},backdropOpacity:{classes:u.map([0,5,10,20,25,30,40,50,60,70,75,80,90,95,100],t=>`backdrop-opacity-${t}`),regExp:"backdrop-opacity-(\\d+)"},backdropSaturate:{classes:u.map([0,50,100,150,200],t=>`backdrop-saturate-${t}`),regExp:"backdrop-saturate-(\\d+)"},backdropSepia:{classes:["backdrop-sepia-0, backdrop-sepia"],regExp:"backdrop-sepia(-0)?"},backgroundOrigin:{classes:["bg-origin-border","bg-origin-padding","bg-origin-content"],regExp:"bg-origin-(border|padding|content)"},transformOrigin:{classes:u.map(P.origin,t=>`origin-${t}`),regExp:"origin-(\\d+|\\S+)"},padding:{classes:u.map(P.padding,t=>`p-${t}`),regExp:"p-(\\d+|\\S+|\\[.*\\])"},paddingX:{classes:u.map(P.padding,t=>`px-${t}`),regExp:"px-(\\d+|\\S+|\\[.*\\])"},paddingY:{classes:u.map(P.padding,t=>`py-${t}`),regExp:"py-(\\d+|\\S+|\\[.*\\])"},paddingTop:{classes:u.map(P.padding,t=>`pt-${t}`),regExp:"pt-(\\d+|\\S+|\\[.*\\])"},paddingRight:{classes:u.map(P.padding,t=>`pr-${t}`),regExp:"pr-(\\d+|\\S+|\\[.*\\])"},paddingBottom:{classes:u.map(P.padding,t=>`pb-${t}`),regExp:"pb-(\\d+|\\S+|\\[.*\\])"},paddingLeft:{classes:u.map(P.padding,t=>`pl-${t}`),regExp:"pl-(\\d+|\\S+|\\[.*\\])"},textDecorationStyle:{classes:["decoration-solid","decoration-double","decoration-dotted","decoration-dashed","decoration-wavy"],regExp:"decoration-(solid|double|dotted|dashed|wavy)"},textDecorationThickness:{classes:u.map(["auto","from-font","0",1,2,4,8],t=>`decoration-${t}`),regExp:"decoration-(auto|from-font|\\d+|\\S+)"},fromColor:{classes:[],regExp:"from-(black|transparent|current|white|__THEME_COLORS_REGEXP__|\\S+-\\d+)"},margin:{classes:u.map(P.margin,t=>`m-${t}`),regExp:"-?m-(\\d+|\\S+|\\[.*\\])"},marginX:{classes:u.map(P.margin,t=>`mx-${t}`),regExp:"-?mx-(\\d+|\\S+|\\[.*\\])"},marginY:{classes:u.map(P.margin,t=>`my-${t}`),regExp:"-?my-(\\d+|\\S+|\\[.*\\])"},marginTop:{classes:u.map(P.margin,t=>`mt-${t}`),regExp:"-?mt-(\\d+|\\S+|\\[.*\\])"},marginRight:{classes:u.map(P.margin,t=>`mr-${t}`),regExp:"-?mr-(\\d+|\\S+|\\[.*\\])"},marginBottom:{classes:u.map(P.margin,t=>`mb-${t}`),regExp:"-?mb-(\\d+|\\S+|\\[.*\\])"},marginLeft:{classes:u.map(P.margin,t=>`ml-${t}`),regExp:"-?ml-(\\d+|\\S+|\\[.*\\])"},spaceX:{classes:u.map(P.space,t=>`space-x-${t}`),regExp:"-?space-x-(\\d+|\\S+|\\[.*\\])"},spaceY:{classes:u.map(P.space,t=>`space-y-${t}`),regExp:"-?space-y-(\\d+|\\S+|\\[.*\\])"},boxShadow:{classes:u.map(["sm","md","lg","xl","2xl","inner","none"],t=>`shadow-${t}`),regExp:"shadow-(sm|md|lg|xl|2xl|inner|none)"},minWidth:{classes:["min-w-0","min-w-full","min-w-min","min-w-max","min-w-fit"],regExp:"min-w-(\\d+|\\S+|\\[.*\\])"},maxWidth:{classes:u.map(P.maxWidth,t=>`max-w-${t}`),regExp:"max-w-(\\d+|\\S+|\\[.*\\])"},width:{classes:u.map([...P.width,"full","screen","min","max","fit"],t=>`w-${t}`),regExp:"w-(\\d+.\\d+|\\d+|px|auto|full|screen|min|max|fit|\\[.*\\])$"},minHeight:{classes:["min-h-0","min-h-full","min-h-screen","min-h-min","min-h-max","min-h-fit"],regExp:"min-h-(\\d+|\\S+|\\[.*\\])"},maxHeight:{classes:u.map(P.maxHeight,t=>`max-h-${t}`),regExp:"max-h-(\\d+|\\S+|\\[.*\\])"},height:{classes:u.map(P.height,t=>`h-${t}`),regExp:"h-(\\d+.\\d+|\\d+|px|auto|full|screen|min|max|fit|\\[.*\\])"},fontFamily:{classes:["font-heading","font-body","font-sans","font-serif","font-mono"],regExp:"font-(heading|body|sans|serif|mono)"},textAlign:{classes:["text-left","text-center","text-right","text-justify"],regExp:"text-(left|center|right|justify)"},textOverflow:{classes:["truncate","text-ellipsis","text-clip"],regExp:"truncate|text-ellipsis|text-clip"},verticalAlign:{classes:["align-baseline","align-top","align-middle","align-bottom","align-text-top","align-text-bottom","align-sub","align-super"],regExp:"align-(baseline|top|middle|bottom|text-top|text-bottom|sub|super)"},fontSize:{classes:["text-xs","text-sm","text-base","text-lg","text-xl","text-2xl","text-3xl","text-4xl","text-5xl","text-6xl","text-7xl","text-8xl","text-9xl"],regExp:"text-(\\d+|\\S+|\\[.*\\])"},fontSmoothing:{classes:["antialiased","subpixel-antialiased"],regExp:"antialiased|subpixel-antialiased"},fontStyle:{classes:["italic","not-italic"],regExp:"not-italic|italic"},fontWeight:{classes:["font-thin","font-extralight","font-light","font-normal","font-medium","font-semibold","font-bold","font-extrabold","font-black"],regExp:"font-(thin|extralight|light|normal|medium|semibold|bold|extrabold|black)"},fontVariantNum:{classes:["normal-nums","ordinal","diagonal-fractions","stacked-fractions","tabular-nums","oldstyle-nums","proportional-nums","lining-nums","slashed-zero"],regExp:"normal-nums|ordinal|diagonal-fractions|stacked-fractions|tabular-nums|oldstyle-nums|proportional-nums|lining-nums|slashed-zero"},letterSpacing:{classes:["tracking-tighter","tracking-tight","tracking-normal","tracking-wide","tracking-wider","tracking-widest"],regExp:"-?tracking-(tighter|tight|normal|wide|wider|widest|\\[.*\\])"},lineHeight:{classes:["leading-none","leading-tight","leading-snug","leading-normal","leading-relaxed","leading-loose","leading-3","leading-4","leading-5","leading-6","leading-7","leading-8","leading-9","leading-10"],regExp:"leading-(none|tight|snug|normal|relaxed|loose|\\[.*\\]|\\d+)"},listStyleType:{classes:["list-none","list-disc","list-decimal"],regExp:"list-(none|disc|decimal)"},listStylePosition:{classes:["list-inside","list-outside"],regExp:"list-(inside|outside)"},textUnderlineOffset:{classes:["underline-offset-auto","underline-offset-0","underline-offset-1","underline-offset-2","underline-offset-4","underline-offset-8"],regExp:"underline-offset-(auto|\\d+|\\S+)"},textDecoration:{classes:["underline","overline","line-through","no-underline"],regExp:"underline|overline|line-through|no-underline"},textDecorationColor:{classes:[],regExp:"decoration-(black|transparent|current|white|__THEME_COLORS_REGEXP__|\\S+-\\d+)"},textTransform:{classes:["uppercase","lowercase","capitalize","normal-case"],regExp:"uppercase|lowercase|capitalize|normal-case"},textIndent:{classes:u.map(P.indent,t=>`indent-${t}`),regExp:"-?indent-(\\d+|\\S+)"},whitespace:{classes:["whitespace-normal","whitespace-nowrap","whitespace-pre","whitespace-pre-line","whitespace-pre-wrap"],regExp:"whitespace-(normal|nowrap|pre|pre-line|pre-wrap)"},wordBreak:{classes:["break-normal","break-words","break-all"],regExp:"break-(normal|words|all)"},content:{classes:["content-none"],regExp:"content-none"},backgroundAttachment:{classes:u.map(["fixed","local","scroll"],t=>`bg-${t}`),regExp:"bg-(fixed|local|scroll)"},backgroundColor:{classes:[],regExp:"bg-(black|transparent|current|white|__THEME_COLORS_REGEXP__|\\S+-\\d+)"},backgroundPosition:{classes:["bg-bottom","bg-center","bg-left","bg-left-bottom","bg-left-top","bg-right","bg-right-bottom","bg-right-top","bg-top"],regExp:"bg-(bottom|center|left|left-bottom|left-top|right|right-bottom|right-top|top)"},backgroundRepeat:{classes:["bg-repeat","bg-repeat-x","bg-repeat-y","bg-no-repeat","bg-repeat-round","bg-repeat-space"],regExp:"bg-(repeat|repeat-x|repeat-y|no-repeat|repeat-round|repeat-space)"},backgroundSize:{classes:["bg-auto","bg-cover","bg-contain"],regExp:"bg-(auto|cover|contain)"},backgroundGradient:{classes:["bg-gradient-none","bg-gradient-to-t","bg-gradient-to-tr","bg-gradient-to-r","bg-gradient-to-br","bg-gradient-to-b","bg-gradient-to-bl","bg-gradient-to-l","bg-gradient-to-tl"],regExp:"bg-gradient-(none|to-(t|tr|r|br|b|bl|l|tl))"},viaColor:{classes:[],regExp:"via-(black|transparent|current|white|__THEME_COLORS_REGEXP__|\\S+-\\d+)"},toColor:{classes:[],regExp:"to-(black|transparent|current|white|__THEME_COLORS_REGEXP__|\\S+-\\d+)"},position:{classes:["static","fixed","absolute","relative","sticky"],regExp:"(static|fixed|absolute|relative|sticky)"},borderRadiusTopLeft:{classes:["rounded-tl",...u.map(P.borderRadius,t=>`rounded-tl-${t}`)],regExp:"rounded-tl-?(\\d+|\\S+)?"},borderRadiusTopRight:{classes:["rounded-tr",...u.map(P.borderRadius,t=>`rounded-tr-${t}`)],regExp:"rounded-tr-?(\\d+|\\S+)?"},borderRadiusBottomRight:{classes:["rounded-br",...u.map(P.borderRadius,t=>`rounded-br-${t}`)],regExp:"rounded-br-?(\\d+|\\S+)?"},borderRadiusBottomLeft:{classes:["rounded-bl",...u.map(P.borderRadius,t=>`rounded-bl-${t}`)],regExp:"rounded-bl-?(\\d+|\\S+)?"},borderRadiusTop:{classes:["rounded-t",...u.map(P.borderRadius,t=>`rounded-t-${t}`)],regExp:"rounded-t-?(\\d+|\\S+)?"},borderRadiusRight:{classes:["rounded-r",...u.map(P.borderRadius,t=>`rounded-r-${t}`)],regExp:"rounded-r-?(\\d+|\\S+)?"},borderRadiusBottom:{classes:["rounded-b",...u.map(P.borderRadius,t=>`rounded-b-${t}`)],regExp:"rounded-b-?(\\d+|\\S+)?"},borderRadiusLeft:{classes:["rounded-l",...u.map(P.borderRadius,t=>`rounded-l-${t}`)],regExp:`(rounded-l-(${P.borderRadius.join("|")})|rounded-l$)`},borderRadius:{classes:["rounded",...u.map(P.borderRadius,t=>`rounded-${t}`)],regExp:`(rounded-(${P.borderRadius.join("|")}$)|rounded)`},borderX:{classes:["border-x",...u.map(P.borderWidth,t=>`border-x-${t}`)],regExp:"border-x-?(\\d+|\\S+|\\[.*\\])?"},borderY:{classes:["border-y",...u.map(P.borderWidth,t=>`border-y-${t}`)],regExp:"border-y-?(\\d+|\\S+|\\[.*\\])?"},borderTop:{classes:["border-t",...u.map(P.borderWidth,t=>`border-t-${t}`)],regExp:"border-t-?(\\d+|\\S+|\\[.*\\])?"},borderRight:{classes:["border-r",...u.map(P.borderWidth,t=>`border-r-${t}`)],regExp:"border-r-?(\\d+|\\S+|\\[.*\\])?"},borderBottom:{classes:["border-b",...u.map(P.borderWidth,t=>`border-b-${t}`)],regExp:"border-b-?(\\d+|\\S+|\\[.*\\])?"},borderLeft:{classes:["border-l",...u.map(P.borderWidth,t=>`border-l-${t}`)],regExp:"border-l-?(\\d+|\\S+|\\[.*\\])?"},borderColor:{classes:[],regExp:"^border-(black|transparent|current|white|__THEME_COLORS_REGEXP__|\\w+-\\d+|\\[#[0-9a-fA-F]+\\])$"},border:{classes:["border",...u.map(P.borderWidth,t=>`border-${t}`)],regExp:"^border(-\\d+|\\[\\d+px\\])?$"},order:{classes:u.map([...u.range(0,13),"first","last","none"],t=>`order-${t}`),regExp:"-?order-(\\d+|first|last|none)"},divideXWidth:{classes:u.map(["0",2,4,8],t=>`divide-x-${t}`),regExp:"divide-x-(\\d+|\\[.*\\])"},divideYWidth:{classes:u.map(["0",2,4,8],t=>`divide-y-${t}`),regExp:"divide-y-(\\d+|\\[.*\\])"},divideColor:{classes:[],regExp:"divide-(black|transparent|current|white|__THEME_COLORS_REGEXP__|\\S+-\\d+)"},divideStyle:{classes:u.map(["solid","dashed","dotted","double","none"],t=>`divide-${t}`),regExp:"divide-(solid|dashed|dotted|double|none)"},outlineWidth:{classes:u.map([0,1,2,4,8],t=>`outline-${t}`),regExp:"outline-(\\d+)"},outlineOffset:{classes:u.map([0,1,2,4,8],t=>`outline-offset-${t}`),regExp:"outline-offset-(\\d+)"},outlineColor:{classes:[],regExp:"outline-(black|transparent|current|white|__THEME_COLORS_REGEXP__|\\S+-\\d+)"},ringWidth:{classes:u.map([0,1,2,4,8,"inset"],t=>`ring-${t}`),regExp:"ring-(\\d+|inset)"},ringOffsetWidth:{classes:u.map([0,1,2,4,8],t=>`ring-offset-${t}`),regExp:"ring-offset-(\\d+)"},ringOffsetColor:{classes:[],regExp:"ring-offset-(black|transparent|current|white|__THEME_COLORS_REGEXP__|\\S+-\\d+)"},ringColor:{classes:[],regExp:"ring-(black|transparent|current|white|__THEME_COLORS_REGEXP__|\\S+-\\d+)"},boxShadowColor:{classes:[],regExp:"shadow-(black|transparent|current|white|__THEME_COLORS_REGEXP__|\\S+-\\d+)"},opacity:{classes:u.map([0,5,10,20,25,30,40,50,60,70,75,80,90,95,100],t=>`opacity-${t}`),regExp:"opacity-(\\d+|\\[.*\\])"},mixBlendMode:{classes:u.map(P.blendEffect,t=>`mix-blend-${t}`),regExp:"mix-blend-(\\d+|\\S+)"},bgBlendMode:{classes:u.map(P.blendEffect,t=>`bg-blend-${t}`),regExp:"bg-blend-(\\d+|\\S+)"},blur:{classes:u.map(["none","sm","md","lg","xl","2xl","3xl"],t=>`blur-${t}`),regExp:"blur-(none|sm|md|lg|xl|2xl|3xl)"},brightness:{classes:u.map([0,50,75,90,95,100,105,110,125,150,200],t=>`brightness-${t}`),regExp:"brightness-(\\d+)"},contrast:{classes:u.map([0,50,75,100,125,150,200],t=>`contrast-${t}`),regExp:"contrast-(\\d+)"},grayScale:{classes:["grayscale-0","grayscale"],regExp:"grayscale(-0)?"},hueRotate:{classes:u.map([0,15,30,60,90,180],t=>`hue-rotate-${t}`),regExp:"-?hue-rotate-(\\d+)"},invert:{classes:["invert-0","invert"],regExp:"invert(-0)?"},saturate:{classes:u.map([0,50,100,150,200],t=>`saturate-${t}`),regExp:"saturate-(\\d+)"},sepia:{classes:["sepia-0","sepia"],regExp:"sepia(-0)?"},transition:{classes:["transition-none","transition-all","transition-colors","transition-opacity","transition-shadow","transition-transform"],regExp:"transition-(none|all|colors|opacity|shadow|transform)"},duration:{classes:u.map([75,100,150,200,300,500,700,1e3],t=>`duration-${t}`),regExp:"duration-(\\d+|\\[.*\\])"},transitionEase:{classes:["ease-linear","ease-in","ease-out","ease-in-out"],regExp:"eas(e-linear|e-in|e-out|e-in-out)"},transitionDelay:{classes:u.map([75,100,150,200,300,500,700,1e3],t=>`delay-${t}`),regExp:"delay-(\\d+|\\[.*\\])"},animation:{classes:["animate-none","animate-spin","animate-ping"],regExp:"animate-(none|spin|ping)"},scaleX:{classes:u.map(P.scale,t=>`scale-x-${t}`),regExp:"-?scale-x-(\\d+|\\S+|\\[.*\\])"},scaleY:{classes:u.map(P.scale,t=>`scale-y-${t}`),regExp:"-?scale-y-(\\d+|\\S+|\\[.*\\])"},scale:{classes:u.map(P.scale,t=>`scale-${t}`),regExp:"-?scale-(\\d+|\\S+|\\[.*\\])"},rotate:{classes:u.map([0,1,2,3,6,12,45,90,180],t=>`rotate-${t}`),regExp:"-?rotate-(\\d+|\\S+|\\[.*\\])"},translateX:{classes:u.map([0,"px","0.5",1],t=>`translate-x-${t}`),regExp:"-?translate-x-(\\d+|\\S+|\\[.*\\])"},translateY:{classes:u.map([0,"px","0.5",1],t=>`translate-y-${t}`),regExp:"-?translate-y-(\\d+|\\S+|\\[.*\\])"},skewX:{classes:u.map([0,1,2,3,6,12],t=>`skew-x-${t}`),regExp:"-?skew-x-(\\d+|\\S+|\\[.*\\])"},skewY:{classes:u.map([0,1,2,3,6,12],t=>`skew-y-${t}`),regExp:"-?skew-y-(\\d+|\\S+|\\[.*\\])"},accentColor:{classes:[],regExp:"accent-(black|transparent|current|white|__THEME_COLORS_REGEXP__|\\S+-\\d+)"},appearance:{classes:["appearance-none"],regExp:"appearance-none"},cursor:{classes:["cursor-auto","cursor-default","cursor-pointer","cursor-wait","cursor-text","cursor-move","cursor-help","cursor-not-allowed"],regExp:"cursor-(auto|default|pointer|wait|text|move|help|not-allowed)"},caretColor:{classes:[],regExp:"caret-(black|transparent|current|white|__THEME_COLORS_REGEXP__|\\S+-\\d+)"},pointerEvents:{classes:["pointer-events-none","pointer-events-auto"],regExp:"pointer-events-(none|auto)"},userSelect:{classes:["select-none","select-text","select-all","select-auto"],regExp:"select-(none|text|all|auto)"},fill:{classes:[],regExp:"caret-(black|transparent|current|white|__THEME_COLORS_REGEXP__|\\S+-\\d+)"},stroke:{classes:[],regExp:"caret-(black|transparent|current|white|__THEME_COLORS_REGEXP__|\\S+-\\d+)"},strokeWidth:{classes:["stroke-0","stroke-1","stroke-2"],regExp:"stroke-(\\d+|\\[.*\\])"}},ex={backgroundColor:"bg",textColor:"text",borderColor:"border",boxShadowColor:"shadow",outlineColor:"outline",divideColor:"divide",fromColor:"from",viaColor:"via",toColor:"to",ringColor:"ring",ringOffsetColor:"ring-offset"},tx=["current","inherit","transparent","black","white"],nx=["slate","gray","zinc","neutral","stone","red","orange","amber","yellow","lime","green","emerald","teal","cyan","sky","blue","indigo","violet","purple","fuchsia","pink","rose"],sx=["50","100","200","300","400","500","600","700","800","900"],Er=u.map(u.values(ex),t=>t),rx=u.flattenDeep([...u.map(tx,t=>u.flatten(u.map(Er,e=>`${e}-${t}`))),...u.map(nx,t=>u.flattenDeep(u.map(Er,e=>u.flattenDeep(u.map(sx,n=>`${e}-${t}-${n}`)))))]),ox=u.map(u.flattenDeep(u.values(Xt).map(t=>t.classes).concat(rx)),t=>({name:t})),ix=()=>{const t=Bn(),e=g.useMemo(()=>{let n=[];if(t.colors){const s=u.flattenDeep(u.map(t.colors,({items:r})=>u.keys(r)));n=u.flattenDeep(u.map(s,r=>u.flatten(u.map(Er,o=>`${o}-${r}`))))}return t.fontFamily&&(n=[...n,...u.map(u.keys(t.fontFamily),s=>`${s}`)]),u.map(n,s=>({name:s}))},[t]);return g.useMemo(()=>new ia([...ox,...e],{isCaseSensitive:!1,threshold:.2,minMatchCharLength:2,keys:["name"]}),[e])},Vs=()=>{const t=Bn(),e=g.useMemo(()=>{if(t.colors){const r=u.flattenDeep(u.map(t.colors,({items:o})=>u.keys(o)));u.each(Xt,(o,a)=>{u.set(Xt,`${a}.regExp`,o.regExp.replace("__THEME_COLORS_REGEXP__",r.join("|")))})}return Xt},[t]),n=g.useCallback((r,o)=>{const a=u.get(e,`${r}.regExp`,"");return o.match(new RegExp(a))},[e]),s=g.useCallback((r,o=[])=>u.get(e,`${r}.classes`,o),[e]);return{match:n,getClasses:s}},mc=({label:t,property:e,onChange:n})=>{const{getClasses:s}=Vs(),r=s(e),o=zn(e),a=g.useMemo(()=>u.get(o,"cls",""),[o]),{canChange:l}=g.useContext($n),c=/\[.*\]/g.test(a);return i.jsx("div",{className:t?"w-full rounded":"grow",children:c?i.jsxs("div",{className:"flex items-center",children:[i.jsx(vt,{className:"w-[70%] rounded py-1",readOnly:!0,value:a}),i.jsxs(pe,{delayDuration:100,children:[i.jsx(fe,{asChild:!0,children:i.jsx("button",{type:"button",className:"invisible ml-3 mt-1 text-blue-600 group-hover:visible",children:i.jsx(v.InfoCircledIcon,{})})}),i.jsx(ue,{children:"Current value is using a Tailwind arbitrary value."})]})]}):i.jsx(Ar,{rounded:t,onChange:d=>n(d,e),selected:a,options:r,disabled:!l})})};function Ar({selected:t,onChange:e,rounded:n=!1,options:s,disabled:r=!1}){const o=t.replace(/.*:/g,"").trim(),{undo:a,redo:l}=Pn();return i.jsxs("select",{disabled:!s.length||r,className:`${n?"rounded-md border border-border":"border-0"} disable:bg-gray-500 h-full w-full truncate rounded bg-background px-2 py-1 text-xs outline-none disabled:cursor-not-allowed`,onChange:c=>e(c.target.value),onKeyDown:c=>{c.ctrlKey&&(c.key==="z"&&a(),c.key==="y"&&l())},value:o,children:[i.jsx("option",{className:"bg-transparent",value:""}),s.map((c,d)=>i.jsx("option",{className:"bg-transparent",value:c,children:c},`option-${d}`))]})}const ax={backgroundColor:"bg",textColor:"text",borderColor:"border",boxShadowColor:"shadow",outlineColor:"outline",divideColor:"divide",fromColor:"from",viaColor:"via",toColor:"to",ringColor:"ring",ringOffsetColor:"ring-offset"},lx=({property:t,onChange:e})=>{const n=zn(t),s=g.useMemo(()=>u.get(n,"cls",""),[n]),{canChange:r}=g.useContext($n),[o,a]=g.useState([]),[l,c]=g.useState({color:"",shade:""}),d=s.split("-"),p=u.get(d,"1",""),f=u.get(d,"2",""),m=g.useCallback(x=>{["current","inherit","transparent","black","white"].includes(x)?(a([]),c({color:x})):(a(["50","100","200","300","400","500","600","700","800","900"]),c(y=>({...y,color:x,shade:y.shade?y.shade:"500"})))},[a,c]);g.useEffect(()=>{if(["current","inherit","transparent","black","white"].includes(p))return a([]);a(["50","100","200","300","400","500","600","700","800","900"])},[p]);const h=g.useCallback(x=>{c({color:p,shade:x})},[p]);g.useEffect(()=>{c({color:"",shade:""})},[n]);const{match:b}=Vs();return g.useEffect(()=>{const y=`${u.get(ax,t,"")}-${l.color}${l.shade?`-${l.shade}`:""}`;b(t,y)&&e(y,t)},[b,l,e,t]),i.jsxs("div",{className:"flex flex-row divide-x divide-solid divide-border rounded-lg border border-transparent text-xs",children:[i.jsx("div",{className:"grow text-center",children:i.jsx(Ar,{disabled:!r,rounded:!0,selected:p,onChange:m,options:["current","transparent","primary","secondary","black","white","slate","gray","zinc","neutral","stone","red","orange","amber","yellow","lime","green","emerald","teal","cyan","sky","blue","indigo","violet","purple","fuchsia","pink","rose"]})}),i.jsx("button",{type:"button",className:"grow text-center",children:i.jsx(Ar,{rounded:!0,selected:f,disabled:!p||!r,onChange:h,options:o})})]})},gc={"not-italic":()=>i.jsx("svg",{width:"16",height:"16",viewBox:"0 0 16 16",fill:"none",xmlns:"http://www.w3.org/2000/svg",children:i.jsx("path",{fillRule:"evenodd",clipRule:"evenodd",d:"M9 3H11V5H9V11H11V13H5V11H7V5H5V3H9Z",fill:"white"})}),visible:v.EyeOpenIcon,invisible:v.EyeClosedIcon,hidden:v.EyeClosedIcon,gap:v.BorderAllIcon,gapX:v.WidthIcon,gapY:v.HeightIcon,spaceX:v.WidthIcon,spaceY:v.HeightIcon,overscroll:v.BorderAllIcon,overscrollX:v.WidthIcon,overscrollY:v.HeightIcon,overflow:v.BorderAllIcon,overflowX:v.WidthIcon,overflowY:v.HeightIcon,top:v.ArrowUpIcon,right:v.ArrowRightIcon,bottom:v.ArrowDownIcon,left:v.ArrowLeftIcon,inset:v.BorderAllIcon,insetX:v.WidthIcon,insetY:v.HeightIcon,border:v.BorderAllIcon,borderX:v.WidthIcon,borderY:v.HeightIcon,borderTop:v.ArrowUpIcon,borderRight:v.ArrowRightIcon,borderBottom:v.ArrowDownIcon,borderLeft:v.ArrowLeftIcon,borderRadius:v.BorderAllIcon,borderRadiusX:v.WidthIcon,borderRadiusY:v.HeightIcon,borderRadiusTop:v.ArrowUpIcon,borderRadiusRight:v.ArrowRightIcon,borderRadiusBottom:v.ArrowDownIcon,borderRadiusLeft:v.ArrowLeftIcon,borderRadiusTopLeft:v.ArrowTopLeftIcon,borderRadiusTopRight:v.ArrowTopRightIcon,borderRadiusBottomRight:v.ArrowBottomRightIcon,borderRadiusBottomLeft:v.ArrowBottomLeftIcon,divideXWidth:v.WidthIcon,divideYWidth:v.HeightIcon,scale:v.BorderAllIcon,scaleX:v.WidthIcon,scaleY:v.HeightIcon,skewX:v.WidthIcon,skewY:v.HeightIcon,translateX:v.WidthIcon,translateY:v.HeightIcon,padding:v.BorderAllIcon,paddingX:v.WidthIcon,paddingY:v.HeightIcon,paddingTop:v.ArrowUpIcon,paddingRight:v.ArrowRightIcon,paddingBottom:v.ArrowDownIcon,paddingLeft:v.ArrowLeftIcon,margin:v.BorderAllIcon,marginX:v.WidthIcon,marginY:v.HeightIcon,marginTop:v.ArrowUpIcon,marginRight:v.ArrowRightIcon,marginBottom:v.ArrowDownIcon,marginLeft:v.ArrowLeftIcon,textLeft:v.AlignLeftIcon,textCenter:v.AlignCenterHorizontallyIcon,textRight:v.AlignRightIcon,textJustify:v.StretchHorizontallyIcon,italic:v.FontItalicIcon,underline:v.UnderlineIcon,overline:v.OverlineIcon,uppercase:v.LetterCaseUppercaseIcon,block:()=>i.jsxs("svg",{width:"16",height:"16",viewBox:"0 0 16 16",fill:"none",xmlns:"http://www.w3.org/2000/svg",children:[i.jsx("path",{opacity:"0.6",fillRule:"evenodd",clipRule:"evenodd",d:"M2 2H14V14H2V2ZM1 1H15V15H1V1Z",fill:"currentColor"}),i.jsx("path",{fillRule:"evenodd",clipRule:"evenodd",d:"M7 4H4V12H7V4ZM9 4H12V12H9V4Z",fill:"currentColor"})]}),"float-right":()=>i.jsxs("svg",{width:"16",height:"16",viewBox:"0 0 16 16",fill:"none",xmlns:"http://www.w3.org/2000/svg",children:[i.jsx("path",{d:"M8 4H16V12H8V4Z",fill:"currentColor"}),i.jsx("path",{opacity:"0.6",fillRule:"evenodd",clipRule:"evenodd",d:"M0 4H6V6H0V4ZM0 7H6V9H0V7ZM4 10H0V12H4V10Z",fill:"currentColor"})]}),"float-left":()=>i.jsxs("svg",{width:"16",height:"16",viewBox:"0 0 16 16",fill:"none",xmlns:"http://www.w3.org/2000/svg",children:[i.jsx("path",{d:"M0 4H8V12H0V4Z",fill:"currentColor"}),i.jsx("path",{opacity:"0.6",fillRule:"evenodd",clipRule:"evenodd",d:"M10 4H16V6H10V4ZM10 7H16V9H10V7ZM14 10H10V12H14V10Z",fill:"currentColor"})]}),"float-none":v.Cross2Icon,fixed:()=>i.jsxs("svg",{width:"16",height:"16",viewBox:"0 0 16 16",fill:"none",xmlns:"http://www.w3.org/2000/svg",children:[i.jsx("path",{opacity:"0.6",fillRule:"evenodd",clipRule:"evenodd",d:"M15 2H14V4H13V5H14V6H15V2ZM10 5V4H9V2H1V8H2V5H10ZM7 4V3H5V4H7ZM4 4V3H2V4H4ZM1 13H7V14H1V13Z",fill:"currentColor"}),i.jsx("path",{fillRule:"evenodd",clipRule:"evenodd",d:"M11 2H10V3H11V6H12V3H13V2H11ZM2 9H1V12H2V11H7V10H2V9ZM15 7H8V14H15V7Z",fill:"currentColor"})]}),absolute:()=>i.jsxs("svg",{width:"16",height:"16",viewBox:"0 0 16 16",fill:"none",xmlns:"http://www.w3.org/2000/svg",children:[i.jsx("path",{opacity:"0.6",fillRule:"evenodd",clipRule:"evenodd",d:"M14 2H15V6H14V2ZM9 3V2H1V8H2V3H9ZM7 13H1V14H7V13Z",fill:"currentColor"}),i.jsx("path",{fillRule:"evenodd",clipRule:"evenodd",d:"M11 2H10V3H11V6H12V3H13V2H11ZM2 9H1V12H2V11H7V10H2V9ZM15 7H8V14H15V7Z",fill:"currentColor"})]}),relative:()=>i.jsx("svg",{width:"16",height:"16",viewBox:"0 0 16 16",fill:"none",xmlns:"http://www.w3.org/2000/svg",children:i.jsx("path",{fillRule:"evenodd",clipRule:"evenodd",d:"M11 2H9V3H11V6H12V3H14V2H11ZM2 8H1V13H2V11H7V10H2V8ZM15 7H8V14H15V7Z",fill:"currentColor"})}),sticky:()=>i.jsxs("svg",{width:"16",height:"16",viewBox:"0 0 16 16",fill:"none",xmlns:"http://www.w3.org/2000/svg",children:[i.jsx("path",{d:"M12.9998 7C13.6558 7 14.2937 6.78498 14.8158 6.38787C15.338 5.99076 15.7156 5.43345 15.8908 4.80128C16.066 4.16912 16.0292 3.49694 15.7859 2.8877C15.5427 2.27846 15.1065 1.76573 14.5441 1.42804C13.9817 1.09034 13.3241 0.946293 12.672 1.01795C12.02 1.08961 11.4094 1.37303 10.9337 1.8248C10.4581 2.27658 10.1436 2.8718 10.0385 3.51932C9.93341 4.16685 10.0434 4.83097 10.3518 5.41L6.88176 8.88C6.80034 8.96122 6.73572 9.05769 6.69158 9.16388C6.64744 9.27008 6.62465 9.38393 6.62451 9.49894C6.62437 9.61395 6.64689 9.72785 6.69077 9.83416C6.73465 9.94046 6.79904 10.0371 6.88026 10.1185C6.96149 10.1999 7.05795 10.2645 7.16415 10.3087C7.27035 10.3528 7.3842 10.3756 7.4992 10.3758C7.61421 10.3759 7.72812 10.3534 7.83442 10.3095C7.94072 10.2656 8.03734 10.2012 8.11876 10.12L11.5888 6.648C12.0088 6.873 12.4888 7 12.9988 7H12.9998Z",fill:"currentColor"}),i.jsx("path",{opacity:"0.6",fillRule:"evenodd",clipRule:"evenodd",d:"M9.535 2H1V14H15V7.465C14.69 7.645 14.355 7.783 14 7.875V13H2V5H9.126C8.86504 3.98486 9.01223 2.90789 9.536 2H9.535ZM7 3V4H5V3H7ZM4 3V4H2V3H4Z",fill:"currentColor"})]}),static:v.Cross1Icon},cx=({property:t,onChange:e})=>{const{getClasses:n}=Vs(),s=n(t),{canChange:r}=g.useContext($n),o=zn(t),a=g.useMemo(()=>u.get(o,"cls",""),[o]);return i.jsx("div",{className:"flex grow flex-wrap gap-1",children:u.map(s,l=>i.jsxs(pe,{children:[i.jsx(fe,{asChild:!0,children:i.jsx("button",{type:"button",disabled:!r,onClick:()=>e(l,t),className:`cursor-pointer rounded border border-border p-1 disabled:cursor-not-allowed ${a===l?"bg-primary text-white":"disabled:bg-gray-600 disabled:text-gray-400"}`,children:g.createElement(u.get(gc,l,v.BoxIcon))})}),i.jsx(ue,{children:u.startCase(u.toLower(l))})]}))})},dx=({property:t,onChange:e})=>{const{canReset:n,canChange:s}=g.useContext($n),r=zn(t),o=g.useMemo(()=>u.get(r,"cls",""),[r]),{getClasses:a}=Vs(),l=a(t,[""]),c=l.indexOf(o)>-1?l.indexOf(o):0,d=/\[.*\]/g.test(o);return i.jsx("div",{className:"flex flex-row divide-x divide-solid divide-border rounded border border-border text-xs",children:d?i.jsx("div",{className:"px-2 py-[5px]",children:o}):i.jsxs(i.Fragment,{children:[i.jsx("button",{type:"button",className:"hover:bg-bg-gray-700 box-border w-2/12 rounded-bl rounded-tl bg-background px-1 text-center disabled:cursor-not-allowed disabled:bg-gray-600",disabled:!s&&(!n||c-1<0),onClick:()=>e(u.nth(l,c-1),t),children:i.jsx("span",{className:"flex items-center justify-center",children:i.jsx(v.MinusIcon,{className:!s&&(!n||c-1<0)?"text-gray-500":"text-black/60 dark:text-white/60"})})}),i.jsx("div",{className:"w-8/12 text-center",children:i.jsx(mc,{label:!1,property:t,onChange:e})}),i.jsx("button",{type:"button",className:"hover:bg-bg-gray-700 w-2/12 rounded-br rounded-tr bg-background px-1 text-center disabled:cursor-not-allowed disabled:bg-gray-600",disabled:!s&&(!n||c+1>=l.length),onClick:()=>e(u.nth(l,c+1),t),children:i.jsx("span",{className:"flex items-center justify-center",children:i.jsx(v.PlusIcon,{className:!s&&(!n||c+1>=l.length)?"text-gray-500":"text-black/60 dark:text-white/60"})})})]})})};function ux(t){if(u.isEmpty(t.trim()))return"";const e=t.match(/sm:|md:|lg:|xl:|2xl:/g);return u.get(e,0,"xs").replace(":","")}function px(t){const e=u.map(zu,s=>`${s}:`).join("|"),n=new RegExp(e,"g");return u.get(n.exec(t.trim()),0,"").replace(":","")}function fx(t){return t.trim().split(":").pop()||""}const pr={};function hx(t){if(u.isEmpty(t))return"";if(pr[t])return pr[t];let e="";for(const n in Xt){const s=u.get(Xt,`${n}.regExp`,"");if(new RegExp(s,"g").test(t)){e=n,pr[t]=e;break}}return e}function Go(t){return u.isEmpty(t)?null:{dark:u.startsWith(t,"dark:"),mq:ux(t),mod:px(t),cls:fx(t),fullCls:t,property:hx(t)}}function mx(t){let e="";return t.dark&&(e+="dark:"),t.mq.toLowerCase()!=="xs"&&(e+=`${t.mq}:`),t.mod&&(e+=`${t.mod}:`),e+=t.cls,e}function xc(t){t=t.replace(/\s+/g," ");const e=t.split(" ").map(Go),n=["xs","sm","md","lg","xl","2xl"];return e.sort((s,r)=>n.indexOf(s.mq)-n.indexOf(r.mq)).map(s=>s.fullCls).join(" ")}function bc(t){if(t=t.replace(/\s+/g," "),!t)return"";const e=["xs","sm","md","lg","xl","2xl"],n=t.split(" ").map(Go);let s=t;if(n.length===1)return n[0].fullCls;for(const r of n){const o=r.property,a=e.indexOf(r.mq);for(let l=a+1;l<e.length;l++){const c=e[l],d=n.find(p=>p.property===o&&p.mq===c);if(d&&d.cls===r.cls)s=s.replace(d.fullCls,"");else if(d&&d.cls!==r.cls)break}}return s.replace(/\s+/g," ").trim()}const gx=S.atom(null,(t,e,{blockIds:n,newClasses:s})=>{const r=u.filter(t(In),a=>n.includes(t(a)._id)),o=u.first(t(Mn));return u.map(r,a=>{const l=t(a),c=u.get(l,o.prop,`${$.STYLES_KEY},`),{classes:d}=$.getSplitChaiClasses(c);return{ids:[l._id],props:{[o.prop]:`${$.STYLES_KEY},${xc(bc($r.twMerge(d,s)))}`}}})}),yc=()=>{const t=S.useSetAtom(gx),{updateBlocks:e,updateBlocksRuntime:n}=Ne();return g.useCallback((s,r,o=!1)=>{const a=t({blockIds:s,newClasses:r});if(!o){n(s,a[0].props);return}e(s,a[0].props)},[t,e,n])},xx=t=>{const e=["xs","sm","md","lg","xl","2xl"],n=e.indexOf(t);return n===-1?["xs"]:e.slice(0,n+1)},bx=S.atom(t=>{const e=u.first(t(Mn)),n=t(_s);if(!e||e.blockId!==u.get(n,"_id",null))return[];const s=u.get(n,e.prop,`${$.STYLES_KEY},`),{classes:r}=$.getSplitChaiClasses(s);return u.filter(u.map(r.trim().split(" "),Go),o=>!u.isNull(o))}),Vi={xs:0,sm:1,md:2,lg:3,xl:4,"2xl":5},yx=S.atom(t=>{const e=t(tc),n=t(Xr),s=t(tl),r=xx(e);let o=u.filter(t(bx),{mod:n});return u.startsWith(n,"_")||(o=u.filter(o,a=>r.includes(a.mq))),o=o.sort((a,l)=>Vi[a.mq]-Vi[l.mq]),s||(o=u.filter(o,{dark:!1})),o}),Ws=()=>S.useAtomValue(yx),vx=()=>S.useAtom(Xr),zn=t=>{const e=Ws();return u.findLast(e,{property:t})},kx=(t,e)=>{const n={xs:0,sm:1,md:2,lg:3,xl:4,"2xl":5};return n[u.get(t,"mq","xs")]<=n[e]},wx={width:"w-",height:"h-",minWidth:"min-w-",minHeight:"min-h-",maxWidth:"max-w-",maxHeight:"max-h-",zIndex:"z-",gap:"gap-",gapX:"gap-x-",gapY:"gap-y-",margin:"m-",marginX:"mx-",marginY:"my-",marginTop:"mt-",marginBottom:"mb-",marginLeft:"ml-",marginRight:"mr-",padding:"p-",paddingX:"px-",paddingY:"py-",paddingTop:"pt-",paddingBottom:"pb-",paddingLeft:"pl-",paddingRight:"pr-",spaceX:"space-x-",spaceY:"space-y-",border:"border-",borderTop:"border-t-",borderBottom:"border-b-",borderLeft:"border-l-",borderRight:"border-r-",borderX:"border-x-",borderY:"border-y-",borderRadius:"rounded-",borderRadiusTop:"rounded-t-",borderRadiusRight:"rounded-r-",borderRadiusBottom:"rounded-b-",borderRadiusLeft:"rounded-l-",borderRadiusTopLeft:"rounded-tl-",borderRadiusTopRight:"rounded-tr-",borderRadiusBottomRight:"rounded-br-",borderRadiusBottomLeft:"rounded-bl-",fontSize:"text-",lineHeight:"leading-",letterSpacing:"tracking-",textIndent:"indent-",rotate:"rotate-",duration:"duration-",transitionDelay:"delay-",scale:"scale-",scaleX:"scale-x-",scaleY:"scale-y-",translateX:"translate-x-",translateY:"translate-y-",skewX:"skew-x-",skewY:"skew-y-",top:"top-",bottom:"bottom-",left:"left-",right:"right-",inset:"inset-",insetX:"inset-x-",insetY:"inset-y-",opacity:"opacity-",flexBasis:"basis-"},Wi={xs:"",sm:"640px",md:"768px",lg:"1024px",xl:"1280px","2xl":"1536px"},Cx=t=>`${t.toUpperCase()} ${Wi[t]?`(${Wi[t]} & up)`:""}`,ks=t=>{const{t:e}=F.useTranslation(),{type:n="icons",label:s,property:r,onEmitChange:o=()=>{},units:a,negative:l=!1}=t,[c]=Dn(),[d]=vx(),[,p]=bs(),f=zn(r),m=yc(),h=Uo(),[b]=K(),x=g.useMemo(()=>u.get(f,"fullCls",""),[f]),y=g.useCallback((I,j=!0)=>{const N={dark:c,mq:p,mod:d,cls:I};(c||d!=="")&&(N.mq="xs");const C=mx(N);m(b,[C],j)},[b,c,p,d,r,m]),k=g.useCallback(()=>{h(b,[x],!0)},[b,x,h]),w=g.useMemo(()=>kx(f,p),[f,p]);g.useEffect(()=>{o(w,f)},[w,o,f]);const[,,E]=bs(),A=g.useCallback(I=>{E({xs:400,sm:640,md:800,lg:1024,xl:1420,"2xl":1920}[I])},[E]),_=u.get(f,"dark",null)===c&&u.get(f,"mod",null)===d&&u.get(f,"mq",null)===p;return i.jsx(Qg,{canChange:w,canReset:f&&_,children:i.jsxs("div",{className:"group flex flex-row items-center py-2 first:pt-0 last:pb-0",children:[i.jsx("div",{className:"relative w-[70px] truncate text-xs text-foreground",children:i.jsx("span",{className:`text-[11px] ${f&&!_?"text-foreground":""}`,children:e(s)})}),i.jsxs("div",{className:"flex flex-row items-center",children:[i.jsxs("div",{className:"w-[150px]",children:[n==="arbitrary"?i.jsx(Zg,{currentClass:u.get(f,"cls",""),classPrefix:u.get(wx,r,""),units:a||[],onChange:y,negative:l,cssProperty:r}):null,n==="icons"&&i.jsx(cx,{property:r,onChange:y}),n==="range"&&i.jsx(dx,{property:r,onChange:y}),n==="color"&&i.jsx(lx,{property:r,onChange:y}),n==="dropdown"&&i.jsx(mc,{label:s,property:r,onChange:y})]}),i.jsx("div",{className:`w-[30px] cursor-pointer ${x?"visible":"invisible"}`,children:_?i.jsx("button",{type:"button",onClick:()=>k(),title:"Reset",className:"flex px-1.5 text-xs",children:i.jsx(v.CrossCircledIcon,{className:"h-5 w-5 text-blue-500 hover:opacity-80"})}):w&&f?i.jsxs(pe,{delayDuration:100,children:[i.jsx(fe,{asChild:!0,children:i.jsx("button",{type:"button",className:"invisible ml-3 mt-1 rounded-full bg-primary text-white group-hover:visible",children:i.jsx(v.InfoCircledIcon,{})})}),i.jsx(ue,{children:i.jsx("div",{className:"text-right",children:i.jsxs("div",{children:["Current style is set at  ",i.jsxs("span",{className:"font-bold",children:[Cx(u.get(f,"mq")),c&&!f.dark?"(Light mode)":""]}),i.jsx("br",{}),i.jsxs("button",{type:"button",onClick:()=>A(u.get(f,"mq")),className:"block w-full cursor-default text-right font-semibold text-blue-500",children:["Switch to ",u.get(f,"mq").toUpperCase()]})]})})})]}):null})]})]})})},jx=["px","%","em","rem","ch","vh","vw"],_r=({label:t,options:e,borderB:n=!1,borderT:s=!1,type:r="arbitrary",units:o=jx,negative:a=!1})=>{const{t:l}=F.useTranslation(),[c,d]=g.useState(e[0].key),p=Ws(),f=g.useCallback(m=>u.map(p,"property").includes(m),[p]);return i.jsxs("div",{className:`mb-2 border-border py-2 first:pt-0 last:pb-0 ${n?"border-b":""} ${s?"border-t":""}`,children:[i.jsxs("div",{className:"flex flex-row text-xs",children:[t&&i.jsx("span",{className:"relative w-[70px] flex-none text-xs text-foreground",children:l(t)}),i.jsx("div",{className:"mb-3 flex grow flex-row flex-wrap gap-x-px",children:e.map(({label:m,key:h},b)=>i.jsx("div",{className:"first:rounded-l last:rounded-r",children:i.jsxs(pe,{children:[i.jsx(fe,{asChild:!0,children:i.jsxs("button",{type:"button",onClick:()=>d(h),className:`relative cursor-pointer rounded-full p-1 text-[8px] ${h===c?"bg-[#3E57F0] text-white":"text-gray-600 dark:text-gray-300"}`,children:[g.createElement("div",{className:f(h)?"-bottom-1.5 absolute bg-[#3E57F0] h-[2px] left-0 w-full":""}),g.createElement(u.get(gc,h,v.BoxIcon),{className:"text-inherit w-3 h-3"})]})}),i.jsx(ue,{children:u.startCase(u.toLower(m))})]})},`option-${b}`))})]}),i.jsx("div",{className:"mt-0 flex items-center",children:i.jsx(ks,{type:r,units:[...o],label:"",property:c,negative:a})})]})},Ui=({heading:t,items:e})=>{const{t:n}=F.useTranslation(),s=Ws(),r=g.useMemo(()=>{const o=c=>u.flatten(c.map(d=>d.styleType==="multiple"?u.map(d.options,"key"):d.property)),a=u.flatten(e.map(c=>c.styleType==="accordion"?o(c.items):c.styleType==="multiple"?u.map(c.options,"key"):c.property)),l=u.map(s,"property");return u.intersection(a,l).length>0},[s,e]);return i.jsxs("details",{children:[i.jsx("summary",{className:"my-px cursor-default rounded-md bg-gray-50 p-px px-2 text-[11px] text-foreground dark:bg-gray-800",children:i.jsxs("div",{className:"inline",children:[u.startCase(n(t.toLowerCase())),r?i.jsx("span",{className:`ml-1 mr-2 inline-block h-[8px] w-[8px] rounded-full ${r?"bg-primary":"bg-gray-300"}`}):null]})}),i.jsx("div",{className:"p-2",children:e.map(o=>o.styleType==="multiple"?i.jsx(_r,{...o},o.label):i.jsx(ks,{...o},o.label))})]})},Sx=g.createContext({}),fr=({section:t,showAccordian:e})=>{const{t:n}=F.useTranslation(),s=Ws(),r=g.useCallback((a=[])=>{const l={};for(let d=0;d<s.length;d++)l[s[d].property]=s[d].cls;let c=!0;for(const d in a)if(!u.has(l,d)||l[d]!==a[d]){c=!1;break}return c},[s]),o=g.useMemo(()=>({}),[]);return i.jsx(Sx.Provider,{value:o,children:e?i.jsxs(Ho,{value:t.heading,className:"border-none",children:[i.jsx(Vo,{className:"border-slate-150 border-t py-2 text-xs",children:i.jsx("div",{className:"flex items-center py-2",children:i.jsx("div",{className:"flex items-center gap-x-2 text-xs font-medium",children:u.startCase(n(t.heading))})})}),i.jsx(Wo,{className:"py-2",children:t.items.map(a=>u.has(a,"component")?g.createElement(a.component,{key:a.label}):u.has(a,"styleType")?a.styleType==="multiple"?i.jsx(_r,{...a},a.label+"multiple-choices"):a.styleType==="accordion"&&r(a==null?void 0:a.conditions)?i.jsx(Ui,{...a},a.label+"nested-options"):null:i.jsx(ks,{...a},a.label+"block-style"))})]}):i.jsx("div",{className:"py-2",children:t.items.map((a,l)=>u.has(a,"component")?g.createElement(a.component,{key:a.label}):u.has(a,"styleType")?a.styleType==="multiple"?i.jsx(_r,{...a},a.label+"multiple-choices"+l):a.styleType==="accordion"&&r(a==null?void 0:a.conditions)?i.jsx(Ui,{...a},a.label+"nested-options"+l):null:i.jsx(ks,{...a},a.label+"block-style"+l))})})},vc=Es.Root,kc=Es.Trigger,qo=M.forwardRef(({className:t,align:e="center",sideOffset:n=4,...s},r)=>i.jsx(Es.Content,{ref:r,align:e,sideOffset:n,className:L("z-50 w-64 origin-[--radix-hover-card-content-transform-origin] rounded-md border bg-popover p-4 text-popover-foreground shadow-md outline-none data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0 data-[state=closed]:zoom-out-95 data-[state=open]:zoom-in-95 data-[side=bottom]:slide-in-from-top-2 data-[side=left]:slide-in-from-right-2 data-[side=right]:slide-in-from-left-2 data-[side=top]:slide-in-from-bottom-2",t),...s}));qo.displayName=Es.Content.displayName;const Nx=we.atomWithStorage("selectedBreakpoints",["XS","MD","XL"]),Ex=()=>{const[t,e]=S.useAtom(Nx);return[t,e]},Gi=({landscape:t=!1,className:e=""})=>i.jsx("svg",{className:ve.cn("h-3 w-3",t?"rotate-90":"",e),stroke:"currentColor",fill:"currentColor",strokeWidth:"0",viewBox:"0 0 448 512",xmlns:"http://www.w3.org/2000/svg",children:i.jsx("path",{d:"M400 0H48C21.5 0 0 21.5 0 48v416c0 26.5 21.5 48 48 48h352c26.5 0 48-21.5 48-48V48c0-26.5-21.5-48-48-48zM224 480c-17.7 0-32-14.3-32-32s14.3-32 32-32 32 14.3 32 32-14.3 32-32 32zm176-108c0 6.6-5.4 12-12 12H60c-6.6 0-12-5.4-12-12V60c0-6.6 5.4-12 12-12h328c6.6 0 12 5.4 12 12v312z"})}),Ir=[{title:"Mobile (Base)",content:"Styles set here are applied to all screen unless edited at higher breakpoint",breakpoint:"xs",icon:i.jsx(v.MobileIcon,{className:"h-4 w-4"}),width:400},{title:"Mobile landscape (SM)",content:"Styles set here are applied at 640px and up unless edited at higher breakpoint",breakpoint:"sm",icon:i.jsx(v.MobileIcon,{className:"h-4 w-4 rotate-90"}),width:640},{title:"Tablet (MD)",content:"Styles set here are applied at 768px and up",breakpoint:"md",icon:i.jsx(Gi,{}),width:800},{title:"Tablet Landscape (LG)",content:"Styles set here are applied at 1024px and up unless edited at higher breakpoint",breakpoint:"lg",icon:i.jsx(Gi,{landscape:!0}),width:1024},{title:"Desktop (XL)",content:"Styles set here are applied at 1280px and up unless edited at higher breakpoint",breakpoint:"xl",icon:i.jsx(v.LaptopIcon,{className:"h-4 w-4"}),width:1420},{title:"Large Desktop (2XL)",content:"Styles set here are applied at 1536px and up",breakpoint:"2xl",icon:i.jsx(v.DesktopIcon,{className:"h-4 w-4"}),width:1920}],qi=({canvas:t=!1,openDelay:e=400,tooltip:n=!0,title:s,content:r,currentBreakpoint:o,breakpoint:a,width:l,icon:c,onClick:d,buttonClass:p="",activeButtonClass:f=""})=>{const{t:m}=F.useTranslation();return n?i.jsxs(vc,{openDelay:e,children:[i.jsx(kc,{asChild:!0,children:i.jsx(q,{onClick:()=>d(l),size:"sm",className:ve.cn("h-7 w-7 rounded-md p-1",a===o?f:p),variant:a===o?"outline":"ghost",children:c})}),i.jsx(qo,{className:"w-fit max-w-52 border-border",children:i.jsx("div",{className:"flex justify-between space-x-4",children:i.jsxs("div",{className:"space-y-1",children:[i.jsx("h4",{className:"text-sm font-semibold",children:m(s)}),t&&i.jsx("p",{className:"text-xs",children:m(r)})]})})})]}):i.jsx(q,{onClick:()=>d(l),size:"sm",className:"h-7 w-7 rounded-md p-1",variant:a===o?"outline":"ghost",children:c})},Ko=({openDelay:t=400,canvas:e=!1,tooltip:n=!0,buttonClass:s="",activeButtonClass:r=""})=>{const[o,,a]=bs(),[l,c]=Ao(),[d,p]=Ex(),f=d,m=p,{t:h}=F.useTranslation(),b=O("breakpoints",Ir),x=w=>{f.includes(w)?f.length>2&&m(f.filter(E=>E!==w)):m(E=>[...E,w])},y=w=>{e||a(w),c(w)},k=ve.getBreakpointValue(e?l:o).toLowerCase();return b.length<4?i.jsx("div",{className:"flex items-center rounded-md",children:u.map(b,w=>g.createElement(qi,{canvas:e,...w,onClick:y,key:w.breakpoint,currentBreakpoint:k}))}):i.jsxs("div",{className:"flex w-full items-center justify-between rounded-md",children:[i.jsx("div",{className:"flex items-center",children:u.map(b.filter(w=>u.includes(f,u.toUpper(w.breakpoint))),w=>g.createElement(qi,{canvas:e,openDelay:t,tooltip:n,...w,onClick:y,key:w.breakpoint,currentBreakpoint:k,buttonClass:s,activeButtonClass:r}))}),i.jsxs(Qe,{children:[i.jsx(et,{asChild:!0,children:i.jsx("span",{className:"cursor-pointer rounded-md p-1 hover:bg-background",children:i.jsx(v.ChevronDownIcon,{className:"scale-90 transform"})})}),i.jsxs(Ue,{className:"w-56 border-border text-xs",children:[i.jsx(ua,{children:h("Screen sizes")}),i.jsx(Hr,{}),u.map(b,w=>i.jsx(da,{disabled:w.breakpoint==="xs",onCheckedChange:()=>x(u.toUpper(w.breakpoint)),checked:u.includes(f,u.toUpper(w.breakpoint)),onSelect:E=>E.preventDefault(),children:h(w.title)},w.breakpoint))]})]})]})};function Ax(){const[,t]=bs(),{t:e}=F.useTranslation(),n=g.useMemo(()=>{const s=Ir.find(r=>r.breakpoint===t);return s==null?void 0:s.content},[t,Ir]);return i.jsxs(i.Fragment,{children:[i.jsxs("div",{className:"sticky top-0 z-10 flex items-center justify-start bg-muted px-2 py-1 shadow-sm",children:[i.jsxs("p",{className:"text-xs text-muted-foreground",children:[e("Screen")," "]}),i.jsx(Ko,{openDelay:1e3,tooltip:!1})]}),i.jsx("div",{className:"mb-2 flex items-center justify-between rounded-md rounded-t-none border border-border p-1",children:i.jsx("p",{className:"flex flex-1 items-center space-x-2 text-[10px] text-foreground",children:i.jsxs("span",{className:"text-xs text-foreground",children:[i.jsx("span",{className:"rounded-md bg-muted px-1 py-px text-xs font-bold uppercase text-muted-foreground",children:t==="xs"?"Base":t}),"  ",e(n)]})})})]})}const _x=_n.cva("text-sm font-medium leading-none peer-disabled:cursor-not-allowed peer-disabled:opacity-70"),ut=M.forwardRef(({className:t,...e},n)=>i.jsx(la.Root,{ref:n,className:L(_x(),t),...e}));ut.displayName=la.Root.displayName;const Tr=({className:t=""})=>i.jsx(v.TokensIcon,{className:t});function Yo({from:t="default",classFromProps:e,onAddNew:n,onRemove:s}){var ft;const r=g.useRef(null),[o,a]=g.useState(""),[l,c]=g.useState(!1),[d,p]=g.useState(-1),[,f]=so(),m=ix(),{t:h}=F.useTranslation(),[b]=Ee(),x=Z(),y=yc(),k=Uo(),[w]=K(),[E,A]=g.useState(""),_=S.useAtomValue(nn),I=(ft=u.first(b))==null?void 0:ft.prop,{classes:j}=$.getSplitChaiClasses(u.get(x,I,"")),C=(t==="default"?j:e??"").split(" ").filter(H=>!u.isEmpty(H)),T=g.useMemo(()=>[...C].sort((H,ce)=>{const Be=H.startsWith($.DESIGN_TOKEN_PREFIX),rt=ce.startsWith($.DESIGN_TOKEN_PREFIX);return Be&&!rt?-1:!Be&&rt?1:0}),[C]),R=O("flags.copyPaste",!0),B=H=>{if(H.startsWith($.DESIGN_TOKEN_PREFIX)){const ce=_[H];return ce?ce.name:H}return H},U=H=>{const ce=Object.entries(_).find(([,Be])=>Be.name===H);return ce?`${ce[0]}`:H},z=()=>{const H=E.trim().replace(/ +(?= )/g,"").split(" ").map(U);t==="designToken"?u.isFunction(n)&&n(H):y(w,H,!0),A("")},[G,he]=g.useState([]),ae=O("flags.designTokens",!1),le=({value:H})=>{const ce=H.trim().toLowerCase(),Be=ce.match(/.+:/g);let rt=[],Js=[];if(ae&&(ce===""?Js=Object.entries(_).map(([ht,un])=>({name:un.name,id:`${ht}`,isDesignToken:!0})):Js=Object.entries(_).filter(([,ht])=>ht.name.toLowerCase().includes(ce)).map(([ht,un])=>({name:un.name,id:`${ht}`,isDesignToken:!0}))),Be&&Be.length>0){const[ht]=Be,un=ce.replace(ht,"");rt=m.search(un).map(Zs=>({...Zs,item:{...Zs.item,name:ht+Zs.item.name}}))}else rt=m.search(ce);const Cd=[...Js,...u.map(rt,"item")];return he(Cd)},Ae=()=>{he([])},W=H=>H.name,Me=H=>i.jsxs("div",{className:"flex items-center gap-2 rounded-md p-1",children:[H.isDesignToken&&i.jsx(Tr,{className:"h-4 w-4 text-gray-600"}),i.jsx("span",{children:H.name})]}),pt=g.useMemo(()=>({ref:r,autoComplete:"off",autoCorrect:"off",autoCapitalize:"off",spellCheck:!1,placeholder:h("Enter classes separated by space"),value:E,onFocus:H=>{setTimeout(()=>{H.target&&H.target.select()},0)},onKeyDown:H=>{if(H.key==="Enter"&&E.trim()!==""&&(H.preventDefault(),z()),H.key==="Tab"&&G.length>0){H.preventDefault();const ce=new KeyboardEvent("keydown",{key:"ArrowDown",code:"ArrowDown",keyCode:40,bubbles:!0});H.target.dispatchEvent(ce)}},onChange:(H,{newValue:ce})=>A(ce),className:`w-full rounded-md text-xs px-2 hover:outline-0 bg-background border-border ${t==="default"?"py-1":"py-1.5"}`}),[E,h,r,G.length]),wt=H=>{const ce=o.trim().replace(/ +(?= )/g,"").split(" ").map(U);k(w,[H]),y(w,ce,!0),a(""),p(-1)},Wt=()=>{if(navigator.clipboard===void 0){me.toast.error(h("Clipboard not supported"));return}navigator.clipboard.writeText(C.join(" ")),me.toast.success(h("Classes copied to clipboard")),c(!0),setTimeout(()=>c(!1),2e3)};return i.jsxs("div",{className:`flex w-full flex-col gap-y-1.5 pb-4 ${t==="designToken"?"border-none":"border-b border-border"}`,children:[i.jsx("div",{className:"flex items-center justify-between gap-x-2",children:i.jsxs("div",{className:"flex w-full items-center justify-between gap-x-2 text-muted-foreground",children:[i.jsxs("span",{className:"flex items-center gap-x-1",children:[i.jsx("span",{children:t==="designToken"?i.jsx(ut,{className:"text-sm font-medium leading-tight text-gray-900 peer-disabled:cursor-not-allowed peer-disabled:opacity-70",children:h("Token Classes")}):h(ae?"Styles":"Classes")}),R&&i.jsxs(pe,{children:[i.jsx(fe,{asChild:!0,children:l?i.jsx(v.CheckIcon,{className:"rounded-full border border-green-500 bg-green-500/10 text-green-500"}):i.jsx(v.CopyIcon,{onClick:Wt,className:"cursor-pointer"})}),i.jsx(ue,{children:i.jsx("p",{children:h("Copy classes to clipboard")})})]})]}),ae&&t==="default"&&i.jsx(q,{variant:"link",className:"underline",onClick:()=>f("design-tokens"),children:h("Design Tokens")})]})}),i.jsxs("div",{className:"relative flex items-center gap-x-3",children:[i.jsx("div",{className:"relative flex w-full items-center gap-x-3",children:i.jsx(Gd,{suggestions:G,onSuggestionsFetchRequested:le,onSuggestionsClearRequested:Ae,getSuggestionValue:W,renderSuggestion:Me,inputProps:pt,onSuggestionSelected:(H,{suggestionValue:ce})=>{const rt=[U(ce)];t==="designToken"?u.isFunction(n)&&n(rt):y(w,rt,!0),A("")},containerProps:{className:"relative h-8 w-full gap-y-1 py-1 border-border text-xs"},theme:{suggestion:"bg-transparent",suggestionHighlighted:"!bg-gray-300 dark:!bg-gray-800 cursor-pointer",suggestionsContainerOpen:"absolute bg-background no-scrollbar z-50 max-h-[230px] overflow-y-auto w-full border border-border rounded-md"}})}),i.jsx(q,{variant:"outline",className:`border-border ${t==="default"?"h-6":"mt-1 h-7"}`,onClick:z,disabled:E.trim()==="",size:"sm",children:i.jsx(v.PlusIcon,{})})]}),i.jsx("div",{className:"flex w-full flex-wrap gap-2 overflow-x-hidden",children:T.map((H,ce)=>d===ce?i.jsx("input",{ref:r,value:o,onChange:Be=>a(Be.target.value),onBlur:()=>{wt(H)},onKeyDown:Be=>{Be.key==="Enter"&&wt(H)},onFocus:Be=>{setTimeout(()=>{Be.target.select()},0)},className:"group relative flex max-w-[260px] cursor-default items-center gap-x-1 truncate break-words rounded border border-border bg-gray-200 p-px px-1.5 pr-2 text-[11px] text-gray-600 hover:border-gray-300 dark:border-gray-700 dark:bg-gray-800 dark:text-gray-300"},H):i.jsx("div",{className:"group relative flex max-w-[260px] items-center",children:i.jsxs("button",{onDoubleClick:()=>{A(B(H)),t==="default"?k(w,[H]):(u.isFunction(s)&&s(H),A(H)),setTimeout(()=>{r.current&&r.current.focus()},10)},className:"flex h-max cursor-default items-center gap-x-1 truncate break-words rounded bg-gray-200 py-px pl-0.5 pr-1 text-[11px] text-gray-600 dark:bg-gray-800 dark:text-gray-300",children:[i.jsxs("div",{className:"z-10 flex h-full w-max items-center justify-center",children:[i.jsx(v.Cross2Icon,{onClick:()=>{t==="default"?k(w,[H]):u.isFunction(s)&&s(H)},className:"hidden h-max w-3.5 cursor-pointer rounded bg-gray-100 p-0.5 text-red-500 hover:bg-gray-50 group-hover:block"}),H.startsWith($.DESIGN_TOKEN_PREFIX)?i.jsx(Tr,{className:"text-[rgba(55, 65, 81, 0.4)] h-3.5 w-3.5 group-hover:hidden"}):i.jsxs("svg",{className:"h-3.5 w-3.5 group-hover:hidden",fill:"rgba(55, 65, 81, 0.4)",viewBox:"0 0 24 24",xmlns:"http://www.w3.org/2000/svg",xmlSpace:"preserve",children:[i.jsx("g",{id:"SVGRepo_bgCarrier",strokeWidth:"0"}),i.jsx("g",{id:"SVGRepo_tracerCarrier",strokeLinecap:"round",strokeLinejoin:"round"}),i.jsx("g",{id:"SVGRepo_iconCarrier",children:i.jsx("path",{fillRule:"evenodd",clipRule:"evenodd",d:"M12 6.036c-2.667 0-4.333 1.325-5 3.976 1-1.325 2.167-1.822 3.5-1.491.761.189 1.305.738 1.906 1.345C13.387 10.855 14.522 12 17 12c2.667 0 4.333-1.325 5-3.976-1 1.325-2.166 1.822-3.5 1.491-.761-.189-1.305-.738-1.907-1.345-.98-.99-2.114-2.134-4.593-2.134zM7 12c-2.667 0-4.333 1.325-5 3.976 1-1.326 2.167-1.822 3.5-1.491.761.189 1.305.738 1.907 1.345.98.989 2.115 2.134 4.594 2.134 2.667 0 4.333-1.325 5-3.976-1 1.325-2.167 1.822-3.5 1.491-.761-.189-1.305-.738-1.906-1.345C10.613 13.145 9.478 12 7 12z"})})]})]}),i.jsx("div",{children:B(H)})]})},H))})]})}const je=["px","%","em","rem","ch","vh","vw"],Ix={heading:"flex.heading",items:[{type:"arbitrary",label:"flex.basis",units:je,property:"flexBasis"},{type:"range",label:"flex.order",property:"order"},{type:"dropdown",label:"flex.flex",property:"flexGrowShrink"},{type:"dropdown",label:"flex.grow",property:"flexGrow"},{type:"dropdown",label:"flex.shrink",property:"flexShrink"}]},Tx={heading:"grid.heading",items:[{type:"range",label:"grid.col_span",property:"gridColSpan"},{type:"range",label:"grid.col_start",property:"gridColStart"},{type:"range",label:"grid.col_end",property:"gridColEnd"},{type:"range",label:"grid.row_span",property:"gridRowSpan"},{type:"range",label:"grid.row_start",property:"gridRowStart"},{type:"range",label:"grid.row_end",property:"gridRowEnd"},{type:"range",label:"grid.order",property:"order"}]},Bx=[{heading:"Styles",items:[{component:Yo},{component:Ax},{type:"arbitrary",label:"layout.width",units:je.concat("auto"),property:"width"},{type:"arbitrary",label:"layout.height",units:je.concat("auto"),property:"height"},{styleType:"multiple",label:"layout.margin",negative:!0,units:[...je,"auto"],options:[{key:"margin",label:"layout.margin_all"},{key:"marginX",label:"layout.margin_lr"},{key:"marginY",label:"layout.margin_tb"},{key:"marginTop",label:"layout.margin_top"},{key:"marginRight",label:"layout.margin_right"},{key:"marginBottom",label:"layout.margin_bottom"},{key:"marginLeft",label:"layout.margin_left"}]},{styleType:"multiple",label:"layout.padding",options:[{key:"padding",label:"layout.padding_all"},{key:"paddingX",label:"layout.padding_lr"},{key:"paddingY",label:"layout.padding_tb"},{key:"paddingTop",label:"layout.padding_top"},{key:"paddingRight",label:"layout.padding_right"},{key:"paddingBottom",label:"layout.padding_bottom"},{key:"paddingLeft",label:"layout.padding_left"}]},{styleType:"accordion",heading:"typography.heading",items:[{type:"dropdown",property:"textAlign",label:"typography.align"},{type:"dropdown",property:"fontFamily",label:"typography.font"},{type:"arbitrary",property:"fontSize",label:"typography.size",units:je},{type:"arbitrary",property:"lineHeight",label:"typography.height",units:je.concat("-")},{type:"range",property:"fontWeight",label:"typography.weight"},{type:"color",property:"textColor",label:"typography.color"}]},{styleType:"accordion",heading:"background.heading",items:[{type:"color",label:"background.bgcolor",property:"backgroundColor"},{type:"dropdown",label:"background.attachment",property:"backgroundAttachment"},{type:"dropdown",label:"background.clipping",property:"backgroundClip"},{type:"dropdown",label:"background.origin",property:"backgroundOrigin"},{type:"dropdown",label:"background.position",property:"backgroundPosition"},{type:"dropdown",label:"background.repeat",property:"backgroundRepeat"},{type:"dropdown",label:"background.size",property:"backgroundSize"}]}]}];je.concat("auto"),je.concat("auto"),[...je],je.concat("auto"),je.concat("auto"),je.concat("auto"),je.concat("auto"),je.concat("-");const Rx={px:1,"%":1,em:100,rem:100,ch:1,vw:1,vh:1,"-":1,deg:1,ms:.1};function Br(){const{flexChild:t,gridChild:e}=ju(),[n]=Ee(),[s,r]=g.useState(""),[o,a]=g.useState({onDrag:d=>d,onDragEnd:d=>d,dragStartY:0,dragging:!1,dragStartValue:0,dragUnit:"",negative:!1,cssProperty:""}),l=ke.useThrottledCallback(d=>{const p=!u.get(o,"negative",!1),f=u.get(o,"cssProperty","");let m=parseFloat(o.dragStartValue);m=isNaN(m)?0:m;let h=Rx[o.dragUnit];(u.startsWith(f,"scale")||f==="opacity")&&(h=10);let x=(o.dragStartY-d.pageY)/h+m;p&&x<0&&(x=0),f==="opacity"&&x>1&&(x=1),o.onDrag(`${x}`),r(`${x}`)},[o],50),c=g.useCallback(()=>{setTimeout(()=>o.onDragEnd(`${s}`),100),a({onDrag:d=>d,onDragEnd:d=>d,dragStartY:0,dragging:!1,dragStartValue:0,dragUnit:"",negative:!1,cssProperty:""})},[o,s,a]);return u.isEmpty(n)?null:i.jsxs(fc.Provider,{value:{setDragData:a},children:[o.dragging?i.jsx("div",{onMouseMove:l,onMouseUp:()=>c(),className:"absolute inset-0 z-30 cursor-row-resize bg-gray-300/10"}):null,i.jsxs("div",{className:"flex flex-col",children:[i.jsx(qg,{}),i.jsxs(uc,{defaultValue:["Styles"],type:"multiple",className:"w-full",children:[t&&i.jsx(fr,{section:Ix,showAccordian:t||e}),e&&i.jsx(fr,{section:Tx,showAccordian:t||e}),Bx.map(d=>i.jsx(fr,{section:d,showAccordian:t||e},d.heading))]})]})]})}const An=M.forwardRef(({className:t,children:e,...n},s)=>i.jsxs(It.Root,{ref:s,className:L("relative overflow-hidden",t),...n,children:[i.jsx(It.Viewport,{className:"h-full w-full rounded-[inherit]",children:e}),i.jsx(wc,{}),i.jsx(It.Corner,{})]}));An.displayName=It.Root.displayName;const wc=M.forwardRef(({className:t,orientation:e="vertical",...n},s)=>i.jsx(It.ScrollAreaScrollbar,{ref:s,orientation:e,className:L("flex touch-none select-none transition-colors",e==="vertical"&&"h-full w-2.5 border-l border-l-transparent p-[1px]",e==="horizontal"&&"h-2.5 flex-col border-t border-t-transparent p-[1px]",t),...n,children:i.jsx(It.ScrollAreaThumb,{className:"relative flex-1 rounded-full bg-border"})}));wc.displayName=It.ScrollAreaScrollbar.displayName;const Us=Ft.Root,Hn=M.forwardRef(({className:t,...e},n)=>i.jsx(Ft.List,{ref:n,className:L("inline-flex h-9 items-center justify-center rounded-lg bg-muted p-1 text-muted-foreground",t),...e}));Hn.displayName=Ft.List.displayName;const He=M.forwardRef(({className:t,...e},n)=>i.jsx(Ft.Trigger,{ref:n,className:L("inline-flex items-center justify-center whitespace-nowrap rounded-md px-3 py-1 text-sm font-medium ring-offset-background transition-all focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2 disabled:pointer-events-none disabled:opacity-50 data-[state=active]:bg-background data-[state=active]:text-foreground data-[state=active]:shadow",t),...e}));He.displayName=Ft.Trigger.displayName;const lt=M.forwardRef(({className:t,...e},n)=>i.jsx(Ft.Content,{ref:n,className:L("mt-2 ring-offset-background focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2",t),...e}));lt.displayName=Ft.Content.displayName;const Px=({block:t,disabled:e,parentId:n,position:s})=>{const{type:r,icon:o,label:a}=t,{addCoreBlock:l,addPredefinedBlock:c}=yt(),d=()=>{if(u.has(t,"blocks")){const b=u.isFunction(t.blocks)?t.blocks():t.blocks;c(J.syncBlocksWithDefaults(b),n||null,s)}else l(t,n||null,s);re.publish(Y.CLOSE_ADD_BLOCK)},p=Ye(),{t:f}=F.useTranslation(),{onDragStart:m,onDragEnd:h}=on();return i.jsx(i.Fragment,{children:i.jsxs(pe,{children:[i.jsx(fe,{asChild:!0,children:i.jsxs("button",{disabled:e,onClick:d,type:"button",onDragStart:b=>m(b,{...t,label:a,icon:o}),onDragEnd:h,draggable:p,className:`${u.kebabCase(`chai-block-${r}`)} ${p?"cursor-grab active:cursor-grabbing":"cursor-pointer"} space-y-2 rounded-lg border border-border p-3 text-center hover:bg-slate-300/50 disabled:cursor-not-allowed disabled:bg-gray-100 disabled:text-gray-400 dark:border-gray-700 dark:text-white dark:hover:bg-slate-800/50 dark:disabled:bg-gray-900 dark:disabled:text-foreground ${e?"opacity-50":""}`,children:[g.createElement(o||v.BoxIcon,{className:"w-4 h-4 mx-auto","data-add-core-block-icon":r}),i.jsx("p",{className:"truncate text-xs",children:u.capitalize(f(a||r))})]})}),i.jsx(ue,{children:i.jsx("p",{children:f(a||r)})})]})})},Cc=({parentId:t,position:e,gridCols:n="grid-cols-2",disableBlockGroupsSidebar:s=!1})=>{const r=J.useRegisteredChaiBlocks(),o=u.groupBy(r,"category"),a=u.uniq(u.map(o.core,"group"));return i.jsx(Mc,{gridCols:n,parentId:t,position:e,groups:a,blocks:o.core,disableBlockGroupsSidebar:s})},Xo=M.forwardRef(({className:t,...e},n)=>i.jsx("div",{ref:n,className:L("rounded-xl border bg-card text-card-foreground shadow",t),...e}));Xo.displayName="Card";const Jo=M.forwardRef(({className:t,...e},n)=>i.jsx("div",{ref:n,className:L("flex flex-col space-y-1.5 p-6",t),...e}));Jo.displayName="CardHeader";const jc=M.forwardRef(({className:t,...e},n)=>i.jsx("div",{ref:n,className:L("font-semibold leading-none tracking-tight",t),...e}));jc.displayName="CardTitle";const Sc=M.forwardRef(({className:t,...e},n)=>i.jsx("div",{ref:n,className:L("text-sm text-muted-foreground",t),...e}));Sc.displayName="CardDescription";const Zo=M.forwardRef(({className:t,...e},n)=>i.jsx("div",{ref:n,className:L("p-6 pt-0",t),...e}));Zo.displayName="CardContent";const Qo=M.forwardRef(({className:t,...e},n)=>i.jsx("div",{ref:n,className:L("flex items-center p-6 pt-0",t),...e}));Qo.displayName="CardFooter";const Vn=M.forwardRef(({className:t,...e},n)=>i.jsx("textarea",{className:L("flex min-h-[60px] w-full rounded-md border border-input bg-transparent px-3 py-2 text-base shadow-sm placeholder:text-muted-foreground focus-visible:outline-none focus-visible:ring-1 focus-visible:ring-ring disabled:cursor-not-allowed disabled:opacity-50 md:text-sm",t),ref:n,...e}));Vn.displayName="Textarea";let Nc=async t=>t;const Lx=t=>{Nc=t},Mx=async t=>await Nc(t),Ec=({parentId:t,position:e,fromSidebar:n})=>{const{t:s}=F.useTranslation(),[r,o]=g.useState(""),{addPredefinedBlock:a}=yt(),[l,c]=g.useState(!1),d=async()=>{c(!0);const p=await Mx(r),f=$.getBlocksFromHTML(p);a([...f],t,e),o(""),c(!1),re.publish(Y.CLOSE_ADD_BLOCK)};return i.jsxs(Xo,{className:`border-border/0 p-0 shadow-none ${n?"w-full":"max-w-full"}`,children:[i.jsx(Jo,{className:n?"p-0":"p-3",children:i.jsx(Sc,{className:n?"text-xs":"",children:s("Use HTML snippets from Tailwind CSS component libraries")})}),i.jsx(Zo,{className:`space-y-2 py-0 ${n?"p-0":"px-3"}`,children:i.jsxs("div",{className:"space-y-1",children:[i.jsx(ut,{htmlFor:"current",className:"text-sm",children:s("Tailwind HTML snippet")}),i.jsx(Vn,{onChange:p=>o(p.target.value),rows:12,value:r,placeholder:s("Enter your code snippet here"),className:"resize-none overflow-x-auto whitespace-pre bg-background font-mono text-xs font-normal"})]})}),i.jsx(Qo,{className:"flex flex-col justify-end p-3",children:i.jsx(q,{disabled:r.trim()===""||l,onClick:()=>d(),size:"sm",className:"w-fit",children:l?i.jsxs(i.Fragment,{children:[i.jsx(v.CircleIcon,{className:"mr-2 h-4 w-4 animate-spin"})," ",s("Importing...")]}):s("Import HTML")})})]})},Gs=ge.Root,ei=ge.Value,Wn=M.forwardRef(({className:t,children:e,...n},s)=>i.jsxs(ge.Trigger,{ref:s,className:L("flex h-9 w-full items-center justify-between whitespace-nowrap rounded-md border border-input bg-transparent px-3 py-2 text-sm shadow-sm ring-offset-background focus:outline-none focus:ring-1 focus:ring-ring disabled:cursor-not-allowed disabled:opacity-50 data-[placeholder]:text-muted-foreground [&>span]:line-clamp-1",t),...n,children:[e,i.jsx(ge.Icon,{asChild:!0,children:i.jsx(v.ChevronDownIcon,{className:"h-4 w-4 opacity-50"})})]}));Wn.displayName=ge.Trigger.displayName;const Ac=M.forwardRef(({className:t,...e},n)=>i.jsx(ge.ScrollUpButton,{ref:n,className:L("flex cursor-default items-center justify-center py-1",t),...e,children:i.jsx(v.ChevronUpIcon,{className:"h-4 w-4"})}));Ac.displayName=ge.ScrollUpButton.displayName;const _c=M.forwardRef(({className:t,...e},n)=>i.jsx(ge.ScrollDownButton,{ref:n,className:L("flex cursor-default items-center justify-center py-1",t),...e,children:i.jsx(v.ChevronDownIcon,{className:"h-4 w-4"})}));_c.displayName=ge.ScrollDownButton.displayName;const Un=M.forwardRef(({className:t,children:e,position:n="popper",...s},r)=>i.jsx(ge.Portal,{children:i.jsxs(ge.Content,{ref:r,className:L("relative z-50 max-h-[--radix-select-content-available-height] min-w-[8rem] origin-[--radix-select-content-transform-origin] overflow-y-auto overflow-x-hidden rounded-md border bg-popover text-popover-foreground shadow-md data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0 data-[state=closed]:zoom-out-95 data-[state=open]:zoom-in-95 data-[side=bottom]:slide-in-from-top-2 data-[side=left]:slide-in-from-right-2 data-[side=right]:slide-in-from-left-2 data-[side=top]:slide-in-from-bottom-2",n==="popper"&&"data-[side=bottom]:translate-y-1 data-[side=left]:-translate-x-1 data-[side=right]:translate-x-1 data-[side=top]:-translate-y-1",t),position:n,...s,children:[i.jsx(Ac,{}),i.jsx(ge.Viewport,{className:L("p-1",n==="popper"&&"h-[var(--radix-select-trigger-height)] w-full min-w-[var(--radix-select-trigger-width)]"),children:e}),i.jsx(_c,{})]})}));Un.displayName=ge.Content.displayName;const Dx=M.forwardRef(({className:t,...e},n)=>i.jsx(ge.Label,{ref:n,className:L("px-2 py-1.5 text-sm font-semibold",t),...e}));Dx.displayName=ge.Label.displayName;const Gn=M.forwardRef(({className:t,children:e,...n},s)=>i.jsxs(ge.Item,{ref:s,className:L("relative flex w-full cursor-default select-none items-center rounded-sm py-1.5 pl-2 pr-8 text-sm outline-none focus:bg-accent focus:text-accent-foreground data-[disabled]:pointer-events-none data-[disabled]:opacity-50",t),...n,children:[i.jsx("span",{className:"absolute right-2 flex h-3.5 w-3.5 items-center justify-center",children:i.jsx(ge.ItemIndicator,{children:i.jsx(v.CheckIcon,{className:"h-4 w-4"})})}),i.jsx(ge.ItemText,{children:e})]}));Gn.displayName=ge.Item.displayName;const Ox=M.forwardRef(({className:t,...e},n)=>i.jsx(ge.Separator,{ref:n,className:L("-mx-1 my-1 h-px bg-muted",t),...e}));Ox.displayName=ge.Separator.displayName;const Fx=({defaultValue:t="",onValueChange:e,options:n,placeholder:s="Select",className:r="",height:o=""})=>{const[a,l]=g.useState(t),c=d=>{const p=d.target.value;l(p),e(p)};return i.jsx("div",{className:ve.cn("relative inline-block w-full",r),children:i.jsxs("select",{className:ve.cn("mt-1 flex w-full rounded-md border border-border bg-background px-3 py-1 text-sm text-foreground 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",o),value:a,onChange:c,children:[i.jsx("option",{value:"",disabled:!0,children:s}),n.map(d=>i.jsx("option",{value:d.value,children:d.label},d.value))]})})};function $x({uiLibraries:t,library:e,setLibrary:n}){const{t:s}=F.useTranslation();return e?i.jsxs("div",{className:"h-12",children:[i.jsx("p",{className:"text-xs font-bold text-gray-500",children:s("Choose library")}),i.jsx(Fx,{className:"mb-1",options:t.map(r=>({value:r.id,label:r.name})),defaultValue:e,onValueChange:r=>n(r)})]}):null}let Ic={};const zx=(t,e)=>{Ic[t]={...e,id:t}},Tc=()=>u.values(Ic),Hx=S.atom({}),Bc=t=>{const[e,n]=S.useAtom(Hx),s=g.useMemo(()=>(t==null?void 0:t.getBlocksList)||(()=>[]),[t]),r=u.get(e,`${t==null?void 0:t.id}.blocks`,null),o=u.get(e,`${t==null?void 0:t.id}.loading`,"idle"),a=g.useRef("idle");g.useEffect(()=>{(async()=>{if(!(o==="complete"||a.current==="loading")){a.current="loading",n(c=>({...c,[t==null?void 0:t.id]:{loading:"loading",blocks:[]}}));try{const c=await s(t);a.current="idle",n(d=>({...d,[t==null?void 0:t.id]:{loading:"complete",blocks:c||[]}}))}catch{a.current="idle",n(c=>({...c,[t==null?void 0:t.id]:{loading:"complete",blocks:[]}}))}}})()},[t,r,o,a,n,s]);const l=g.useCallback(c=>{n(d=>({...d,[c]:{loading:"idle",blocks:[]}}))},[n]);return{data:r||[],isLoading:o==="loading",resetLibrary:l}},Vx=()=>S.useAtom(io),Rc=({block:t,html:e,blocks:n,children:s,onDragStart:r,onDragEnd:o,draggable:a,className:l="",type:c="Box"})=>{const{onDragStart:d,onDragEnd:p}=on(),f=Ye(),[,m]=K(),{clearHighlight:h}=nt(),b=a!==void 0?a:f,x=async k=>{try{if(r){r(k);return}let w=null;if(c==="Image"){if(!(t!=null&&t.image))return;w={type:"Image",blocks:[{_type:"Image",styles:"#styles:,w-full h-full object-cover",image:t==null?void 0:t.image,alt:(t==null?void 0:t.alt)||"",_name:(t==null?void 0:t.name)||"Image"}]}}else if(e){const E=typeof e=="function"?await e():e,A=$.getBlocksFromHTML(E);if(u.isEmpty(A))return;w={type:"Box",blocks:A,name:u.get(A,"0._type","Block")}}else if(n){const E=typeof n=="function"?await n():n;if(u.isEmpty(E))return;w={type:"Box",blocks:E,name:u.get(E,"0._type","Block")}}else if(t){const E=typeof t=="function"?await t():t;w=typeof E=="object"?u.omit(E,["component","icon"]):E}if(!w)return;d(k,w,!0),setTimeout(()=>{m([]),h()},200)}catch(w){console.error("Error in ChaiDraggableBlock drag start:",w)}},y=k=>{o?o(k):p()};return i.jsx("div",{draggable:b,onDragStart:x,onDragEnd:y,className:`${b?"cursor-grab active:cursor-grabbing":""} ${l}`.trim(),children:s})};function Pc({value:t,setValue:e}){const{t:n}=F.useTranslation();return i.jsx("div",{className:"flex py-2",children:i.jsxs("div",{className:"relative flex w-full max-w-md items-center rounded border px-2",children:[i.jsxs("div",{className:"flex w-full items-center gap-x-2",children:[i.jsx(v.MagnifyingGlassIcon,{className:"h-5 w-5 flex-shrink-0 stroke-[1px] text-muted-foreground"}),i.jsx(vt,{placeholder:n("Search blocks..."),value:t,onChange:s=>e(s.target.value),className:"w-full flex-1 border-none p-0 leading-tight outline-none"})]}),t&&i.jsx("button",{onClick:()=>e(""),className:"absolute right-2.5 top-2.5 text-muted-foreground hover:text-foreground",children:i.jsx(v.Cross1Icon,{className:"h-3.5 w-3.5"})})]})})}const Ki=({block:t,library:e,parentId:n=void 0,position:s=-1})=>{const[r,o]=g.useState(!1),a=g.useMemo(()=>(e==null?void 0:e.getBlock)||(()=>[]),[e]),{addCoreBlock:l,addPredefinedBlock:c}=yt(),d=u.get(t,"name",u.get(t,"label")),p=u.get(t,"description",""),{onDragStart:f,onDragEnd:m}=on(),h=Ye(),b=g.useCallback(async y=>{if(y.stopPropagation(),u.has(t,"component")){l(t,n,s),re.publish(Y.CLOSE_ADD_BLOCK);return}o(!0);let k=await a({library:e,block:t});typeof k=="string"&&(k=$.getBlocksFromHTML(k)),u.isEmpty(k)||c(J.syncBlocksWithDefaults(k),n,s),re.publish(Y.CLOSE_ADD_BLOCK),setTimeout(()=>o(!1),1e3)},[l,c,t,a,e,n,s]),x=async y=>{if(!h)return;let k=await a({library:e,block:t});typeof k=="string"&&(k=$.getBlocksFromHTML(k)),f(y,{type:"Box",blocks:k,name:d},!0)};return i.jsxs(pe,{children:[i.jsx(fe,{asChild:!0,children:i.jsx(Rc,{draggable:h,onDragStart:x,onDragEnd:m,children:i.jsxs("div",{onClick:r?()=>{}:b,className:Fr("relative mt-2 overflow-hidden rounded-md border border-border duration-200 hover:border-blue-500 hover:shadow-xl",h?"":"cursor-pointer"),children:[r&&i.jsxs("div",{className:"absolute flex h-full w-full items-center justify-center bg-black/70",children:[i.jsx(v.ReloadIcon,{className:"h-4 w-4 animate-spin text-white"}),i.jsx("span",{className:"pl-2 text-sm text-white",children:"Adding..."})]}),t.preview?i.jsx("img",{src:t.preview,className:"min-h-[45px] w-full rounded-md",alt:d}):i.jsxs("div",{className:"flex h-fit w-full flex-col items-center justify-center gap-1 rounded-md border border-border p-6 py-10 text-center",children:[i.jsx("p",{className:"font-medium text-gray-800",children:d}),p&&i.jsx("p",{className:"text-sm text-gray-600",children:p})]})]})})}),i.jsx(ue,{children:i.jsx("div",{className:"max-w-xs",children:i.jsx("p",{className:"font-medium",children:d})})})]})},Wx=({parentId:t,position:e,fromSidebar:n})=>{const[s,r]=Vx(),o=Tc(),a=o.find(R=>R.id===s)||u.first(o),{data:l,isLoading:c,resetLibrary:d}=Bc(a),[p,f]=g.useState(""),[m,h]=g.useState([]),b=g.useRef(null);g.useEffect(()=>{l&&l.length>0&&(b.current=new ia(l,{keys:["name","label","description","group"],threshold:.4,ignoreLocation:!0}))},[l]),g.useEffect(()=>{if(!p.trim()||!b.current){h([]);return}const R=b.current.search(p).map(B=>B.item);h(R)},[p]);const x=p.trim()&&!u.isEmpty(m)?m:l,y=u.groupBy(x,"group"),[k,w]=g.useState(null);g.useEffect(()=>{if(u.isEmpty(u.keys(y))){w(null);return}if(!k||!y[k]){w(u.first(u.keys(y)));return}},[y,k]);const E=u.get(y,k,[]),A=g.useRef(null),{t:_}=F.useTranslation(),I=g.useRef(null);g.useEffect(()=>{var B;const R=(B=I.current)==null?void 0:B.querySelector("[data-radix-scroll-area-viewport]");R&&R.scrollTo({top:0,behavior:"smooth"})},[a,k]);const j=R=>{A.current&&(clearTimeout(A.current),A.current=null),A.current=setTimeout(()=>{A.current&&w(R)},400)},N=()=>{a!=null&&a.id&&d(a.id)};if(c)return i.jsxs("div",{className:"mt-4 grid h-full w-full grid-cols-12 gap-2",children:[i.jsx(Mt,{className:"col-span-3 h-full"}),i.jsx(Mt,{className:"col-span-9 h-full"})]});const C=u.filter(E,(R,B)=>B%2===0),T=u.filter(E,(R,B)=>B%2===1);return i.jsx(i.Fragment,{children:i.jsxs("div",{className:"flex h-full max-h-full flex-col",children:[i.jsx(Pc,{value:p,setValue:f}),i.jsx("div",{className:"relative flex h-full max-h-full flex-1 overflow-hidden bg-background",children:i.jsxs("div",{className:`flex h-full flex-1 pt-2 ${n?"flex-col":""}`,children:[i.jsxs("div",{className:`flex max-h-full min-w-60 flex-col gap-1 ${n?"pb-2":"w-60 max-w-60 px-1 pr-2"}`,children:[i.jsx($x,{library:a==null?void 0:a.id,setLibrary:r,uiLibraries:o}),i.jsxs("div",{className:"mt-2 flex h-full max-h-full w-full flex-1 flex-col",children:[i.jsx("span",{className:"text-xs font-bold text-gray-500",children:_("Groups")}),!n&&i.jsx("hr",{className:"mt-1 border-border"}),i.jsx("div",{className:`no-scrollbar mt-2 h-full max-h-full flex-1 overflow-y-auto ${n?"":"pb-20"}`,children:u.isEmpty(y)?i.jsx("div",{className:"mt-4 flex flex-col items-center justify-center gap-3 p-4 text-center",children:p?i.jsx("p",{className:"text-sm",children:_("No matching blocks found")}):i.jsxs(i.Fragment,{children:[i.jsx("p",{className:"text-sm",children:_("Failed to load the UI library. Try again")}),i.jsxs(q,{onClick:N,variant:"outline",size:"sm",className:"gap-2",children:[i.jsx(v.ReloadIcon,{className:"h-4 w-4"}),_("Retry")]})]})}):n?i.jsxs(Gs,{value:k,onValueChange:w,children:[i.jsx(Wn,{className:"w-full",children:i.jsx(ei,{placeholder:_("Select a group")})}),i.jsx(Un,{children:u.map(y,(R,B)=>i.jsx(Gn,{value:B,children:u.capitalize(_(B.toLowerCase()))},B))})]}):u.map(y,(R,B)=>i.jsxs("div",{onMouseEnter:()=>j(B),onMouseLeave:()=>clearTimeout(A.current),role:"button",onClick:()=>w(B),className:L("flex w-full cursor-pointer items-center justify-between rounded-md p-2 text-sm text-foreground transition-all ease-in-out hover:bg-gray-200 dark:hover:bg-gray-800",B===k?"bg-primary text-primary-foreground hover:bg-primary/80":""),children:[i.jsx("span",{children:u.capitalize(_(B.toLowerCase()))}),i.jsx(v.CaretRightIcon,{className:"ml-2 h-5 w-5"})]},B))})]})]}),i.jsx("div",{className:`flex h-full max-h-full w-full flex-col border-border ${n?"":"border-l"}`,children:i.jsxs(An,{ref:I,onMouseEnter:()=>A.current?clearTimeout(A.current):null,className:"z-10 flex h-full max-h-full w-full flex-col gap-2 transition-all ease-linear",children:[u.isEmpty(E)&&!u.isEmpty(y)?i.jsx("div",{className:"flex h-full flex-col items-center justify-center p-6 text-center",children:i.jsx("p",{className:"text-sm",children:_("No blocks found in this group")})}):i.jsxs("div",{className:`grid w-full gap-2 ${n?"grid-cols-1 pb-20":"grid-cols-2 px-2"}`,children:[i.jsx("div",{className:"flex flex-col gap-1",children:C.map((R,B)=>i.jsx(Ki,{parentId:t,position:e,block:R,library:a},`block-${B}`))}),i.jsx("div",{className:"flex flex-col gap-1",children:T.map((R,B)=>i.jsx(Ki,{parentId:t,position:e,block:R,library:a},`block-second-${B}`))})]}),i.jsx("br",{}),i.jsx("br",{}),i.jsx("br",{})]})})]})})]})})},Lc=({parentId:t,position:e,fromSidebar:n})=>i.jsx(Wx,{parentId:t,position:e,fromSidebar:n}),Ux=S.atom({blocks:[],groups:[],isLoading:!0,error:null}),Gx=S.atom(!1),Yi=t=>{if(!t)return"";let e=t.replace(/[-_]/g," ");return e=e.replace(/([a-z])([A-Z])/g,"$1 $2"),e.split(" ").map(n=>n.charAt(0).toUpperCase()+n.slice(1).toLowerCase()).join(" ")},qx=({parentId:t,position:e,gridCols:n="grid-cols-2",disableBlockGroupsSidebar:s=!1})=>{const{data:r,isLoading:o,refetch:a,error:l}=Xa(),[c,d]=S.useAtom(Ux),[p,f]=S.useAtom(Gx);g.useEffect(()=>{if(!p||Object.keys(c.blocks).length===0)if(l)d({blocks:[],groups:[],isLoading:!1,error:l}),f(!0);else if(!o&&Object.keys(r||{}).length>0){const h=Object.entries(r).map(([x,y])=>{const k=y,w=k.type||"partial",E=Yi(w);return{type:"PartialBlock",label:Yi(k.name||x),description:k.description||"",icon:v.FrameIcon,group:E,category:"partial",partialBlockId:x,_name:k.name}}),b=u.uniq(u.map(h,"group"));d({blocks:h,groups:b,isLoading:!1,error:null}),f(!0)}else o?d(h=>({...h,isLoading:!0,error:null})):!o&&Object.keys(r||{}).length===0&&(d({blocks:[],groups:[],isLoading:!1,error:"No partial blocks available"}),f(!0))},[o,r,p,f,d,c.blocks,l]);const m=()=>{d(h=>({...h,isLoading:!0,error:null})),f(!1),a()};return c.isLoading?i.jsx("div",{className:"flex items-center justify-center p-8 text-center text-muted-foreground",children:"Loading partial blocks..."}):c.error||c.blocks.length===0?i.jsxs("div",{className:"flex flex-col items-center justify-center gap-4 p-8 text-center text-muted-foreground",children:[i.jsx("p",{children:c.error||"No partial blocks available"}),i.jsx("button",{onClick:m,className:"rounded-md bg-primary px-3 py-1 text-sm text-primary-foreground hover:bg-primary/90",children:"Refresh"})]}):i.jsx(Mc,{gridCols:n,parentId:t,position:e,groups:c.groups,blocks:c.blocks,disableBlockGroupsSidebar:s})},Rr={},Kx=(t,e)=>{u.has(Rr,t)&&console.warn(`Add block tab with id ${t} already registered`),u.set(Rr,t,{id:t,...e})},Yx=()=>g.useMemo(()=>u.values(Rr),[]),Xi=["basic","typography","media","layout","form","advanced","other"],Mc=({groups:t,blocks:e,parentId:n,position:s,gridCols:r="grid-cols-4",disableBlockGroupsSidebar:o})=>{var R;const{t:a}=F.useTranslation(),[l]=te(),[c,d]=g.useState(""),p=g.useRef(null),[f]=S.useAtom(Dc),m=(R=u.find(l,B=>B._id===n))==null?void 0:R._type,[h,b]=g.useState("all"),[x,y]=g.useState(null),k=g.useRef(null),w=O("flags.dragAndDrop",!1);g.useEffect(()=>{const B=setTimeout(()=>{var U;(U=p.current)==null||U.focus()},0);return()=>clearTimeout(B)},[f]),g.useEffect(()=>{c&&(b("all"),y(null))},[c]),g.useEffect(()=>(k.current=u.debounce(B=>{b(B)},500),()=>{k.current&&k.current.cancel()}),[]);const E=g.useCallback(B=>{y(B),k.current&&k.current(B)},[]),A=g.useCallback(()=>{y(null),k.current&&k.current.cancel()},[]),_=g.useCallback(B=>{k.current&&k.current.cancel(),b(B),y(null)},[]),I=g.useMemo(()=>c?u.values(e).filter(B=>{var U,z;return(((U=B.label)==null?void 0:U.toLowerCase())+" "+((z=B.type)==null?void 0:z.toLowerCase())).includes(c.toLowerCase())}):e,[e,c]),j=g.useMemo(()=>c?t.filter(B=>u.reject(u.filter(u.values(I),{group:B}),{hidden:!0}).length>0):t.filter(B=>u.reject(u.filter(u.values(e),{group:B}),{hidden:!0}).length>0),[e,I,t,c]),N=g.useMemo(()=>u.sortBy(j,B=>Xi.indexOf(B)===-1?99:Xi.indexOf(B)),[j]),C=g.useMemo(()=>h==="all"?I:u.filter(u.values(I),{group:h}),[I,h]),T=g.useMemo(()=>h==="all"?N:[h],[N,h]);return i.jsxs("div",{className:"mx-auto flex h-full w-full flex-col",children:[i.jsx(Pc,{value:c,setValue:d}),i.jsxs("div",{className:"sticky top-10 flex h-[calc(100%-48px)] overflow-hidden pt-2",children:[!o&&N.length>0&&i.jsx("div",{className:"w-1/4 min-w-[120px] border-r border-border",children:i.jsx(An,{className:"h-full",children:i.jsxs("div",{className:"space-y-1",children:[i.jsx("button",{onClick:()=>_("all"),onMouseEnter:()=>E("all"),onMouseLeave:A,className:`w-full rounded-md px-2 py-1.5 text-left text-sm font-medium ${h==="all"||x==="all"?"bg-primary text-primary-foreground":"hover:bg-primary/50 hover:text-primary-foreground"}`,children:a("All")},"sidebar-all"),N.map(B=>i.jsx("button",{onClick:()=>_(B),onMouseEnter:()=>E(B),onMouseLeave:A,className:`w-full rounded-md px-2 py-1.5 text-left text-sm ${h===B||x===B?"bg-primary text-primary-foreground":"hover:bg-primary/50 hover:text-primary-foreground"}`,children:u.capitalize(a(B.toLowerCase()))},`sidebar-${B}`))]})})}),i.jsx("div",{className:`h-full flex-1 overflow-hidden ${!o&&N.length>0?"w-3/4":"w-full"}`,children:i.jsx(An,{id:"add-blocks-scroll-area",className:"no-scrollbar h-full",children:j.length===0&&c?i.jsx("div",{className:"flex flex-col items-center justify-center p-8 text-center text-muted-foreground",children:i.jsxs("p",{children:[a("No blocks found matching"),' "',c,'"']})}):i.jsx("div",{className:`${o?"p-0":"p-4"} space-y-6`,children:T.map((B,U)=>i.jsxs("div",{className:"space-y-3",children:[i.jsx("h3",{className:"px-1 text-sm font-medium",children:u.capitalize(a(B.toLowerCase()))}),i.jsx("div",{className:"grid gap-2 "+r,children:u.reject(h==="all"?u.filter(u.values(C),{group:B}):u.values(C),{hidden:!0}).map((z,G)=>i.jsx(Px,{parentId:n,position:s,block:z,disabled:!w&&(!Ze(m,z.type)||!du(m,z.type))},z.type+"-"+U+"-"+G))})]},B))})})})]})]})},Dc=we.atomWithStorage("__add_block_tab","library"),ti=({className:t,showHeading:e=!0,parentId:n=void 0,position:s=-1,fromSidebar:r=!1})=>{const{t:o}=F.useTranslation(),[a,l]=S.useAtom(Dc),[,c]=S.useAtom(Ia),d=O("flags.importHtml",!0),{data:p}=Xa(),f=Object.keys(p||{}).length>0,{hasPermission:m}=qe();g.useEffect(()=>{a==="partials"&&!f&&l("library")},[a,f,l]);const h=g.useCallback(()=>{re.publish(Y.CLOSE_ADD_BLOCK)},[]),b=Yx(),x=d&&m(ne.IMPORT_HTML),k=Tc().length>0;return g.useEffect(()=>{a==="library"&&!k&&l("core")},[a,k,l]),i.jsxs("div",{className:ve.cn("flex h-full w-full flex-col overflow-hidden",t),children:[e?i.jsxs("div",{className:"mb-2 flex flex-col justify-between rounded-md bg-background/30 p-1",children:[i.jsx("h1",{className:"flex flex-col items-baseline px-1 text-xl font-semibold xl:flex-col",children:o("Add block")}),i.jsx("span",{className:"p-0 text-xs font-light leading-3 opacity-80 xl:pl-1",children:o(a==="html"?"Enter or paste TailwindCSS HTML snippet":"Click to add block to page")})]}):null,i.jsxs(Us,{onValueChange:w=>{c(""),l(w)},value:a,className:"flex h-full max-h-full flex-col overflow-hidden",children:[i.jsxs(Hn,{className:`flex items-center ${r?"h-max w-max justify-start p-1":"w-full"}`,children:[k&&i.jsx(He,{value:"library",className:r?"h-5 px-2 text-xs":"",children:o("Library")}),i.jsx(He,{value:"core",className:r?"h-5 px-2 text-xs":"",children:o("Blocks")}),f&&i.jsx(He,{value:"partials",className:r?"h-5 px-2 text-xs":"",children:o("Partials")}),x?i.jsx(He,{value:"html",className:r?"h-5 px-2 text-xs":"",children:o("Import")}):null,u.map(b,w=>i.jsx(He,{value:w.id,className:r?"h-5 px-2 text-xs":"",children:g.createElement(w.tab)},`tab-add-block-${w.id}`))]}),i.jsx(lt,{value:"core",className:"h-full max-h-full flex-1 pb-20",children:i.jsx("div",{className:"h-full max-h-full overflow-hidden",children:i.jsx("div",{className:"h-full w-full",children:i.jsx(Cc,{gridCols:r?"grid-cols-2":"grid-cols-4",parentId:n,position:s,disableBlockGroupsSidebar:r})})})}),k&&i.jsx(lt,{value:"library",className:"h-full max-h-full flex-1 pb-20",children:i.jsx(Lc,{fromSidebar:r,parentId:n,position:s})}),f&&i.jsx(lt,{value:"partials",className:"h-full max-h-full flex-1 pb-20",children:i.jsx("div",{className:"h-full max-h-full overflow-hidden",children:i.jsx("div",{className:"h-full w-full",children:i.jsx(qx,{gridCols:r?"grid-cols-2":"grid-cols-4",parentId:n,position:s,disableBlockGroupsSidebar:r})})})}),x?i.jsx(lt,{value:"html",className:"h-full max-h-full flex-1 pb-20 ",children:i.jsx(Ec,{parentId:n,position:s,fromSidebar:r})}):null,u.map(b,w=>i.jsx(lt,{value:w.id,children:g.createElement(w.tabContent,{close:h,parentId:n,position:s})},`panel-add-block-${w.id}`))]})]})},Xx={display:"flex",alignItems:"center",zIndex:1},Jx=g.memo(function({top:e,left:n}){const s={position:"absolute",pointerEvents:"none",top:e+"px",left:n+"px",right:0};return i.jsx("div",{style:{...Xx,...s},children:i.jsx("div",{className:"h-0.5 flex-1 rounded-[1px] bg-green-500"})})}),Ji="h-3 w-3 flex-shrink-0",ni=t=>{const e=J.useRegisteredChaiBlocks(),n=u.get(e,[t==null?void 0:t.type,"icon"]);return n?g.createElement(n,{className:Ji}):i.jsx(v.SquareIcon,{className:Ji})},Zx=g.memo(function({children:e,isDragging:n}){return n?i.jsx("div",{className:"pointer-events-none fixed left-0 top-0 z-[100] h-full w-full",children:e}):null}),Qx=g.memo(({id:t,isDragging:e,mouse:n})=>{const[s]=te(),r=g.useMemo(()=>s.find(a=>a._id===t),[s,t]),o=g.useMemo(()=>({transform:`translate(${(n==null?void 0:n.x)-10}px, ${(n==null?void 0:n.y)-10}px)`}),[n]);return n?i.jsx("div",{children:i.jsx(Zx,{isDragging:e,children:i.jsx("div",{className:"pointer-events-none absolute z-50 rounded border border-border bg-gray-100/80 font-semibold text-blue-600 shadow-md dark:border-gray-700 dark:bg-gray-800",style:o,children:i.jsxs("button",{type:"button",className:"flex !cursor-grab items-center p-0.5","aria-label":`Type: ${r==null?void 0:r._type}`,children:[i.jsx("div",{className:"-mt-0.5 h-3 w-3",children:i.jsx(ni,{type:r==null?void 0:r._type})}),i.jsx("div",{className:"ml-2 truncate text-[11px]",children:(r==null?void 0:r._name)||(r==null?void 0:r._type)})]})})})}):i.jsx("div",{className:"hidden"})}),eb=[{key:"ArrowDown",command:"selectNext"},{key:"ArrowUp",command:"selectPrev"},{key:"ArrowLeft",command:"selectParent",when:"isLeaf || isClosed"},{key:"ArrowLeft",command:"close",when:"isOpen"},{key:"ArrowRight",command:"open",when:"isClosed"},{key:"ArrowRight",command:"selectNext",when:"isOpen"},{key:"Home",command:"selectFirst"},{key:"End",command:"selectLast"}];function tb(t){t.firstNode&&t.select(t.firstNode.id)}function nb(t){t.lastNode&&t.select(t.lastNode.id)}function sb(t){const e=t.selectedNodes[0].next||t.firstNode;t.select(e.id)}function rb(t){const e=t.selectedNodes[0].prev||t.lastNode;t.select(e.id)}const ob=(t,e)=>{var s;const n=((s=t.selectedIds[0])==null?void 0:s.parent)||null;n&&e&&t.select(n.id)},ib=(t,e)=>{const n=t.selectedNodes[0];n.isInternal&&e&&n.open()},ab=(t,e)=>{const n=t.selectedNodes[0];n.isInternal&&e&&n.close()},si=Pe.Root,Oc=Pe.Trigger,lb=Pe.Portal,Fc=M.forwardRef(({className:t,...e},n)=>i.jsx(Pe.Overlay,{className:L("fixed inset-0 z-50 bg-black/80 data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0",t),...e,ref:n}));Fc.displayName=Pe.Overlay.displayName;const qs=M.forwardRef(({className:t,...e},n)=>i.jsxs(lb,{children:[i.jsx(Fc,{}),i.jsx(Pe.Content,{ref:n,className:L("fixed left-[50%] top-[50%] z-50 grid w-full max-w-lg translate-x-[-50%] translate-y-[-50%] gap-4 border bg-background p-6 shadow-lg duration-200 data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0 data-[state=closed]:zoom-out-95 data-[state=open]:zoom-in-95 data-[state=closed]:slide-out-to-left-1/2 data-[state=closed]:slide-out-to-top-[48%] data-[state=open]:slide-in-from-left-1/2 data-[state=open]:slide-in-from-top-[48%] sm:rounded-lg",t),...e})]}));qs.displayName=Pe.Content.displayName;const Ks=({className:t,...e})=>i.jsx("div",{className:L("flex flex-col space-y-2 text-center sm:text-left",t),...e});Ks.displayName="AlertDialogHeader";const ri=({className:t,...e})=>i.jsx("div",{className:L("flex flex-col-reverse sm:flex-row sm:justify-end sm:space-x-2",t),...e});ri.displayName="AlertDialogFooter";const Ys=M.forwardRef(({className:t,...e},n)=>i.jsx(Pe.Title,{ref:n,className:L("text-lg font-semibold",t),...e}));Ys.displayName=Pe.Title.displayName;const oi=M.forwardRef(({className:t,...e},n)=>i.jsx(Pe.Description,{ref:n,className:L("text-sm text-muted-foreground",t),...e}));oi.displayName=Pe.Description.displayName;const ii=M.forwardRef(({className:t,...e},n)=>i.jsx(Pe.Action,{ref:n,className:L(Bo(),t),...e}));ii.displayName=Pe.Action.displayName;const ai=M.forwardRef(({className:t,...e},n)=>i.jsx(Pe.Cancel,{ref:n,className:L(Bo({variant:"outline"}),"mt-2 sm:mt-0",t),...e}));ai.displayName=Pe.Cancel.displayName;const $c=({children:t})=>{const{t:e}=F.useTranslation(),{setNewBlocks:n}=Ne(),[,s]=K(),[,r]=Ee(),o=g.useCallback(()=>{n([]),s([]),r([])},[n]);return i.jsx("div",{className:"flex items-center",children:i.jsxs(si,{children:[i.jsx(Oc,{asChild:!0,children:t||i.jsxs(q,{size:"sm",variant:"ghost",className:"flex items-center",children:[i.jsx(v.EraserIcon,{})," ",e("Clear")]})}),i.jsxs(qs,{className:"border-border",children:[i.jsxs(Ks,{children:[i.jsx(Ys,{className:"text-foreground",children:e("Clear whole canvas?")}),i.jsx(oi,{children:e("Are you sure you want to clear the page?")})]}),i.jsxs(ri,{children:[i.jsx(ai,{className:"text-foreground",children:e("Cancel")}),i.jsx(ii,{onClick:o,children:e("Yes")})]})]})]})})};let zc=null;const cb=t=>{zc=t},Hc=()=>g.useMemo(()=>zc,[]),Vc=S.atom({isOpen:!1,blockId:null}),Wc=(t,e)=>{const n=u.filter(t,{_parent:e});if(n.length===0)return[];const s=[...n];return n.forEach(r=>{s.push(...Wc(t,r==null?void 0:r._id))}),s},db=()=>{const[t,e]=S.useAtom(Vc),{t:n}=F.useTranslation(),[s]=te(),r=()=>e({isOpen:!1,blockId:null}),o=Hc(),a=g.useMemo(()=>{if(!t.blockId)return[];const l=u.find(s,{_id:t.blockId});return l==null||delete l._parent,[l,...Wc(s,l==null?void 0:l._id)]},[t.blockId,s]);return i.jsx(On,{open:t.isOpen,onOpenChange:l=>!l&&r(),children:i.jsxs(ln,{className:"p-4 sm:max-w-[450px]",children:[i.jsx(Fn,{className:"pb-2",children:i.jsx(cn,{children:n("Save to Library")})}),o&&!u.isEmpty(t.blockId)&&i.jsx(o,{blockId:t.blockId,blocks:a,close:r})]})})},ub=()=>{const t=Z(),{t:e}=F.useTranslation(),[,n]=S.useAtom(Vc),s=Hc(),r=()=>{t&&n({isOpen:!0,blockId:t._id})};return s?i.jsxs(de,{className:"flex items-center gap-x-4 text-xs",onClick:r,children:[i.jsx(v.CheckIcon,{className:"h-4 w-4"})," ",t!=null&&t._libBlockId?e("Update library block"):e("Save to library")]}):null},pb=()=>{const{t}=F.useTranslation(),e=Z(),n=tt(),s=()=>{n([e._id],{_libBlockId:null})};return i.jsxs(de,{onClick:s,className:"flex items-center gap-x-4 text-xs",children:[i.jsx(v.LinkBreak2Icon,{className:"h-4 w-4"})," ",t("Unlink from library")]})},Zi=()=>{const{t}=F.useTranslation(),[e]=K();return O("flags.exportCode",!1)?i.jsxs(de,{className:"flex items-center gap-x-4 text-xs",onClick:()=>re.publish(Y.OPEN_EXPORT_CODE,e),children:[i.jsx(v.DownloadIcon,{})," ",t("Export")]}):null},Qi=({isFromBody:t=!1})=>{const[e]=te(),[n]=K(),{pasteBlocks:s}=mo(),[,r,o]=Za(),{t:a}=F.useTranslation(),l=Z(),c=O("flags.copyPaste",!0),d=g.useCallback(()=>{var m;const f=(t?(m=e==null?void 0:e.filter(h=>!(h!=null&&h._parent)))==null?void 0:m.map(h=>h==null?void 0:h._id):n).map(h=>{const b=e.find(x=>x._id===h);return{id:h,data:b}});o(f.map(h=>h.id))?me.toast.warning("Partial blocks detected. Clone partial blocks?",{cancel:{label:a("No"),onClick:()=>{r(f.map(h=>h.id)),me.toast.dismiss()}},action:{label:a("Yes"),onClick:()=>{r(f.map(h=>h.id),!0),me.toast.dismiss()}},position:"top-center"}):r(f.map(h=>h.id))},[n,e,r,o]);return i.jsxs(i.Fragment,{children:[c&&i.jsxs(de,{disabled:!Vr(l==null?void 0:l._type),onClick:d,className:"flex items-center gap-x-4 text-xs",children:[i.jsx(v.CopyIcon,{})," ",a("Copy")]}),c&&i.jsxs(de,{className:"flex items-center gap-x-4 text-xs",onClick:()=>{s(n)},children:[i.jsx(v.CardStackIcon,{})," ",a("Paste")]})]})},fb=()=>{const[t]=K(),[,e]=Ms(),{t:n}=F.useTranslation(),s=O("flags.copyPaste",!0);return i.jsx(i.Fragment,{children:s&&i.jsxs(de,{className:"flex items-center gap-x-4 text-xs",onClick:()=>e(t),children:[i.jsx(v.ScissorsIcon,{})," ",n("Cut")]})})},hb=()=>{const[t]=K(),e=Is(),n=Z(),{t:s}=F.useTranslation();return i.jsxs(de,{disabled:!Wr(n==null?void 0:n._type),className:"flex items-center gap-x-4 text-xs",onClick:()=>e(t),children:[i.jsx(v.TrashIcon,{})," ",s("Remove")]})},mb=({node:t})=>{const{t:e}=F.useTranslation();return i.jsxs(de,{onClick:n=>{n.stopPropagation(),t.edit(),t.deselect()},className:"flex items-center gap-x-4 text-xs",children:[i.jsx(v.Pencil2Icon,{className:"h-4 w-4"})," ",e("Rename")]})},gb=({node:t})=>{const{t:e}=F.useTranslation(),[n]=K(),s=fo(),r=Z(),{hasPermission:o}=qe(),{librarySite:a}=O("flags",{librarySite:!1}),l=Ye(),c=g.useCallback(()=>{s(n)},[n,s]),d=g.useMemo(()=>u.has(r,"_libBlockId")&&!u.isEmpty(r._libBlockId),[r==null?void 0:r._libBlockId]);return t==="BODY"?i.jsx(Ue,{side:"bottom",className:"border-border text-xs",children:o(ne.ADD_BLOCK)&&i.jsxs(i.Fragment,{children:[i.jsxs(de,{disabled:!1,className:"flex items-center gap-x-4 text-xs",onClick:()=>re.publish(Y.OPEN_ADD_BLOCK,r),children:[i.jsx(v.PlusIcon,{className:"h-3.5 w-3.5"})," ",e("Add block")]}),o(ne.ADD_BLOCK)&&i.jsx(Qi,{isFromBody:!0}),i.jsx(Zi,{}),i.jsx(de,{disabled:!1,onClick:p=>p.preventDefault(),className:"flex items-center gap-x-4 text-xs",children:i.jsx($c,{children:i.jsxs("div",{className:"flex items-center gap-x-4 text-xs",children:[i.jsx(v.EraserIcon,{})," ",e("Clear canvas")]})})})]})}):i.jsxs(Ue,{side:"bottom",className:"border-border text-xs",children:[o(ne.ADD_BLOCK)&&i.jsxs(i.Fragment,{children:[!l&&i.jsxs(de,{disabled:!ls(r==null?void 0:r._type),className:"flex items-center gap-x-4 text-xs",onClick:()=>re.publish(Y.OPEN_ADD_BLOCK,r),children:[i.jsx(v.PlusIcon,{className:"h-3.5 w-3.5"})," ",e("Add block")]}),i.jsxs(de,{disabled:!Vr(r==null?void 0:r._type),className:"flex items-center gap-x-4 text-xs",onClick:c,children:[i.jsx(v.CardStackPlusIcon,{})," ",e("Duplicate")]})]}),i.jsx(mb,{node:t}),o(ne.MOVE_BLOCK)&&i.jsx(fb,{}),o(ne.ADD_BLOCK)&&i.jsx(Qi,{}),d&&a&&i.jsx(pb,{}),o(ne.CREATE_LIBRARY_BLOCK)&&a&&i.jsx(ub,{}),i.jsx(Zi,{}),o(ne.DELETE_BLOCK)&&i.jsx(hb,{})]})},Uc=({children:t,id:e,node:n})=>{const[,s]=K();return i.jsx(i.Fragment,{children:i.jsxs(Qe,{onOpenChange:r=>{r&&s([e])},children:[i.jsx(et,{children:t}),i.jsx(gb,{node:n})]})})},ne={ADD_BLOCK:"add_block",DELETE_BLOCK:"delete_block",EDIT_BLOCK:"edit_block",MOVE_BLOCK:"move_block",EDIT_THEME:"edit_theme",SAVE_PAGE:"save_page",EDIT_STYLES:"edit_styles",IMPORT_HTML:"import_html",CREATE_LIBRARY_BLOCK:"create_library_block",CREATE_LIBRARY_GROUP:"create_library_group",EDIT_LIBRARY_BLOCK:"edit_library_block",DELETE_LIBRARY_BLOCK:"delete_library_block"};Object.values(ne);const Gc=()=>{const[t]=S.useAtom(tn),[e]=S.useAtom(Gr),[n]=S.useAtom(qr),[s]=S.useAtom(Kr),[r]=S.useAtom(ma),[o]=S.useAtom(ga),[a]=S.useAtom(xa);return{errors:t,isValid:e,hasErrors:n,hasWarnings:s,errorCount:r,warningCount:o,errorsByBlock:a,getBlockErrors:l=>a[l]||[],getErrorsBySeverity:l=>t.filter(c=>c.severity===l),getErrorMessages:()=>t.map(l=>l.message),getErrorMessagesBySeverity:l=>t.filter(c=>c.severity===l).map(c=>c.message),getAllErrorMessages:()=>({errors:t.filter(l=>l.severity==="error").map(l=>l.message),warnings:t.filter(l=>l.severity==="warning").map(l=>l.message)})}},xb=({node:t})=>{var e,n;return i.jsx("input",{autoFocus:!0,className:be("ml-2 !h-4 w-full rounded-sm border border-border bg-background px-1 text-[11px] leading-tight outline-none",t.isSelected?"text-black dark:text-white":""),type:"text",defaultValue:((e=t.data)==null?void 0:e._name)||((n=t.data)==null?void 0:n._type),onFocus:s=>s.currentTarget.select(),onBlur:s=>t.submit(s.currentTarget.value),onKeyDown:s=>{s.key==="Enter"&&t.submit(s.currentTarget.value)}})},bb=S.atom(null),hr=t=>{var e;return t!=null&&t._name?t._name:(t==null?void 0:t._type)==="Box"&&(t!=null&&t.tag)&&(t==null?void 0:t.tag)!=="div"?u.startCase(t.tag):((e=t==null?void 0:t._type)==null?void 0:e.split("/").pop())||""},yb=(t,e)=>t.length>e?t.substring(0,e)+"...":t,vb=g.memo(({node:t,style:e,dragHandle:n})=>{var Ae;const{t:s}=F.useTranslation(),r=tt(),[o]=S.useAtom(Rs),{hasPermission:a}=qe();let l=null;const c=t.children.length>0,{highlightBlock:d,clearHighlight:p}=nt(),f=Ye(),{id:m,data:h,isSelected:b,willReceiveDrop:x,isDragging:y,isEditing:k,handleClick:w}=t,E=Gc(),A=g.useMemo(()=>E.getBlockErrors(m),[E,m]),_=u.get(h,"_show",!0),I=W=>{W.stopPropagation(),_&&t.toggle()},j=W=>{W.isInternal&&(l=W.isOpen,W.isOpen&&W.close())},N=W=>{W.isInternal&&l!==null&&(l?W.open():W.close(),l=null)},[C,T]=S.useAtom(bb),R=()=>{var W;B(),t.parent.isSelected||T((W=t==null?void 0:t.parent)==null?void 0:W.id)},B=()=>{T(null)},U=W=>{B(),W.stopPropagation(),!t.isOpen&&_&&t.toggle(),w(W)};g.useEffect(()=>{const W=setTimeout(()=>{x&&!t.isOpen&&!y&&_&&t.toggle()},500);return()=>clearTimeout(W)},[x,t,y]);const z=(W,Me)=>{const pt=o.contentDocument||o.contentWindow.document,wt=pt.querySelector(`[data-block-id=${W}]`);wt&&wt.setAttribute("data-drop",Me);const Wt=wt.getBoundingClientRect(),ft=o.getBoundingClientRect();Wt.top>=ft.top&&Wt.left>=ft.left&&Wt.bottom<=ft.bottom&&Wt.right<=ft.right||(pt.documentElement.scrollTop=wt.offsetTop-ft.top)},G=W=>{B();const Me=u.get(t,"parent.id");Me!=="__REACT_ARBORIST_INTERNAL_ROOT__"?re.publish(Y.OPEN_ADD_BLOCK,{_id:Me,position:W}):re.publish(Y.OPEN_ADD_BLOCK,{position:W})};if(m===$.ROOT_TEMP_KEY)return i.jsxs("div",{className:"group relative mt-2 w-full cursor-pointer",children:[i.jsx("br",{}),a(ne.ADD_BLOCK)&&i.jsx("div",{role:"button",onClick:()=>G(-1),className:"h-1 rounded bg-primary opacity-0 duration-200 group-hover:opacity-100",children:i.jsxs("div",{className:"absolute left-1/2 top-1/2 flex -translate-x-1/2 -translate-y-1/2 transform items-center gap-x-1 rounded-full bg-primary px-3 py-1 text-[9px] leading-tight text-white hover:bg-primary",children:[i.jsx(v.PlusIcon,{className:"w-2.4 h-2.5 stroke-[5] text-white"})," ",s("Add block")]})}),i.jsx("br",{})]});const{librarySite:he}=O("flags",{librarySite:!1}),ae=g.useMemo(()=>he&&u.has(h,"_libBlockId")&&!u.isEmpty(h._libBlockId)&&(a(ne.CREATE_LIBRARY_BLOCK)||a(ne.EDIT_LIBRARY_BLOCK)),[h,a,he]),le=g.useMemo(()=>(h==null?void 0:h._type)==="PartialBlock"||(h==null?void 0:h._type)==="GlobalBlock",[h]);return i.jsx("div",{className:"w-full",children:i.jsxs("div",{onMouseEnter:()=>d(m),onMouseLeave:()=>p(),onClick:U,style:e,"data-node-id":m,ref:n,onDragStart:()=>j(t),onDragEnd:()=>N(t),onDragOver:W=>{W.preventDefault(),z(m,"yes")},onDragLeave:W=>{W.preventDefault(),z(m,"no")},onDrop:W=>{W.preventDefault(),z(m,"no")},children:[a(ne.ADD_BLOCK)&&!f&&(t==null?void 0:t.rowIndex)>0&&(t.parent.isOpen&&ls(u.get(t,"parent.data._type"))||((Ae=t==null?void 0:t.parent)==null?void 0:Ae.id)==="__REACT_ARBORIST_INTERNAL_ROOT__")&&i.jsx("div",{className:"group relative ml-5 h-full w-full cursor-pointer",children:i.jsx("div",{onClick:W=>{W.stopPropagation(),G(t.childIndex)},onMouseEnter:R,onMouseLeave:B,className:"absolute -top-0.5 h-0.5 w-[90%] rounded bg-primary/80 opacity-0 delay-200 duration-200 group-hover:opacity-100",children:i.jsx("div",{className:"absolute left-1/2 top-1/2 flex h-4 w-4 -translate-x-1/2 -translate-y-1/2 transform items-center justify-center rounded-full bg-primary/80 p-1 outline outline-2 outline-white hover:bg-primary/80",children:i.jsx(v.PlusIcon,{className:"h-2 w-2 stroke-[2] text-white"})})})}),i.jsxs("div",{className:be("group flex w-full cursor-pointer items-center justify-between space-x-px !rounded p-1 py-0 outline-none",b?"bg-primary/20":"hover:bg-primary/10",x&&Ze(h._type,"Icon")?"bg-green-200":"",(t==null?void 0:t.id)===C?"bg-primary/10":"",y&&"opacity-20",_?"":"line-through opacity-50",ae&&b&&"bg-primary/20 text-primary"),children:[i.jsxs("div",{className:"flex items-center",children:[i.jsx("div",{className:`flex h-4 w-4 rotate-0 transform cursor-pointer items-center justify-center transition-transform duration-100 ${t.isOpen?"rotate-90":""}`,children:c&&i.jsx("button",{onClick:I,type:"button",children:i.jsx(v.ChevronRightIcon,{className:"h-3 w-3"})})}),i.jsxs("div",{className:be("leading-1 flex items-center",ae&&"text-orange-600/90",ae&&b&&"text-orange-800",le&&"text-purple-600/90",le&&b&&"text-purple-800"),children:[A.length>0?i.jsx("div",{className:"text-red-500",children:i.jsx(v.ExclamationTriangleIcon,{className:"h-3 w-3"})}):i.jsx(ni,{type:h==null?void 0:h._type}),k?i.jsx(xb,{node:t}):i.jsx("div",{className:"ml-1.5 flex items-center gap-x-1 truncate text-[13px]",onDoubleClick:W=>{W.stopPropagation(),t.edit(),t.deselect()},children:i.jsx("span",{title:hr(h).length>17?hr(h):"",children:yb(hr(h),17)})})]})]}),i.jsxs("div",{className:"invisible flex items-center space-x-1.5 pr-px group-hover:visible",children:[ls(h==null?void 0:h._type)&&_&&a(ne.ADD_BLOCK)?i.jsxs(pe,{children:[i.jsx(fe,{onClick:()=>re.publish(Y.OPEN_ADD_BLOCK,{_id:m}),className:"cursor-pointer rounded bg-transparent p-px hover:bg-primary/10",asChild:!0,children:i.jsx(v.PlusIcon,{className:"h-4 w-4"})}),i.jsx(ue,{className:"isolate z-[9999]",side:"bottom",children:s("Add block inside")})]}):null,i.jsxs(pe,{children:[i.jsx(fe,{onClick:W=>{W.stopPropagation(),r([m],{_show:!_}),t.isOpen&&t.toggle()},className:"cursor-pointer rounded bg-transparent p-0.5 hover:bg-primary/10",asChild:!0,children:_?i.jsx(v.EyeClosedIcon,{className:"h-4 w-4"}):i.jsx(v.EyeOpenIcon,{className:"h-4 w-4"})}),i.jsx(ue,{className:"isolate z-[9999] text-xs",side:"bottom",children:s(_?"Hide the block from page":"Show the block on page")})]}),i.jsx(Uc,{node:t,id:m,children:i.jsx("div",{className:"cursor-pointer rounded bg-transparent p-px hover:bg-primary/10",children:i.jsx(v.DotsVerticalIcon,{className:"h-3 w-3"})})})]})]})]})})}),kb=({parentContext:t,setParentContext:e})=>{const{t:n}=F.useTranslation(),{canPaste:s,pasteBlocks:r}=mo(),o=O("flags.copyPaste",!0);return g.useEffect(()=>{s("root")||e(null)},[s("root")]),!t||!s("root")||!o?null:i.jsx("div",{className:"absolute inset-0",children:i.jsxs(Qe,{open:!0,onOpenChange:()=>e(null),children:[i.jsx(et,{className:"hidden"}),i.jsx(Ue,{className:"absolute w-28 p-1 text-xs",style:{top:t.y,left:t.x},children:i.jsxs(de,{className:"flex items-center gap-x-4 text-xs",onClick:()=>{r("root"),e(null)},children:[i.jsx(v.CardStackIcon,{})," ",n("Paste")]})})]})})},wb=()=>{const[t]=te();return(e,n)=>{var o;const s=(o=u.find(t,{_id:n}))==null?void 0:o._type,r=u.first(e.map(a=>{var l;return(l=u.find(t,{_id:a}))==null?void 0:l._type}));return Ze(s,r)}},qc=()=>{const[t]=S.useAtom(fa),[e,n]=K(),[s]=Ms(),r=tt(),[,o]=Ee(),{moveBlocks:a}=Ne(),l=wb(),c=g.useRef(null),[,d]=S.useAtom(oo),{t:p}=F.useTranslation(),[f,m]=g.useState(null),h=()=>{n([]),o([])},b=g.useMemo(()=>{const j=(C,T)=>C.filter(R=>!T.includes(R._id)).map(R=>({...R,children:R.children?j(R.children,T):[]}));return[...j(t,s),{_type:$.ROOT_TEMP_KEY,_id:$.ROOT_TEMP_KEY,children:[]}]},[t,s]),x=({id:j,name:N,node:C})=>{r([j],{_name:N},C.data._name)},y=({dragIds:j,parentId:N,index:C})=>{l(j,N)&&a(j,N,C)},k=j=>{if(j.length===0)return;const N=j[0]?j[0].id:"";o([]),n([N])},w=j=>{var T;j.preventDefault(),f&&m(null);const N=j.target,C=N.getAttribute("data-node-id")||((T=N.closest("[data-node-id]"))==null?void 0:T.getAttribute("data-node-id"));C?(o([]),n([C])):(o([]),n([]),m({x:j.clientX,y:j.clientY}))},E=ke.useDebouncedCallback(({parentNode:j,dragNodes:N})=>{var C;return(j==null?void 0:j.data._type)===$.ROOT_TEMP_KEY||!Ze(j==null?void 0:j.data._type,(C=N[0])==null?void 0:C.data._type)},[],300),A=(j,N)=>{if(!j)return!0;const C={isLeaf:!N.isInternal,isClosed:!N.isOpen,isOpen:N.isOpen};try{let T=j;return Object.keys(C).forEach(R=>{const B=new RegExp(`\\b${R}\\b`,"g");T=T.replace(B,C[R])}),new Function(`return ${T}`)()}catch{return console.warn("Invalid condition expression:",j),!1}},_=j=>{if(!c.current)return;const N=c.current,C=N.selectedNodes[0];if(!C)return;n[C.id],o([]);const T=!C.isInternal,R=!C.isOpen,B=C.isOpen,U=eb.find(z=>z.key===j.key&&(!z.when||A(z.when,C)));if(U)switch(j.preventDefault(),U.command){case"selectNext":sb(N);break;case"selectPrev":rb(N);break;case"selectParent":ob(N,T||R);break;case"close":ab(N,B);break;case"open":ib(N,R);break;case"selectFirst":tb(N);break;case"selectLast":nb(N);break}};g.useEffect(()=>{const j=()=>{c.current&&d(c.current)};j();const N=new MutationObserver(j);return N.observe(document.body,{childList:!0,subtree:!0}),()=>N.disconnect()},[d]);const{hasPermission:I}=qe();return u.isEmpty(t)?i.jsx("div",{children:i.jsx("div",{className:"mt-10 flex h-full w-full items-center justify-center p-8",children:i.jsxs("div",{className:"flex flex-col items-center space-y-6 text-center",children:[i.jsx("div",{className:"rounded-full bg-muted p-6",children:i.jsx(v.StackIcon,{className:"h-12 w-12 text-muted-foreground"})}),i.jsxs("div",{className:"space-y-2",children:[i.jsx("h3",{className:"text-lg font-semibold text-foreground",children:p("This page is empty")}),i.jsx("p",{className:"max-w-sm text-sm text-muted-foreground",children:p("Get started by adding your first block to begin building your page")})]}),I(ne.ADD_BLOCK)&&i.jsxs(q,{onClick:()=>re.publish(Y.OPEN_ADD_BLOCK),className:"bg-primary shadow-sm hover:bg-primary/90",size:"sm",children:[i.jsx(v.PlusIcon,{className:"h-4 w-4"}),p("Add Block")]})]})})}):i.jsxs(i.Fragment,{children:[i.jsx("div",{className:ve.cn("flex h-full select-none flex-col space-y-1"),onClick:()=>h(),children:i.jsxs("div",{id:"outline-view ",className:"no-scrollbar h-full overflow-y-auto text-sm",onKeyDown:j=>{c.current.isEditing||_(j)},children:[i.jsxs("div",{className:"mb-2 flex items-center justify-end gap-x-1 pb-2 text-sm text-muted-foreground",children:[i.jsxs(pe,{children:[i.jsx(fe,{asChild:!0,children:i.jsx(q,{className:"h-fit p-1",onClick:()=>{var j;return(j=c==null?void 0:c.current)==null?void 0:j.openAll()},variant:"ghost",size:"sm",children:i.jsx(v.DoubleArrowDownIcon,{className:"h-2 w-2"})})}),i.jsx(ue,{className:"isolate z-[9999]",children:p("Expand all")})]}),i.jsxs(pe,{children:[i.jsx(fe,{asChild:!0,children:i.jsx(q,{className:"h-fit p-1",onClick:()=>{var j;return(j=c==null?void 0:c.current)==null?void 0:j.closeAll()},variant:"ghost",size:"sm",children:i.jsx(v.DoubleArrowUpIcon,{className:"h-2 w-2"})})}),i.jsx(ue,{className:"isolate z-[9999]",children:p("Collapse all")})]})]}),i.jsx("div",{className:"group relative z-30 ml-5 w-full cursor-pointer",children:i.jsx("div",{onClick:()=>re.publish(Y.OPEN_ADD_BLOCK,{position:0}),className:"h-1 w-[90%] rounded bg-primary opacity-0 duration-200 group-hover:opacity-100",children:i.jsx("div",{className:"absolute left-[45%] top-1/2 flex h-4 w-4 -translate-x-1/2 -translate-y-1/2 transform items-center justify-center rounded-full bg-primary p-1 outline outline-2 outline-white hover:bg-primary",children:i.jsx(v.PlusIcon,{className:"h-3 w-3 stroke-[3] text-white"})})})}),i.jsx("div",{children:i.jsx("div",{role:"treeitem","aria-level":0,"aria-selected":!0,"aria-expanded":!1,onClick:()=>n([]),className:"flex h-full items-center border-b border-transparent",children:i.jsxs("div",{className:ve.cn("group flex w-full cursor-pointer items-center justify-between space-x-px !rounded p-1 py-0 outline-none",e.length===0?"bg-primary/20":""),children:[i.jsxs("div",{className:"leading-1 flex items-center",children:[i.jsx(v.CardStackIcon,{className:"h-3 w-3 flex-shrink-0 rotate-180"}),i.jsx("div",{className:"ml-1.5 flex items-center gap-x-1 truncate text-[13px]",children:"Body"})]}),i.jsx(Uc,{node:"BODY",id:"BODY",children:i.jsx("div",{className:"hidden cursor-pointer rounded bg-transparent p-px hover:bg-primary/10 group-hover:block",children:i.jsx(v.DotsVerticalIcon,{className:"h-3 w-3"})})})]})})}),i.jsx(Jd.Tree,{ref:c,height:window.innerHeight-160,className:"no-scrollbar !h-full max-w-full space-y-1 !overflow-y-auto !overflow-x-hidden",rowClassName:"flex items-center h-full border-b border-transparent",selection:e[0]||"",onRename:x,openByDefault:!1,onMove:y,data:[...b],renderCursor:Jx,onSelect:k,childrenAccessor:j=>j.children,width:"100%",rowHeight:25,renderDragPreview:Qx,indent:10,onContextMenu:w,disableDrop:E,idAccessor:"_id",children:vb})]})}),i.jsx(db,{}),i.jsx(kb,{parentContext:f,setParentContext:m})]})},Pt=M.forwardRef(({className:t,orientation:e="horizontal",decorative:n=!0,...s},r)=>i.jsx(ca.Root,{ref:r,decorative:n,orientation:e,className:L("shrink-0 bg-border",e==="horizontal"?"h-[1px] w-full":"h-full w-[1px]",t),...s}));Pt.displayName=ca.Root.displayName;const dn=M.forwardRef(({className:t,thumbClassName:e,...n},s)=>i.jsx(br.Root,{className:L("peer inline-flex h-5 w-9 shrink-0 cursor-pointer items-center rounded-full border-2 border-transparent shadow-sm transition-colors focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2 focus-visible:ring-offset-background disabled:cursor-not-allowed disabled:opacity-50 data-[state=checked]:bg-primary data-[state=unchecked]:bg-input",t),...n,ref:s,children:i.jsx(br.Thumb,{className:L("pointer-events-none block h-4 w-4 rounded-full bg-background shadow-lg ring-0 transition-transform",e,"data-[state=checked]:translate-x-3 data-[state=unchecked]:translate-x-0")})}));dn.displayName=br.Root.displayName;const Kc=M.forwardRef(({className:t,...e},n)=>i.jsxs(fn.Root,{ref:n,className:L("relative flex w-full touch-none select-none items-center",t),...e,children:[i.jsx(fn.Track,{className:"relative h-1.5 w-full grow overflow-hidden rounded-full bg-neutral-300",children:i.jsx(fn.Range,{className:"absolute h-full bg-neutral-900"})}),i.jsx(fn.Thumb,{className:"block h-4 w-4 rounded-full border border-neutral-900 bg-neutral-900 shadow transition-colors focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-neutral-900 disabled:pointer-events-none disabled:opacity-50"})]}));Kc.displayName=fn.Root.displayName;const Cb=({value:t,onChange:e,disabled:n})=>{const[s,r]=g.useState(t),o=ke.useThrottledCallback(e,[t],200,!0);return i.jsx(Kc,{min:0,step:1,max:50,disabled:n,value:[Number(s.replace("px",""))],onValueChange:a=>{r(a[0].toString()+"px"),o(a[0].toString())},className:"flex-1 cursor-pointer"})},jb=({value:t,onChange:e})=>{const n=u.debounce(s=>e(s),200);return i.jsx("div",{className:"relative flex h-6 w-6 cursor-pointer rounded-lg border border-border",style:{backgroundColor:t},children:i.jsx("input",{type:"color",value:t.startsWith("#")?t:"#000000",onChange:s=>{const r=s.target.value;/^#[0-9A-F]{6}$/i.test(r)&&n(r)},className:"absolute inset-0 h-full w-full cursor-pointer rounded-lg border-0 opacity-0"})})},Sb=({label:t,value:e,onChange:n})=>{const s=aa.useRegisteredFonts(),{t:r}=F.useTranslation();return g.useEffect(()=>{s.some(o=>o.family===e)||n(s[0].family)},[e,n]),i.jsxs("div",{className:"space-y-0.5",children:[i.jsx(ut,{className:"mb-1 block text-xs text-gray-600",children:r(u.startCase(t))}),i.jsxs(Gs,{value:e,onValueChange:n,children:[i.jsx(Wn,{className:"h-8 w-full text-xs text-black",children:i.jsx(ei,{placeholder:r("Select font")})}),i.jsx(Un,{children:s.map(o=>i.jsx(Gn,{value:o.family,children:o.family},o.family))})]})]})},Nb={fontFamily:{heading:"Poppins",body:"Poppins"},borderRadius:"6px",colors:{background:["#ffffff","#0a0a0a"],foreground:["#0a0a0a","#fafafa"],primary:["#171717","#e5e5e5"],"primary-foreground":["#fafafa","#171717"],secondary:["#f5f5f5","#262626"],"secondary-foreground":["#171717","#fafafa"],muted:["#f5f5f5","#262626"],"muted-foreground":["#737373","#a1a1a1"],accent:["#f5f5f5","#404040"],"accent-foreground":["#171717","#fafafa"],destructive:["#e7000b","#ff6467"],"destructive-foreground":["#ffffff","#fafafa"],border:["#e5e5e5","#282828"],input:["#e5e5e5","#343434"],ring:["#a1a1a1","#737373"],card:["#ffffff","#171717"],"card-foreground":["#0a0a0a","#fafafa"],popover:["#ffffff","#262626"],"popover-foreground":["#0a0a0a","#fafafa"]}},Eb={fontFamily:{heading:"Poppins",body:"Poppins"},borderRadius:"4px",colors:{background:["#ffffff","#000000"],foreground:["#0f1419","#e7e9ea"],primary:["#1e9df1","#1c9cf0"],"primary-foreground":["#ffffff","#ffffff"],secondary:["#0f1419","#f0f3f4"],"secondary-foreground":["#ffffff","#0f1419"],muted:["#e5e5e6","#181818"],"muted-foreground":["#0f1419","#72767a"],accent:["#e3ecf6","#061622"],"accent-foreground":["#1e9df1","#1c9cf0"],destructive:["#f4212e","#f4212e"],"destructive-foreground":["#ffffff","#ffffff"],border:["#e1eaef","#242628"],input:["#f7f9fa","#22303c"],ring:["#1da1f2","#1da1f2"],card:["#f7f8f8","#17181c"],"card-foreground":["#0f1419","#d9d9d9"],popover:["#ffffff","#000000"],"popover-foreground":["#0f1419","#e7e9ea"],sidebar:["#f7f8f8","#17181c"],"sidebar-foreground":["#0f1419","#d9d9d9"],"sidebar-primary":["#1e9df1","#1da1f2"],"sidebar-primary-foreground":["#ffffff","#ffffff"],"sidebar-accent":["#e3ecf6","#061622"],"sidebar-accent-foreground":["#1e9df1","#1c9cf0"],"sidebar-border":["#e1e8ed","#38444d"],"sidebar-ring":["#1da1f2","#1da1f2"]}},Ab={fontFamily:{heading:"Geist",body:"Geist"},borderRadius:"4px",colors:{background:["#fdf6e3","#002b36"],foreground:["#073642","#93a1a1"],primary:["#d33682","#d33682"],"primary-foreground":["#ffffff","#ffffff"],secondary:["#2aa198","#2aa198"],"secondary-foreground":["#ffffff","#ffffff"],muted:["#93a1a1","#586e75"],"muted-foreground":["#073642","#93a1a1"],accent:["#cb4b16","#cb4b16"],"accent-foreground":["#ffffff","#ffffff"],destructive:["#dc322f","#dc322f"],"destructive-foreground":["#ffffff","#ffffff"],border:["#839496","#586e75"],input:["#839496","#586e75"],ring:["#d33682","#d33682"],card:["#eee8d5","#073642"],"card-foreground":["#073642","#93a1a1"],popover:["#eee8d5","#073642"],"popover-foreground":["#073642","#93a1a1"]}},_b={fontFamily:{heading:"Poppins",body:"Poppins"},borderRadius:"6px",colors:{background:["#faf9f5","#262624"],foreground:["#3d3929","#c3c0b6"],primary:["#c96442","#d97757"],"primary-foreground":["#ffffff","#ffffff"],secondary:["#e9e6dc","#faf9f5"],"secondary-foreground":["#535146","#30302e"],muted:["#ede9de","#1b1b19"],"muted-foreground":["#83827d","#b7b5a9"],accent:["#e9e6dc","#1a1915"],"accent-foreground":["#28261b","#f5f4ee"],destructive:["#141413","#ef4444"],"destructive-foreground":["#ffffff","#ffffff"],border:["#dad9d4","#3e3e38"],input:["#b4b2a7","#52514a"],ring:["#c96442","#d97757"],card:["#faf9f5","#262624"],"card-foreground":["#141413","#faf9f5"],popover:["#ffffff","#30302e"],"popover-foreground":["#28261b","#e5e5e2"]}},Ib={fontFamily:{heading:"Inter",body:"Inter"},borderRadius:"6px",colors:{background:["#fff9f5","#2a2024"],foreground:["#3d3436","#f2e9e4"],primary:["#ff7e5f","#ff7e5f"],"primary-foreground":["#ffffff","#ffffff"],secondary:["#ffedea","#463a41"],"secondary-foreground":["#b35340","#f2e9e4"],muted:["#fff0eb","#392f35"],"muted-foreground":["#78716c","#d7c6bc"],accent:["#feb47b","#feb47b"],"accent-foreground":["#3d3436","#2a2024"],destructive:["#e63946","#e63946"],"destructive-foreground":["#ffffff","#ffffff"],border:["#ffe0d6","#463a41"],input:["#ffe0d6","#463a41"],ring:["#ff7e5f","#ff7e5f"],card:["#ffffff","#392f35"],"card-foreground":["#3d3436","#f2e9e4"],popover:["#ffffff","#392f35"],"popover-foreground":["#3d3436","#f2e9e4"]}},Tb=g.lazy(()=>Promise.resolve().then(()=>require("./css-import-modal-BSMGKA2T.cjs")).then(t=>({default:t.CssImportModal}))),Yc="chai-builder-previous-theme",Bb=[{shadcn_default:Nb},{twitter_theme:Eb},{solarized_theme:Ab},{claude_theme:_b},{supabase_theme:Ib}],Rb=t=>{if(!(typeof window>"u"))try{localStorage.setItem(Yc,JSON.stringify(t))}catch(e){console.warn("Failed to save previous theme to localStorage:",e)}},Pb=()=>{if(!(typeof window>"u"))try{localStorage.removeItem(Yc)}catch(t){console.warn("Failed to clear previous theme from localStorage:",t)}},Xc=M.memo(({className:t=""})=>{const[e,n]=Dn(),[s,r]=M.useState(""),[o,a]=M.useState(!1),l=O("themePresets",[]),c=O("themePanelComponent",null),{hasPermission:d}=qe(),p=O("flags.importTheme",!0),f=O("flags.darkMode",!0),m=ro();(!l||l.length===0)&&Bb.map(N=>{l.push(N)});const[h,b]=Tn(),x=Bn(),{t:y}=F.useTranslation(),k=M.useCallback(N=>{const C={...h};Rb(C),b(N),m(),me.toast.success("Theme updated",{action:{label:i.jsxs("span",{className:"flex items-center gap-2",children:[i.jsx(v.ResetIcon,{className:"h-4 w-4"})," Undo"]}),onClick:()=>{b(C),Pb(),me.toast.dismiss()}},closeButton:!0,duration:15e3})},[h,b,m]),w=()=>{const N=l.find(C=>Object.keys(C)[0]===s);if(N){const C=Object.values(N)[0];C&&typeof C=="object"&&"fontFamily"in C&&"borderRadius"in C&&"colors"in C?(k(C),r(""),m()):console.error("Invalid preset structure:",C)}else console.error("Preset not found:",s)},E=N=>{k(N),r(""),m()},A=ke.useDebouncedCallback((N,C)=>{b(()=>({...h,fontFamily:{...h.fontFamily,[N.replace(/font-/g,"")]:C}})),m()},[h,m],200),_=M.useCallback(N=>{b(()=>({...h,borderRadius:`${N}px`})),m()},[h,m]),I=ke.useDebouncedCallback((N,C)=>{b(()=>{const T=u.get(h,`colors.${N}`);return e?u.set(T,1,C):u.set(T,0,C),m(),{...h,colors:{...h.colors,[N]:T}}})},[h,m],200),j=N=>i.jsx("div",{className:"grid grid-cols-1",children:Object.entries(N.items).map(([C])=>{const T=u.get(h,`colors.${C}.${e?1:0}`);return T?i.jsxs("div",{id:`theme-${C}`,className:"mt-1 flex items-center gap-x-2",children:[i.jsx(jb,{value:T,onChange:R=>I(C,R)}),i.jsx(ut,{className:"text-xs font-normal leading-tight",children:C.split(/(?=[A-Z])/).join(" ").replace(/-/g," ").split(" ").map(R=>R.charAt(0).toUpperCase()+R.slice(1)).join(" ")+(!C.toLowerCase().includes("foreground")&&!C.toLowerCase().includes("border")&&!C.toLowerCase().includes("input")&&!C.toLowerCase().includes("ring")&&!C.toLowerCase().includes("background")?" Background":"")})]},C):null})});return d("edit_theme")?i.jsxs("div",{className:"relative w-full",children:[i.jsxs("div",{className:ve.cn("no-scrollbar h-full w-full overflow-y-auto",t),children:[l.length>0&&i.jsxs("div",{className:"mx-0 my-2 flex flex-col gap-1 py-2",children:[i.jsxs("div",{className:"flex w-full items-center justify-between",children:[i.jsx(ut,{className:"text-sm",children:y("Presets")}),i.jsx("div",{className:"flex gap-2",children:p&&i.jsxs(q,{className:"px-1",variant:"link",size:"sm",onClick:()=>a(!0),children:[i.jsx(v.UploadIcon,{className:"h-4 w-4"}),y("Import theme")]})})]}),i.jsxs("div",{className:"flex items-center gap-2 px-0",children:[i.jsx("div",{className:"w-[70%]",children:i.jsxs(Gs,{value:s,onValueChange:r,children:[i.jsx(Wn,{className:"h-9 w-full text-sm",children:i.jsx(ei,{placeholder:y("Select preset")})}),i.jsx(Un,{children:Array.isArray(l)&&l.map(N=>{const C=Object.keys(N)[0],T=C.replaceAll("_"," ");return i.jsx(Gn,{value:C,children:u.capitalize(T)},C)})})]})}),i.jsx("div",{className:"w-[25%]",children:i.jsx(q,{className:"w-full text-sm",disabled:!s,onClick:w,children:y("Apply")})})]})]}),i.jsx(Pt,{}),i.jsxs("div",{className:ve.cn("my-2 space-y-3",t),children:[i.jsxs("div",{className:"flex items-center gap-2",children:[i.jsx(v.TextIcon,{className:"h-3 w-3 text-gray-600"}),i.jsx("span",{className:"text-xs font-medium text-gray-700",children:y("Typography")})]}),(x==null?void 0:x.fontFamily)&&i.jsx("div",{className:"space-y-2",children:Object.entries(x.fontFamily).map(([N,C])=>i.jsx(Sb,{label:N,value:h.fontFamily[N.replace(/font-/g,"")]||C[Object.keys(C)[0]],onChange:T=>A(N,T)},N))}),i.jsx(Pt,{}),(x==null?void 0:x.borderRadius)&&i.jsxs("div",{className:"space-y-0.5",children:[i.jsxs("div",{className:"flex items-center justify-between",children:[i.jsxs("div",{className:"flex items-center gap-2",children:[i.jsx(v.CornerTopRightIcon,{className:"h-3 w-3 text-gray-600"}),i.jsx("span",{className:"text-xs font-medium text-gray-700",children:y("Border Radius")})]}),i.jsx(Hs,{variant:"secondary",className:"text-xs",children:h.borderRadius})]}),i.jsx("div",{className:"flex items-center gap-4 py-2",children:i.jsx(Cb,{value:h.borderRadius,onChange:_})})]}),i.jsx(Pt,{}),(x==null?void 0:x.colors)&&i.jsxs("div",{className:"space-y-3",children:[i.jsxs("div",{className:"flex items-center justify-between",children:[i.jsxs("div",{className:"flex items-center gap-2",children:[i.jsx(v.MixerHorizontalIcon,{className:"h-3 w-3 text-gray-600"}),i.jsx("span",{className:"text-xs font-medium text-gray-700",children:y("Colors")})]}),f&&i.jsxs("div",{className:"flex items-center gap-2",children:[i.jsx(v.SunIcon,{className:"h-4 w-4"}),i.jsx(dn,{checked:e,onCheckedChange:N=>n(N),"aria-label":y("Toggle dark mode"),className:"mx-1"}),i.jsx(v.MoonIcon,{className:"h-4 w-4"})]})]}),i.jsx("div",{className:"space-y-2",children:x.colors.map(N=>j(N))})]}),i.jsx(g.Suspense,{fallback:i.jsx("div",{children:y("Loading...")}),children:o&&p&&i.jsx(Tb,{open:o,onOpenChange:a,onImport:E})})]}),i.jsx("br",{}),i.jsx("br",{}),i.jsx("br",{}),i.jsx("br",{})]}),c&&i.jsx("div",{className:"absolute bottom-4 w-full",children:M.createElement(c)})]}):i.jsx("div",{className:"relative w-full",children:i.jsx("div",{className:ve.cn("no-scrollbar h-full w-full overflow-y-auto text-center",t),children:i.jsx("div",{className:"mt-10 h-full items-center justify-center gap-2 text-muted-foreground",children:i.jsx("p",{className:"text-sm",children:y("You don't have permission to edit the theme. Please contact your administrator to get access.")})})})})}),Lb="Core",Mb="Import",Db="Breakpoints",Ob="Clear",Fb="Cancel",$b="Yes",zb="Preview",Hb="Settings",Vb="Style",Wb="Enter SVG code here",Ub="Remove",Gb="Choose",qb="Cut",Kb="Copy",Yb="Paste",Xb="Delete",Jb="classes",Zb="Theme",Qb="Outline",ey="Copied",ty="Stop",ny="Edit",sy="Tag",ry="Value",oy="URL",iy="Images",ay="Library",ly="Blocks",cy="Basic",dy="Media",uy="Advanced",py="Form",fy="Groups",hy="Accordions",my="Buttons",gy="Layouts",xy="FAQ",by="Hero",yy="Features",vy="Footer",ky="Navbar",wy="Icons",Cy="Testimonials",jy="Blog",Sy="Saved",Ny="Unsaved",Ey="Randomize",Ay="Classes",_y="All",Iy="Undo",Ty="Redo",By="Duplicate",Ry="Close",Py="Selected",Ly="Select",My="Attributes",Dy="apply",Oy="presets",Fy="Orientation",$y="Color",zy="Upload",Hy="Apply",Vy="Back",Wy="Insert",Uy="Rename",Gy="Partials",qy="Happy",Ky="Sad",Yy="Retry",Xy="Canvas is empty",Jy="Presets",Zy="No",Qy="Saving",e0={heading_font:"Heading Font",body_font:"Body Font",rounded_corner:"Rounded Corners",primary:"Primary",secondary:"Secondary",background:"Background",text_color:"Text Color",background_dark_mode:"Background (Dark Mode)",text_color_dark_mode:"Text Color (Dark Mode)"},t0={box:"box",tag:"Tag",div:"div",level:"Level",header:"header",footer:"footer",section:"section",article:"article",aside:"aside",main:"main",nav:"navigation",figure:"figure",details:"details",summary:"summary",dialog:"dialog",strike:"strike",caption:"caption",legend:"legend",figcaption:"figure caption",mark:"mark",background_image:"Background Image",label:"Label",default:"default",icon_size:"Icon Size",icon_position:"Icon Position",start:"Start",end:"End",button:"Button",custom_html:"Custom HTML",html_code:"HTML Code",default_snippet:"The HTML snippet goes here...",placeholder:"Enter custom HTML code here",custom_script:"Custom Script",dark_mode:"Dark Mode",divider:"Divider",empty_box:"Empty Box",heading:"Heading",image:"Image",alt:"Alt",width:"Width",height:"Height",video:"Video",span:"Span",content:"Content",icon:"Icon",richtext:"Rich Text",list:"List",list_type:"List Type",listitem:"List Item",link:"Link",list_item:"List Item",none:"None",disc:"Disc",number:"Number",paragraph:"Paragraph",lightbox_link:"Lightbox Link",href:"Link",type:"Type",iframe:"iframe",inline:"inline",ajax:"ajax",autoplay:"Video autoplay",max_width:"Max Width",backdrop_color:"Background Color",gallery_name:"Gallery Name",slot:"Slot",empty_slot:"Empty Slot",text:"Text",video_url:"Video URL",controls:"Show Controls",loop:"Loop",muted:"Muted",checkbox:"Checkbox",required:"Required",checked:"Checked",submit_button:"Submit Button",form:"Form",submit_url:"Submit URL",error_message:"Error Message",success_message:"Success Message",input:"Input",value:"Value",show_label:"Show Label",field_name:"Field Name",radio:"Radio",multiple:"Multiple",options:"Options",select:"Select",multiple_choice:"Multiple Choice",textarea:"Textarea",rows:"Rows"},n0="Add",s0="Save",r0="Screen",o0={"Add block":"Add Block","Add Block":"Add Block","Add blocks":"Add blocks","Add inside":"Add inside","Add before":"Add before","Add after":"Add after","Add block inside":"Add block inside","Add field":"Add field","Enter or paste TailwindCSS HTML snippet":"Enter or paste TailwindCSS HTML snippet","Click to add block to page":"Click to add block to page",Core:Lb,"Custom Blocks":"Custom Blocks","UI Library":"UI Library",Import:Mb,"Use HTML snippets from Tailwind CSS component libraries":"Use HTML snippets from Tailwind CSS component libraries","Tailwind HTML snippet":"Tailwind HTML snippet","Enter your code snippet here":"Enter your code snippet here","Import HTML":"Import HTML","Imported HTML Note":"NOTE: Imported html will be added to the currently selected block. If no block is selected, the html will be added to the page.","Dark Mode":"Dark Mode","This page has no blocks. Add a block by clicking the + button":"This page has no blocks. Add a block by clicking the + button","This page is empty":"This page is empty","Please select a block to edit settings or styles":"Please select a block to edit settings or styles","Please select a block to Ask AI":"Please select a block to ask AI","Please select a styling block":"Please select a styling block","Drop your block here":"Drop your block here","Use setting":"Use setting","Mobile (XS)":"Mobile (XS)","Styles set here are applied to all screen unless edited at higher breakpoint":"Styles set here are applied to all screen unless edited at higher breakpoint","Mobile landscape (SM)":"Mobile landscape (SM)","Styles set here are applied at 640px and up unless edited at higher breakpoint":"Styles set here are applied at 640px and up unless edited at higher breakpoint","Tablet (MD)":"Tablet (MD)","Styles set here are applied at 768px and up":"Styles set here are applied at 768px and up","Tablet Landscape (LG)":"Tablet Landscape (LG)","Styles set here are applied at 1024px and up unless edited at higher breakpoint":"Styles set here are applied at 1024px and up unless edited at higher breakpoint","Desktop (XL)":"Desktop (XL)","Styles set here are applied at 1280px and up unless edited at higher breakpoint":"Styles set here are applied at 1280px and up unless edited at higher breakpoint","Large Desktop (2XL)":"Large Desktop (2XL)","Styles set here are applied at 1536px and up":"Styles set here are applied at 1536px and up",Breakpoints:Db,Clear:Ob,"Clear whole canvas?":"Clear whole canvas?","Are you sure you want to clear the whole canvas?":"Are you sure you want to clear the whole canvas?",Cancel:Fb,Yes:$b,Preview:zb,Settings:Hb,Styling:Vb,SVG_code:Wb,"Paste SVG_code":"Choose icon or paste SVG code","Enter Key":"Enter Key","Data Provider":"Data Provider","Remove Provider Confirmation":"Are you sure you want to remove <span class='text-blue-500'>{name}</span> provider?","Your data provider will be removed from this page and all added data binding will be not visible on blocks.":"Your data provider will be removed from this page and all added data binding will be not visible on blocks.",Remove:Ub,"You have no data providers registered. Please add a data provider to your project.":"You have no data providers registered. Please add a data provider to your project.","Learn more":"Learn more","Add data providers:":"Add data providers:","Select a provider":"Select a provider",Choose:Gb,"Page data providers:":"Page data providers:","View Data":"View Data","Mark as Global":"Mark as Global","Note: Global blocks are single instances. Editing global blocks will be reflected on all pages using these blocks.":"Note: Global blocks are single instances. Editing global blocks will be reflected on all pages using these blocks.","Global blocks are indicated with":"Global blocks are indicated with","Global blocks are available under 'Global' category":"Global blocks are available under 'Global' category","Enter global block name":"Enter global block name","Eg: Header, Footer":"Eg: Header, Footer","{length} blocks selected.":"{length} blocks selected.",Cut:qb,Copy:Kb,Paste:Yb,Delete:Xb,"Clear Selection":"Clear Selection","This is dev mode. Visit":"This is dev mode. Visit","to see page preview":"to see page preview",classes:Jb,Theme:Zb,Outline:Qb,"Not supported":"Not supported","Please use Chrome, Firefox or Safari":"Please use Chrome, Firefox or Safari","Download Complete":"Download complete",Copied:ey,"Enter Classes":"Add classes or design tokens (space-separated)","Ask AI":"Ask AI","Edit with AI":"Edit with AI","Generating... Please wait...":"Generating... Please wait...","Saving... Please wait...":"Saving... Please wait...","Deleting... Please wait...":"Deleting... Please wait...",Stop:ty,"E.g.: This page is about an AI assistant app called Chai Studio. It allows users to create beautiful webpages and edit content with AI":"E.g.: This page is about an AI assistant app called Chai Studio. It allows users to create beautiful webpages and edit content with AI.","Ask AI to edit styles":"Ask AI to edit styles","Ask AI to edit content":"Ask AI to edit content","AI Context":"AI Context","Select Block for AI":"Select a block to edit with AI","Select Block to Edit":"Please select a block to edit",Edit:ny,"Describe this page. E.g.: This page is about...":"Describe this page. E.g.: This page is about...",Tag:sy,Value:ry,"Background Image":"Background Image","Enter image URL":"Enter image URL","Enter URL":"Enter URL",URL:oy,"Replace image":"Replace image","Choose image":"Choose image",Images:iy,Library:ay,Blocks:ly,Basic:cy,Media:dy,Advanced:uy,Form:py,"Choose Icon or SVG":"Choose an icon or enter SVG",Groups:fy,"UI Libraries":"UI Libraries",Accordions:hy,Buttons:my,Layouts:gy,"Choose Library":"Choose library","No Library Found":"No library found.",FAQ:xy,Hero:by,Features:yy,Footer:vy,Navbar:ky,Icons:wy,Testimonials:Cy,Blog:jy,"Remove context":"Remove context","Yes, Delete":"Yes, Delete","AI Context Updated":"AI Context Updated","You can now ask AI to edit your content.":"You can now ask AI to edit your content.",Saved:Sy,Unsaved:Ny,"Saving...":"Saving...","Improve writing":"Improve writing","Replace placeholder content":"Replace placeholder content","Discard current placeholder content and replace with meaningful relevant content.":"Discard current placeholder content and replace with meaningful relevant content.","Fix grammar":"Fix grammar","Fix grammar in all text elements. Ensuring the text is grammatically correct and free of errors.":"Fix grammar in all text elements. Ensuring the text is grammatically correct and free of errors.","Make longer":"Make longer","Make all text elements longer.":"Make all text elements longer.","Make shorter":"Make shorter","Make all text elements shorter.":"Make all text elements shorter.","Add emojis":"Add emojis","Add emojis to text elements if relevant.":"Add emojis to text elements if relevant.",Randomize:Ey,"Randomize all text elements.":"Randomize all text elements.","Edit Block":"Edit Block","AI Assistant":"AI Assistant","Theme Config":{"Heading Font":"Heading Font","Body Font":"Body Font","Rounded Corner":"Rounded Corners",Primary:"Primary",Secondary:"Secondary",Background:"Background","Text Color":"Text Color","Background Dark Mode":"Background (Dark Mode)","Text Color Dark Mode":"Text Color (Dark Mode)","Reset styles":"Reset styles"},"Copy classes to clipboard":"Copy classes to clipboard","Classes copied to clipboard":"Classes copied to clipboard",Classes:Ay,All:_y,"Enter classes separated by space":"Add classes or design tokens (space-separated)","Show hidden blocks":"Show hidden blocks","Expand all":"Expand all","Collapse all":"Collapse all","Choose library":"Choose library","Close Preview":"Close Preview",Error:"Error","Failed to copy template":"Failed to copy template","Total tokens used":"Total tokens used","Updated AI Context":"Updated AI Context","You can now Ask AI to edit your content":"You can now Ask AI to edit your content","Tell about this page eg this page is about":"Tell about this page eg this page is about..","Delete Context":"Delete Context","Keyboard shortcuts":"Keyboard shortcuts",Undo:Iy,Redo:Ty,Duplicate:By,"Deselect blocks":"Deselect blocks","Delete block":"Delete block","Save page":"Save page","Scripts will be only executed in preview and live mode.":"Scripts will be only executed in preview and live mode.","HTML Code Editor |":"HTML Code Editor |",Close:Ry,"Coming soon":"Coming soon",Selected:Py,Select:Ly,"Choose Builder Layout":"Choose Builder Layout","Single side panel":"Single side panel","Suitable for smaller screens. Bigger canvas size.":"Suitable for smaller screens. Bigger canvas size.","Dual side panel":"Dual side panel","Suitable for larger screens. Smaller canvas size.":"Suitable for larger screens. Smaller canvas size.","Dual side panel advanced":"Dual side panel advanced","Suitable for heavy styling & block editing. Setting are always visible.":"Suitable for heavy styling & block editing. Setting are always visible.","Block Settings":"Block Settings","Visibility settings":"Visibility settings","Show on canvas":"Show on canvas",Attributes:My,"Apply Presets":"Apply Presets",apply:Dy,presets:Oy,"Global presets":"Global presets",Orientation:Fy,Color:$y,"Please select an image":"Please select an image","click to upload":"click to upload","SVG, PNG, JPG or GIF (Max. 2mb)":"SVG, PNG, JPG or GIF (Max. 2mb)","Uploading...":"Uploading...",Upload:zy,"Something went wrong":"Something went wrong","Fetching...":"Fetching...","No images found":"No images found","It looks like you haven't uploaded any images yet. Start by clicking the upload button above.":"It looks like you haven't uploaded any images yet. Start by clicking the upload button above.","Open Code Editor":"Open Code Editor","Clear search":"Clear search","No results found for":"No results found for","Search {{pageTypeName}}":"Search {{pageTypeName}}","Goto Page":"Goto Page","Open URL":"Open URL","Compose Email":"Compose Email","Call Phone":"Call Phone","Scroll to element":"Scroll to element","#ElementID":"#ElementID","Enter details":"Enter details","Open in new tab":"Open in new tab",Apply:Hy,Back:Vy,Insert:Wy,Rename:Uy,"Unlink from library":"Unlink from library","Save to Library":"Save to Library","No blocks found in this group":"No blocks found in this group","No blocks found matching":"No blocks found matching","No matching blocks found":"No matching blocks found","Search blocks...":"Search blocks...",Partials:Gy,Happy:qy,Sad:Ky,"Importing...":"Importing...","Failed to load the UI library. Try again":"Failed to load the UI library. Try again",Retry:Yy,"Oops! Something went wrong.":"Oops! Something went wrong.","Please try again.":"Please try again.","No option found.":"No option found.","Clipboard not supported":"Clipboard not supported","Are you sure you want to clear the page?":"Are you sure you want to clear the page?",canvas_empty:Xy,Presets:Jy,"Reset style":"Reset style","Reset styles":"Reset styles","Clear styles":"Clear styles","Open code editor":"Open code editor","Style element":"Style element","Repeater Data":"Repeater Data","Toggle Data Binding":"Toggle Data Binding",No:Zy,Saving:Qy,"Screen sizes":"Screen sizes","Theme Settings":"Theme Settings","Import CSS Theme":"Import CSS Theme","Import theme":"Import theme","Import Theme":"Import Theme","CSS Variables":"CSS Variables","You don't have permission to edit settings or styles":"You don't have permission to edit settings or styles","Please contact your administrator to get access":"Please contact your administrator to get access","flex.heading":"Flex Child","flex.basis":"Basis","flex.order":"Order","flex.flex":"Flex","flex.grow":"Grow","flex.shrink":"Shrink","grid.heading":"Grid Child","grid.col_span":"Col Span","grid.col_start":"Col Start","grid.col_end":"Col End","grid.row_span":"Row Span","grid.row_start":"Row Start","grid.row_end":"Row End","grid.order":"Order","layout.heading":"Layout","layout.width":"Width","layout.height":"Height","layout.margin":"Margin","layout.margin_all":"All","layout.margin_lr":"Left-Right","layout.margin_tb":"Top-Bottom","layout.margin_top":"Top","layout.margin_right":"Right","layout.margin_bottom":"Bottom","layout.margin_left":"Left","layout.padding":"Padding","layout.padding_all":"All","layout.padding_lr":"Left-Right","layout.padding_tb":"Top-Bottom","layout.padding_top":"Top","layout.padding_right":"Right","layout.padding_bottom":"Bottom","layout.padding_left":"Left","layout.space_bt":"Space Bt.","layout.space_lr":"Left-Right","layout.space_tb":"Top-Bottom","size.heading":"Size","size.min_width_height":"Min width & height","size.min_width":"Min Width","size.min_height":"Min Height","size.max_width_height":"Max width & height","size.max_width":"Max Width","size.max_height":"Max Height","size.object_options_aspect_ratio":"Object options & aspect ratio","size.aspect":"Aspect","size.fit":"Fit","size.position":"Position","display.heading":"Display","display.display":"Display","display.flex_options":"Flex options","display.flex_direction":"Direction","display.flex_wrap":"Wrap","display.justify_content":"Justify","display.align_content":"Content","display.align_items":"Items","display.gap":"Gap","display.gap_all":"All","display.gap_lr":"Left-Right","display.gap_tb":"Top-Bottom","display.grid_options":"Grid options","display.grid_columns":"Columns","display.grid_rows":"Rows","display.grid_auto_flow":"Auto Flow","display.grid_auto_cols":"Auto Cols","display.grid_auto_rows":"Auto Rows","display.visibility_opacity":"Visibility & Opacity","display.visibility":"Visibility","display.opacity":"Opacity","position.heading":"Position","position.position":"Position","position.options":"Position options","position.direction":"Direction","position.top":"Top","position.right":"Right","position.bottom":"Bottom","position.left":"Left","position.inset":"Inset","position.all":"All","position.lr":"Left Right","position.tb":"Top Bottom","position.z_index":"Z-Index","position.float_clear":"Float & Clear","position.float":"Float","position.clear":"Clear","position.overflow_overscroll":"Overflow & Overscroll","position.overflow":"Overflow","position.overscroll":"Overscroll","typography.heading":"Typography","typography.font":"Font","typography.size":"Size","typography.height":"Height","typography.weight":"Weight","typography.color":"Color","typography.alignments":"Alignments","typography.align":"Align","typography.valign":"V. Align","typography.spacing_decoration_more":"Spacing, decoration & more","typography.spacing":"Spacing","typography.decoration":"Decoration","typography.thickness":"Thickness","typography.transform":"Transform","typography.whitespace_breaks":"White space & breaks","typography.whitespace":"Whitespace","typography.wordbreak":"Wordbreak","background.heading":"Background","background.bgcolor":"Bg. Color","background.position_size_more":"Position, Size & more","background.attachment":"Attachment","background.clipping":"Clipping","background.origin":"Origin","background.position":"Position","background.repeat":"Repeat","background.size":"Size","background.gradient":"Gradient","background.gradient_colors":"Gradient colors","background.from_color":"From","background.via_color":"Via","background.to_color":"To","border.heading":"Border & Outline","border.width":"Width","border.all":"All","border.lr":"Left Right","border.tb":"Top bottom","border.top":"Top","border.right":"Right","border.bottom":"Bottom","border.left":"Left","border.corners":"Corners","border.top_left":"Top Left","border.top_right":"Top right","border.bottom_right":"Bottom right","border.bottom_left":"Bottom left","border.color":"Color","border.style":"Style","border.divide_options":"Divide options","border.divide_color":"Color","border.divide_style":"Style","border.outline_styling":"Outline styling","border.outline_width":"Width","border.outline_offset":"Offset","border.outline_style":"Style","border.ring_options":"Ring options","border.ring_width":"Width","border.ring_color":"Color","border.ring_offset_width":"Offset","border.ring_offset_color":"Off. color","effect.heading":"Effect & Animation","effect.shadow":"Shadow","effect.color":"Color","effect.cursor":"Cursor","effect.blend_cursor":"Blend & Cursor","effect.mix_blend":"Mix Blend","effect.bg_blend":"Bg. Blend","effect.transform":"Transform","effect.origin":"Origin","effect.scale":"Scale","effect.all":"All","effect.lr":"Left-Right","effect.tb":"Top-Bottom","effect.skew":"Skew","effect.translate":"Translate","effect.rotate":"Rotate","effect.animation":"Animation","effect.transition":"Transition","effect.easing":"Easing","effect.duration":"Duration","effect.delay":"Delay","classes.heading":"Classes",theme_config:e0,web_blocks:t0,"Export Code":"Export Code","Exporting {{count}} blocks":"Exporting {{count}} blocks","Exporting all blocks":"Exporting all blocks","Export code copied!":"Export code copied!","Failed to copy export code":"Failed to copy export code","Export code downloaded successfully!":"Export code downloaded successfully!","Failed to generate export HTML":"Failed to generate export HTML","Enter value":"Enter value","Attribute keys cannot start with @":"Attribute keys cannot start with @","Enter key":"Enter key",Add:n0,Save:s0,Screen:r0};xt.use(F.initReactI18next).init({resources:{en:{translation:o0}},lng:"en",fallbackLng:"en",interpolation:{escapeValue:!1}});function i0(t,e,n){n.push(u.find(t,{_id:e}));const s=u.filter(t,{_parent:e});for(const r of s)n.push(...Jc(r._id,t));return n}const Jc=(t,e)=>{let n=[];return n=u.flattenDeep([...n,...i0(e,t,n)]),n},a0=(t,e,n)=>u.compact(t.map(s=>{const r=["_id","_type","_parent"],o=u.pick(s,r),a=J.getRegisteredChaiBlock(s._type),l={},c=u.get(a,"aiProps",[]);for(const d in s)if(!r.includes(d)&&c.includes(d)){const p=u.get(s,`${d}-${e}`,""),f=u.get(s,d,"");l[d]=u.isString(p)&&p.trim()||f,n&&(l[d]=f)}return u.isEmpty(l)?!1:(u.has(o,"_parent")&&u.isEmpty(o._parent)&&delete o._parent,{...o,...l})})),l0=(t,e,n)=>!e||n!=="content"?t:`${t}. Generate content in ${u.get(Qt,e,e)} language.`,c0=S.atom(!1),Zc=()=>{const[t,e]=S.useAtom(c0),[n,s]=g.useState(null),r=O("askAiCallBack",null),o=Ca(),a=Eu(),[l]=te(),{selectedLang:c,fallbackLang:d}=Le(),p=c.length?c:d,f=(m,h)=>{const b=u.cloneDeep(h.find(x=>x._id===m));for(const x in b){const y=b[x];if(typeof y=="string"&&u.startsWith(y,$.STYLES_KEY)){const{baseClasses:k,classes:w}=$.getSplitChaiClasses(y);b[x]=u.compact(u.flattenDeep([k,w])).join(" ")}else x!=="_id"&&delete b[x]}return b};return{askAi:g.useCallback(async(m,h,b,x)=>{if(r){e(!0),s(null);try{const y=c===d?"":c,k=b.toLowerCase().includes("translate the content"),w=m==="content"?a0(u.cloneDeep(Jc(h,l)),c,k):[f(h,l)],E=await r(m,l0(b,p,m),w,y),{blocks:A,error:_}=E;if(_){s(_);return}if(m==="styles"){const I=A.map(j=>{for(const N in j)N!=="_id"&&(j[N]=`${$.STYLES_KEY},${j[N]}`);return j});a(I)}else o(A);x&&x(E)}catch(y){s(y)}finally{e(!1),x&&x()}}},[r,e,c,d,l,p,a,o]),loading:t,error:n}};function d0({onClick:t}){const{loading:e}=Zc(),{t:n}=F.useTranslation(),{selectedLang:s,fallbackLang:r}=Le(),a=[...[{name:n("Improve writing"),icon:v.Pencil2Icon,prompt:n("Improving writing in all text elements. Replacing placeholder content with meaningful relevant content.")},{name:n("Replace placeholder content"),icon:v.LoopIcon,prompt:n("Discard current placeholder content and replace with meaningful relevant content.")},{name:n("Fix grammar"),icon:v.CheckIcon,prompt:n("Fix grammar in all text elements. Ensuring the text is grammatically correct and free of errors.")},{name:n("Make longer"),icon:v.ArrowUpIcon,prompt:n("Make all text elements longer.")},{name:n("Make shorter"),icon:v.ArrowDownIcon,prompt:n("Make all text elements shorter.")},{name:n("Add emojis"),icon:v.FaceIcon,prompt:n("Add emojis to text elements if relevant.")},{name:n("Randomize"),icon:v.ShuffleIcon,prompt:n("Randomize all text elements.")}]];return s&&s!==r&&a.splice(0,0,{name:n("Translate to {{lang}}",{lang:u.get(Qt,s,s)}),icon:v.ChatBubbleIcon,prompt:n("Translate the content to {{lang}}. Maintain same tone, style and length.",{lang:u.get(Qt,s,s)})}),i.jsx("div",{className:e?"pointer-events-none opacity-50":"",children:i.jsx("ul",{className:"space-y-1",children:a.map(({name:l,icon:c,subMenus:d,prompt:p})=>d?i.jsxs(Oo,{children:[i.jsx(Fo,{asChild:!0,children:i.jsxs("li",{className:"flex cursor-pointer items-center space-x-2 rounded p-1 pl-2 text-sm hover:bg-gray-100 dark:hover:bg-gray-800",children:[i.jsx(c,{className:"h-4 w-4"}),i.jsx("span",{children:l})]},l)}),i.jsx(zs,{side:"right",children:i.jsx("ul",{children:i.jsx("li",{children:n("Happy")})})})]}):i.jsxs("li",{onClick:()=>t(p),className:"flex cursor-pointer items-center space-x-2 rounded p-1 text-xs hover:bg-primary/10 hover:text-primary dark:hover:bg-gray-800",children:[i.jsx(c,{className:"h-3.5 w-3.5"}),i.jsx("span",{children:n(l)})]},l))})})}const Qc=({blockId:t})=>{const{t:e}=F.useTranslation(),{askAi:n,loading:s,error:r}=Zc(),[o,a]=g.useState(""),l=g.useRef(null),c=g.useRef(null),d=Z();g.useEffect(()=>{var f;(f=l.current)==null||f.focus()},[]);const p=()=>{r||a("")};return i.jsx("div",{className:"",children:t?i.jsxs("div",{className:"",children:[i.jsx("label",{className:"text-xs font-medium text-gray-500",children:e("Selected block")}),d&&i.jsxs("div",{className:"flex items-center gap-x-1 rounded border border-primary/20 bg-primary/10 p-1.5 text-xs text-primary",children:[i.jsx(ni,{type:d._type})," ",i.jsx("p",{className:"truncate whitespace-nowrap leading-none",children:d._name||d._type})]}),i.jsx("br",{}),i.jsx("label",{className:"text-xs font-medium text-gray-500",children:e("Quick actions")}),i.jsx("div",{className:"rounded border p-2 text-sm",children:i.jsx(d0,{onClick:f=>{c.current&&clearTimeout(c.current),n("content",t,f,p)}})}),i.jsx("br",{}),i.jsx("label",{className:"text-xs font-medium text-gray-500",children:e("Ask AI")}),i.jsxs("div",{className:"rounded border p-2 text-xs focus-within:border-gray-300",children:[i.jsx(Vn,{ref:l,value:o,onChange:f=>a(f.target.value),placeholder:e("Ask AI to edit content"),className:"w-full resize-none border-none p-0 text-xs shadow-none outline-none",rows:3,onKeyDown:f=>{f.key==="Enter"&&(f.preventDefault(),c.current&&clearTimeout(c.current),n("content",t,o,p))}}),i.jsxs("div",{className:"flex items-center justify-end",children:[s&&i.jsx(q,{variant:"destructive",onClick:()=>stop(),className:"hidden h-4 w-4",size:"icon",children:i.jsx(v.StopIcon,{className:"h-4 w-4"})}),i.jsx(q,{onClick:()=>{c.current&&clearTimeout(c.current),n("content",t,o,p)},variant:"default",className:"h-7 w-7",disabled:s||o.trim().length<1,size:"icon",children:s?i.jsx(v.ReloadIcon,{className:"h-4 w-4 animate-spin"}):i.jsx(v.ArrowTopRightIcon,{className:"h-4 w-4"})})]})]}),i.jsx("div",{className:"max-w-full pt-2",children:r&&i.jsx("p",{className:"break-words rounded border border-red-500 bg-red-100 p-1 text-xs text-red-500",children:r.message})})]}):i.jsx("div",{className:"p-4 text-center",children:i.jsxs("div",{className:"space-y-4 rounded-xl p-4 text-muted-foreground",children:[i.jsx(zr,{className:"mx-auto h-7 w-7 text-muted-foreground"}),i.jsx("h1",{children:e("Please select a block to Ask AI")})]})})})},ed=()=>{const[t]=K();return i.jsx("div",{className:"no-scrollbar mt-2 flex-1 overflow-y-auto",children:i.jsx(Qc,{blockId:u.first(t)})})};function td(){const[t,e]=Dn();return i.jsxs("div",{className:"flex items-center",children:[t?i.jsx(v.MoonIcon,{className:"size-4 shrink-0"}):i.jsx(v.SunIcon,{className:"size-4 shrink-0"}),i.jsx(dn,{id:"dark-mode-switch",checked:t,onCheckedChange:()=>{e(!t)},className:`${t?"bg-violet-600":"bg-violet-300"} relative ml-2 inline-flex h-[20px] w-[32px] shrink-0 cursor-pointer rounded-full border-2 border-transparent transition-colors duration-200 ease-in-out focus:outline-none focus-visible:ring-2 focus-visible:ring-white focus-visible:ring-opacity-75`,children:i.jsx("span",{"aria-hidden":"true",className:`${t?"translate-x-5":"translate-x-0"} pointer-events-none -mt-px inline-block h-[18px] w-[20px] transform rounded-full bg-white shadow-lg ring-0 transition duration-200 ease-in-out`})})]})}const nd=()=>{const{hasUndo:t,hasRedo:e,undo:n,redo:s}=Pn();return i.jsxs("div",{className:"flex items-center",children:[i.jsx(q,{disabled:!t(),size:"sm",onClick:n,className:"rounded-full",variant:"ghost",children:i.jsx(v.ResetIcon,{})}),i.jsx(q,{disabled:!e(),onClick:s,size:"sm",className:"rounded-full",variant:"ghost",children:i.jsx(v.ResetIcon,{className:"rotate-180 scale-y-[-1] transform"})})]})},sd=ie.Root,u0=ie.Trigger,p0=ie.Portal,rd=M.forwardRef(({className:t,...e},n)=>i.jsx(ie.Overlay,{className:L("fixed inset-0 z-50 bg-black/80 data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0",t),...e,ref:n}));rd.displayName=ie.Overlay.displayName;const f0=_n.cva("fixed z-50 gap-4 bg-background p-6 shadow-lg transition ease-in-out data-[state=closed]:duration-300 data-[state=open]:duration-500 data-[state=open]:animate-in data-[state=closed]:animate-out",{variants:{side:{top:"inset-x-0 top-0 border-b data-[state=closed]:slide-out-to-top data-[state=open]:slide-in-from-top",bottom:"inset-x-0 bottom-0 border-t data-[state=closed]:slide-out-to-bottom data-[state=open]:slide-in-from-bottom",left:"inset-y-0 left-0 h-full w-3/4 border-r data-[state=closed]:slide-out-to-left data-[state=open]:slide-in-from-left sm:max-w-sm",right:"inset-y-0 right-0 h-full w-3/4 border-l data-[state=closed]:slide-out-to-right data-[state=open]:slide-in-from-right sm:max-w-sm"}},defaultVariants:{side:"right"}}),li=M.forwardRef(({side:t="right",className:e,children:n,...s},r)=>i.jsxs(p0,{children:[i.jsx(rd,{}),i.jsxs(ie.Content,{ref:r,className:L(f0({side:t}),e),...s,children:[i.jsxs(ie.Close,{className:"absolute right-4 top-4 rounded-sm opacity-70 ring-offset-background transition-opacity hover:opacity-100 focus:outline-none focus:ring-2 focus:ring-ring focus:ring-offset-2 disabled:pointer-events-none data-[state=open]:bg-secondary",children:[i.jsx(v.Cross1Icon,{className:"h-4 w-4"}),i.jsx("span",{className:"sr-only",children:"Close"})]}),n]})]}));li.displayName=ie.Content.displayName;const ci=({className:t,...e})=>i.jsx("div",{className:L("flex flex-col space-y-2 text-center sm:text-left",t),...e});ci.displayName="SheetHeader";const di=M.forwardRef(({className:t,...e},n)=>i.jsx(ie.Title,{ref:n,className:L("text-lg font-semibold text-foreground",t),...e}));di.displayName=ie.Title.displayName;const od=M.forwardRef(({className:t,...e},n)=>i.jsx(ie.Description,{ref:n,className:L("text-sm text-muted-foreground",t),...e}));od.displayName=ie.Description.displayName;const h0=()=>{const[t]=Ql();return i.jsxs("div",{className:"flex w-12 cursor-not-allowed items-center justify-center gap-x-1 space-x-0 font-medium text-gray-400",children:[i.jsx(v.ZoomInIcon,{className:"h-3.5 w-3.5 flex-shrink-0"})," ",i.jsxs("div",{className:"text-xs leading-3",children:[u.round(t,0),"%"]})]})},m0=()=>{const{hasErrors:t,hasWarnings:e,errorCount:n,warningCount:s,errors:r}=Gc(),[,o]=K(),{t:a}=F.useTranslation();if(!t&&!e)return null;const l=()=>t?"text-red-500":e?"text-orange-500":"text-gray-500",c=()=>t?i.jsx(v.ExclamationTriangleIcon,{className:"h-4 w-4"}):e?i.jsx(v.InfoCircledIcon,{className:"h-4 w-4"}):null,d=()=>t&&e?`${n} error${n>1?"s":""}, ${s} warning${s>1?"s":""}`:t?`${n} error${n>1?"s":""}`:e?`${s} warning${s>1?"s":""}`:"";return i.jsxs(Qe,{children:[i.jsx(et,{asChild:!0,children:i.jsxs("div",{className:`ml-2 flex cursor-pointer items-center gap-2 ${l()}`,children:[c(),i.jsx("span",{className:"text-xs font-medium",children:d()})]})}),i.jsx(Ue,{side:"bottom",className:"max-w-xs p-2",align:"end",children:i.jsxs("div",{className:"space-y-2",children:[i.jsx("h4",{className:"text-sm font-semibold",children:a("Invalid structure")}),r.length===0?i.jsx("p",{className:"text-xs",children:a("No validation issues found.")}):i.jsxs("div",{className:"space-y-1",children:[r.slice(0,5).map(p=>i.jsxs("div",{onClick:()=>{p.blockId&&o([p.blockId])},className:`cursor-pointer rounded p-2 text-xs transition-opacity hover:opacity-80 ${p.severity==="error"?"border border-red-200 bg-red-50 text-red-700":"border border-orange-200 bg-orange-50 text-orange-700"}`,children:[i.jsx("div",{className:"font-medium",children:p.severity==="error"?"Error:":"Warning:"}),i.jsx("div",{children:p.message})]},p.id)),r.length>5&&i.jsxs("p",{className:"text-xs italic text-gray-500",children:["... and ",r.length-5," more issues"]})]})]})})]})},g0=()=>{const t=O("flags.darkMode",!0),e=O("flags.dataBinding",!0),[n,s]=S.useAtom(ao),{t:r}=F.useTranslation(),o=t,a=e;return i.jsxs("div",{className:"flex h-10 items-center justify-between border-b border-border bg-background/70 px-2 shadow-xl",children:[i.jsx("div",{className:"flex h-full space-x-2",children:o?i.jsx(td,{}):null}),i.jsxs("div",{className:"flex h-full items-center space-x-2",children:[i.jsx(Ko,{canvas:!0,openDelay:400}),i.jsx(Pt,{orientation:"vertical"}),i.jsx(h0,{}),i.jsx(Pt,{orientation:"vertical"}),i.jsx(nd,{})]}),i.jsxs("div",{className:"flex h-full items-center",children:[a?i.jsxs(Qe,{children:[i.jsx(et,{asChild:!0,children:i.jsx(q,{size:"sm",variant:"ghost",className:"h-7 w-7 rounded-md p-1",children:i.jsx(v.DotsHorizontalIcon,{className:"h-4 w-4"})})}),i.jsx(Ue,{className:"w-56 border-border text-xs",children:i.jsxs(de,{className:"flex items-center gap-2",onSelect:l=>l.preventDefault(),children:[i.jsx(v.LightningBoltIcon,{className:"h-4 w-4 text-gray-500"}),i.jsx("span",{className:"flex-1",children:r("Data Binding")}),i.jsx(dn,{checked:n,onCheckedChange:()=>s(!n)})]})})]}):null,i.jsx(m0,{}),i.jsx($c,{})]})]})},id=()=>{const{t}=F.useTranslation(),[e,n]=g.useState(""),[s,r]=g.useState(-1),[o,a]=g.useState(!1),l=Ye(),[,c]=Ls();return Yt(Y.OPEN_ADD_BLOCK,d=>{l?c("add-block"):(n(d?d._id:null),r(isNaN(d==null?void 0:d.position)?-1:d==null?void 0:d.position),a(!0))}),Yt(Y.CLOSE_ADD_BLOCK,()=>{n(""),r(-1),a(!1)}),i.jsx(si,{open:o,onOpenChange:()=>o?a(!1):"",children:i.jsxs(qs,{className:"max-w-5xl overflow-hidden border-border",children:[i.jsxs(Ks,{className:"flex flex-row items-center justify-between",children:[i.jsx(Ys,{className:"text-foreground",children:t("Add blocks")}),i.jsx("button",{onClick:()=>a(!1),className:"text-gray-500 hover:text-gray-600 dark:text-gray-400 dark:hover:text-gray-300",children:i.jsx(v.Cross2Icon,{className:"h-6 w-6"})})]}),i.jsx("div",{className:"no-scrollbar h-[500px] max-h-full overflow-hidden",children:i.jsx(ti,{parentId:e,position:s,showHeading:!1})})]})})},x0=g.memo(function({preloadedAttributes:e=[],onAttributesChange:n}){const[s,r]=g.useState([]),[o,a]=g.useState(""),[l,c]=g.useState(""),[d,p]=g.useState(null),[f,m]=g.useState(""),h=g.useRef(null),b=g.useRef(null),x=sn(),{t:y}=F.useTranslation();g.useEffect(()=>{r(e)},[e]);const k=()=>{if(o.startsWith("@")){m(y("Attribute keys cannot start with @"));return}if(o){const j=[...s,{key:o,value:l}];n(j),r(s),a(""),c(""),m("")}},w=j=>{const N=s.filter((C,T)=>T!==j);n(N),r(N)},E=j=>{p(j),a(s[j].key),c(s[j].value)},A=()=>{if(o.startsWith("@")){m(y("Attribute keys cannot start with @"));return}if(d!==null&&o){const j=[...s];j[d]={key:o,value:l},n(j),r(j),p(null),a(""),c(""),m("")}},_=j=>{j.key==="Enter"&&!j.shiftKey&&(j.preventDefault(),d!==null?A():k())},I=g.useCallback(j=>{const N=R=>/[.,!?;:]/.test(R),C=(R,B,U)=>{let z="",G="";const he=B>0?R[B-1]:"",ae=B<R.length?R[B]:"";return B>0&&(he==="."||!N(he)&&he!==" ")&&(z=" "),B<R.length&&!N(ae)&&ae!==" "&&(G=" "),{text:z+U+G,prefixLength:z.length,suffixLength:G.length}},T=b.current;if(T){const R=T.selectionStart||0,B=T.value||"",U=T.selectionEnd||R;if(U>R){const le=`{{${j}}}`,{text:Ae}=C(B,R,le),W=B.slice(0,R)+Ae+B.slice(U);c(W);return}const G=`{{${j}}}`,{text:he}=C(B,R,G),ae=B.slice(0,R)+he+B.slice(R);c(ae)}},[]);return i.jsxs("div",{className:"flex max-h-full flex-1 flex-col",children:[i.jsxs("form",{onSubmit:j=>{j.preventDefault(),d!==null?A():k()},className:"space-y-3",children:[i.jsxs("div",{className:"flex flex-col gap-y-1",children:[i.jsxs("div",{className:"w-full",children:[i.jsx(ut,{htmlFor:"attrKey",className:"text-[11px] font-normal leading-tight text-slate-600",children:y("Key")}),i.jsx(vt,{autoCapitalize:"off",autoCorrect:"off",spellCheck:"false",id:"attrKey",ref:h,value:o,onChange:j=>a(j.target.value),placeholder:y("Enter key"),className:"py-0 text-xs font-normal leading-tight placeholder:text-slate-400"})]}),i.jsxs("div",{className:"w-full",children:[i.jsxs("div",{className:"flex items-center justify-between",children:[i.jsx(ut,{htmlFor:"attrValue",className:"text-[11px] font-normal text-slate-600",children:y("Value")}),!u.isEmpty(x)&&i.jsx($o,{data:x,onSelect:I})]}),i.jsx(Vn,{autoCapitalize:"off",autoCorrect:"off",spellCheck:"false",id:"attrValue",ref:b,value:l,onChange:j=>c(j.target.value),onKeyDown:_,placeholder:y("Enter value"),className:"text-xs font-normal leading-tight placeholder:text-slate-400"})]})]}),i.jsx("div",{className:"flex justify-end",children:i.jsx(q,{type:"submit",disabled:!o.length,variant:"default",size:"sm",className:"h-8 w-24 text-xs",children:y(d!==null?"Save":"Add")})}),f&&i.jsx("p",{className:"text-xs text-red-500",children:f})]}),i.jsx("div",{className:"space-y-1 py-4",children:s.map((j,N)=>i.jsxs("div",{className:"flex items-center justify-between rounded border p-2 text-sm",children:[i.jsxs("div",{className:"flex flex-col text-xs leading-tight",children:[i.jsx("span",{className:"truncate text-[12px] font-light text-muted-foreground",children:j.key}),i.jsx("span",{className:"max-w-[200px] text-wrap font-normal",children:j.value.toString()})]}),i.jsxs("div",{className:"flex-shrink-0 text-slate-400",children:[i.jsx(q,{variant:"ghost",size:"icon",className:"h-6 w-6",onClick:()=>E(N),children:i.jsx(v.Pencil2Icon,{className:"h-3 w-3"})}),i.jsx(q,{variant:"ghost",size:"icon",className:"h-6 w-6",onClick:()=>w(N),children:i.jsx(v.Cross1Icon,{className:"h-3 w-3"})})]})]},N))})]})}),ad=M.memo(()=>{const t=Z(),[e,n]=g.useState([]),[s]=Ee(),r=tt(),o=`${u.get(s,"0.prop")}_attrs`;M.useEffect(()=>{const l=u.map(u.get(t,o),(c,d)=>({key:d,value:c}));u.isEmpty(l)?n([]):n(l)},[u.get(t,o)]);const a=M.useCallback((l=[])=>{const c={};u.forEach(l,d=>{u.isEmpty(d.key)||u.set(c,d.key,d.value)}),r([u.get(t,"_id")],{[o]:c})},[t,r,o]);return i.jsx("div",{className:"flex-col gap-y-2",children:i.jsx("div",{className:"flex flex-col",children:i.jsx("div",{children:i.jsx(x0,{preloadedAttributes:e,onAttributesChange:a})})})})}),Ut=()=>null,ea=()=>{const{resetAll:t}=pc(),e=Z(),[n]=Ee(),s=Gg(),{t:r}=F.useTranslation();return!e||u.isEmpty(n)?null:i.jsxs(Qe,{children:[i.jsx(et,{asChild:!0,children:i.jsx("div",{className:"inline-flex rounded-sm p-0.5 hover:bg-gray-300",onClick:o=>o.stopPropagation(),children:i.jsx(v.DotsVerticalIcon,{className:"h-3 w-3"})})}),i.jsxs(Ue,{side:"bottom",className:"border-border text-xs",children:[i.jsxs(de,{className:"flex items-center gap-1 text-xs",onClick:()=>{t()},children:[i.jsx(v.ResetIcon,{className:"h-3 w-3"}),r("Reset styles")]}),i.jsxs(de,{className:"text-xs",onClick:()=>{e&&s(e,!0)},children:[i.jsx(v.Cross2Icon,{className:"h-3 w-3"}),r("Clear styles")]})]})]})};function ta(){const{t}=F.useTranslation(),[e,n]=g.useState(!0),[s]=Ee();return u.isEmpty(s)?null:i.jsxs(i.Fragment,{children:[i.jsxs("div",{onClick:()=>n(!e),className:"flex cursor-pointer items-center justify-between border-t border-border py-3 text-xs font-medium hover:underline",children:[i.jsx("span",{children:t("Attributes")}),i.jsx("span",{children:i.jsx(v.ChevronDownIcon,{className:"h-4 w-4 text-gray-500 "+(e?"rotate-180":"")})})]}),e&&i.jsx(ad,{})]})}const b0=({partialBlockId:t})=>{const e=O("gotoPage",u.noop),{saveState:n}=Rn(),{selectedLang:s,fallbackLang:r}=Le(),o=g.useCallback(a=>{if(a.stopPropagation(),n!=="SAVED"){me.toast.error("You have unsaved changes. Please save the page first.");return}e({pageId:t,lang:s||r})},[n,e,t,s,r]);return i.jsx(i.Fragment,{children:i.jsx("div",{className:"hidden",children:i.jsx("div",{onDoubleClick:o,className:"h-full w-full items-center justify-center",children:i.jsx("p",{className:"rounded-md bg-white px-2 py-1 text-xs",children:"Partial block. Double click to edit."})})})})},y0=()=>{const t=Z(),{t:e}=F.useTranslation(),n=O("onError",u.noop),{hasPermission:s}=qe();let r=!s(ne.EDIT_BLOCK);const o=!s(ne.EDIT_STYLES),[a,l]=Aa();if(t&&t._type==="PartialBlock")return i.jsx(b0,{partialBlockId:t.partialBlockId});if(u.isNull(t))return i.jsx("div",{className:"p-4 text-center",children:i.jsxs("div",{className:"space-y-4 rounded-xl p-4 text-muted-foreground",children:[i.jsx(v.MixerHorizontalIcon,{className:"mx-auto text-3xl"}),i.jsx("h1",{children:e("Please select a block to edit settings or styles")})]})});if(r&&o)return i.jsx("div",{className:"p-4 text-center",children:i.jsxs("div",{className:"space-y-4 rounded-xl p-4 text-muted-foreground",children:[i.jsx(v.MixerHorizontalIcon,{className:"mx-auto text-3xl"}),i.jsx("h1",{children:e("You don't have permission to edit settings or styles")}),i.jsx("p",{children:e("Please contact your administrator to get access")})]})});if(o)return i.jsx(_t.ErrorBoundary,{fallback:i.jsx(kn,{}),onError:n,children:i.jsxs("div",{className:"no-scrollbar h-full max-h-min w-full overflow-y-auto",children:[i.jsx(Nr,{}),i.jsx("br",{}),i.jsx("br",{})]})});if(r)return i.jsx(_t.ErrorBoundary,{fallback:i.jsx(kn,{}),onError:n,children:i.jsxs("div",{className:"no-scrollbar h-full max-h-min w-full overflow-y-auto overflow-x-hidden",children:[i.jsx("div",{className:"flex w-full items-center justify-end",children:i.jsx(ea,{})}),i.jsx(Br,{}),i.jsx(ta,{}),i.jsx("br",{}),i.jsx("br",{}),i.jsx("br",{})]})});const d=p=>{(p==="settings"||p==="styles")&&l(p)};return i.jsx(_t.ErrorBoundary,{fallback:i.jsx(kn,{}),onError:n,children:i.jsxs(Us,{value:a,onValueChange:d,className:"flex flex-1 flex-col",children:[i.jsx("div",{className:"flex items-center justify-between",children:i.jsxs(Hn,{className:"grid h-auto w-full grid-cols-2 p-1 py-1",children:[i.jsx(He,{value:"settings",className:"text-xs",children:e("Settings")}),i.jsx(He,{value:"styles",className:"text-xs",children:i.jsxs("div",{className:"flex w-full items-center justify-between",children:[i.jsx("span",{className:"w-[90%] text-center",children:e("Styling")}),i.jsx("span",{className:"w-[10%]",children:i.jsx(ea,{})})]})})]})}),i.jsxs(lt,{value:"settings",className:"no-scrollbar h-full max-h-min overflow-y-auto",children:[i.jsx(Nr,{}),i.jsx("br",{}),i.jsx("br",{})]}),i.jsxs(lt,{value:"styles",className:"no-scrollbar h-full max-h-min max-w-full overflow-y-auto overflow-x-hidden",children:[i.jsx(Br,{}),i.jsx(ta,{}),i.jsx("br",{}),i.jsx("br",{}),i.jsx("br",{})]})]})})},ws={},Xs=(t,e)=>{u.has(ws,t)&&console.warn(`Panel ${t} already registered. Overriding...`),u.set(ws,t,{id:t,...e})},na=t=>g.useMemo(()=>u.filter(u.values(ws),e=>e.position===t),[t,ws]),v0=()=>i.jsx("div",{}),ld={component:v0},k0=t=>{ld.component=t},w0=()=>g.useMemo(()=>ld.component,[]),C0=g.lazy(()=>Promise.resolve().then(()=>require("./manage-design-tokens-ConiyuPr.cjs"))),gt=280,j0=({isActive:t,show:e})=>i.jsx(q,{variant:t?"default":"ghost",size:"icon",onClick:e,children:i.jsx(v.StackIcon,{className:"h-5 w-5"})}),S0=({isActive:t,show:e})=>Ye()&&i.jsx(q,{variant:t?"default":"ghost",size:"icon",onClick:e,children:i.jsx(v.PlusCircledIcon,{className:"h-5 w-5"})}),N0=({isActive:t,show:e})=>i.jsx(q,{variant:t?"default":"ghost",size:"icon",onClick:e,children:i.jsx(zr,{})});Xs("add-block",{button:S0,label:"Add Blocks",position:"top",isInternal:!0,width:gt,panel:()=>i.jsx(ti,{showHeading:!1,fromSidebar:!0,parentId:void 0,position:-1})});Xs("chai-chat-panel",{button:N0,label:"Ask AI",position:"top",isInternal:!0,width:gt,panel:()=>i.jsx("div",{className:"",children:i.jsx(ed,{})})});Xs("outline",{button:j0,label:"Outline",position:"top",isInternal:!0,width:gt,panel:()=>i.jsx("div",{className:"-mt-8",children:i.jsx(qc,{})})});const E0=()=>{const t=w0(),[e,n]=Ls(),s=g.useRef("outline"),[r,o]=g.useState(gt),[a,l]=so(),[,c]=Aa(),d=na("top"),p=na("bottom"),f=u.reverse([...p??[]]),m=g.useCallback(N=>{N.preventDefault()},[]),h=g.useMemo(()=>[d].flat(),[d]),b=g.useCallback(N=>{console.log("handleMenuItemClick",N,e),n(e===N?null:N)},[e,n]),{t:x}=F.useTranslation(),y=g.useMemo(()=>[...d,...p],[d,p]),k=O("htmlDir","ltr"),w=u.find(y,{id:e})??u.first(y),E=u.get(w,"width",gt);g.useEffect(()=>{if(e!==null){const N=u.find(y,{id:e});N&&u.get(N,"view","standard")==="standard"&&(s.current=e,o(u.get(N,"width",gt)))}},[e,y]);const A=g.useMemo(()=>{if(e===null)return 0;const N=u.find(y,{id:e});return u.get(N,"view","standard")==="standard"?E:r},[e,E,r,y]),_=g.useCallback(()=>{n(s.current)},[n,e]),I=g.useCallback(()=>{n("outline")},[n]);g.useEffect(()=>{e!==null&&!u.find(y,{id:e})&&n("outline")},[e,y]);const j=g.useCallback(N=>{b(N)},[b]);return i.jsx("div",{dir:k,className:"h-screen max-h-full w-screen overflow-x-hidden bg-background text-foreground",children:i.jsxs(vs,{children:[i.jsxs("div",{onContextMenu:m,className:"flex h-full max-h-full flex-col bg-background text-foreground",children:[i.jsx("div",{className:"flex h-[50px] w-screen items-center border-b border-border",children:i.jsx(g.Suspense,{children:i.jsx(t,{})})}),i.jsxs("main",{className:"relative flex h-[calc(100vh-56px)] max-w-full flex-1 flex-row",children:[i.jsxs("div",{id:"sidebar",className:"flex w-12 flex-col items-center justify-between border-r border-border py-2",children:[i.jsx("div",{className:"flex flex-col gap-y-1",children:h.map((N,C)=>i.jsxs(pe,{children:[i.jsx(fe,{asChild:!0,children:g.createElement(u.get(N,"button",Ut),{position:"top",panelId:N.id,isActive:e===N.id,show:()=>j(N.id)})}),i.jsx(ue,{side:"right",children:i.jsx("p",{children:x(N.label)})})]},"button-top-"+C))}),i.jsx("div",{className:"flex flex-col space-y-1"}),i.jsx("div",{className:"flex flex-col",children:f==null?void 0:f.map((N,C)=>i.jsxs(pe,{children:[i.jsx(fe,{asChild:!0,children:g.createElement(u.get(N,"button",Ut),{position:"bottom",panelId:N.id,isActive:e===N.id,show:()=>j(N.id)})}),i.jsx(ue,{side:"right",children:i.jsx("p",{children:x(N.label)})})]},"button-bottom-"+C))})]}),i.jsx(qn.motion.div,{id:"left-panel",className:"h-full max-h-full border-r border-border",initial:{width:A},animate:{width:A},transition:{duration:.3,ease:"easeInOut"},children:e!==null&&u.get(w,"view","standard")==="standard"&&i.jsxs("div",{className:"no-scrollbar flex h-full flex-col overflow-hidden px-3 py-2",children:[i.jsx("div",{className:`absolute top-2 flex h-10 items-center space-x-1 py-2 text-base font-bold ${u.get(w,"isInternal",!1)?"":"w-64"}`,children:i.jsx("span",{children:x(u.get(w,"label",""))})}),i.jsx("div",{className:"no-scrollbar h-full max-h-full overflow-y-auto pt-10",children:i.jsx(g.Suspense,{fallback:i.jsx("div",{children:"Loading..."}),children:g.createElement(u.get(w,"panel",Ut),{})})})]})}),i.jsxs("div",{id:"canvas-container",className:"flex h-full max-h-full flex-1 flex-col bg-slate-800/20",children:[i.jsx(g0,{}),i.jsx(g.Suspense,{children:i.jsx(nc,{})})]}),i.jsx(qn.motion.div,{id:"right-panel",className:"h-full max-h-full border-l border-border",initial:{width:e==="ai"?0:gt},animate:{width:e==="ai"?0:gt},transition:{duration:.3,ease:"easeInOut"},children:i.jsx("div",{className:"no-scrollbar overflow h-full max-h-full overflow-hidden",children:i.jsxs("div",{className:"flex h-full max-h-full flex-col overflow-hidden p-3",children:[i.jsx("h2",{className:"-mt-1 flex items-center space-x-1 text-base font-bold",children:i.jsx("div",{className:"flex grow items-center gap-2",children:i.jsx("div",{className:"flex w-full items-center justify-between gap-2",children:a==="ai"?i.jsx(i.Fragment,{children:i.jsxs("div",{className:"flex items-center gap-2",children:[i.jsx(v.LightningBoltIcon,{className:"rtl:ml-2"})," ",x("AI Assistant")]})}):a==="design-tokens"?i.jsxs("div",{className:"mb-1 flex w-full items-center justify-between gap-2",children:[i.jsxs("span",{className:"flex items-center gap-2",children:[i.jsx(Tr,{className:"h-4 w-4 text-gray-600"}),x("Design Tokens")]}),i.jsx(q,{onClick:()=>{c("styles"),l("block")},variant:"ghost",size:"icon",className:"text-xs",children:i.jsx(v.Cross1Icon,{className:"h-4 w-4 rtl:ml-2"})})]}):a==="theme"?i.jsxs("div",{className:"flex w-full items-center justify-between gap-2",children:[i.jsxs("span",{className:"flex items-center gap-2",children:[i.jsx(v.MixerHorizontalIcon,{className:"h-4 w-4 text-gray-600"}),x("Theme Settings")]}),i.jsx(q,{onClick:()=>l("block"),variant:"ghost",size:"icon",className:"text-xs",children:i.jsx(v.Cross1Icon,{className:"h-4 w-4 rtl:ml-2"})})]}):null})})}),i.jsx("div",{className:"flex h-full max-h-full w-full",children:i.jsx(g.Suspense,{fallback:i.jsx("div",{children:"Loading..."}),children:a==="ai"?i.jsx(ed,{}):a==="design-tokens"?i.jsx(g.Suspense,{fallback:i.jsx("div",{className:"h-1/2 w-full animate-pulse"}),children:i.jsx(C0,{})}):a==="theme"?i.jsx(Xc,{}):i.jsx(y0,{})})})]})})})]})]}),i.jsx(id,{}),e!==null&&u.get(w,"view")==="drawer"&&i.jsx(sd,{open:!0,onOpenChange:()=>_(),children:i.jsxs(li,{side:"left",className:"flex flex-col gap-0 p-0 sm:max-w-full",style:{width:`${E}px`},children:[i.jsx(ci,{className:"border-b border-border px-2 py-2.5",children:i.jsxs(di,{className:"flex items-center gap-2",children:[i.jsx("span",{className:"inline-block",children:u.get(w,"icon",null)}),i.jsx("span",{children:x(u.get(w,"label",""))})]})}),i.jsx("div",{className:"h-full max-h-full overflow-y-auto p-4",children:i.jsx(g.Suspense,{fallback:i.jsx("div",{children:"Loading..."}),children:g.createElement(u.get(w,"panel",Ut),{close:I})})})]})})," ",e!==null&&u.get(w,"view")==="modal"&&i.jsx(On,{open:!0,onOpenChange:()=>_(),children:i.jsxs(ln,{className:"gap-0 p-0",style:{maxWidth:`${E}px`},children:[i.jsx(Fn,{className:"border-b border-border px-2 py-3.5",children:i.jsxs(cn,{className:"flex items-center gap-2",children:[i.jsx("span",{className:"inline-block",children:u.get(w,"icon",null)}),i.jsx("span",{children:x(u.get(w,"label",""))})]})}),i.jsx("div",{className:"max-h-[70vh] overflow-y-auto p-4",children:i.jsx(g.Suspense,{fallback:i.jsx("div",{children:"Loading..."}),children:g.createElement(u.get(w,"panel",Ut),{close:I})})})]})}),e!==null&&u.get(w,"view")==="overlay"&&i.jsx(qn.motion.div,{className:"absolute bottom-0 left-12 right-0 top-0 z-50",initial:{opacity:0},animate:{opacity:1},exit:{opacity:0},transition:{duration:.3},children:i.jsx("div",{className:"h-full w-full",children:i.jsxs(qn.motion.div,{className:"flex h-full w-full flex-col bg-background",initial:{y:-20,opacity:0},animate:{y:0,opacity:1},exit:{y:20,opacity:0},transition:{duration:.3,delay:.1},children:[i.jsxs("div",{className:"flex h-[50px] items-center justify-between border-b border-border p-4",children:[i.jsxs("div",{className:"-ml-2 flex items-center gap-2 text-lg font-bold",children:[i.jsx("span",{className:"rtl:ml-2 rtl:inline-block",children:u.get(w,"icon",null)}),i.jsx("span",{children:x(u.get(w,"label",""))})]}),i.jsx(q,{onClick:()=>_(),variant:"ghost",size:"icon",className:"",children:i.jsx(v.Cross1Icon,{className:"h-5 w-5"})})]}),i.jsx("div",{className:"flex-1 overflow-y-auto p-4",children:i.jsx(g.Suspense,{fallback:i.jsx("div",{children:"Loading..."}),children:g.createElement(u.get(w,"panel",Ut),{close:I})})})]})})})]})})},A0=S.atom(!1),_0=()=>{const[t,e]=S.useAtom(A0);return[t,e]},I0=()=>{const[t,e]=_0(),{t:n}=F.useTranslation(),s=O("previewComponent",null);return t?i.jsxs("div",{className:ve.cn("fixed inset-0 z-[999] bg-background",t?"block":"hidden"),children:[i.jsxs(q,{size:"sm",className:"absolute right-0 top-0 m-4 space-x-2",onClick:()=>e(!1),children:[i.jsx(v.EyeClosedIcon,{}),i.jsx("span",{children:n("Close Preview")})]}),i.jsx("div",{children:s?i.jsx(g.Suspense,{fallback:i.jsx(Mt,{className:"h-96 w-full"}),children:g.createElement(s)}):null})]}):null},Pr={},T0=(t,e)=>{if(Pr[t])throw new Error(`Flag ${t} already exists`);Pr[t]={key:t,value:!1,...e}},B0=()=>Pr,cd=we.atomWithStorage("chai-feature-flags",[]),dd=t=>{const[e]=S.useAtom(cd);return e.includes(t)},R0=t=>{const[e,n]=S.useAtom(cd);return()=>{e.includes(t)?n(e.filter(r=>r!==t)):n([...e,t])}},P0=({featureKey:t,options:e})=>{const n=R0(t),s=dd(t);return i.jsxs("div",{className:"flex items-center space-x-3 rounded-md p-2 transition-colors hover:bg-gray-50 dark:hover:bg-gray-800",children:[i.jsx(dn,{checked:s,onCheckedChange:n}),i.jsxs("div",{className:"flex-1",children:[i.jsx("p",{className:"text-sm font-medium text-gray-900 dark:text-gray-100",children:e.key}),e.description&&i.jsx("p",{className:"mt-0.5 text-xs text-gray-500 dark:text-gray-400",children:e.description})]})]})},L0=we.atomWithStorage("show-feature-flag",null),M0=({close:t,position:e,updatePosition:n})=>{const s=B0(),[r,o]=g.useState(""),[a,l]=g.useState(!1),[c,d]=g.useState({x:0,y:0}),p=g.useMemo(()=>{if(!r.trim())return s;const b=r.toLowerCase();return Object.fromEntries(Object.entries(s).filter(([x,y])=>{var k;return(x==null?void 0:x.toLowerCase().includes(b))||((k=y==null?void 0:y.description)==null?void 0:k.toLowerCase().includes(b))}))},[s,r]),f=b=>{l(!0),d({x:b.clientX-e.x,y:b.clientY-e.y})},m=b=>{if(!a)return;const x=b.clientX-c.x,y=b.clientY-c.y,k=b.currentTarget,w=k.offsetWidth,E=k.offsetHeight,A=window.innerWidth-w,_=window.innerHeight-E,I=Math.max(0,Math.min(x,A)),j=Math.max(0,Math.min(y,_));n(I,j)},h=()=>{l(!1)};return g.useEffect(()=>{const b=()=>{a&&l(!1)};return window.addEventListener("mouseup",b),()=>window.removeEventListener("mouseup",b)},[a]),!e||e.x<0||e.y<0?null:i.jsxs("div",{onMouseDown:f,onMouseMove:m,onMouseUp:h,className:"fixed z-[9999999] select-none rounded-md border border-gray-300 bg-white p-3 shadow-2xl",style:{left:e.x,top:e.y,cursor:a?"grabbing":"grab",userSelect:"none"},children:[i.jsxs("div",{className:"relative sticky top-0 rounded-t-lg bg-white",children:[i.jsxs("div",{className:"mb-3 flex items-center justify-between",children:[i.jsxs("div",{children:[i.jsxs("h3",{className:"flex items-center gap-x-2 text-base font-semibold text-gray-900 dark:text-gray-100",children:[i.jsx(v.DragHandleDots2Icon,{})," Feature Flags"]}),i.jsxs("p",{className:"text-xs text-gray-400 dark:text-gray-400",children:["Toggle experimental features (",i.jsx("span",{className:"font-mono",children:"Ctrl+Shift+1"})," to toggle)"]})]}),i.jsx(q,{variant:"ghost",size:"sm",onClick:t,className:"absolute -right-2 -top-2 p-1 text-gray-500 hover:text-gray-700 dark:text-gray-400 dark:hover:text-gray-200",children:i.jsx(v.Cross1Icon,{className:"h-4 w-4"})})]}),i.jsxs("div",{className:"relative",children:[i.jsx(v.MagnifyingGlassIcon,{className:"absolute left-2.5 top-2.5 h-4 w-4 text-gray-400"}),i.jsx(vt,{type:"search",placeholder:"Search features...",className:"w-full pl-8",value:r,onChange:b=>o(b.target.value),autoFocus:!0})]})]}),i.jsx("div",{className:"max-h-96 overflow-y-auto py-2",children:Object.keys(p).length>0?i.jsx("div",{className:"space-y-1",children:Object.entries(p).map(([b,x])=>i.jsx(P0,{featureKey:b,options:x},b))}):i.jsx("div",{className:"py-8 text-center",children:i.jsxs("p",{className:"text-sm text-gray-500 dark:text-gray-400",children:['No features found matching "',r,'"']})})})]})},D0=()=>{const[t,e]=S.useAtom(L0);return Xe.useHotkeys("ctrl+shift+1,meta+shift+1",()=>e(n=>n?{...n,show:!n.show}:{x:0,y:0,show:!0}),{enableOnFormTags:!0}),t!=null&&t.show?i.jsx(M0,{position:t,close:()=>e(n=>({...n,show:!1})),updatePosition:(n,s)=>e(r=>({...r,x:n,y:s}))}):null},O0=t=>{},F0=()=>{const{clear:t}=Pn(),[,e]=K(),{clearHighlight:n}=nt(),[,s]=Ee(),[,r]=S.useAtom(Ta),{reset:o}=Ds(),{setSaveState:a}=Rn(),[,l]=ja(),[,c]=S.useAtom(Bs);return()=>{l({}),e([]),s([]),n(),t(),r(!1),o(),a("SAVED"),c(0)}},$0=(t,e)=>{const n=[];let s=u.find(t,{_id:e}),r=u.get(s,"_parent","");for(;u.isString(r)&&!u.isEmpty(r);)n.push(s==null?void 0:s._parent),s=u.find(t,{_id:r}),r=s==null?void 0:s._parent;return u.flatten(n)},z0=S.atom([]),H0=()=>{const[t]=K(),e=S.useAtomValue(Se),[,n]=S.useAtom(z0);g.useEffect(()=>{let s=[];const r=u.first(t);u.isString(r)&&(s=[r,...$0(e,r)]),n(s)},[t,e,n])},V0=["data-block-index","draggable","data-drop","data-style-id","data-block-parent","data-style-prop","data-highlighted"],W0=["Box","Button","Checkbox","Divider","EmptyBox","Form","FormButton","Heading","Image","Input","Label","LineBreak","Link","List","ListItem","Paragraph","Radio","RichText","Select","Span","Text","TextArea","Video"],ud=t=>t.type==="element"&&["script","style","link"].includes(t.tagName||"")||t.type==="comment"?null:t.type==="text"?t:t.type==="element"&&t.attributes&&t.attributes.find(e=>e.key==="id"&&e.value==="add-block-bottom")?null:(t.type==="element"&&t.attributes&&(t.attributes=t.attributes.filter(e=>!V0.includes(e.key))),t.children&&(t.children=t.children.map(ud).filter(e=>e!==null)),t),rs=(t,e,n={})=>{var o,a,l,c,d,p;if(t.type!=="element"||!t.attributes)return t;if(t.tagName==="span"&&t.attributes.find(m=>m.key==="role"&&m.value==="link")){t.tagName="a",t.attributes=t.attributes.filter(b=>b.key!=="role");const m=(o=t.attributes.find(b=>b.key==="data-block-id"))==null?void 0:o.value,h=e==null?void 0:e.find(b=>(b==null?void 0:b._id)===m);if(h!=null&&h.link&&((l=(a=h==null?void 0:h.link)==null?void 0:a.href)==null?void 0:l.length)>0){const b=(c=h==null?void 0:h.link)==null?void 0:c.href,x=(d=h==null?void 0:h.link)==null?void 0:d.target;t.attributes.push({key:"href",value:b}),typeof x=="string"&&x.length>0&&t.attributes.push({key:"target",value:x})}}const s=t.attributes.find(f=>f.key==="data-block-type"),r=t.attributes.find(f=>f.key==="data-block-id");if(s){const f=s.value;if(W0.includes(f)||(p=n==null?void 0:n.additionalCoreBlocks)!=null&&p.includes(f))t.attributes=t.attributes.filter(m=>m.key!=="data-block-type"),t.children&&(t.children=t.children.map(m=>rs(m,e,n)));else{const m=`chai-${u.kebabCase(f)}`;t.tagName=m,t.attributes=[],t.attributes.push({key:"chai-type",value:f});const h=J.getRegisteredChaiBlock(f),b=e.find(x=>x._id===(r==null?void 0:r.value));if(b&&t.attributes.push(...Object.entries(b).filter(([x])=>!["_id","_type","_parent","_index","_name"].includes(x)).map(([x,y])=>({key:x,value:typeof y=="string"?y:JSON.stringify(y)}))),h&&(h!=null&&h.description)&&t.attributes.push({key:"about-this-component",value:h.description}),h){if(h.canMove){const x=typeof h.canMove=="function"?h.canMove():h.canMove;t.attributes.push({key:"can-move",value:String(x)})}if(h.canDelete){const x=typeof h.canDelete=="function"?h.canDelete():h.canDelete;t.attributes.push({key:"can-delete",value:String(x)})}}f==="Icon"&&(t.attributes=t.attributes.filter(x=>x.key!=="icon")),h&&h.canAcceptBlock?t.children&&(t.children=t.children.map(x=>rs(x,e,n))):t.children=[]}}else t.children&&(t.children=t.children.map(f=>rs(f,e,n)));return r&&t.attributes.push({key:"bid",value:r.value}),t.attributes=t.attributes.filter(f=>f.key!=="data-block-type"&&f.key!=="data-block-id"),t},pd=()=>{const[t]=rn();return g.useCallback(e=>{var d,p;if(!t)return"";const n=e!=null&&e.blockId?`[data-block-id="${e.blockId}"]`:"#canvas",s=(p=(d=t.contentDocument)==null?void 0:d.querySelector(n))==null?void 0:p[n==="#canvas"?"innerHTML":"outerHTML"];if(!s)return"";const o=pi.parse(s).map(ud).filter(f=>f!==null),a=hu(),l=o.map(f=>rs(f,a,e));let c=pi.stringify(l);return c=c.replace(/#styles:,/g,"#styles:"),c.replace(/\s+/g," ").trim()},[t])};function sa(t){const e={class:"className",for:"htmlFor",tabindex:"tabIndex",readonly:"readOnly",maxlength:"maxLength",minlength:"minLength",autocomplete:"autoComplete",autofocus:"autoFocus",autoplay:"autoPlay",formaction:"formAction",formenctype:"formEncType",formmethod:"formMethod",formnovalidate:"formNoValidate",formtarget:"formTarget",novalidate:"noValidate",crossorigin:"crossOrigin",datetime:"dateTime",rowspan:"rowSpan",colspan:"colSpan",usemap:"useMap",frameborder:"frameBorder",allowfullscreen:"allowFullScreen"};if(e[t.toLowerCase()])return e[t.toLowerCase()];const n={"accent-height":"accentHeight","alignment-baseline":"alignmentBaseline","arabic-form":"arabicForm","baseline-shift":"baselineShift","cap-height":"capHeight","clip-path":"clipPath","clip-rule":"clipRule","color-interpolation":"colorInterpolation","color-interpolation-filters":"colorInterpolationFilters","color-profile":"colorProfile","color-rendering":"colorRendering","dominant-baseline":"dominantBaseline","enable-background":"enableBackground","fill-opacity":"fillOpacity","fill-rule":"fillRule","flood-color":"floodColor","flood-opacity":"floodOpacity","font-family":"fontFamily","font-size":"fontSize","font-size-adjust":"fontSizeAdjust","font-stretch":"fontStretch","font-style":"fontStyle","font-variant":"fontVariant","font-weight":"fontWeight","glyph-name":"glyphName","glyph-orientation-horizontal":"glyphOrientationHorizontal","glyph-orientation-vertical":"glyphOrientationVertical","horiz-adv-x":"horizAdvX","horiz-origin-x":"horizOriginX","image-rendering":"imageRendering","letter-spacing":"letterSpacing","lighting-color":"lightingColor","marker-end":"markerEnd","marker-mid":"markerMid","marker-start":"markerStart","overline-position":"overlinePosition","overline-thickness":"overlineThickness","paint-order":"paintOrder","panose-1":"panose1","pointer-events":"pointerEvents","rendering-intent":"renderingIntent","shape-rendering":"shapeRendering","stop-color":"stopColor","stop-opacity":"stopOpacity","strikethrough-position":"strikethroughPosition","strikethrough-thickness":"strikethroughThickness","stroke-dasharray":"strokeDasharray","stroke-dashoffset":"strokeDashoffset","stroke-linecap":"strokeLinecap","stroke-linejoin":"strokeLinejoin","stroke-miterlimit":"strokeMiterlimit","stroke-opacity":"strokeOpacity","stroke-width":"strokeWidth","text-anchor":"textAnchor","text-decoration":"textDecoration","text-rendering":"textRendering","underline-position":"underlinePosition","underline-thickness":"underlineThickness","unicode-bidi":"unicodeBidi","unicode-range":"unicodeRange","units-per-em":"unitsPerEm","v-alphabetic":"vAlphabetic","v-hanging":"vHanging","v-ideographic":"vIdeographic","v-mathematical":"vMathematical","vector-effect":"vectorEffect","vert-adv-y":"vertAdvY","vert-origin-x":"vertOriginX","vert-origin-y":"vertOriginY","word-spacing":"wordSpacing","writing-mode":"writingMode","x-height":"xHeight"};return n[t]?n[t]:t}function is(t,e=0){var d;if(Array.isArray(t)){if(t.length===0)return"";if(t.length===1)return is(t[0],e);const p=" ".repeat(e);let f=`${p}<>
135
+ `,textSerializers:a={}}=n||{};let l="";return t.nodesBetween(s,r,(c,d,p,f)=>{var m;c.isBlock&&d>s&&(l+=o);const h=a==null?void 0:a[c.type.name];if(h)return p&&(l+=h({node:c,pos:d,parent:p,index:f,range:e})),!1;c.isText&&(l+=(m=c==null?void 0:c.text)===null||m===void 0?void 0:m.slice(Math.max(s,d)-d,r-d))}),l}function Bh(t){return Object.fromEntries(Object.entries(t.nodes).filter(([,e])=>e.spec.toText).map(([e,n])=>[e,n.spec.toText]))}Ge.create({name:"clipboardTextSerializer",addOptions(){return{blockSeparator:void 0}},addProseMirrorPlugins(){return[new Ht({key:new Vt("clipboardTextSerializer"),props:{clipboardTextSerializer:()=>{const{editor:t}=this,{state:e,schema:n}=t,{doc:s,selection:r}=e,{ranges:o}=r,a=Math.min(...o.map(p=>p.$from.pos)),l=Math.max(...o.map(p=>p.$to.pos)),c=Bh(n);return Th(s,{from:a,to:l},{...this.options.blockSeparator!==void 0?{blockSeparator:this.options.blockSeparator}:{},textSerializers:c})}}})]}});const Rh=()=>({editor:t,view:e})=>(requestAnimationFrame(()=>{var n;t.isDestroyed||(e.dom.blur(),(n=window==null?void 0:window.getSelection())===null||n===void 0||n.removeAllRanges())}),!0),Ph=(t=!1)=>({commands:e})=>e.setContent("",t),Lh=()=>({state:t,tr:e,dispatch:n})=>{const{selection:s}=e,{ranges:r}=s;return n&&r.forEach(({$from:o,$to:a})=>{t.doc.nodesBetween(o.pos,a.pos,(l,c)=>{if(l.type.isText)return;const{doc:d,mapping:p}=e,f=d.resolve(p.map(c)),m=d.resolve(p.map(c+l.nodeSize)),h=f.blockRange(m);if(!h)return;const b=an(h);if(l.type.isTextblock){const{defaultType:x}=f.parent.contentMatchAt(f.index());e.setNodeMarkup(h.start,x)}(b||b===0)&&e.lift(h,b)})}),!0},Mh=t=>e=>t(e),Dh=()=>({state:t,dispatch:e})=>Ol(t,e),Oh=(t,e)=>({editor:n,tr:s})=>{const{state:r}=n,o=r.doc.slice(t.from,t.to);s.deleteRange(t.from,t.to);const a=s.mapping.map(e);return s.insert(a,o.content),s.setSelection(new oe(s.doc.resolve(Math.max(a-1,0)))),!0},Fh=()=>({tr:t,dispatch:e})=>{const{selection:n}=t,s=n.$anchor.node();if(s.content.size>0)return!1;const r=t.selection.$anchor;for(let o=r.depth;o>0;o-=1)if(r.node(o).type===s.type){if(e){const l=r.before(o),c=r.after(o);t.delete(l,c).scrollIntoView()}return!0}return!1},$h=t=>({tr:e,state:n,dispatch:s})=>{const r=Ie(t,n.schema),o=e.selection.$anchor;for(let a=o.depth;a>0;a-=1)if(o.node(a).type===r){if(s){const c=o.before(a),d=o.after(a);e.delete(c,d).scrollIntoView()}return!0}return!1},zh=t=>({tr:e,dispatch:n})=>{const{from:s,to:r}=t;return n&&e.delete(s,r),!0},Hh=()=>({state:t,dispatch:e})=>vo(t,e),Vh=()=>({commands:t})=>t.keyboardShortcut("Enter"),Wh=()=>({state:t,dispatch:e})=>uh(t,e);function gs(t,e,n={strict:!0}){const s=Object.keys(e);return s.length?s.every(r=>n.strict?e[r]===t[r]:_h(e[r])?e[r].test(t[r]):e[r]===t[r]):!0}function Wl(t,e,n={}){return t.find(s=>s.type===e&&gs(Object.fromEntries(Object.keys(n).map(r=>[r,s.attrs[r]])),n))}function Li(t,e,n={}){return!!Wl(t,e,n)}function Ul(t,e,n){var s;if(!t||!e)return;let r=t.parent.childAfter(t.parentOffset);if((!r.node||!r.node.marks.some(p=>p.type===e))&&(r=t.parent.childBefore(t.parentOffset)),!r.node||!r.node.marks.some(p=>p.type===e)||(n=n||((s=r.node.marks[0])===null||s===void 0?void 0:s.attrs),!Wl([...r.node.marks],e,n)))return;let a=r.index,l=t.start()+r.offset,c=a+1,d=l+r.node.nodeSize;for(;a>0&&Li([...t.parent.child(a-1).marks],e,n);)a-=1,l-=t.parent.child(a).nodeSize;for(;c<t.parent.childCount&&Li([...t.parent.child(c).marks],e,n);)d+=t.parent.child(c).nodeSize,c+=1;return{from:l,to:d}}function kt(t,e){if(typeof t=="string"){if(!e.marks[t])throw Error(`There is no mark type named '${t}'. Maybe you forgot to add the extension?`);return e.marks[t]}return t}const Uh=(t,e={})=>({tr:n,state:s,dispatch:r})=>{const o=kt(t,s.schema),{doc:a,selection:l}=n,{$from:c,from:d,to:p}=l;if(r){const f=Ul(c,o,e);if(f&&f.from<=d&&f.to>=p){const m=oe.create(a,f.from,f.to);n.setSelection(m)}}return!0},Gh=t=>e=>{const n=typeof t=="function"?t(e):t;for(let s=0;s<n.length;s+=1)if(n[s](e))return!0;return!1};function Gl(t){return t instanceof oe}function At(t=0,e=0,n=0){return Math.min(Math.max(t,e),n)}function qh(t,e=null){if(!e)return null;const n=X.atStart(t),s=X.atEnd(t);if(e==="start"||e===!0)return n;if(e==="end")return s;const r=n.from,o=s.to;return e==="all"?oe.create(t,At(0,r,o),At(t.content.size,r,o)):oe.create(t,At(e,r,o),At(e,r,o))}function Kh(){return navigator.platform==="Android"||/android/i.test(navigator.userAgent)}function So(){return["iPad Simulator","iPhone Simulator","iPod Simulator","iPad","iPhone","iPod"].includes(navigator.platform)||navigator.userAgent.includes("Mac")&&"ontouchend"in document}const Yh=(t=null,e={})=>({editor:n,view:s,tr:r,dispatch:o})=>{e={scrollIntoView:!0,...e};const a=()=>{(So()||Kh())&&s.dom.focus(),requestAnimationFrame(()=>{n.isDestroyed||(s.focus(),e!=null&&e.scrollIntoView&&n.commands.scrollIntoView())})};if(s.hasFocus()&&t===null||t===!1)return!0;if(o&&t===null&&!Gl(n.state.selection))return a(),!0;const l=qh(r.doc,t)||n.state.selection,c=n.state.selection.eq(l);return o&&(c||r.setSelection(l),c&&r.storedMarks&&r.setStoredMarks(r.storedMarks),a()),!0},Xh=(t,e)=>n=>t.every((s,r)=>e(s,{...n,index:r})),Jh=(t,e)=>({tr:n,commands:s})=>s.insertContentAt({from:n.selection.from,to:n.selection.to},t,e),ql=t=>{const e=t.childNodes;for(let n=e.length-1;n>=0;n-=1){const s=e[n];s.nodeType===3&&s.nodeValue&&/^(\n\s\s|\n)$/.test(s.nodeValue)?t.removeChild(s):s.nodeType===1&&ql(s)}return t};function Zn(t){const e=`<body>${t}</body>`,n=new window.DOMParser().parseFromString(e,"text/html").body;return ql(n)}function En(t,e,n){if(t instanceof Rt||t instanceof D)return t;n={slice:!0,parseOptions:{},...n};const s=typeof t=="object"&&t!==null,r=typeof t=="string";if(s)try{if(Array.isArray(t)&&t.length>0)return D.fromArray(t.map(l=>e.nodeFromJSON(l)));const a=e.nodeFromJSON(t);return n.errorOnInvalidContent&&a.check(),a}catch(o){if(n.errorOnInvalidContent)throw new Error("[tiptap error]: Invalid JSON content",{cause:o});return console.warn("[tiptap warn]: Invalid content.","Passed value:",t,"Error:",o),En("",e,n)}if(r){if(n.errorOnInvalidContent){let a=!1,l="";const c=new Vf({topNode:e.spec.topNode,marks:e.spec.marks,nodes:e.spec.nodes.append({__tiptap__private__unknown__catch__all__node:{content:"inline*",group:"block",parseDOM:[{tag:"*",getAttrs:d=>(a=!0,l=typeof d=="string"?d:d.outerHTML,null)}]}})});if(n.slice?Kt.fromSchema(c).parseSlice(Zn(t),n.parseOptions):Kt.fromSchema(c).parse(Zn(t),n.parseOptions),n.errorOnInvalidContent&&a)throw new Error("[tiptap error]: Invalid HTML content",{cause:new Error(`Invalid element found: ${l}`)})}const o=Kt.fromSchema(e);return n.slice?o.parseSlice(Zn(t),n.parseOptions).content:o.parse(Zn(t),n.parseOptions)}return En("",e,n)}function Zh(t,e,n){const s=t.steps.length-1;if(s<e)return;const r=t.steps[s];if(!(r instanceof $e||r instanceof Oe))return;const o=t.mapping.maps[s];let a=0;o.forEach((l,c,d,p)=>{a===0&&(a=p)}),t.setSelection(X.near(t.doc.resolve(a),n))}const Qh=t=>!("type"in t),em=(t,e,n)=>({tr:s,dispatch:r,editor:o})=>{var a;if(r){n={parseOptions:o.options.parseOptions,updateSelection:!0,applyInputRules:!1,applyPasteRules:!1,...n};let l;const c=y=>{o.emit("contentError",{editor:o,error:y,disableCollaboration:()=>{o.storage.collaboration&&(o.storage.collaboration.isDisabled=!0)}})},d={preserveWhitespace:"full",...n.parseOptions};if(!n.errorOnInvalidContent&&!o.options.enableContentCheck&&o.options.emitContentError)try{En(e,o.schema,{parseOptions:d,errorOnInvalidContent:!0})}catch(y){c(y)}try{l=En(e,o.schema,{parseOptions:d,errorOnInvalidContent:(a=n.errorOnInvalidContent)!==null&&a!==void 0?a:o.options.enableContentCheck})}catch(y){return c(y),!1}let{from:p,to:f}=typeof t=="number"?{from:t,to:t}:{from:t.from,to:t.to},m=!0,h=!0;if((Qh(l)?l:[l]).forEach(y=>{y.check(),m=m?y.isText&&y.marks.length===0:!1,h=h?y.isBlock:!1}),p===f&&h){const{parent:y}=s.doc.resolve(p);y.isTextblock&&!y.type.spec.code&&!y.childCount&&(p-=1,f+=1)}let x;if(m){if(Array.isArray(e))x=e.map(y=>y.text||"").join("");else if(e instanceof D){let y="";e.forEach(k=>{k.text&&(y+=k.text)}),x=y}else typeof e=="object"&&e&&e.text?x=e.text:x=e;s.insertText(x,p,f)}else x=l,s.replaceWith(p,f,x);n.updateSelection&&Zh(s,s.steps.length-1,-1),n.applyInputRules&&s.setMeta("applyInputRules",{from:p,text:x}),n.applyPasteRules&&s.setMeta("applyPasteRules",{from:p,text:x})}return!0},tm=()=>({state:t,dispatch:e})=>lh(t,e),nm=()=>({state:t,dispatch:e})=>ch(t,e),sm=()=>({state:t,dispatch:e})=>Tl(t,e),rm=()=>({state:t,dispatch:e})=>Ll(t,e),om=()=>({state:t,dispatch:e,tr:n})=>{try{const s=Os(t.doc,t.selection.$from.pos,-1);return s==null?!1:(n.join(s,2),e&&e(n),!0)}catch{return!1}},im=()=>({state:t,dispatch:e,tr:n})=>{try{const s=Os(t.doc,t.selection.$from.pos,1);return s==null?!1:(n.join(s,2),e&&e(n),!0)}catch{return!1}},am=()=>({state:t,dispatch:e})=>ih(t,e),lm=()=>({state:t,dispatch:e})=>ah(t,e);function Kl(){return typeof navigator<"u"?/Mac/.test(navigator.platform):!1}function cm(t){const e=t.split(/-(?!$)/);let n=e[e.length-1];n==="Space"&&(n=" ");let s,r,o,a;for(let l=0;l<e.length-1;l+=1){const c=e[l];if(/^(cmd|meta|m)$/i.test(c))a=!0;else if(/^a(lt)?$/i.test(c))s=!0;else if(/^(c|ctrl|control)$/i.test(c))r=!0;else if(/^s(hift)?$/i.test(c))o=!0;else if(/^mod$/i.test(c))So()||Kl()?a=!0:r=!0;else throw new Error(`Unrecognized modifier name: ${c}`)}return s&&(n=`Alt-${n}`),r&&(n=`Ctrl-${n}`),a&&(n=`Meta-${n}`),o&&(n=`Shift-${n}`),n}const dm=t=>({editor:e,view:n,tr:s,dispatch:r})=>{const o=cm(t).split(/-(?!$)/),a=o.find(d=>!["Alt","Ctrl","Meta","Shift"].includes(d)),l=new KeyboardEvent("keydown",{key:a==="Space"?" ":a,altKey:o.includes("Alt"),ctrlKey:o.includes("Ctrl"),metaKey:o.includes("Meta"),shiftKey:o.includes("Shift"),bubbles:!0,cancelable:!0}),c=e.captureTransaction(()=>{n.someProp("handleKeyDown",d=>d(n,l))});return c==null||c.steps.forEach(d=>{const p=d.map(s.mapping);p&&r&&s.maybeStep(p)}),!0};function No(t,e,n={}){const{from:s,to:r,empty:o}=t.selection,a=e?Ie(e,t.schema):null,l=[];t.doc.nodesBetween(s,r,(f,m)=>{if(f.isText)return;const h=Math.max(s,m),b=Math.min(r,m+f.nodeSize);l.push({node:f,from:h,to:b})});const c=r-s,d=l.filter(f=>a?a.name===f.node.type.name:!0).filter(f=>gs(f.node.attrs,n,{strict:!1}));return o?!!d.length:d.reduce((f,m)=>f+m.to-m.from,0)>=c}const um=(t,e={})=>({state:n,dispatch:s})=>{const r=Ie(t,n.schema);return No(n,r,e)?dh(n,s):!1},pm=()=>({state:t,dispatch:e})=>Fl(t,e),fm=t=>({state:e,dispatch:n})=>{const s=Ie(t,e.schema);return wh(s)(e,n)},hm=()=>({state:t,dispatch:e})=>Dl(t,e);function Yl(t,e){return e.nodes[t]?"node":e.marks[t]?"mark":null}function Mi(t,e){const n=typeof e=="string"?[e]:e;return Object.keys(t).reduce((s,r)=>(n.includes(r)||(s[r]=t[r]),s),{})}const mm=(t,e)=>({tr:n,state:s,dispatch:r})=>{let o=null,a=null;const l=Yl(typeof t=="string"?t:t.name,s.schema);return l?(l==="node"&&(o=Ie(t,s.schema)),l==="mark"&&(a=kt(t,s.schema)),r&&n.selection.ranges.forEach(c=>{s.doc.nodesBetween(c.$from.pos,c.$to.pos,(d,p)=>{o&&o===d.type&&n.setNodeMarkup(p,void 0,Mi(d.attrs,e)),a&&d.marks.length&&d.marks.forEach(f=>{a===f.type&&n.addMark(p,p+d.nodeSize,a.create(Mi(f.attrs,e)))})})}),!0):!1},gm=()=>({tr:t,dispatch:e})=>(e&&t.scrollIntoView(),!0),xm=()=>({tr:t,dispatch:e})=>{if(e){const n=new We(t.doc);t.setSelection(n)}return!0},bm=()=>({state:t,dispatch:e})=>Rl(t,e),ym=()=>({state:t,dispatch:e})=>Ml(t,e),vm=()=>({state:t,dispatch:e})=>hh(t,e),km=()=>({state:t,dispatch:e})=>xh(t,e),wm=()=>({state:t,dispatch:e})=>gh(t,e);function Cm(t,e,n={},s={}){return En(t,e,{slice:!1,parseOptions:n,errorOnInvalidContent:s.errorOnInvalidContent})}const jm=(t,e=!1,n={},s={})=>({editor:r,tr:o,dispatch:a,commands:l})=>{var c,d;const{doc:p}=o;if(n.preserveWhitespace!=="full"){const f=Cm(t,r.schema,n,{errorOnInvalidContent:(c=s.errorOnInvalidContent)!==null&&c!==void 0?c:r.options.enableContentCheck});return a&&o.replaceWith(0,p.content.size,f).setMeta("preventUpdate",!e),!0}return a&&o.setMeta("preventUpdate",!e),l.insertContentAt({from:0,to:p.content.size},t,{parseOptions:n,errorOnInvalidContent:(d=s.errorOnInvalidContent)!==null&&d!==void 0?d:r.options.enableContentCheck})};function Sm(t,e){const n=kt(e,t.schema),{from:s,to:r,empty:o}=t.selection,a=[];o?(t.storedMarks&&a.push(...t.storedMarks),a.push(...t.selection.$head.marks())):t.doc.nodesBetween(s,r,c=>{a.push(...c.marks)});const l=a.find(c=>c.type.name===n.name);return l?{...l.attrs}:{}}function Nm(t){for(let e=0;e<t.edgeCount;e+=1){const{type:n}=t.edge(e);if(n.isTextblock&&!n.hasRequiredAttrs())return n}return null}function Em(t,e){for(let n=t.depth;n>0;n-=1){const s=t.node(n);if(e(s))return{pos:n>0?t.before(n):0,start:t.start(n),depth:n,node:s}}}function Eo(t){return e=>Em(e.$from,t)}function ns(t,e,n){return Object.fromEntries(Object.entries(n).filter(([s])=>{const r=t.find(o=>o.type===e&&o.name===s);return r?r.attribute.keepOnSplit:!1}))}function Am(t,e,n={}){const{empty:s,ranges:r}=t.selection,o=e?kt(e,t.schema):null;if(s)return!!(t.storedMarks||t.selection.$from.marks()).filter(f=>o?o.name===f.type.name:!0).find(f=>gs(f.attrs,n,{strict:!1}));let a=0;const l=[];if(r.forEach(({$from:f,$to:m})=>{const h=f.pos,b=m.pos;t.doc.nodesBetween(h,b,(x,y)=>{if(!x.isText&&!x.marks.length)return;const k=Math.max(h,y),w=Math.min(b,y+x.nodeSize),E=w-k;a+=E,l.push(...x.marks.map(A=>({mark:A,from:k,to:w})))})}),a===0)return!1;const c=l.filter(f=>o?o.name===f.mark.type.name:!0).filter(f=>gs(f.mark.attrs,n,{strict:!1})).reduce((f,m)=>f+m.to-m.from,0),d=l.filter(f=>o?f.mark.type!==o&&f.mark.type.excludes(o):!0).reduce((f,m)=>f+m.to-m.from,0);return(c>0?c+d:c)>=a}function Di(t,e){const{nodeExtensions:n}=Eh(e),s=n.find(a=>a.name===t);if(!s)return!1;const r={name:s.name,options:s.options,storage:s.storage},o=xn(Et(s,"group",r));return typeof o!="string"?!1:o.split(" ").includes("list")}function Xl(t,{checkChildren:e=!0,ignoreWhitespace:n=!1}={}){var s;if(n){if(t.type.name==="hardBreak")return!0;if(t.isText)return/^\s*$/m.test((s=t.text)!==null&&s!==void 0?s:"")}if(t.isText)return!t.text;if(t.isAtom||t.isLeaf)return!1;if(t.content.childCount===0)return!0;if(e){let r=!0;return t.content.forEach(o=>{r!==!1&&(Xl(o,{ignoreWhitespace:n,checkChildren:e})||(r=!1))}),r}return!1}function _m(t,e,n){var s;const{selection:r}=e;let o=null;if(Gl(r)&&(o=r.$cursor),o){const l=(s=t.storedMarks)!==null&&s!==void 0?s:o.marks();return!!n.isInSet(l)||!l.some(c=>c.type.excludes(n))}const{ranges:a}=r;return a.some(({$from:l,$to:c})=>{let d=l.depth===0?t.doc.inlineContent&&t.doc.type.allowsMarkType(n):!1;return t.doc.nodesBetween(l.pos,c.pos,(p,f,m)=>{if(d)return!1;if(p.isInline){const h=!m||m.type.allowsMarkType(n),b=!!n.isInSet(p.marks)||!p.marks.some(x=>x.type.excludes(n));d=h&&b}return!d}),d})}const Im=(t,e={})=>({tr:n,state:s,dispatch:r})=>{const{selection:o}=n,{empty:a,ranges:l}=o,c=kt(t,s.schema);if(r)if(a){const d=Sm(s,c);n.addStoredMark(c.create({...d,...e}))}else l.forEach(d=>{const p=d.$from.pos,f=d.$to.pos;s.doc.nodesBetween(p,f,(m,h)=>{const b=Math.max(h,p),x=Math.min(h+m.nodeSize,f);m.marks.find(k=>k.type===c)?m.marks.forEach(k=>{c===k.type&&n.addMark(b,x,c.create({...k.attrs,...e}))}):n.addMark(b,x,c.create(e))})});return _m(s,n,c)},Tm=(t,e)=>({tr:n})=>(n.setMeta(t,e),!0),Bm=(t,e={})=>({state:n,dispatch:s,chain:r})=>{const o=Ie(t,n.schema);let a;return n.selection.$anchor.sameParent(n.selection.$head)&&(a=n.selection.$anchor.parent.attrs),o.isTextblock?r().command(({commands:l})=>Pi(o,{...a,...e})(n)?!0:l.clearNodes()).command(({state:l})=>Pi(o,{...a,...e})(l,s)).run():(console.warn('[tiptap warn]: Currently "setNode()" only supports text block nodes.'),!1)},Rm=t=>({tr:e,dispatch:n})=>{if(n){const{doc:s}=e,r=At(t,0,s.content.size),o=ee.create(s,r);e.setSelection(o)}return!0},Pm=t=>({tr:e,dispatch:n})=>{if(n){const{doc:s}=e,{from:r,to:o}=typeof t=="number"?{from:t,to:t}:t,a=oe.atStart(s).from,l=oe.atEnd(s).to,c=At(r,a,l),d=At(o,a,l),p=oe.create(s,c,d);e.setSelection(p)}return!0},Lm=t=>({state:e,dispatch:n})=>{const s=Ie(t,e.schema);return Sh(s)(e,n)};function Oi(t,e){const n=t.storedMarks||t.selection.$to.parentOffset&&t.selection.$from.marks();if(n){const s=n.filter(r=>e==null?void 0:e.includes(r.type.name));t.tr.ensureMarks(s)}}const Mm=({keepMarks:t=!0}={})=>({tr:e,state:n,dispatch:s,editor:r})=>{const{selection:o,doc:a}=e,{$from:l,$to:c}=o,d=r.extensionManager.attributes,p=ns(d,l.node().type.name,l.node().attrs);if(o instanceof ee&&o.node.isBlock)return!l.parentOffset||!ct(a,l.pos)?!1:(s&&(t&&Oi(n,r.extensionManager.splittableMarks),e.split(l.pos).scrollIntoView()),!0);if(!l.parent.isBlock)return!1;const f=c.parentOffset===c.parent.content.size,m=l.depth===0?void 0:Nm(l.node(-1).contentMatchAt(l.indexAfter(-1)));let h=f&&m?[{type:m,attrs:p}]:void 0,b=ct(e.doc,e.mapping.map(l.pos),1,h);if(!h&&!b&&ct(e.doc,e.mapping.map(l.pos),1,m?[{type:m}]:void 0)&&(b=!0,h=m?[{type:m,attrs:p}]:void 0),s){if(b&&(o instanceof oe&&e.deleteSelection(),e.split(e.mapping.map(l.pos),1,h),m&&!f&&!l.parentOffset&&l.parent.type!==m)){const x=e.mapping.map(l.before()),y=e.doc.resolve(x);l.node(-1).canReplaceWith(y.index(),y.index()+1,m)&&e.setNodeMarkup(e.mapping.map(l.before()),m)}t&&Oi(n,r.extensionManager.splittableMarks),e.scrollIntoView()}return b},Dm=(t,e={})=>({tr:n,state:s,dispatch:r,editor:o})=>{var a;const l=Ie(t,s.schema),{$from:c,$to:d}=s.selection,p=s.selection.node;if(p&&p.isBlock||c.depth<2||!c.sameParent(d))return!1;const f=c.node(-1);if(f.type!==l)return!1;const m=o.extensionManager.attributes;if(c.parent.content.size===0&&c.node(-1).childCount===c.indexAfter(-1)){if(c.depth===2||c.node(-3).type!==l||c.index(-2)!==c.node(-2).childCount-1)return!1;if(r){let k=D.empty;const w=c.index(-1)?1:c.index(-2)?2:3;for(let N=c.depth-w;N>=c.depth-3;N-=1)k=D.from(c.node(N).copy(k));const E=c.indexAfter(-1)<c.node(-2).childCount?1:c.indexAfter(-2)<c.node(-3).childCount?2:3,A={...ns(m,c.node().type.name,c.node().attrs),...e},_=((a=l.contentMatch.defaultType)===null||a===void 0?void 0:a.createAndFill(A))||void 0;k=k.append(D.from(l.createAndFill(null,_)||void 0));const I=c.before(c.depth-(w-1));n.replace(I,c.after(-E),new V(k,4-w,0));let j=-1;n.doc.nodesBetween(I,n.doc.content.size,(N,C)=>{if(j>-1)return!1;N.isTextblock&&N.content.size===0&&(j=C+1)}),j>-1&&n.setSelection(oe.near(n.doc.resolve(j))),n.scrollIntoView()}return!0}const h=d.pos===c.end()?f.contentMatchAt(0).defaultType:null,b={...ns(m,f.type.name,f.attrs),...e},x={...ns(m,c.node().type.name,c.node().attrs),...e};n.delete(c.pos,d.pos);const y=h?[{type:l,attrs:b},{type:h,attrs:x}]:[{type:l,attrs:b}];if(!ct(n.doc,c.pos,2))return!1;if(r){const{selection:k,storedMarks:w}=s,{splittableMarks:E}=o.extensionManager,A=w||k.$to.parentOffset&&k.$from.marks();if(n.split(c.pos,2,y).scrollIntoView(),!A||!r)return!0;const _=A.filter(I=>E.includes(I.type.name));n.ensureMarks(_)}return!0},lr=(t,e)=>{const n=Eo(a=>a.type===e)(t.selection);if(!n)return!0;const s=t.doc.resolve(Math.max(0,n.pos-1)).before(n.depth);if(s===void 0)return!0;const r=t.doc.nodeAt(s);return n.node.type===(r==null?void 0:r.type)&&zt(t.doc,n.pos)&&t.join(n.pos),!0},cr=(t,e)=>{const n=Eo(a=>a.type===e)(t.selection);if(!n)return!0;const s=t.doc.resolve(n.start).after(n.depth);if(s===void 0)return!0;const r=t.doc.nodeAt(s);return n.node.type===(r==null?void 0:r.type)&&zt(t.doc,s)&&t.join(s),!0},Om=(t,e,n,s={})=>({editor:r,tr:o,state:a,dispatch:l,chain:c,commands:d,can:p})=>{const{extensions:f,splittableMarks:m}=r.extensionManager,h=Ie(t,a.schema),b=Ie(e,a.schema),{selection:x,storedMarks:y}=a,{$from:k,$to:w}=x,E=k.blockRange(w),A=y||x.$to.parentOffset&&x.$from.marks();if(!E)return!1;const _=Eo(I=>Di(I.type.name,f))(x);if(E.depth>=1&&_&&E.depth-_.depth<=1){if(_.node.type===h)return d.liftListItem(b);if(Di(_.node.type.name,f)&&h.validContent(_.node.content)&&l)return c().command(()=>(o.setNodeMarkup(_.pos,h),!0)).command(()=>lr(o,h)).command(()=>cr(o,h)).run()}return!n||!A||!l?c().command(()=>p().wrapInList(h,s)?!0:d.clearNodes()).wrapInList(h,s).command(()=>lr(o,h)).command(()=>cr(o,h)).run():c().command(()=>{const I=p().wrapInList(h,s),j=A.filter(N=>m.includes(N.type.name));return o.ensureMarks(j),I?!0:d.clearNodes()}).wrapInList(h,s).command(()=>lr(o,h)).command(()=>cr(o,h)).run()},Fm=(t,e={},n={})=>({state:s,commands:r})=>{const{extendEmptyMarkRange:o=!1}=n,a=kt(t,s.schema);return Am(s,a,e)?r.unsetMark(a,{extendEmptyMarkRange:o}):r.setMark(a,e)},$m=(t,e,n={})=>({state:s,commands:r})=>{const o=Ie(t,s.schema),a=Ie(e,s.schema),l=No(s,o,n);let c;return s.selection.$anchor.sameParent(s.selection.$head)&&(c=s.selection.$anchor.parent.attrs),l?r.setNode(a,c):r.setNode(o,{...c,...n})},zm=(t,e={})=>({state:n,commands:s})=>{const r=Ie(t,n.schema);return No(n,r,e)?s.lift(r):s.wrapIn(r,e)},Hm=()=>({state:t,dispatch:e})=>{const n=t.plugins;for(let s=0;s<n.length;s+=1){const r=n[s];let o;if(r.spec.isInputRules&&(o=r.getState(t))){if(e){const a=t.tr,l=o.transform;for(let c=l.steps.length-1;c>=0;c-=1)a.step(l.steps[c].invert(l.docs[c]));if(o.text){const c=a.doc.resolve(o.from).marks();a.replaceWith(o.from,o.to,t.schema.text(o.text,c))}else a.delete(o.from,o.to)}return!0}}return!1},Vm=()=>({tr:t,dispatch:e})=>{const{selection:n}=t,{empty:s,ranges:r}=n;return s||e&&r.forEach(o=>{t.removeMark(o.$from.pos,o.$to.pos)}),!0},Wm=(t,e={})=>({tr:n,state:s,dispatch:r})=>{var o;const{extendEmptyMarkRange:a=!1}=e,{selection:l}=n,c=kt(t,s.schema),{$from:d,empty:p,ranges:f}=l;if(!r)return!0;if(p&&a){let{from:m,to:h}=l;const b=(o=d.marks().find(y=>y.type===c))===null||o===void 0?void 0:o.attrs,x=Ul(d,c,b);x&&(m=x.from,h=x.to),n.removeMark(m,h,c)}else f.forEach(m=>{n.removeMark(m.$from.pos,m.$to.pos,c)});return n.removeStoredMark(c),!0},Um=(t,e={})=>({tr:n,state:s,dispatch:r})=>{let o=null,a=null;const l=Yl(typeof t=="string"?t:t.name,s.schema);return l?(l==="node"&&(o=Ie(t,s.schema)),l==="mark"&&(a=kt(t,s.schema)),r&&n.selection.ranges.forEach(c=>{const d=c.$from.pos,p=c.$to.pos;let f,m,h,b;n.selection.empty?s.doc.nodesBetween(d,p,(x,y)=>{o&&o===x.type&&(h=Math.max(y,d),b=Math.min(y+x.nodeSize,p),f=y,m=x)}):s.doc.nodesBetween(d,p,(x,y)=>{y<d&&o&&o===x.type&&(h=Math.max(y,d),b=Math.min(y+x.nodeSize,p),f=y,m=x),y>=d&&y<=p&&(o&&o===x.type&&n.setNodeMarkup(y,void 0,{...x.attrs,...e}),a&&x.marks.length&&x.marks.forEach(k=>{if(a===k.type){const w=Math.max(y,d),E=Math.min(y+x.nodeSize,p);n.addMark(w,E,a.create({...k.attrs,...e}))}}))}),m&&(f!==void 0&&n.setNodeMarkup(f,void 0,{...m.attrs,...e}),a&&m.marks.length&&m.marks.forEach(x=>{a===x.type&&n.addMark(h,b,a.create({...x.attrs,...e}))}))}),!0):!1},Gm=(t,e={})=>({state:n,dispatch:s})=>{const r=Ie(t,n.schema);return bh(r,e)(n,s)},qm=(t,e={})=>({state:n,dispatch:s})=>{const r=Ie(t,n.schema);return yh(r,e)(n,s)};var Km=Object.freeze({__proto__:null,blur:Rh,clearContent:Ph,clearNodes:Lh,command:Mh,createParagraphNear:Dh,cut:Oh,deleteCurrentNode:Fh,deleteNode:$h,deleteRange:zh,deleteSelection:Hh,enter:Vh,exitCode:Wh,extendMarkRange:Uh,first:Gh,focus:Yh,forEach:Xh,insertContent:Jh,insertContentAt:em,joinBackward:sm,joinDown:nm,joinForward:rm,joinItemBackward:om,joinItemForward:im,joinTextblockBackward:am,joinTextblockForward:lm,joinUp:tm,keyboardShortcut:dm,lift:um,liftEmptyBlock:pm,liftListItem:fm,newlineInCode:hm,resetAttributes:mm,scrollIntoView:gm,selectAll:xm,selectNodeBackward:bm,selectNodeForward:ym,selectParentNode:vm,selectTextblockEnd:km,selectTextblockStart:wm,setContent:jm,setMark:Im,setMeta:Tm,setNode:Bm,setNodeSelection:Rm,setTextSelection:Pm,sinkListItem:Lm,splitBlock:Mm,splitListItem:Dm,toggleList:Om,toggleMark:Fm,toggleNode:$m,toggleWrap:zm,undoInputRule:Hm,unsetAllMarks:Vm,unsetMark:Wm,updateAttributes:Um,wrapIn:Gm,wrapInList:qm});Ge.create({name:"commands",addCommands(){return{...Km}}});Ge.create({name:"drop",addProseMirrorPlugins(){return[new Ht({key:new Vt("tiptapDrop"),props:{handleDrop:(t,e,n,s)=>{this.editor.emit("drop",{editor:this.editor,event:e,slice:n,moved:s})}}})]}});Ge.create({name:"editable",addProseMirrorPlugins(){return[new Ht({key:new Vt("editable"),props:{editable:()=>this.editor.options.editable}})]}});const Ym=new Vt("focusEvents");Ge.create({name:"focusEvents",addProseMirrorPlugins(){const{editor:t}=this;return[new Ht({key:Ym,props:{handleDOMEvents:{focus:(e,n)=>{t.isFocused=!0;const s=t.state.tr.setMeta("focus",{event:n}).setMeta("addToHistory",!1);return e.dispatch(s),!1},blur:(e,n)=>{t.isFocused=!1;const s=t.state.tr.setMeta("blur",{event:n}).setMeta("addToHistory",!1);return e.dispatch(s),!1}}}})]}});Ge.create({name:"keymap",addKeyboardShortcuts(){const t=()=>this.editor.commands.first(({commands:a})=>[()=>a.undoInputRule(),()=>a.command(({tr:l})=>{const{selection:c,doc:d}=l,{empty:p,$anchor:f}=c,{pos:m,parent:h}=f,b=f.parent.isTextblock&&m>0?l.doc.resolve(m-1):f,x=b.parent.type.spec.isolating,y=f.pos-f.parentOffset,k=x&&b.parent.childCount===1?y===f.pos:X.atStart(d).from===m;return!p||!h.type.isTextblock||h.textContent.length||!k||k&&f.parent.type.name==="paragraph"?!1:a.clearNodes()}),()=>a.deleteSelection(),()=>a.joinBackward(),()=>a.selectNodeBackward()]),e=()=>this.editor.commands.first(({commands:a})=>[()=>a.deleteSelection(),()=>a.deleteCurrentNode(),()=>a.joinForward(),()=>a.selectNodeForward()]),s={Enter:()=>this.editor.commands.first(({commands:a})=>[()=>a.newlineInCode(),()=>a.createParagraphNear(),()=>a.liftEmptyBlock(),()=>a.splitBlock()]),"Mod-Enter":()=>this.editor.commands.exitCode(),Backspace:t,"Mod-Backspace":t,"Shift-Backspace":t,Delete:e,"Mod-Delete":e,"Mod-a":()=>this.editor.commands.selectAll()},r={...s},o={...s,"Ctrl-h":t,"Alt-Backspace":t,"Ctrl-d":e,"Ctrl-Alt-Backspace":e,"Alt-Delete":e,"Alt-d":e,"Ctrl-a":()=>this.editor.commands.selectTextblockStart(),"Ctrl-e":()=>this.editor.commands.selectTextblockEnd()};return So()||Kl()?o:r},addProseMirrorPlugins(){return[new Ht({key:new Vt("clearDocument"),appendTransaction:(t,e,n)=>{if(t.some(x=>x.getMeta("composition")))return;const s=t.some(x=>x.docChanged)&&!e.doc.eq(n.doc),r=t.some(x=>x.getMeta("preventClearDocument"));if(!s||r)return;const{empty:o,from:a,to:l}=e.selection,c=X.atStart(e.doc).from,d=X.atEnd(e.doc).to;if(o||!(a===c&&l===d)||!Xl(n.doc))return;const m=n.tr,h=Hl({state:n,transaction:m}),{commands:b}=new Nh({editor:this.editor,state:h});if(b.clearNodes(),!!m.steps.length)return m}})]}});Ge.create({name:"paste",addProseMirrorPlugins(){return[new Ht({key:new Vt("tiptapPaste"),props:{handlePaste:(t,e,n)=>{this.editor.emit("paste",{editor:this.editor,event:e,slice:n})}}})]}});Ge.create({name:"tabindex",addProseMirrorPlugins(){return[new Ht({key:new Vt("tabindex"),props:{attributes:()=>this.editor.isEditable?{tabindex:"0"}:{}}})]}});const Xm=Ge.create({name:"color",addOptions(){return{types:["textStyle"]}},addGlobalAttributes(){return[{types:this.options.types,attributes:{color:{default:null,parseHTML:t=>{var e;return(e=t.style.color)===null||e===void 0?void 0:e.replace(/['"]+/g,"")},renderHTML:t=>t.color?{style:`color: ${t.color}`}:{}}}}]},addCommands(){return{setColor:t=>({chain:e})=>e().setMark("textStyle",{color:t}).run(),unsetColor:()=>({chain:t})=>t().setMark("textStyle",{color:null}).removeEmptyTextStyle().run()}}}),Jl=({blockId:t,value:e="",onUpdate:n=()=>{},onBlur:s=()=>{},placeholder:r="",from:o="settings",style:a={}})=>as.useEditor({extensions:[Od,Bd,Xm.configure({types:["textStyle"]}),Rd.configure({multicolor:!0}),Pd.configure({openOnClick:!1,HTMLAttributes:{class:"underline"}}),Md.configure({types:["heading","paragraph"],alignments:["left","center","right"],defaultAlignment:"left"}),Dd,Ld.configure({placeholder:r||"Enter text here",emptyEditorClass:"cursor-text before:content-[attr(data-placeholder)] before:absolute before:opacity-50 before:pointer-events-none"})],content:e||"",onUpdate:n,onBlur:s,editorProps:{attributes:{...a?{style:a}:{},class:o!=="canvas"?"text-sm p-1 px-2 rte":"rte"}}},[t]);function Jm(t){let e=t;for(;e;){if(e.style&&e.style.textAlign)return e.style.textAlign;const n=window.getComputedStyle(e).textAlign;if(n&&n!=="start"&&n!=="initial"&&n!=="inherit")return n;e=e.parentElement}return null}const Zm=g.memo(({blockContent:t,editingElement:e,onClose:n,onChange:s,onEscape:r})=>{const{document:o}=st(),a=Jl({value:t,blockId:"active-inline-editing-element",placeholder:"Enter text here",onUpdate:({editor:d})=>s((d==null?void 0:d.getHTML())||""),onBlur:({editor:d,event:p})=>{const f=p==null?void 0:p.relatedTarget,m=o.querySelector(".ProseMirror"),h=o.querySelector(".tippy-box"),b=o.querySelector("#chai-rich-text-menu-bar"),x=m==null?void 0:m.contains(f),y=h==null?void 0:h.contains(f),k=b==null?void 0:b.contains(f),w=window.document.getElementById("rte-widget-color-picker");if(!x&&!y&&!k&&!w){const E=(d==null?void 0:d.getHTML())||"";n(E)}},from:"canvas"});g.useEffect(()=>{var p,f;const d=Jm(e);d&&((p=a==null?void 0:a.commands)==null||p.setTextAlign(d)),(f=a==null?void 0:a.commands)==null||f.focus(),a==null||a.emit("focus",{editor:a,event:new FocusEvent("focus"),transaction:[]})},[a]);const l=g.useMemo(()=>{var f;const d="max-w-none shadow-none outline outline-[2px] [&_*]:shadow-none";if(!e)return d;const p=((f=e==null?void 0:e.className)==null?void 0:f.replace("sr-only",""))||"";return`${d} ${p}`},[e]),c=d=>{d.key==="Escape"&&r(d)};return a&&i.jsxs("div",{onKeyDown:c,onClick:d=>d.stopPropagation(),className:"relative",children:[i.jsx(as.BubbleMenu,{editor:a,shouldShow:()=>a&&(a==null?void 0:a.isFocused),tippyOptions:{duration:100,arrow:!0,hideOnClick:!1},className:"w-max",children:i.jsx(sl,{editor:a,from:"canvas"})}),i.jsx(as.EditorContent,{id:"active-inline-editing-element",onKeyDown:c,value:t,editor:a,className:l})]})}),Qm=g.memo(({editingElement:t,blockContent:e,onClose:n,editorRef:s,onChange:r,onEscape:o})=>{const{document:a,window:l}=st();g.useEffect(()=>{if(s.current){s.current.innerHTML=e,s.current.focus();const m=a.createRange(),h=l.getSelection();m.selectNodeContents(s.current),m.collapse(!1),h==null||h.removeAllRanges(),h==null||h.addRange(m),s.current.focus()}else n()},[a,l]);const c=g.useMemo(()=>{var h;const m=((h=t==null?void 0:t.tagName)==null?void 0:h.toLowerCase())||"div";return m==="button"?"div":m},[t]),d=g.useCallback(m=>{(m.key==="Enter"||m.key==="Escape")&&o(m)},[o]),p=g.useCallback(()=>{n()},[n]),f=g.useMemo(()=>{var m;return{id:"active-inline-editing-element",contentEditable:!0,className:`${((m=t==null?void 0:t.className)==null?void 0:m.replace("sr-only",""))||""} outline outline-[2px] outline-green-500 shadow-none empty:before:content-[attr(data-placeholder)] empty:before:text-gray-400 empty:before:absolute empty:before:pointer-events-none empty:before:select-none empty:before:inset-0 empty:before:z-0 relative min-h-[1em]`,style:u.cloneDeep(t==null?void 0:t.style)||{},onInput:h=>{const b=h.target;b&&(b.innerText.trim()===""?(b.setAttribute("data-placeholder","Enter text here"),b.children.length>0&&b.children[0].remove()):h.target.removeAttribute("data-placeholder"),r(h.target.innerText))},onClick:h=>{h.stopPropagation(),h.preventDefault()}}},[t==null?void 0:t.className,t==null?void 0:t.style]);return i.jsx(i.Fragment,{children:g.createElement(c,{ref:s,onBlur:p,onKeyDown:d,...f})})}),eg=g.memo(({block:t,children:e})=>{const n="content",{document:s}=st(),{editingBlockId:r,editingItemIndex:o,setEditingBlockId:a,setEditingItemIndex:l}=$t(),[c,d]=g.useState(null),p=g.useRef(null),{clearHighlight:f}=nt(),m=tt(),{selectedLang:h}=Le(),[,b]=K(),x=g.useRef(null),y=r,{blockContent:k,blockType:w}=g.useMemo(()=>{var R;const j=t._type;let N=t[n];const C=J.getRegisteredChaiBlock(t._type);return h&&((R=C==null?void 0:C.i18nProps)==null?void 0:R.includes(n))&&u.has(t,`${n}-${h}`)&&(N=u.get(t,`${n}-${h}`)),{blockContent:N,blockType:j}},[t,h]),E=g.useCallback(j=>{var C;const N=j||((C=p.current)==null?void 0:C.innerText);m([y],{[n]:N}),d(null),a(null),l(-1),b([]),y&&setTimeout(()=>b([y]),100)},[y,m,a,b,h]),A=ke.useDebouncedCallback(j=>{m([y],{[n]:j})},[y,t,m,h],1e3),_=g.useCallback(j=>{j.preventDefault(),y&&(x.current=y),E(),setTimeout(()=>{const N=x.current;x.current=null,b([N])},100)},[b,y,h]);g.useEffect(()=>{var T;if(!y)return;const j=`[data-block-id="${y}"]`,N=o>=0?`[data-block-index="${o}"]`:"",C=s.querySelector(`${j}${N}`);C&&((T=C==null?void 0:C.classList)==null||T.add("sr-only"),d(C))},[y,w,s,o]);const I=g.useMemo(()=>c?(f(),["RichText","Paragraph"].includes(w)?i.jsx(Zm,{blockContent:k,editingElement:c,onChange:A,onClose:E,onEscape:_}):i.jsx(Qm,{editorRef:p,blockContent:k,editingElement:c,onClose:E,onChange:A,onEscape:_})):null,[c,y,w,k,E,h]);return i.jsxs(i.Fragment,{children:[I,e]})},(t,e)=>t.block._id===e.block._id&&t.block.content===e.block.content),Zl=g.createContext({index:-1,key:""}),tg=["Box","Repeater","GlobalBlock","PartialBlock","Heading","Text","RichText","Span","Image","Button","Paragraph","Link","Video","Audio","Icon","List","ListItem","CustomScript","CustomHTML"],ng=({asyncProps:t,blockAtom:e,children:n})=>{const{editingBlockId:s,editingItemIndex:r}=$t(),[o]=S.useAtom(e),a=g.useMemo(()=>J.getRegisteredChaiBlock(o._type),[o._type]),{selectedLang:l,fallbackLang:c}=Le(),d=yf(),p=sn(),[f]=S.useAtom(ao),m=u.get(a,"component",null),{index:h,key:b}=g.useContext(Zl),{mode:x}=nl(),y=S.useAtomValue(nn),k=Ye(),w=x==="edit",E=bf(),A=g.useMemo(()=>f?$.applyBindingToBlockProps($.applyLanguage(o,l,a),p,{index:h,key:b}):$.applyLanguage(o,l,a),[o,l,a,p,f,h,b]),_=g.useMemo(()=>$.getBlockTagAttributes(o,!0,y),[o,$.getBlockTagAttributes,y]),I=g.useMemo(()=>d(o._id,$.getBlockRuntimeProps(o._type)),[o._id,o._type,d,$.getBlockRuntimeProps]),j=g.useMemo(()=>{const U={"data-block-id":o._id,"data-block-type":o._type,"data-block-index":h};return w&&k?{...U,draggable:!s,onMouseDown:E.onMouseDown,onDragStart:E.onDragStart,onDragEnd:E.onDragEnd}:U},[o._id,o._type,h,w,k,E,s]),N=g.useMemo(()=>({blockProps:j,inBuilder:x==="edit",lang:l||c,pageData:p,...A,..._,...I,...t}),[x,j,l,c,A,_,I,t]),C=g.useMemo(()=>!tg.includes(o._type),[o._type]),T=g.useMemo(()=>u.get(o,"_show",!0),[o]);if(u.isNull(m)||!T)return null;let R=i.jsx(g.Suspense,{children:g.createElement(m,{...N,children:n({_id:o._id,_type:o._type,...u.isArray(A.repeaterItems)?{repeaterItems:$.applyLimit(A.repeaterItems,o),$repeaterItemsKey:A.$repeaterItemsKey}:{},...o.partialBlockId?{partialBlockId:o.partialBlockId}:"",...o.globalBlock?{partialBlockId:o.globalBlock}:""})})});const B=s===o._id&&(r===h||h<0)?i.jsx(eg,{block:o,children:R}):R;return C?i.jsx(_t.ErrorBoundary,{fallbackRender:wf,children:B}):B},sg=({children:t,partialBlockId:e})=>{const n=O("gotoPage",u.noop),{saveState:s}=Rn(),{selectedLang:r,fallbackLang:o}=Le(),a=g.useCallback(l=>{if(l.stopPropagation(),s!=="SAVED"){me.toast.error("You have unsaved changes. Please save the page first.");return}n({pageId:e,lang:r||o})},[s,n,e,r,o]);return i.jsxs(i.Fragment,{children:[t,i.jsx("div",{className:"partial-overlay group absolute inset-0 z-50",children:i.jsx("div",{onDoubleClick:a,className:"flex h-full w-full items-center justify-center bg-black/10 opacity-0 transition-opacity duration-300 ease-in-out group-hover:opacity-100 group-hover:backdrop-opacity-85",children:i.jsx("p",{className:"rounded-md bg-white px-2 py-1 text-xs",children:"Partial block. Double click to edit."})})})]})},rg=({partialBlockId:t})=>{const{getPartailBlocks:e}=Ds(),n=g.useMemo(()=>e(t),[e,t]),s=g.useMemo(()=>we.splitAtom(S.atom(n)),[n]);return u.isEmpty(n)?null:i.jsx(sg,{partialBlockId:t,children:i.jsx(xs,{splitAtoms:s,blocks:n,type:"PartialBlock"})})},xs=({blocks:t,parent:e=null,splitAtoms:n=void 0,type:s=""})=>{const r=Du(n);let o=g.useMemo(()=>u.filter(t,l=>u.has(l,"_id")&&(u.isEmpty(e)?!l._parent:l._parent===e)),[t,e]);const a=g.useCallback(l=>u.filter(t,c=>c._parent===l).length>0,[t]);return a&&(s==="Heading"||s==="Paragraph"||s==="Link")&&(o=$.adjustSpacingInContentBlocks(o)),u.map(o,l=>{const c=r(l._id);return c?i.jsx(kf,{block:l,children:d=>i.jsx(ng,{blockAtom:c,asyncProps:d,children:({_id:p,_type:f,partialBlockId:m,repeaterItems:h,$repeaterItemsKey:b})=>f==="Repeater"?u.isArray(h)&&h.map((x,y)=>i.jsx(Zl.Provider,{value:{index:y,key:b},children:i.jsx(xs,{splitAtoms:n,blocks:t,parent:l._id,type:f})},`${p}-${y}`)):f==="GlobalBlock"||f==="PartialBlock"?i.jsx(S.Provider,{store:Ve,children:i.jsx(rg,{partialBlockId:m})}):a(p)?i.jsx(xs,{splitAtoms:n,blocks:t,parent:l._id,type:f}):null})},l._id):null})},og=()=>{const[t]=te();return i.jsx(xs,{splitAtoms:In,blocks:t})},ig=()=>{const[t]=te(),[e]=S.useAtom(co),n=u.isEmpty(t)?null:i.jsx(og,{},e);return i.jsx(i.Fragment,{children:n})},ag=we.atomWithStorage("canvasZoom",100),Ql=()=>S.useAtom(ag),lg=()=>S.useAtom(ka),ec=we.atomWithStorage("canvasWidth",800),cg=we.atomWithStorage("canvasDisplayWidth",800),tc=S.atom(t=>{const e=t(ec);return ve.getBreakpointValue(e).toLowerCase()}),bs=()=>{const[t,e]=S.useAtom(ec),n=S.useAtomValue(tc),[s,r]=lg();return g.useEffect(()=>{s!=="xs"&&r(n)},[n,s,r]),[t,n,e]},Ao=()=>{const[t,e]=S.useAtom(cg);return[t,e]},dg=t=>{const[e]=Ao(),[,n]=Ql(),s=O("htmlDir","ltr"),[r,o]=g.useState({}),a=g.useCallback(()=>{const{width:l,height:c}=t;if(l<e){const d=parseFloat((l/e).toFixed(2).toString());let p={};const f=c*d,m=l*d;c&&(p={height:100+(c-f)/f*100+"%",width:100+(l-m)/m*100+"%"}),o({position:"relative",top:0,transform:`scale(${d})`,transformOrigin:s==="rtl"?"top right":"top left",...p,maxWidth:"none"}),n(d*100)}else o({}),n(100)},[e,t,s,n]);return g.useEffect(()=>{a()},[e,t,n,a]),r};function Yt(t,e){g.useEffect(()=>{const n=re.subscribe(t,e);return()=>n()},[t,e])}const ug=()=>{const[,t]=K(),[e,n]=Ee(),{document:s}=st(),{clearHighlight:r}=nt(),[o]=K(),[a]=S.useAtom(oo);return g.useEffect(()=>{setTimeout(()=>{if(!u.isEmpty(e))return;const l=Ga(s,u.first(o));if(l){const c=l.getAttribute("data-style-prop");if(c){const d=l.getAttribute("data-style-id"),p=l.getAttribute("data-block-parent");n([{id:d,prop:c,blockId:p}])}}},100)},[s,o,n,e]),g.useEffect(()=>()=>r(),[r]),Yt(Y.CANVAS_BLOCK_SELECTED,l=>{l&&(!u.isEmpty(l)&&!u.includes(o,u.first(l))&&(a==null||a.closeAll()),t(l))}),Yt(Y.CANVAS_BLOCK_STYLE_SELECTED,l=>{if(!l)return;const{blockId:c,styleId:d,styleProp:p}=l;c&&(u.includes(o,c)||a==null||a.closeAll(),n([{id:d,prop:p,blockId:c}]),t([c]))}),Yt(Y.CLEAR_CANVAS_SELECTION,()=>{r(),t([]),n([])}),null},pg=()=>{const[t]=Ao(),[,e]=$a(),n=g.useRef(null),s=g.useRef(null),[r,o]=g.useState({width:0,height:0}),a=dg(r),[,l]=rn(),c=O("loading",!1),d=O("htmlDir","ltr"),{onDragOver:p,onDrop:f,onDragEnd:m}=on(),h=Mp(),b=g.useCallback(y=>{o(k=>({...k,width:y}))},[o]);g.useEffect(()=>{if(!s.current)return;const{clientWidth:y,clientHeight:k}=s.current;o({width:y,height:k})},[s,t]);const x=g.useMemo(()=>{let y=nf;return y=y.replace("__HTML_DIR__",d),y},[d]);return i.jsx(xf,{onMount:b,onResize:b,children:i.jsx("div",{onMouseLeave:()=>setTimeout(()=>e(""),300),className:"relative mx-auto h-full w-full overflow-hidden",onDragOver:p,onDrop:f,onDragEnd:m,ref:s,children:i.jsxs(rf,{contentDidMount:()=>l(n.current),ref:n,id:"canvas-iframe",style:{...a,...u.isEmpty(a)?{width:`${t}px`}:{}},className:"relative mx-auto box-content h-full w-full max-w-full shadow-lg transition-all duration-300 ease-linear",initialContent:x,children:[i.jsx(uf,{}),i.jsx(ef,{}),i.jsx(ff,{}),i.jsxs(iu.Provider,{children:[i.jsxs(Zp,{children:[c?i.jsx("div",{className:"h-full p-4",children:i.jsx(Mt,{className:"h-full"})}):i.jsx(ig,{}),i.jsx(pf,{})]}),i.jsx(ug,{})]}),h.isVisible&&i.jsx("div",{id:"placeholder",className:`pointer-events-none absolute z-[99999] max-w-full transition-all duration-150 ${h.isEmpty?"bg-purple-500/10 outline-dashed outline-2 -outline-offset-2 outline-purple-500":"rounded-full bg-green-500"}`,style:{top:h.top,left:h.left,width:h.width,height:h.height}})]})})})},kn=()=>{const{t}=F.useTranslation();return i.jsx("div",{className:"h-full w-full rounded-md bg-red-200 p-4 text-red-500",children:i.jsxs("div",{className:"flex h-full w-full flex-col items-center justify-center",children:[i.jsx("p",{className:"font-semibold",children:t("Oops! Something went wrong.")}),i.jsx("p",{children:t("Please try again.")})]})})},fg=S.atom(null),_o=()=>S.useAtom(fg),hg=g.lazy(()=>Promise.resolve().then(()=>require("./code-editor-o3___nu2.cjs"))),nc=()=>{const[t]=_o(),e=O("onError",u.noop);return i.jsx("div",{className:"flex h-full max-h-full w-full flex-1 flex-col",children:i.jsxs("div",{className:"relative flex h-full max-h-full flex-col overflow-hidden bg-gray-100/40",children:[i.jsx(g.Suspense,{fallback:i.jsx(Mt,{className:"h-full"}),children:i.jsx(_t.ErrorBoundary,{fallback:i.jsx(kn,{}),onError:e,children:i.jsx(pg,{})})}),t?i.jsx(g.Suspense,{fallback:i.jsx(Mt,{className:"h-full"}),children:i.jsx(hg,{})}):null]})})},$s={},mg=(t,e)=>{$s[t]={id:t,component:e,type:"widget"}},gg=(t,e)=>{$s[t]={id:t,component:e,type:"field"}},xg=(t,e)=>{$s[t]={id:t,component:e,type:"template"}},dr=t=>Object.values($s).filter(e=>e.type===t).reduce((e,n)=>(e[n.id]=n.component,e),{}),bg=g.lazy(()=>Promise.resolve().then(()=>require("./IconPicker-DREyo007.cjs")).then(t=>({default:t.IconPicker}))),yg=t=>{try{let e=t.replace(/<svg([^>]*)\sheight="[^"]*"([^>]*)>/gi,"<svg$1$2>").replace(/<svg([^>]*)\swidth="[^"]*"([^>]*)>/gi,"<svg$1$2>");return e=e.replace(/>\s+</g,"><"),e=e.replace(/\n/g,"").replace(/\s{2,}/g," "),e=e.replace(/\s+=/g,"=").replace(/=\s+/g,"="),e=e.replace(/<!--[\s\S]*?-->/g,""),e.trim()}catch{return t}},vg=({value:t,onChange:e,id:n})=>{const{t:s}=F.useTranslation(),[r,o]=g.useState(t||"");g.useEffect(()=>{o(t||"")},[t]);const a=l=>{o(l);const c=yg(l);e(c)};return i.jsxs("div",{className:"mt-1 flex flex-col gap-2",id:"icon-picker-field",children:[i.jsxs("div",{className:"flex items-center gap-x-2",children:[i.jsx("div",{className:"flex h-12 w-12 items-center justify-center overflow-hidden rounded-lg border bg-gray-50",children:r?i.jsx("div",{className:"h-6 w-6",dangerouslySetInnerHTML:{__html:r}}):i.jsx("span",{className:"text-xs text-gray-400",children:"SVG"})}),i.jsx("textarea",{id:n,autoCapitalize:"off",autoCorrect:"off",spellCheck:"false",value:r,onChange:l=>a(l.target.value),placeholder:s("SVG_code"),rows:2,className:"no-scrollbar w-full rounded-md border border-border bg-background px-3 py-1.5 text-xs shadow-sm transition-colors placeholder:text-muted-foreground focus-visible:outline-none focus-visible:ring-1 focus-visible:ring-ring disabled:cursor-not-allowed disabled:opacity-50"})]}),i.jsxs("div",{className:"flex items-center gap-2",children:[i.jsx(g.Suspense,{fallback:i.jsx("div",{className:"text-xs text-muted-foreground",children:"Loading..."}),children:i.jsx(bg,{onSelectIcon:a})}),i.jsx("p",{className:"text-xs text-muted-foreground",children:s("Paste SVG_code")})]})]})},On=ie.Root,sc=ie.Trigger,kg=ie.Portal,rc=M.forwardRef(({className:t,...e},n)=>i.jsx(ie.Overlay,{ref:n,className:L("fixed inset-0 z-50 bg-black/80 data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0",t),...e}));rc.displayName=ie.Overlay.displayName;const ln=M.forwardRef(({className:t,children:e,...n},s)=>i.jsxs(kg,{children:[i.jsx(rc,{}),i.jsxs(ie.Content,{ref:s,className:L("fixed left-[50%] top-[50%] z-50 grid w-full max-w-lg translate-x-[-50%] translate-y-[-50%] gap-4 border bg-background p-6 shadow-lg duration-200 data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0 data-[state=closed]:zoom-out-95 data-[state=open]:zoom-in-95 data-[state=closed]:slide-out-to-left-1/2 data-[state=closed]:slide-out-to-top-[48%] data-[state=open]:slide-in-from-left-1/2 data-[state=open]:slide-in-from-top-[48%] sm:rounded-lg",t),...n,children:[e,i.jsxs(ie.Close,{className:"absolute right-4 top-4 rounded-sm opacity-70 ring-offset-background transition-opacity hover:opacity-100 focus:outline-none focus:ring-2 focus:ring-ring focus:ring-offset-2 disabled:pointer-events-none data-[state=open]:bg-accent data-[state=open]:text-muted-foreground",children:[i.jsx(v.Cross1Icon,{className:"h-4 w-4"}),i.jsx("span",{className:"sr-only",children:"Close"})]})]})]}));ln.displayName=ie.Content.displayName;const Fn=({className:t,...e})=>i.jsx("div",{className:L("flex flex-col space-y-1.5 text-center sm:text-left",t),...e});Fn.displayName="DialogHeader";const oc=({className:t,...e})=>i.jsx("div",{className:L("flex flex-col-reverse sm:flex-row sm:justify-end sm:space-x-2",t),...e});oc.displayName="DialogFooter";const cn=M.forwardRef(({className:t,...e},n)=>i.jsx(ie.Title,{ref:n,className:L("text-lg font-semibold leading-none tracking-tight",t),...e}));cn.displayName=ie.Title.displayName;const ic=M.forwardRef(({className:t,...e},n)=>i.jsx(ie.Description,{ref:n,className:L("text-sm text-muted-foreground",t),...e}));ic.displayName=ie.Description.displayName;const wg=_n.cva("relative w-full rounded-lg border px-4 py-3 text-sm [&>svg+div]:translate-y-[-3px] [&>svg]:absolute [&>svg]:left-4 [&>svg]:top-4 [&>svg]:text-foreground [&>svg~*]:pl-7",{variants:{variant:{default:"bg-background text-foreground",destructive:"border-destructive/50 text-destructive dark:border-destructive [&>svg]:text-destructive"}},defaultVariants:{variant:"default"}}),Io=M.forwardRef(({className:t,variant:e,...n},s)=>i.jsx("div",{ref:s,role:"alert",className:L(wg({variant:e}),t),...n}));Io.displayName="Alert";const Cg=M.forwardRef(({className:t,...e},n)=>i.jsx("h5",{ref:n,className:L("mb-1 font-medium leading-none tracking-tight",t),...e}));Cg.displayName="AlertTitle";const To=M.forwardRef(({className:t,...e},n)=>i.jsx("div",{ref:n,className:L("text-sm [&_p]:leading-relaxed",t),...e}));To.displayName="AlertDescription";const Bo=_n.cva("inline-flex items-center justify-center gap-2 whitespace-nowrap rounded-md text-sm font-medium transition-colors focus-visible:outline-none focus-visible:ring-1 focus-visible:ring-ring disabled:pointer-events-none disabled:opacity-50 [&_svg]:pointer-events-none [&_svg]:size-4 [&_svg]:shrink-0",{variants:{variant:{default:"bg-primary text-primary-foreground shadow hover:bg-primary/90",destructive:"bg-destructive text-destructive-foreground shadow-sm hover:bg-destructive/90",outline:"border border-input bg-background shadow-sm hover:bg-accent hover:text-accent-foreground",secondary:"bg-secondary text-secondary-foreground shadow-sm hover:bg-secondary/80",ghost:"hover:bg-accent hover:text-accent-foreground",link:"text-primary underline-offset-4 hover:underline"},size:{default:"h-9 px-4 py-2",sm:"h-8 rounded-md px-3 text-xs",lg:"h-10 rounded-md px-8",icon:"h-9 w-9"}},defaultVariants:{variant:"default",size:"default"}}),q=M.forwardRef(({className:t,variant:e,size:n,asChild:s=!1,...r},o)=>{const a=s?_d.Slot:"button";return i.jsx(a,{className:L(Bo({variant:e,size:n,className:t})),ref:o,...r})});q.displayName="Button";const jg=({close:t,onSelect:e,mode:n="image"})=>{const[s,r]=g.useState(""),[o,a]=g.useState(!1),[l,c]=g.useState(!1),[d,p]=g.useState(null),f=async h=>{if(!h.trim()){c(!1),p("Please enter a URL");return}try{a(!0),p(null),c(!0),p(null)}catch{c(!1),p("Error validating URL")}finally{a(!1)}},{t:m}=F.useTranslation();return i.jsxs("div",{className:"flex w-96 flex-col gap-4 p-4",children:[i.jsx("h2",{className:"text-xl font-semibold",children:m(`${n.charAt(0).toUpperCase()+n.slice(1)} Manager`)}),d&&i.jsxs(Io,{variant:"destructive",children:[i.jsx(v.ExclamationTriangleIcon,{className:"h-4 w-4"}),i.jsx(To,{children:d})]}),i.jsxs("div",{className:"flex flex-col gap-4",children:[i.jsx(vt,{placeholder:m(`Enter ${n} URL`),value:s,onChange:h=>r(h.target.value),onKeyUp:()=>f(s)}),i.jsxs("div",{className:"flex justify-end gap-2",children:[i.jsx(q,{variant:"outline",onClick:t,children:m("Cancel")}),i.jsx(q,{onClick:()=>e({id:"dam-id",url:s,width:600,height:400,description:"This is image description"}),disabled:!l||o,children:m("Insert")})]})]})]})},ac={component:jg},Sg=t=>{ac.component=t},lc=()=>g.useMemo(()=>ac.component,[]),ss=({assetId:t,children:e,onSelect:n,mode:s="image"})=>{const[r,o]=g.useState(!1),a=lc(),l=(...c)=>{n.call(void 0,...c),o(!1)};return i.jsxs(On,{open:r,onOpenChange:c=>o(c),children:[i.jsx(sc,{asChild:!0,children:e}),i.jsxs(ln,{className:"flex max-h-[90vh] max-w-7xl border-border md:w-fit",children:[i.jsx(cn,{className:"sr-only",children:"Media Manager"}),i.jsx("div",{className:"h-full w-full",children:a?i.jsx(a,{close:()=>o(!1),onSelect:l,mode:s,assetId:t}):null})]})]})};ss.displayName="MediaManagerModal";const Qn="data:image/svg+xml;base64,PHN2ZyB3aWR0aD0iNTAwIiBoZWlnaHQ9IjQwMCIgeG1sbnM9Imh0dHA6Ly93d3cudzMub3JnLzIwMDAvc3ZnIj48cmVjdCB3aWR0aD0iMTAwJSIgaGVpZ2h0PSIxMDAlIiBmaWxsPSIjZjNmNGY2Ii8+PHRleHQgeD0iNTAlIiB5PSI1MCUiIGZvbnQtZmFtaWx5PSJBcmlhbCwgc2Fucy1zZXJpZiIgZm9udC1zaXplPSIxNiIgZmlsbD0iI2Q1ZDdkYSIgdGV4dC1hbmNob3I9Im1pZGRsZSIgZHk9Ii4zZW0iPkltYWdlIFBsYWNlaG9sZGVyPC90ZXh0Pjwvc3ZnPg==",Ng=t=>{var r;if(!t||u.startsWith(t,"data"))return"";const e=((r=t.split("/").pop())==null?void 0:r.split("?")[0])||"";return[".jpg",".jpeg",".png",".gif",".webp",".svg",".bmp",".ico",".avif"].some(o=>e.toLowerCase().endsWith(o))?e:""},Eg=({value:t,onChange:e,id:n,onBlur:s,uiSchema:r})=>{const{t:o}=F.useTranslation(),{selectedLang:a}=Le(),l=Z(),c=tt(),d=sn(),p=(r==null?void 0:r["ui:allowEmpty"])===!0,f=n.split(".").pop()||"",m=a?`_${f}Id-${a}`:`_${f}Id`,h=u.isEmpty(a)&&(l==null?void 0:l._type)==="Image"&&u.has(l,"assetId"),b=u.get(l,m,h?l==null?void 0:l.assetId:""),x=g.useMemo(()=>{if(!t||!l||!/\{\{.*?\}\}/.test(t))return t;const _={...l,[f]:t},I=$.applyBindingToBlockProps(_,d,{index:-1,key:""});return u.get(I,f,t)},[t,l,d,f]),y=!!b||x!==Qn&&x!=="",k=A=>{const _=u.isArray(A)?u.first(A):A;if(_){e(_==null?void 0:_.url);const I=_==null?void 0:_.width,j=_==null?void 0:_.height,N=m.includes("mobile");if(l!=null&&l._id){const C={...I&&{[N?"mobileWidth":"width"]:I},...j&&{[N?"mobileHeight":"height"]:j},..._.description&&{alt:_.description}};if(u.set(C,m,_.id),u.isEmpty(C))return;c([l._id],C)}}},w=g.useCallback(()=>{if(e(p?"":Qn),l!=null&&l._id){const _={},I=m.includes("mobile");u.set(_,m,""),u.set(_,I?"mobileWidth":"width",""),u.set(_,I?"mobileHeight":"height",""),c([l._id],_)}},[e,l==null?void 0:l._id,c,m,p]),E=Ng(x);return i.jsxs("div",{className:"mt-1.5 flex items-start gap-x-3",children:[x?i.jsxs("div",{className:"group relative",children:[i.jsx("img",{src:x,className:"h-14 w-14 overflow-hidden rounded-md border border-border object-cover transition duration-200 "+(b&&b!==""?"cursor-pointer group-hover:blur-sm":""),alt:""}),y&&i.jsx("button",{type:"button",onClick:w,className:"absolute -right-2 -top-2 z-20 rounded-full bg-destructive p-1 text-destructive-foreground hover:bg-destructive/90",children:i.jsx(v.Cross1Icon,{className:"h-3 w-3"})}),b&&b!==""&&i.jsx(ss,{onSelect:k,assetId:b,children:i.jsx("button",{type:"button",className:"absolute inset-0 z-10 flex cursor-pointer items-center justify-center bg-black/10 opacity-0 transition duration-200 group-hover:bg-black/30 group-hover:opacity-100",children:i.jsx(v.Pencil2Icon,{className:"h-4 w-4 text-white"})})})]}):i.jsx(ss,{onSelect:k,mode:"image",assetId:b,children:i.jsx("div",{className:"h-14 w-14 cursor-pointer rounded-md border border-border bg-[radial-gradient(#AAA,transparent_1px)] duration-300 [background-size:10px_10px]"})}),i.jsxs("div",{className:"flex w-3/5 flex-col",children:[i.jsxs(i.Fragment,{children:[i.jsx("p",{className:"max-w-[250px] truncate pr-2 text-xs text-gray-400",children:E}),i.jsx(ss,{onSelect:k,assetId:"",children:i.jsx("small",{className:"mb-1 h-6 w-full cursor-pointer rounded-md bg-secondary px-1 py-1 text-center text-xs text-secondary-foreground hover:bg-secondary/80",children:!u.isEmpty(x)&&x!==Qn?o("Replace image"):o("Choose image")})}),i.jsx("div",{className:"text-center text-xs text-gray-400",children:"OR"})]}),i.jsx("input",{id:n,autoCapitalize:"off",autoCorrect:"off",spellCheck:"false",type:"url",className:"h-6 text-xs",placeholder:o("Enter image URL"),value:t===Qn?"":t,onBlur:({target:{value:A}})=>s(n,A),onChange:A=>e(A.target.value)})]})]})},Qt={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"},Ro=M.forwardRef(({className:t,...e},n)=>i.jsx(Fe.Command,{ref:n,className:L("flex h-full w-full flex-col overflow-hidden rounded-md bg-popover text-popover-foreground",t),...e}));Ro.displayName=Fe.Command.displayName;const Po=M.forwardRef(({className:t,...e},n)=>i.jsxs("div",{className:"flex items-center border-b px-3","cmdk-input-wrapper":"",children:[i.jsx(v.MagnifyingGlassIcon,{className:"mr-2 h-4 w-4 shrink-0 opacity-50"}),i.jsx(Fe.Command.Input,{ref:n,className:L("flex h-10 w-full rounded-md bg-transparent py-3 text-sm outline-none placeholder:text-muted-foreground disabled:cursor-not-allowed disabled:opacity-50",t),...e})]}));Po.displayName=Fe.Command.Input.displayName;const Lo=M.forwardRef(({className:t,...e},n)=>i.jsx(Fe.Command.List,{ref:n,className:L("max-h-[300px] overflow-y-auto overflow-x-hidden",t),...e}));Lo.displayName=Fe.Command.List.displayName;const Mo=M.forwardRef((t,e)=>i.jsx(Fe.Command.Empty,{ref:e,className:"py-6 text-center text-sm",...t}));Mo.displayName=Fe.Command.Empty.displayName;const Do=M.forwardRef(({className:t,...e},n)=>i.jsx(Fe.Command.Group,{ref:n,className:L("overflow-hidden p-1 text-foreground [&_[cmdk-group-heading]]:px-2 [&_[cmdk-group-heading]]:py-1.5 [&_[cmdk-group-heading]]:text-xs [&_[cmdk-group-heading]]:font-medium [&_[cmdk-group-heading]]:text-muted-foreground",t),...e}));Do.displayName=Fe.Command.Group.displayName;const Ag=M.forwardRef(({className:t,...e},n)=>i.jsx(Fe.Command.Separator,{ref:n,className:L("-mx-1 h-px bg-border",t),...e}));Ag.displayName=Fe.Command.Separator.displayName;const ys=M.forwardRef(({className:t,...e},n)=>i.jsx(Fe.Command.Item,{ref:n,className:L("relative flex cursor-default select-none items-center gap-2 rounded-sm px-2 py-1.5 text-sm outline-none data-[disabled=true]:pointer-events-none data-[selected=true]:bg-accent data-[selected=true]:text-accent-foreground data-[disabled=true]:opacity-50 [&_svg]:pointer-events-none [&_svg]:size-4 [&_svg]:shrink-0",t),...e}));ys.displayName=Fe.Command.Item.displayName;const Oo=wn.Root,Fo=wn.Trigger,zs=M.forwardRef(({className:t,align:e="center",sideOffset:n=4,...s},r)=>i.jsx(wn.Portal,{children:i.jsx(wn.Content,{ref:r,align:e,sideOffset:n,className:L("z-50 w-72 origin-[--radix-popover-content-transform-origin] rounded-md border bg-popover p-4 text-popover-foreground shadow-md outline-none data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0 data-[state=closed]:zoom-out-95 data-[state=open]:zoom-in-95 data-[side=bottom]:slide-in-from-top-2 data-[side=left]:slide-in-from-right-2 data-[side=right]:slide-in-from-left-2 data-[side=top]:slide-in-from-bottom-2",t),...s})}));zs.displayName=wn.Content.displayName;const vs=Jt.Provider,pe=Jt.Root,fe=Jt.Trigger,ue=M.forwardRef(({className:t,sideOffset:e=4,...n},s)=>i.jsx(Jt.Portal,{children:i.jsx(Jt.Content,{ref:s,sideOffset:e,className:L("z-50 origin-[--radix-tooltip-content-transform-origin] overflow-hidden rounded-md bg-primary px-3 py-1.5 text-xs text-primary-foreground animate-in fade-in-0 zoom-in-95 data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=closed]:zoom-out-95 data-[side=bottom]:slide-in-from-top-2 data-[side=left]:slide-in-from-right-2 data-[side=right]:slide-in-from-left-2 data-[side=top]:slide-in-from-bottom-2",t),...n})}));ue.displayName=Jt.Content.displayName;const _g=({data:t,onSelect:e,dataType:n})=>{const[s,r]=g.useState([]),[o,a]=g.useState(t),l=f=>Array.isArray(f)?"array":typeof f=="object"&&f!==null?"object":"value",c=g.useCallback(f=>{const m=h=>n==="value"?h==="value"||h==="object":n==="array"?h==="array":h===n;f.type==="object"?(r(h=>[...h,f.key]),a(f.value)):m(f.type)&&e([...s,f.key].join("."),n)},[s,e,n]),d=g.useCallback(()=>{if(s.length>0){const f=s.slice(0,-1);r(f),a(f.reduce((m,h)=>m[h],t))}},[s,t]),p=g.useMemo(()=>o?Object.entries(o).map(([f,m])=>({key:f,value:m,type:l(m)})).filter(f=>!u.startsWith(f.key,$.REPEATER_PREFIX)&&f.key.includes("/")?!1:n==="value"?f.type==="value"||f.type==="object":n==="array"?f.type==="array"||f.type==="object":n==="object"?f.type==="object":!0):[],[o,n]);return i.jsxs(Ro,{className:"fields-command",children:[i.jsx(Po,{className:"border-none",placeholder:"Search..."}),i.jsxs(Lo,{children:[i.jsx(Mo,{children:xt.t("No option found.")}),i.jsxs(Do,{children:[s.length>0&&i.jsxs(ys,{onSelect:d,className:"flex items-center text-sm",children:[i.jsx(v.ChevronLeftIcon,{className:"mr-2 h-4 w-4"}),xt.t("Back")]}),p.map(f=>i.jsxs(ys,{value:f.key,disabled:!1,onSelect:()=>c(f),className:"flex items-center justify-between",children:[i.jsxs("span",{className:"flex items-center gap-x-2",children:[u.startsWith(f.key,$.REPEATER_PREFIX)?i.jsx(v.LoopIcon,{}):u.startsWith(f.key,$.COLLECTION_PREFIX)?i.jsx(v.IdCardIcon,{}):null,u.startsWith(f.key,$.REPEATER_PREFIX)?xt.t("Repeater Data"):u.startsWith(f.key,$.COLLECTION_PREFIX)?f.key.replace($.COLLECTION_PREFIX,""):f.key]}),i.jsxs("div",{className:"flex items-center gap-2",children:[n==="object"&&f.type==="object"&&i.jsx(q,{size:"sm",variant:"ghost",className:"h-6 px-2 hover:bg-primary hover:text-primary-foreground",onClick:m=>{m.stopPropagation(),e([...s,f.key].join("."),n)},children:xt.t("Select")}),f.type==="object"&&i.jsx("div",{className:"cursor-pointer rounded p-1 hover:bg-muted",children:i.jsx(v.ChevronRightIcon,{className:"h-4 w-4 opacity-50"})})]})]},f.key))]})]})]})};function $o({data:t,onSelect:e,dataType:n="value"}){const[s,r]=g.useState(!1),o=O("collections",[]),a=g.useMemo(()=>n==="array"?{...o.map(c=>c.id).reduce((c,d)=>({...c,[$.COLLECTION_PREFIX+d]:[]}),{}),...t}:t,[t,o,n]);return i.jsxs(Oo,{open:s,onOpenChange:r,children:[i.jsxs(pe,{children:[i.jsx(fe,{asChild:!0,children:i.jsx(Fo,{asChild:!0,children:i.jsx(q,{size:"sm",variant:"ghost",className:"h-5 rounded-sm px-1 py-0 text-[9px] text-muted-foreground",role:"combobox","aria-expanded":s,children:i.jsx("svg",{xmlns:"http://www.w3.org/2000/svg",width:"24px",height:"24px",viewBox:"0 0 24 24",fill:"none",children:i.jsx("path",{d:"M9.5 5H9C7.89543 5 7 5.89543 7 7V9C7 10 6.4 12 4 12C5 12 7 12.6 7 15V17.0002C7 18.1048 7.89543 19 9 19H9.5M14.5 5H15C16.1046 5 17 5.89543 17 7V9C17 10 17.6 12 20 12C19 12 17 12.6 17 15V17.0002C17 18.1048 16.1046 19 15 19H14.5",stroke:"#000000",strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:"2"})})})})}),i.jsx(ue,{children:xt.t("Add field")})]}),i.jsx(zs,{className:"z-[1000]! relative mr-3 w-[300px] p-0",children:i.jsx(_g,{data:a,onSelect:(l,c)=>{e(l,c),r(!1)},dataType:n})})]})}const cc=({schema:t,onChange:e,id:n,formData:s})=>{const r=sn(),o=O("flags.dataBinding",!0),a=Nu(),l=Z(),c=g.useMemo(()=>{if(a.length===1)return"";const f=a.find(b=>b._type==="Repeater"),h=u.get(f,"repeaterItems","").replace(/\{\{(.*)\}\}/g,"$1");return`${$.REPEATER_PREFIX}${u.startsWith(h,$.COLLECTION_PREFIX)?`${h}/${f._id}`:h}`},[a]),d=g.useMemo(()=>u.first(u.get(r,c.replace($.REPEATER_PREFIX,""),[])),[c,r]),p=g.useCallback((f,m)=>{if(f=u.isEmpty(c)?f:f.replace(`${c}`,"$index"),m==="array"||m==="object"){e(`{{${f}}}`,{},n);return}const h=k=>/[.,!?;:]/.test(k),b=(k,w,E)=>{let A="",_="";const I=w>0?k[w-1]:"",j=w<k.length?k[w]:"";return w>0&&(I==="."||!h(I)&&I!==" ")&&(A=" "),w<k.length&&!h(j)&&j!==" "&&(_=" "),{text:A+E+_,prefixLength:A.length,suffixLength:_.length}},x=document.getElementById(n);if(!x)return;const y=document.getElementById(`chai-rte-${n}`)||document.getElementById(`chai-rte-modal-${n}`);if(y&&(y.querySelector(".ProseMirror")||y.__chaiRTE)){const k=y.__chaiRTE;if(k){const w=`{{${f}}}`;k.commands.focus();const{from:E,to:A}=k.state.selection;if(E!==A)k.chain().deleteSelection().insertContent(w).run();else{const{state:I}=k,j=I.selection.from,N=I.doc.textBetween(Math.max(0,j-1),j),C=I.doc.textBetween(j,Math.min(j+1,I.doc.content.size));let T="";j>0&&N!==" "&&!h(N)&&(T=" ");let R="";C&&C!==" "&&!h(C)&&(R=" "),k.chain().insertContent(T+w+R).run()}setTimeout(()=>e(k.getHTML(),{},n),100);return}}else{const k=x,w=k.selectionStart||0,E=k.value||"",A=k.selectionEnd||w;if(A>w){const C=`{{${f}}}`,{text:T}=b(E,w,C),R=E.slice(0,w)+T+E.slice(A);e(R,{},n);return}const I=`{{${f}}}`,{text:j}=b(E,w,I),N=E.slice(0,w)+j+E.slice(w);e(N,{},n)}},[n,e,s,l==null?void 0:l._id,c]);return o?i.jsx($o,{data:{...d&&{[c]:d},...r},onSelect:p,dataType:t.binding==="array"?"array":"value"}):null},Ig=({href:t,pageTypes:e,onChange:n})=>{var N;const{t:s}=F.useTranslation(),r=O("searchPageTypeItems",(C,T)=>[]),[o,a]=g.useState(!1),[l,c]=g.useState(!1),[d,p]=g.useState("page"),[f,m]=g.useState(""),[h,b]=g.useState([]),[x,y]=g.useState(-1),k=g.useRef(null),w=(N=e==null?void 0:e.find(C=>C.key===d))==null?void 0:N.name;g.useEffect(()=>{if(m(""),b([]),y(-1),c(!1),!t||o||!u.startsWith(t,"pageType:"))return;const C=u.split(t,":"),T=u.get(C,1,"page")||"page";p(T),(async()=>{const R=await r(T,[u.get(C,2,"page")]);R&&Array.isArray(R)&&m(u.get(R,[0,"name"],""))})()},[t]);const E=ke.useDebouncedCallback(async C=>{if(u.isEmpty(C))b([]);else{const T=await r(d,C);b(T)}a(!1),y(-1)},[d],300),A=C=>{const T=["pageType",d,C.id];T[1]&&(n(T.join(":")),m(C.name),c(!1),b([]),y(-1))},_=C=>{switch(C.key){case"ArrowDown":C.preventDefault(),y(T=>T<h.length-1?T+1:T);break;case"ArrowUp":C.preventDefault(),y(T=>T>0?T-1:T);break;case"Enter":if(C.preventDefault(),h.length===0)return;x>=0&&A(h[x]);break;case"Escape":C.preventDefault(),I();break}};g.useEffect(()=>{if(x>=0&&k.current){const C=k.current.children[x];C==null||C.scrollIntoView({block:"nearest"})}},[x]);const I=()=>{m(""),b([]),y(-1),c(!1),n("")},j=C=>{m(C),c(!u.isEmpty(C)),a(!0),E(C)};return i.jsxs("div",{children:[i.jsx("select",{name:"pageType",value:d,onChange:C=>p(C.target.value),children:u.map(e,C=>i.jsx("option",{value:C.key,children:C.name},C.key))}),d&&i.jsxs("div",{className:"group relative mt-2 flex items-center",children:[i.jsx("input",{type:"text",value:f,onChange:C=>j(C.target.value),onKeyDown:_,placeholder:s(`Search ${w??""}`),className:"w-full rounded-md border border-gray-300 p-2 pr-16"}),i.jsx("div",{className:"absolute bottom-2 right-2 top-3 flex items-center gap-1.5",children:f&&i.jsx("button",{onClick:I,className:"text-gray-400 hover:text-gray-600",title:s("Clear search"),children:i.jsx(v.Cross1Icon,{className:"h-4 w-4"})})})]}),(o||!u.isEmpty(h)||l&&u.isEmpty(h))&&i.jsx("div",{className:"absolute z-40 mt-2 max-h-40 w-full max-w-[250px] overflow-y-auto rounded-md border border-border bg-background shadow-lg",children:o?i.jsxs("div",{className:"space-y-1 p-2",children:[i.jsx("div",{className:"h-6 w-full animate-pulse rounded bg-gray-200"}),i.jsx("div",{className:"h-6 w-full animate-pulse rounded bg-gray-200"})]}):l&&u.isEmpty(h)?i.jsxs("div",{className:"flex items-center justify-center p-4 text-sm text-gray-500",children:[s("No results found for"),' "',f,'"']}):i.jsx("ul",{ref:k,children:u.map(h==null?void 0:h.slice(0,20),(C,T)=>i.jsxs("li",{onClick:()=>A(C),className:`cursor-pointer p-2 text-xs ${t!=null&&t.includes(C.id)?"bg-blue-200":T===x?"bg-gray-100":"hover:bg-gray-100"}`,children:[C.name," ",C.slug&&i.jsxs("small",{className:"font-light text-gray-500",children:["( ",C.slug," )"]})]},C.id))})})]})},Tg=({schema:t,formData:e,onChange:n,name:s})=>{const{t:r}=F.useTranslation(),{type:o="pageType",href:a="",target:l="self"}=e??{},c=O("pageTypes",[]),{selectedLang:d,fallbackLang:p,languages:f}=Le(),m=g.useMemo(()=>u.isEmpty(f)?"":u.isEmpty(d)?p:d,[f,d,p]),h=g.useMemo(()=>u.get(Qt,m,m),[m]),b=o==="pageType"&&u.isEmpty(c)?"url":o;return i.jsxs("div",{children:[i.jsxs("span",{className:"flex items-center justify-between gap-x-2 text-xs font-medium",children:[i.jsxs("span",{children:[(t==null?void 0:t.title)??"Link",i.jsx("span",{className:"pl-1 text-[9px] text-zinc-400",children:h})]}),i.jsx(cc,{schema:t,onChange:x=>{n({...e,href:x,...b==="pageType"?{type:"url"}:{}})},id:`root.${s}.href`,formData:e})]}),i.jsxs("div",{className:"flex flex-col gap-y-1.5",children:[i.jsx("select",{name:"type",value:o,onChange:x=>n({...e,type:x.target.value}),children:u.map([...u.isEmpty(c)?[]:[{const:"pageType",title:r("Goto Page")}],{const:"url",title:r("Open URL")},{const:"email",title:r("Compose Email")},{const:"telephone",title:r("Call Phone")},{const:"scroll",title:r("Scroll to element")}],x=>i.jsx("option",{value:x.const,children:x.title},x.const))}),b==="pageType"&&!u.isEmpty(c)?i.jsx(Ig,{href:a,pageTypes:c,onChange:x=>n({...e,href:x})}):null,i.jsx("input",{id:`root.${s}.href`,autoCapitalize:"off",autoCorrect:"off",spellCheck:"false",name:"href",type:"text",className:b==="pageType"?"!hidden":"",value:a,onChange:x=>n({...e,href:x.target.value}),placeholder:r(o==="url"?"Enter URL":o==="scroll"?"#ElementID":"Enter details")}),b==="url"&&i.jsxs("div",{className:"flex items-center gap-x-2 text-muted-foreground",children:[i.jsx("input",{id:`root.${s}.target`,autoCapitalize:"off",autoCorrect:"off",spellCheck:"false",type:"checkbox",checked:l==="_blank",className:"!w-fit cursor-pointer rounded-md border border-border",onChange:()=>n({...e,target:l==="_blank"?"_self":"_blank"})}),i.jsx("span",{className:"pt-1 text-xs",children:r("Open in new tab")})]})]})]})},dc=S.atom(t=>{var a;const e=t(Se),n=t(As),s=n.length===1?n[0]:null;if(!s)return null;const r=u.find(e,{_id:s});if(!r)return null;let o=r._parent;for(;o;){const l=u.find(e,{_id:o});if(!l)return null;if((a=J.getRegisteredChaiBlock(l._type))!=null&&a.wrapper)return l;o=l._parent}return null});dc.debugLabel="wrapperBlockAtom";const zo=()=>S.useAtomValue(dc),Bg=()=>{const t=Z(),e=zo(),{addCoreBlock:n}=yt();if(!t&&!e)return null;const s=(t==null?void 0:t._type)==="Row"?t:e;return i.jsx("div",{className:"pt-1",children:i.jsxs("button",{type:"button",className:"duratiom-300 flex items-center gap-x-1 rounded border border-gray-400 bg-gray-100 px-4 py-1 text-[11px] font-medium leading-tight hover:bg-slate-200",onClick:()=>n({type:"Column",styles:"#styles:,"},s==null?void 0:s._id),children:[i.jsx(v.PlusIcon,{className:"h-4 w-4"})," Add Column"]})})},Rg=g.lazy(()=>Promise.resolve().then(()=>require("./rte-widget-modal-BaHIuEjF.cjs"))),Pg=({blockId:t,id:e,placeholder:n,value:s,onChange:r,onBlur:o})=>{const a=g.useRef(null),[l,c]=g.useState(!1),d=Jl({blockId:t,value:s,placeholder:n,onBlur:({editor:m})=>{const h=m==null?void 0:m.getHTML();o(e,h)},onUpdate:({editor:m})=>{const h=m==null?void 0:m.getHTML();r(h)}});g.useEffect(()=>{a.current&&d&&(a.current.__chaiRTE=d)},[t,d]);const p=()=>{c(!1)},f=i.jsxs("div",{id:`chai-rte-${e}`,ref:a,className:"mt-1 rounded-md border border-input",children:[i.jsx(sl,{editor:d,onExpand:()=>c(!0)}),i.jsx(as.EditorContent,{editor:d,id:e,placeholder:n,className:`overflow-auto ${l?"max-h-[500px] min-h-[400px]":"max-h-[200px] min-h-[100px]"}`},e)]});return i.jsxs(i.Fragment,{children:[l&&i.jsx(g.Suspense,{fallback:i.jsx("div",{children:"Loading..."}),children:i.jsx(Rg,{isOpen:l,onClose:p,editor:d,rteElement:f})}),l?i.jsx("div",{children:"Open in modal"}):i.jsx("div",{className:"relative",children:f})]})},Lg=t=>{const{editingBlockId:e}=$t(),[n,s]=g.useState(null),r=Z(),o=r==null?void 0:r._id;return g.useEffect(()=>{s(o)},[o]),n&&n!==e?i.jsx(Pg,{...t,blockId:n},n):null},Mg=({formData:t,onChange:e})=>{const[n]=te(),s=Z(),r=zo(),{addCoreBlock:o}=yt(),[,a]=K();if(!s&&!r)return null;const l=(s==null?void 0:s._type)==="Slider"?s:r,c=u.find(n,{_parent:l==null?void 0:l._id,_type:"Slides"});if(!c)return null;const d=u.filter(n,{_parent:c==null?void 0:c._id,_type:"Slide"}),p=(t==null?void 0:t.currentSlide)||u.get(d,"0._id");g.useEffect(()=>{(s==null?void 0:s._type)==="Slide"&&(t==null?void 0:t.currentSlide)!==(s==null?void 0:s._id)&&e({...t,currentSlide:s==null?void 0:s._id})},[s]),g.useEffect(()=>{d!=null&&d.length&&!u.find(d,{_id:t==null?void 0:t.currentSlide})&&e({...t,currentSlide:u.get(d,"0._id")})},[t,d]);const f=()=>{const b=u.findIndex(d,{_id:p});if(b>-1){const x=(b+1)%d.length,y=u.get(d,[x,"_id"]);if(!y)return;e({...t,currentSlide:y}),a([y])}},m=()=>{const b=u.findIndex(d,{_id:p});if(b>-1){const x=(b-1+d.length)%d.length,y=u.get(d,[x,"_id"]);if(!y)return;e({...t,currentSlide:y}),a([y])}},h=()=>{const b=o({styles:"#styles:,h-full w-full min-w-full",type:"Slide"},c==null?void 0:c._id),x=b==null?void 0:b._id;x&&(e({...t,currentSlide:x}),a([x]))};return i.jsxs("div",{className:"space-y-1.5 px-2",children:[i.jsxs("div",{className:"flex items-center gap-x-2 pb-2 text-[12px]",children:[i.jsx("button",{onClick:m,className:"rounded bg-gray-200 p-1.5 hover:opacity-80",children:i.jsx(v.ChevronLeftIcon,{className:"h-3 w-3"})}),i.jsx("div",{className:"whitespace-nowrap text-center text-[10px] text-slate-500",children:p?i.jsxs("span",{className:"",children:[i.jsxs("b",{className:"text-[12px]",children:[" ",u.findIndex(d,{_id:p})+1]}),"/",d.length]}):"-"}),i.jsx("button",{onClick:f,className:"rounded bg-gray-200 p-1.5 hover:opacity-80",children:i.jsx(v.ChevronRightIcon,{className:"h-3 w-3"})}),i.jsxs("button",{onClick:h,className:"flex w-full items-center justify-center gap-x-1 rounded bg-gray-200 p-1.5 text-xs font-medium leading-tight hover:opacity-80",children:[i.jsx(v.PlusCircledIcon,{className:"h-3 w-3"}),"Add Slide"]})]}),i.jsxs("div",{className:"flex items-center gap-x-2 leading-tight",children:[i.jsx("input",{type:"checkbox",checked:!!(t!=null&&t.showSlideButton),onChange:()=>e({...t,showSlideButton:!(t!=null&&t.showSlideButton)}),className:"cursor-pointer"}),i.jsx("label",{htmlFor:"autoplay",className:"mt-0.5 text-[12px]",children:"Show Slide Buttons"})]}),i.jsxs("div",{className:"flex items-center gap-x-2 leading-tight",children:[i.jsx("input",{type:"checkbox",checked:!!(t!=null&&t.showSlideNavbar),onChange:()=>e({...t,showSlideNavbar:!(t!=null&&t.showSlideNavbar)}),className:"cursor-pointer"}),i.jsx("label",{htmlFor:"autoplay",className:"mt-0.5 text-[12px]",children:"Show Slide Navbar"})]}),i.jsx("div",{children:i.jsxs("div",{className:"flex flex-col",children:[i.jsxs("div",{className:"flex items-center gap-x-2 leading-tight",children:[i.jsx("input",{type:"checkbox",checked:!!(t!=null&&t.autoplay),onChange:()=>e({...t,autoplay:!(t!=null&&t.autoplay)}),className:"cursor-pointer"}),i.jsx("label",{htmlFor:"autoplay",className:"mt-0.5 text-[12px]",children:"Autoplay slides"})]}),(t==null?void 0:t.autoplay)&&i.jsxs("div",{className:"pt-0.5 leading-tight",children:[i.jsxs("label",{htmlFor:"interval",className:"whitespace-nowrap text-[9px]",children:["Autoplay Interval ",i.jsx("span",{className:"font-light opacity-80",children:"(in seconds)"})]}),i.jsx("input",{type:"number",id:"interval",name:"interval",placeholder:"0",value:t==null?void 0:t.autoplayInterval,className:"text-xs",pattern:"[0-9]*",onChange:b=>{let x=b.target.value;x.length&&(x=x.replace("-","")),e({...t,autoplayInterval:x})}})]})]})})]})},Dg=({formData:t,onChange:e})=>{const n=u.get(t,"srcsets",[])||[],s=(a,l)=>{const c=a.target.name,d=a.target.value;e({srcsets:u.map(n,(p,f)=>f===l?{...p,[c]:d}:p)})},r=()=>{e({srcsets:[...n,{}]})},o=a=>{e({srcsets:u.reject(n,(l,c)=>c===a)})};return i.jsxs("div",{children:[i.jsxs("div",{className:"flex items-center justify-between pb-2",children:[i.jsx("label",{children:"Responsive Video (optional)"}),i.jsx("button",{type:"button",onClick:r,className:"flex items-center gap-x-1 rounded-md border border-blue-500 bg-blue-100 px-2 py-px text-xs text-blue-600 hover:opacity-80",children:i.jsx(v.PlusIcon,{className:"h-3 w-3"})})]}),i.jsx("div",{className:"space-y-2",children:n.length===0?i.jsx("div",{className:"rounded border border-dashed border-gray-200 p-2 text-xs italic text-gray-500",children:"Add additional sources to create responsive videos"}):u.map(n,(a,l)=>i.jsxs("div",{className:"group relative space-y-1.5 rounded border border-gray-200 px-2 pb-1.5",children:[i.jsx("button",{type:"button",onClick:()=>o(l),className:"absolute -right-px -top-0 -translate-y-1/2 rounded-full bg-red-100 p-1 opacity-0 hover:bg-red-200 group-hover:opacity-100",children:i.jsx(v.Cross1Icon,{className:"h-2.5 w-2.5 text-red-500"})}),i.jsxs("div",{className:"flex items-center gap-x-2 rounded border",children:[i.jsx("label",{className:"flex !h-6 h-full w-1/4 items-center justify-center bg-gray-200 px-2 !text-[10px] !font-medium",children:"Width"}),i.jsx("input",{name:"width",placeholder:"Enter width (in px)",type:"number",value:u.get(a,"width"),onChange:c=>s(c,l),className:"!placeholder:text-gray-100 !mt-0 !rounded-none !border-0 !p-0 !text-xs"})]}),i.jsxs("div",{className:"flex items-center gap-x-2 rounded border",children:[i.jsx("label",{className:"flex !h-6 h-full w-1/4 items-center justify-center bg-gray-200 px-2 !text-[10px] !font-medium",children:"URL"}),i.jsx("input",{name:"url",placeholder:"Enter url",className:"!mt-0 !rounded-none !border-0 !p-0 !text-xs !shadow-none",value:u.get(a,"url",""),onChange:c=>s(c,l)})]})]},l))})]})},Og=({id:t,placeholder:e})=>{const{t:n}=F.useTranslation(),[,s]=_o(),r=Z();if(typeof window>"u")return null;const o=t.replace("root.",""),a=u.get(r,o,""),l=()=>{const c=r==null?void 0:r._id;s({blockId:c,blockProp:o,placeholder:e,initialCode:u.get(r,o,a)})};return i.jsxs("div",{className:"mt-2 flex flex-col gap-y-1",children:[i.jsx("button",{onClick:l,className:"w-[90%] max-w-full cursor-default truncate text-pretty rounded border border-border bg-background p-2 text-left text-[10px]",children:a.trim().length>0?a.substring(0,46):e||"Eg: <script>console.log('Hello, world!');<\/script>"}),i.jsx(q,{onClick:l,size:"sm",variant:"outline",className:"w-fit",children:n("Open code editor")})]})},Fg=({id:t,value:e,onChange:n,onBlur:s})=>{const r=O("collections",[]),o=Z(),a=u.get(o,"repeaterItems","").replace(/\{\{(.*)\}\}/g,"$1").replace($.COLLECTION_PREFIX,""),l=u.find(r,{id:a}),c=t==="root.filter"?"filters":"sorts",d=u.get(l,c,[]);return i.jsx("div",{children:i.jsxs("select",{value:e,onChange:p=>n(p.target.value),onBlur:p=>s(t,p.target.value),children:[i.jsx("option",{value:"",children:"Select"}),d.map(p=>i.jsx("option",{value:p.id,children:p.name},p.id))]})})},$g=_n.cva("inline-flex items-center rounded-md border px-2.5 py-0.5 text-xs font-semibold transition-colors focus:outline-none focus:ring-2 focus:ring-ring focus:ring-offset-2",{variants:{variant:{default:"border-transparent bg-primary text-primary-foreground shadow hover:bg-primary/80",secondary:"border-transparent bg-secondary text-secondary-foreground hover:bg-secondary/80",destructive:"border-transparent bg-destructive text-destructive-foreground shadow hover:bg-destructive/80",outline:"text-foreground"}},defaultVariants:{variant:"default"}});function Hs({className:t,variant:e,...n}){return i.jsx("div",{className:L($g({variant:e}),t),...n})}const zg=t=>{const{id:e,classNames:n,label:s,children:r,errors:o,help:a,hidden:l,required:c,schema:d,formData:p,onChange:f}=t,{selectedLang:m,fallbackLang:h,languages:b}=Le(),x=g.useMemo(()=>u.isEmpty(b)?"":u.isEmpty(m)?h:m,[b,m,h]),y=g.useMemo(()=>u.get(Qt,x,x),[x]),k=sn(),w=Z(),E=J.useRegisteredChaiBlocks(),A=g.useMemo(()=>u.get(E,[w==null?void 0:w._type,"i18nProps"],[]),[E,w==null?void 0:w._type]),[_,I]=g.useState(null);if(l)return null;if(d.type==="boolean")return i.jsx("div",{className:n,children:r});const N=A==null?void 0:A.includes(e.replace("root.",""));if(d.type==="array"){const R=_===e;return i.jsxs("div",{className:`${n} relative`,children:[d.title&&i.jsx("div",{className:"flex items-center justify-between gap-1",children:i.jsxs("label",{htmlFor:e,onClick:()=>I(R?null:e),className:"flex cursor-pointer items-center gap-x-1 py-1 leading-tight duration-200 hover:bg-slate-100",children:[R?i.jsx(v.ChevronDownIcon,{className:"h-3 w-3"}):i.jsx(v.ChevronRightIcon,{className:"h-3 w-3"}),i.jsx(v.ListBulletIcon,{className:"h-3 w-3"}),i.jsx("span",{className:"leading-tight",children:s})," ",i.jsx(Hs,{className:"m-0 bg-gray-200 px-2 leading-tight text-gray-500 hover:bg-gray-200 hover:text-gray-500",children:i.jsx("span",{className:"text-[9px] font-medium text-slate-600",children:p==null?void 0:p.length})}),d.description&&i.jsx(vs,{children:i.jsxs(pe,{children:[i.jsx(fe,{asChild:!0,children:i.jsx(v.InfoCircledIcon,{className:"h-3 w-3 text-muted-foreground/70",onClick:B=>B.stopPropagation(),onMouseDown:B=>B.stopPropagation()})}),i.jsx(ue,{className:"max-w-xs",children:d.description})]})})]})}),(p==null?void 0:p.length)===0?i.jsx("div",{className:"h-0 overflow-hidden",children:r}):i.jsxs("div",{className:`${R?"pt-0.5":"h-0 overflow-hidden"}`,children:[r,o,a]})]})}const C=e.replace("root.",""),T=A.includes(C)&&!u.isEmpty(m)&&u.isEmpty(p);return i.jsxs("div",{className:n,children:[d.title&&i.jsxs("div",{className:"flex items-center justify-between",children:[i.jsxs("div",{className:"flex items-center gap-2",children:[i.jsxs("label",{htmlFor:e,className:d.type==="object"?"pb-2":"",children:[s," ",N&&i.jsxs("small",{className:"text-[9px] text-zinc-400",children:[" ",y]}),c&&d.type!=="object"?" *":null]}),d.description&&i.jsx(vs,{children:i.jsxs(pe,{children:[i.jsx(fe,{asChild:!0,children:i.jsx(v.InfoCircledIcon,{className:"h-3 w-3 text-muted-foreground/70"})}),i.jsx(ue,{className:"max-w-xs",children:d.description})]})})]}),!d.enum&&!d.oneOf&&k&&i.jsxs("span",{className:"flex items-center space-x-1",children:[T?i.jsxs(pe,{children:[i.jsx(fe,{asChild:!0,children:i.jsxs("svg",{xmlns:"http://www.w3.org/2000/svg",width:"24",height:"24",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor","stroke-width":"2","stroke-linecap":"round","stroke-linejoin":"round",className:"lucide lucide-triangle-alert-icon lucide-triangle-alert h-3 w-3 text-orange-400",children:[i.jsx("path",{d:"m21.73 18-8-14a2 2 0 0 0-3.48 0l-8 14A2 2 0 0 0 4 21h16a2 2 0 0 0 1.73-3"}),i.jsx("path",{d:"M12 9v4"}),i.jsx("path",{d:"M12 17h.01"})]})}),i.jsxs(ue,{className:"max-w-xs",children:["No translation provided. ",i.jsx("br",{}),"Using default language value."]})]}):null,i.jsx(cc,{schema:d,onChange:R=>{f(R,p,e)},id:e,formData:p})]})]}),r,o,a]})},Hg=({value:t,onChange:e})=>{var o;if(!t)return i.jsxs("div",{className:"mt-1 flex items-center gap-2 rounded-md border border-gray-200 bg-gray-50 px-2 py-1.5 text-xs text-gray-500 text-gray-600",children:[i.jsx(v.FileIcon,{className:"h-4 w-4"})," Choose a collection"]});const n=`{{${$.COLLECTION_PREFIX}`,s=t==null?void 0:t.startsWith(n);let r=t;return s&&(r=(o=t==null?void 0:t.replace(n,""))==null?void 0:o.replace("}}","")),i.jsx("div",{className:"mt-1 flex flex-col gap-1",children:i.jsxs("div",{className:"flex items-center justify-between gap-2 rounded-md border border-blue-200 bg-blue-50 px-2 py-1 text-xs text-blue-600",children:[i.jsxs("span",{className:"flex max-w-[200px] items-center gap-2",children:[" ",s?i.jsx(v.IdCardIcon,{className:"h-3 min-h-3 w-3 min-w-3"}):null,i.jsxs(pe,{delayDuration:500,children:[i.jsx(fe,{asChild:!0,children:i.jsx("span",{className:"cursor-default truncate",children:r})}),i.jsx(ue,{side:"left",hidden:r.length<50,children:r})]})]}),i.jsxs(pe,{children:[i.jsx(fe,{asChild:!0,children:i.jsx(q,{variant:"ghost",size:"icon",className:"h-5 w-5 rounded-full bg-gray-200 text-gray-900 hover:bg-gray-300",onClick:()=>e(""),children:i.jsx(v.Cross1Icon,{className:"h-4 w-4"})})}),i.jsx(ue,{side:"left",children:"Remove binding"})]})]})})},Vg=t=>i.jsx("button",{...t,className:"duration absolute right-2 top-2 cursor-pointer text-blue-400 hover:text-blue-500",children:i.jsxs("div",{className:"flex items-center gap-x-0.5 text-[11px] leading-tight",children:[i.jsx(v.PlusIcon,{className:"h-3 w-3"})," ",i.jsx("span",{children:"Add"})]})}),Fi=g.memo(({blockId:t,schema:e,uiSchema:n,formData:s,onChange:r})=>{const{selectedLang:o}=Le(),a=dr("widget"),l=dr("field"),c=dr("template"),d=ke.useThrottledCallback(async({formData:p},f)=>{u.get(p,f)===void 0&&u.set(p,f,""),r({formData:p},f)},[r,o],400);return i.jsx($d,{widgets:{richtext:Lg,icon:vg,image:Eg,code:Og,colCount:Bg,collectionSelect:Fg,repeaterBinding:Hg,...a},fields:{link:Tg,slider:Mg,sources:Dg,...l},templates:{FieldTemplate:zg,ButtonTemplates:{AddButton:Vg},...c},idSeparator:".",autoComplete:"off",omitExtraData:!1,liveOmit:!1,liveValidate:!1,validator:zd,uiSchema:n,schema:e,formData:s,onChange:({formData:p},f)=>{if(!f||t!==(p==null?void 0:p._id))return;const m=u.take(f.split("."),2).join(".").replace("root.","");d({formData:p},m)}},o)}),$i=(t,e,n)=>{const s=u.cloneDeep(t);return u.forEach(u.keys(t),r=>{u.includes(u.get(n,"i18nProps",[]),r)&&!u.isEmpty(e)&&(s[r]=u.get(t,`${r}-${e}`))}),s};function Nr(){const{selectedLang:t}=Le(),e=Z(),n=Jr(),s=tt(),r=J.getRegisteredChaiBlock(e==null?void 0:e._type),o=$i(e,t,r),[a,l]=g.useState(o),[c,d]=g.useState(!1),p=zo(),f=J.getRegisteredChaiBlock(p==null?void 0:p._type),m=$i(p,t,f),h=({formData:_},I,j)=>{I&&(a==null?void 0:a._id)===e._id&&s([e._id],{[I]:u.get(_,I)},j)},b=g.useCallback(u.debounce(({formData:_},I,j)=>{h({formData:_},I,j),l(_)},1500),[e==null?void 0:e._id,t]),x=({formData:_},I)=>{I&&(n([e._id],{[I]:u.get(_,I)}),b({formData:_},I,{[I]:u.get(a,I)}))},y=({formData:_},I)=>{I&&(n([p._id],{[I]:u.get(_,I)}),b({formData:_},I,{[I]:u.get(a,I)}))},{schema:k,uiSchema:w}=g.useMemo(()=>{const _=e==null?void 0:e._type;if(!_)return{schema:{},uiSchema:{}};try{const{schema:I,uiSchema:j}=J.getBlockFormSchemas(_);if(_==="Repeater"){const N=u.get(e,"repeaterItems","");u.startsWith(N,`{{${$.COLLECTION_PREFIX}`)?(u.set(j,"filter",{"ui:widget":"collectionSelect"}),u.set(j,"sort",{"ui:widget":"collectionSelect"})):(u.set(j,"filter",{"ui:widget":"hidden"}),u.set(j,"sort",{"ui:widget":"hidden"}))}return{schema:I,uiSchema:j}}catch{return{schema:{},uiSchema:{}}}},[e]),{wrapperSchema:E,wrapperUiSchema:A}=g.useMemo(()=>{if(!p||!(p!=null&&p._type))return{wrapperSchema:{},wrapperUiSchema:{}};const _=p==null?void 0:p._type,{schema:I={},uiSchema:j={}}=J.getBlockFormSchemas(_);return{wrapperSchema:I,wrapperUiSchema:j}},[p]);return i.jsxs("div",{className:"no-scrollbar overflow-x-hidden px-px",children:[!u.isEmpty(p)&&i.jsxs("div",{className:"mb-4 rounded border bg-zinc-100 px-1",children:[i.jsxs("div",{onClick:()=>d(_=>!_),className:"flex cursor-pointer items-center gap-x-1 py-2 text-xs font-medium leading-tight hover:bg-slate-100",children:[c?i.jsx(v.ChevronDownIcon,{className:"h-4 w-4 text-slate-400"}):i.jsx(v.ChevronRightIcon,{className:"h-4 w-4 text-slate-400"}),u.startCase(p._type)," settings"," ",p._name&&i.jsxs("span",{className:"text-[11px] font-light text-slate-400",children:["(",p._name,")"]})]}),i.jsx("div",{className:c?"h-auto":"invisible h-0",children:i.jsx(Fi,{blockId:p==null?void 0:p._id,onChange:y,formData:m,schema:E,uiSchema:A})})]}),u.isEmpty(k)?null:i.jsx(Fi,{blockId:e==null?void 0:e._id,onChange:x,formData:o,schema:k,uiSchema:w})]})}const uc=Lt.Root,Ho=M.forwardRef(({className:t,...e},n)=>i.jsx(Lt.Item,{ref:n,className:L("border-b",t),...e}));Ho.displayName="AccordionItem";const Vo=M.forwardRef(({className:t,children:e,...n},s)=>i.jsx(Lt.Header,{className:"flex",children:i.jsxs(Lt.Trigger,{ref:s,className:L("flex flex-1 items-center justify-between py-4 text-sm font-medium transition-all hover:underline text-left [&[data-state=open]>svg]:rotate-180",t),...n,children:[e,i.jsx(v.ChevronDownIcon,{className:"h-4 w-4 shrink-0 text-muted-foreground transition-transform duration-200"})]})}));Vo.displayName=Lt.Trigger.displayName;const Wo=M.forwardRef(({className:t,children:e,...n},s)=>i.jsx(Lt.Content,{ref:s,className:"overflow-hidden text-sm data-[state=closed]:animate-accordion-up data-[state=open]:animate-accordion-down",...n,children:i.jsx("div",{className:L("pb-4 pt-0",t),children:e})}));Wo.displayName=Lt.Content.displayName;const Wg=S.atom(null,(t,e,{blockIds:n,fullClasses:s})=>{const r=u.first(t(Mn)),o=u.filter(t(In),a=>n.includes(t(a)._id));return u.map(o,a=>{const l=t(a),c=s;let{classes:d,baseClasses:p}=$.getSplitChaiClasses(u.get(l,r.prop,`${$.STYLES_KEY},`));return u.each(c,f=>{const m=f.replace(/[.*+?^${}()|[\]\\]/g,"\\$&"),h=new RegExp(`(^|\\s)${m}(?=\\s|$)`,"g");d=d.replace(h," ").replace(/\s+/g," ").trim();const b=u.first(f.split(":"));u.includes(["2xl","xl","lg","md","sm"],b)&&c.push(f.split(":").pop().trim())}),u.each(c,f=>{const m=f.replace(/[.*+?^${}()|[\]\\]/g,"\\$&"),h=new RegExp(`(^|\\s)${m}(?=\\s|$)`,"g");p=p.replace(h," ").replace(/\s+/g," ").trim()}),{ids:[l._id],props:{[r.prop]:`${$.STYLES_KEY}${p},${d}`}}})}),Ug=t=>{const e=Object.keys(t).filter(s=>typeof t[s]=="string"&&t[s].startsWith($.STYLES_KEY)),n={};return e.forEach(s=>{n[s]=`${$.STYLES_KEY},`}),{ids:[t._id],props:n}},Gg=()=>{const{updateBlocks:t,updateBlocksRuntime:e}=Ne();return g.useCallback((n,s=!1)=>{const{ids:r,props:o}=Ug(n);s?t(r,o):e(r,o)},[t,e])},Uo=()=>{const{updateBlocks:t,updateBlocksRuntime:e}=Ne(),n=S.useSetAtom(Wg);return g.useCallback((s,r,o=!1)=>{const a=n({blockIds:s,fullClasses:r});o?t(s,a[0].props):e(s,a[0].props)},[n])},pc=()=>{const t=Z(),e=tt(),n=g.useCallback(a=>J.getDefaultBlockProps(a)||{},[]),s=g.useCallback(a=>Object.keys(a).filter(l=>typeof a[l]=="string"&&a[l].startsWith("#styles:")),[]),r=g.useCallback(a=>{if(!t)return;const c=n(t._type)[a]??"#styles:,";e([t._id],{[a]:c})},[t,n,e]);return{resetAll:g.useCallback(()=>{if(!t)return;const a=s(t);if(a.length===0)return;const l=n(t._type),c=u.pick(l,a);e([t._id],c)},[t,s,n,e]),reset:r}},qg=()=>{var h;const t=Z(),[e,n]=Ee(),s=Uo(),[r]=K(),{t:o}=F.useTranslation();if(!t)return null;const a=Object.keys(t).filter(b=>typeof t[b]=="string"&&t[b].startsWith("#styles:")),{reset:l}=pc(),c=!u.isEmpty(a)&&a.length>1,d=u.get(t,(h=e[0])==null?void 0:h.prop,""),{classes:p=""}=$.getSplitChaiClasses(d)||{},f=p?p.split(" ").filter(b=>!u.isEmpty(b)):[],m=b=>u.find(e,x=>x.prop===b);return i.jsx(i.Fragment,{children:c&&i.jsxs("div",{className:"flex flex-wrap gap-1",children:[i.jsxs("label",{htmlFor:"block-styling-props",className:"py-1 text-xs",children:[o("Style element"),":"]}),i.jsx("div",{className:"flex flex-wrap gap-2",children:u.map(a,b=>i.jsxs(Hs,{className:"flex cursor-pointer items-center gap-1 pr-1",variant:m(b)?"default":"secondary",onClick:()=>{n([{id:`${b}-${t._id}`,blockId:t._id,prop:b}])},children:[u.startCase(b),i.jsxs(Qe,{children:[i.jsx(et,{asChild:!0,children:i.jsx("button",{type:"button",className:"ml-1 rounded-sm p-0.5 hover:bg-blue-300 hover:text-blue-600",onClick:x=>x.stopPropagation(),children:i.jsx(v.DotsVerticalIcon,{className:"h-3 w-3"})})}),i.jsxs(Ue,{side:"bottom",className:"border-border text-xs",children:[i.jsx(de,{className:"text-xs",onClick:()=>{l(b)},children:o("Reset style")}),i.jsx(de,{className:"text-xs",onClick:()=>{s(r,f,!0)},children:o("Clear styles")})]})]})]},b))}),i.jsx("div",{className:"my-2 h-[1px] w-full bg-border"})]})})},fc=g.createContext({setDragData:()=>{}}),zi=(t,e)=>{t=t.toLowerCase();let n=t.trim().replace(/ |\+/g,"");if((n==="auto"||n==="none")&&e.includes(n))return{value:"",unit:n};const s=e.length?new RegExp(e.join("|"),"g"):/XXXXXX/g;n=n.replace(s,"");const r=t.match(s),o=r&&r.length>1,a=!u.isEmpty(n)&&Number.isNaN(Number(n));return o||a?{error:"Invalid value"}:r&&(r[0]==="auto"||r[0]==="none")?{value:r[0],unit:""}:{value:n,unit:r?r[0]:""}},Kg=t=>{const e=t.startsWith("-")?"-":"",n=t.split("-").pop();if(["auto","none"].includes(n))return{value:"",unit:n};if(n==="px")return{value:"1",unit:"px"};if(n==="screen")return{value:"100",unit:t.indexOf("w-")!==-1?"vw":"vh"};if(n==="full")return{value:"100",unit:"%"};if(u.includes(t,"skew-"))return{value:`${e}${n}`,unit:"deg"};if(u.includes(t,"rotate-"))return{value:`${e}${n}`,unit:"deg"};if(u.includes(t,"opacity-"))return{value:`${n/100}`,unit:"-"};if(u.includes(t,"duration-")||u.includes(t,"delay-"))return{value:`${n}`,unit:"ms"};if(u.includes(t,"translate-")&&!n.includes("/"))return{value:`${e}${`${n/4}`}`,unit:"rem"};if(u.includes(t,"scale-"))return{value:`${e}${`${n/100}`}`,unit:"-"};if(u.startsWith(t,"border")){const s=t.match(/border-?(x|y|t|r|b|l)?\d+/g);if(s)return{value:s[0].split("-").pop(),unit:"px"};if(t.match(/border-?(x|y|t|r|b|l)?/g))return{value:"1",unit:"px"}}if(u.startsWith(t,"max-w-")){if(t==="max-w-screen-sm")return{value:"640",unit:"px"};if(t==="max-w-screen-md")return{value:"768",unit:"px"};if(t==="max-w-screen-lg")return{value:"1024",unit:"px"};if(t==="max-w-screen-xl")return{value:"1280",unit:"px"};if(t==="max-w-screen-2xl")return{value:"1536",unit:"px"};if(n==="xs")return{value:"320",unit:"px"};if(n==="sm")return{value:"384",unit:"px"};if(n==="md")return{value:"448",unit:"px"};if(n==="lg")return{value:"512",unit:"px"};if(n==="xl")return{value:"576",unit:"px"};if(n==="2xl")return{value:"672",unit:"px"};if(n==="3xl")return{value:"768",unit:"px"};if(n==="4xl")return{value:"896",unit:"px"};if(n==="5xl")return{value:"1024",unit:"px"};if(n==="6xl")return{value:"1152",unit:"px"};if(n==="7xl")return{value:"1280",unit:"px"};if(n==="prose")return{value:"65",unit:"ch"}}if(u.startsWith(t,"text-")){if(n==="xs")return{value:"12",unit:"px"};if(n==="sm")return{value:"14",unit:"px"};if(n==="base")return{value:"16",unit:"px"};if(n==="lg")return{value:"18",unit:"px"};if(n==="xl")return{value:"20",unit:"px"};if(n==="2xl")return{value:"24",unit:"px"};if(n==="3xl")return{value:"30",unit:"px"};if(n==="4xl")return{value:"36",unit:"px"};if(n==="5xl")return{value:"48",unit:"px"};if(n==="6xl")return{value:"60",unit:"px"};if(n==="7xl")return{value:"72",unit:"px"};if(n==="8xl")return{value:"96",unit:"px"};if(n==="9xl")return{value:"128",unit:"px"}}if(u.startsWith(t,"leading-")){if(n==="none")return{value:"1",unit:"-"};if(n==="tight")return{value:"1.25",unit:"-"};if(n==="snug")return{value:"1.375",unit:"-"};if(n==="normal")return{value:"1.5",unit:"-"};if(n==="relaxed")return{value:"1.625",unit:"-"};if(n==="loose")return{value:"2",unit:"-"}}if(u.startsWith(t,"tracking-")){if(n==="tighter")return{value:"-0.05",unit:"em"};if(n==="tight")return{value:"-0.025",unit:"em"};if(n==="normal")return{value:"0",unit:"em"};if(n==="wide")return{value:"0.025",unit:"em"};if(n==="wider")return{value:"0.05",unit:"em"};if(n==="widest")return{value:"0.1",unit:"em"}}if(["max","min","fit"].includes(n))return{value:t,unit:"class"};if(n.includes("/")){const[s,r]=u.map(n.split("/"),o=>parseInt(o,10));return{value:e+(s/r*100).toFixed(2).replace(".00",""),unit:"%"}}return u.isNumber(parseFloat(n))?{value:`${e+parseFloat(n)*4}`,unit:"px"}:{value:n,unit:"class"}},hc=t=>{if(u.isEmpty(t))return{value:"",unit:""};const e=t.match(/\[.*\]/g);if(e===null)return Yg(t);const n=u.get(e,"0","").replace(/\[|\]/g,""),s=t.startsWith("-")?"-":"",r=u.first(n.match(/\d+.\d+|\d+/g));return{value:`${s}${r}`,unit:n.replace(r,"")}},Yg=t=>u.isEmpty(t)?{value:"",unit:""}:Kg(t),Xg=({unit:t,currentValue:e,onDrag:n,onDragEnd:s,onDragStart:r,negative:o,cssProperty:a})=>{const{setDragData:l}=g.useContext(fc);return i.jsx("button",{type:"button",onMouseDown:c=>{const d={onDrag:n,onDragEnd:s,dragging:!0,dragStartY:c.pageY,dragStartValue:`${e}`,dragUnit:t,negative:o,cssProperty:a};r(d),l(d)},color:void 0,className:"relative z-50 ml-1 hidden h-6 cursor-row-resize rounded bg-background/70 px-2 group-hover:inline",children:i.jsx(v.RowSpacingIcon,{})})},Jg=({onSelect:t,current:e,units:n})=>i.jsx("div",{"data-theme":"light",className:"-m-[7px] -mx-[13px] flex w-9 flex-col",children:n.map(s=>i.jsx(q,{className:"h-max rounded-none px-1 py-1 text-right text-[11px] hover:bg-blue-400",color:e===s?"primary":void 0,size:"sm",onClick:r=>{r.stopPropagation(),t(s)},children:s},s))}),Hi=50,Zg=t=>{const[e,n]=g.useState(!1),[s,r]=g.useState(""),{currentClass:o,onChange:a,classPrefix:l,cssProperty:c,units:d,negative:p}=t,[f,m]=g.useState(c!=null&&c.toLowerCase().includes("width")?"%":d[0]),[h,b]=g.useState(!1),[x,y]=g.useState(""),[k,w]=g.useState(!1),[E,A]=g.useState(!1);g.useEffect(()=>{const{value:C,unit:T}=hc(o);if(T===""){r(C),m(c!=null&&c.toLowerCase().includes("width")?"%":u.first(d));return}m(T),r(T==="class"||u.isEmpty(C)?"":C)},[o,c,d]);const _=ke.useThrottledCallback(C=>a(C),[a],Hi),I=ke.useThrottledCallback(C=>a(C,!1),[a],Hi),j=g.useCallback((C=!1)=>{const T=zi(`${s}`,d);if(u.get(T,"error",!1)){b(!0);return}const R=u.get(T,"unit")!==""?u.get(T,"unit"):f;if(R==="auto"||R==="none"){_(`${l}${R}`);return}if(u.get(T,"value")==="")return;const U=`${u.get(T,"value","").startsWith("-")?"-":""}${l}[${u.get(T,"value","").replace("-","")}${R==="-"?"":R}]`;C?I(U):_(U)},[_,I,s,f,l,d]),N=g.useCallback(C=>{const T=zi(`${s}`,d);if(u.get(T,"error",!1)){b(!0);return}if(C==="auto"||C==="none"){_(`${l}${C}`);return}if(u.get(T,"value")==="")return;const R=u.get(T,"unit")!==""?u.get(T,"unit"):C,U=`${u.get(T,"value","").startsWith("-")?"-":""}${l}[${u.get(T,"value","").replace("-","")}${R==="-"?"":R}]`;_(U)},[_,s,l,d]);return i.jsx("div",{className:"flex w-full flex-col",children:i.jsx("div",{className:"flex items-center justify-start",children:f==="class"?i.jsxs(i.Fragment,{children:[i.jsx("input",{className:"h-6 w-24 rounded border border-foreground/20 bg-background px-2 py-0.5 text-sm focus-visible:outline-0",readOnly:!0,value:o}),i.jsxs(pe,{children:[i.jsx(fe,{asChild:!0,children:i.jsx("button",{type:"button",className:"invisible ml-3 mt-1 text-blue-600 group-hover:visible",children:i.jsx(v.InfoCircledIcon,{})})}),i.jsx(ue,{children:"Current value is using a Tailwind preset class."})]})]}):i.jsxs("div",{className:`group relative flex items-center ${k?"z-auto":""}`,children:[i.jsxs("div",{className:"flex items-center rounded-md border border-border",children:[["none","auto"].indexOf(f)!==-1?null:i.jsx("input",{readOnly:f==="class",onKeyPress:C=>{C.key==="Enter"&&j()},onKeyDown:C=>{if(C.keyCode!==38&&C.keyCode!==40)return;C.preventDefault(),A(!0);const T=u.parseInt(C.target.value);let R=u.isNaN(T)?0:T;C.keyCode===38&&(R+=1),C.keyCode===40&&(R-=1);const B=`${R}`,z=`${B.startsWith("-")?"-":""}${l}[${B.replace("-","")}${f==="-"?"":f}]`;I(z)},onKeyUp:C=>{E&&(C.preventDefault(),A(!1))},onBlur:()=>j(),onChange:C=>{b(!1),r(C.target.value)},onClick:C=>{var T;(T=C==null?void 0:C.target)==null||T.select(),n(!1)},value:k?x:s,className:"h-6 w-14 rounded rounded-r-none border border-transparent bg-background pl-2 text-sm focus-visible:outline-0".concat(" ",h?"border-red-500 text-red-500":"border-foreground/20")}),i.jsxs(pe,{open:e,delayDuration:100,children:[i.jsx(fe,{asChild:!0,children:i.jsxs("button",{type:"button",onClick:()=>n(!e),className:"flex h-6 cursor-pointer items-center gap-x-1 rounded rounded-l-none bg-background p-px px-1 text-[11px] uppercase",children:[i.jsx("span",{className:`inline-block ${d.length===1?"px-2 font-semibold":""}`,children:f}),d.length>1?i.jsx(v.TriangleDownIcon,{}):null]})}),i.jsx(ue,{className:"bg-background",children:i.jsx(Jg,{units:d,current:f,onSelect:C=>{n(!1),m(C),N(C)}})})]})]}),["none","auto"].indexOf(f)!==-1||k?null:i.jsx(Xg,{onDragStart:()=>w(!0),onDragEnd:C=>{if(y(()=>""),w(!1),u.isEmpty(C))return;const T=`${C}`,B=`${T.startsWith("-")?"-":""}${l}[${T.replace("-","")}${f==="-"?"":f}]`;_(B)},onDrag:C=>{if(u.isEmpty(C))return;y(C);const T=`${C}`,B=`${T.startsWith("-")?"-":""}${l}[${T.replace("-","")}${f==="-"?"":f}]`;I(B)},currentValue:s,unit:f,negative:p,cssProperty:c})]})})})},$n=g.createContext({canReset:!1,canChange:!0}),Qg=({children:t,canReset:e=!1,canChange:n=!0})=>i.jsx($n.Provider,{value:{canReset:e,canChange:n},children:t}),ur=[0,1,2,3,4,5,6,7,8,9,10,11,12,14,16,20,24,28,32,36,40,44,48,52,56,60,64,72,80,96],P={columns:[...u.range(1,13),"auto","3xs","2xs","xs","sm","md","lg","xl",...u.map(u.range(2,8),t=>`${t}xl`)],breakAfter:["auto","avoid","all","avoid-page","page","left","right","column"],breakInside:["auto","avoid","avoid-page","avoid-column"],display:["block","flex","grid","inline-block","inline","hidden"],objectFit:["contain","cover","fill","none","scale-down"],objectPosition:["bottom","center","left","left-bottom","left-top","right","right-bottom","right-top","top"],overflow:["auto","hidden","clip","visible","scroll"],overscroll:["auto","contain","none"],trbl:[0,"px","0.5",1,1.5,2,2.5,3,3.5,...u.range(4,13),14,16,20,24,28,32,36,40,44,48,52,56,60,64,72,80,96,"auto","1/2","1/3","2/3","1/4","2/4","3/4","full"],flexBasis:[...ur,"auto","px","0.5","1.5","2.5","3.5","1/2","1/3","2/3","1/4","2/4","3/4","1/5","2/5","3/5","4/5","1/6","2/6","3/6","4/6","5/6","1/12","2/12","3/12","4/12","5/12","6/12","7/12","8/12","9/12","10/12","11/12","full"],padding:[...ur,"px","0.5","1.5","2.5","3.5"],margin:["auto",...ur,"px","0.5","1.5","2.5","3.5"],scale:[0,50,75,90,95,100,105,110,125,150],origin:["center","top","top-right","right","bottom-right","bottom","bottom-left","left","top-left"],blendEffect:["normal","multiply","screen","overlay","darken","lighten","color-dodge","color-burn","hard-light","soft-light","difference","exclusion","hue","saturation","color","luminosity"],borderWidth:[0,2,4,8],borderRadius:["global","none","sm","md","lg","xl","2xl","3xl","full"],indent:[0,"px","0.5",1,1.5,2,2.5,3,3.5,...u.range(4,13),14,16,20,24,28,32,36,40,44,48,52,56,60,64,72,80,96],maxHeight:[0,"px","0.5",1,1.5,2,2.5,3,3.5,...u.range(4,13),14,16,20,24,28,32,36,40,44,48,52,56,60,64,72,80,96,"full","screen","min","max","fit"],space:[0,"px","0.5",1,1.5,2,2.5,3,3.5,...u.range(4,13),14,16,20,24,28,32,36,40,44,48,52,56,60,64,72,80,96,"px","reverse"],width:["0","px","0.5","1","1.5","2","2.5","3","3.5","4","5","6","7","8","9","10","11","12","14","16","20","24","28","32","36","40","44","48","52","56","60","64","72","80","96","auto","1/2","1/3","2/3","1/4","2/4","3/4","1/5","2/5","3/5","4/5","1/6","2/6","3/6","4/6","5/6","1/12","2/12","3/12","4/12","5/12","6/12","7/12","8/12","9/12","10/12","11/12"],maxWidth:["0","none","xs","sm","md","lg","xl","2xl","3xl","4xl","5xl","6xl","7xl","full","min","max","fit","prose","screen-sm","screen-md","screen-lg","screen-xl","screen-2xl"],height:["0","px","0.5","1","1.5","2","2.5","3","3.5","4","5","6","7","8","9","10","11","12","14","16","20","24","28","32","36","40","44","48","52","56","60","64","72","80","96","auto","1/2","1/3","2/3","1/4","2/4","3/4","1/5","2/5","3/5","4/5","1/6","2/6","3/6","4/6","5/6","full","screen","min","max","fit"]},Xt={textColor:{classes:[],regExp:"text-(black|transparent|current|white|__THEME_COLORS_REGEXP__|\\S+-\\d+)"},aspectRatio:{classes:["aspect-auto","aspect-square","aspect-video"],regExp:"aspect-(auto|square|video)"},container:{classes:["container"],regExp:"container"},columns:{classes:u.map(P.columns,t=>`columns-${t}`),regExp:"columns-(auto|[0-9]xl|[0-9]xs|xs|sm|md|lg|xl|\\d+)"},breakAfter:{classes:u.map(P.breakAfter,t=>`break-after-${t}`),regExp:"break-after-\\S+"},breakBefore:{classes:u.map(P.breakAfter,t=>`break-before-${t}`),regExp:"break-before-\\S+"},breakInside:{classes:u.map(P.breakInside,t=>`break-inside-${t}`),regExp:"break-inside-\\S+"},boxDecoration:{classes:["box-decoration-clone","box-decoration-slice"],regExp:"box-decoration-\\S+"},boxSizing:{classes:["box-border","box-content"],regExp:"box-(border|content)"},flexDirection:{classes:["flex-row","flex-row-reverse","flex-col","flex-col-reverse"],regExp:"flex-(row|row-reverse|col|col-reverse)"},flexWrap:{classes:["flex-wrap","flex-wrap-reverse","flex-nowrap"],regExp:"flex-(wrap|wrap-reverse|nowrap)"},flexGrowShrink:{classes:["flex-1","flex-auto","flex-initial","flex-none"],regExp:"flex-1|flex-auto|flex-initial|flex-none"},gridColumns:{classes:u.map([...u.range(0,13),"none"],t=>`grid-cols-${t}`),regExp:"grid-cols-(\\d+|none)"},gridFlow:{classes:["grid-flow-row","grid-flow-col","grid-flow-row-dense","grid-flow-col-dense"],regExp:"grid-flow-(row|col|row-dense|col-dense)"},outlineStyle:{classes:u.map(["none","dashed","dotted","double","hidden"],t=>`outline-${t}`),regExp:"outline-(none|dashed|dotted|double|hidden)"},borderStyle:{classes:u.map(["solid","dashed","dotted","double","hidden","none"],t=>`border-${t}`),regExp:"border-(solid|dashed|dotted|double|hidden|none)"},overflow:{classes:u.map(P.overflow,t=>`overflow-${t}`),regExp:`overflow-(${P.overflow.join("|")})`},overflowX:{classes:u.map(P.overflow,t=>`overflow-x-${t}`),regExp:`overflow-x-(${P.overflow.join("|")})`},overflowY:{classes:u.map(P.overflow,t=>`overflow-y-${t}`),regExp:`overflow-y-(${P.overflow.join("|")})`},gridRows:{classes:u.map([1,2,3,4,5,6,"none"],t=>`grid-rows-${t}`),regExp:"grid-rows-(\\d|none)"},display:{classes:u.map(P.display,t=>t.toString()),regExp:`(${P.display.join("|")})`},float:{classes:["float-right","float-left","float-none"],regExp:"float-\\S+"},clear:{classes:["clear-right","clear-left","clear-none","clear-both"],regExp:"clear-\\S+"},isolation:{classes:["isolate","isolation-auto"],regExp:"isolate|isolation-auto"},objectFit:{classes:u.map(P.objectFit,t=>`object-${t}`),regExp:"object-(contain|cover|fill|none|scale-down)"},objectPosition:{classes:u.map(P.objectPosition,t=>`object-${t}`),regExp:`object-(${P.objectPosition.join("|")})`},overscroll:{classes:u.map(P.overscroll,t=>`overscroll-${t}`),regExp:`overscroll-(${P.overscroll.join("|")})`},overscrollX:{classes:u.map(P.overscroll,t=>`overscroll-x-${t}`),regExp:`overscroll-x-(${P.overscroll.join("|")})`},overscrollY:{classes:u.map(P.overscroll,t=>`overscroll-y-${t}`),regExp:`overscroll-y-(${P.overscroll.join("|")})`},inset:{classes:u.map(P.trbl,t=>`inset-${t}`),regExp:"-?inset-(px|\\d\\/\\d|\\d\\.\\d|\\d+|full|auto|\\[.*\\])"},insetX:{classes:u.map(P.trbl,t=>`inset-x-${t}`),regExp:"-?inset-x-(px|\\d\\/\\d|\\d\\.\\d|\\d+|full|auto|\\[.*\\])"},insetY:{classes:u.map(P.trbl,t=>`inset-y-${t}`),regExp:"-?inset-y-(px|\\d\\/\\d|\\d\\.\\d|\\d+|full|auto|\\[.*\\])"},top:{classes:u.map(P.trbl,t=>`top-${t}`),regExp:"-?top-(px|\\d\\/\\d|\\d\\.\\d|\\d+|full|auto|\\[.*\\])"},topX:{classes:u.map(P.trbl,t=>`top-x-${t}`),regExp:"-?top-x-(px|\\d\\/\\d|\\d\\.\\d|\\d+|full|auto|\\[.*\\])"},topY:{classes:u.map(P.trbl,t=>`top-y-${t}`),regExp:"-?top-y-(px|\\d\\/\\d|\\d\\.\\d|\\d+|full|auto|\\[.*\\])"},right:{classes:u.map(P.trbl,t=>`right-${t}`),regExp:"-?right-(px|\\d\\/\\d|\\d\\.\\d|\\d+|full|auto|\\[.*\\])"},rightX:{classes:u.map(P.trbl,t=>`right-x-${t}`),regExp:"-?right-x-(px|\\d\\/\\d|\\d\\.\\d|\\d+|full|auto|\\[.*\\])"},rightY:{classes:u.map(P.trbl,t=>`right-y-${t}`),regExp:"-?right-y-(px|\\d\\/\\d|\\d\\.\\d|\\d+|full|auto|\\[.*\\])"},bottom:{classes:u.map(P.trbl,t=>`bottom-${t}`),regExp:"-?bottom-(px|\\d\\/\\d|\\d\\.\\d|\\d+|full|auto|\\[.*\\])"},bottomX:{classes:u.map(P.trbl,t=>`bottom-x-${t}`),regExp:"-?bottom-x-(px|\\d\\/\\d|\\d\\.\\d|\\d+|full|auto|\\[.*\\])"},bottomY:{classes:u.map(P.trbl,t=>`bottom-y-${t}`),regExp:"-?bottom-y-(px|\\d\\/\\d|\\d\\.\\d|\\d+|full|auto|\\[.*\\])"},left:{classes:u.map(P.trbl,t=>`left-${t}`),regExp:"-?left-(px|\\d\\/\\d|\\d\\.\\d|\\d+|full|auto|\\[.*\\])"},leftX:{classes:u.map(P.trbl,t=>`left-x-${t}`),regExp:"-?left-x-(px|\\d\\/\\d|\\d\\.\\d|\\d+|full|auto|\\[.*\\])"},leftY:{classes:u.map(P.trbl,t=>`left-y-${t}`),regExp:"-?left-y-(px|\\d\\/\\d|\\d\\.\\d|\\d+|full|auto|\\[.*\\])"},visibility:{classes:["visible","invisible"],regExp:"invisible|visible"},zIndex:{classes:u.map(["0",10,20,30,40,50,"auto"],t=>`z-${t}`),regExp:"-?z-(\\d+|auto|\\[.*\\])"},flexBasis:{classes:u.map(P.flexBasis,t=>`basis-${t}`),regExp:"basis-(\\d+|\\S+)"},flexGrow:{classes:["grow","grow-0"],regExp:"grow(-0)?"},flexShrink:{classes:["shrink","shrink-0"],regExp:"shrink(-0)?"},gridColSpan:{classes:["col-auto",...u.map(u.range(1,13),t=>`col-span-${t}`),"col-span-full"],regExp:"col-(auto|span-(\\d+|full))"},gridColStart:{classes:[...u.map(u.range(1,14),t=>`col-start-${t}`),"col-start-auto"],regExp:"col-start-(\\d+|auto)"},gridColEnd:{classes:[...u.map(u.range(1,14),t=>`col-end-${t}`),"col-end-auto"],regExp:"col-end-(\\d+|auto)"},gridRowSpan:{classes:["row-auto",...u.map(u.range(1,7),t=>`row-span-${t}`),"row-span-full"],regExp:"row-(auto|span-(\\d+|full))"},gridRowStart:{classes:[...u.map(u.range(1,8),t=>`row-start-${t}`),"row-start-auto"],regExp:"row-start-(\\d+|auto)"},gridRowEnd:{classes:[...u.map(u.range(1,8),t=>`row-end-${t}`),"row-end-auto"],regExp:"row-end-(\\d+|auto)"},gridAutoColumns:{classes:["auto-cols-auto","auto-cols-min","auto-cols-max","auto-cols-fr"],regExp:"auto-cols-(auto|min|max|fr)"},gridAutoRows:{classes:["auto-rows-auto","auto-rows-min","auto-rows-max","auto-rows-fr"],regExp:"auto-rows-(auto|min|max|fr)"},gap:{classes:u.map(P.indent,t=>`gap-${t}`),regExp:"gap-(px|\\d.\\d|\\d|\\[.*\\])"},gapX:{classes:u.map(P.indent,t=>`gap-x-${t}`),regExp:"gap-x-(px|\\d.\\d|\\d|\\[.*\\])"},gapY:{classes:u.map(P.indent,t=>`gap-y-${t}`),regExp:"gap-y-(px|\\d.\\d|\\d|\\[.*\\])"},justifyContent:{classes:["justify-start","justify-end","justify-center","justify-between","justify-around","justify-evenly"],regExp:"justify-(start|end|center|between|around|evenly)"},justifyItems:{classes:["justify-items-start","justify-items-end","justify-items-center","justify-items-stretch"],regExp:"justify-items-(start|end|center|stretch)"},justifySelf:{classes:["justify-self-auto","justify-self-start","justify-self-end","justify-self-center","justify-self-stretch"],regExp:"justify-self-(auto|start|end|center|stretch)"},placeContent:{classes:["place-content-center","place-content-start","place-content-end","place-content-between","place-content-around","place-content-evenly","place-content-stretch"],regExp:"place-content-(center|start|end|between|around|evenly|stretch)"},placeItems:{classes:["place-items-start","place-items-end","place-items-center","place-items-stretch"],regExp:"place-items-(start|end|center|stretch)"},placeSelf:{classes:["place-self-auto","place-self-start","place-self-end","place-self-center","place-self-stretch"],regExp:"place-self-(auto|start|end|center|stretch)"},alignContent:{classes:["content-center","content-start","content-end","content-between","content-around","content-evenly"],regExp:"content-(center|start|end|between|around|evenly)"},alignItems:{classes:["items-start","items-end","items-center","items-baseline","items-stretch"],regExp:"items-(start|end|center|baseline|stretch)"},alignSelf:{classes:["self-auto","self-start","self-end","self-center","self-stretch","self-baseline"],regExp:"self-(auto|start|end|center|stretch|baseline)"},backgroundClip:{classes:["bg-clip-border","bg-clip-padding","bg-clip-content","bg-clip-text"],regExp:"bg-clip-(border|padding|content|text)"},dropShadow:{classes:u.map(["sm","md","lg","xl","2xl","none"],t=>`drop-shadow-${t}`),regExp:"drop-shadow-(sm|md|lg|xl|2xl|none)"},backdropBlur:{classes:u.map(["none","sm","md","lg","xl","2xl","3xl"],t=>`backdrop-blur-${t}`),regExp:"backdrop-blur-(none|sm|md|lg|xl|2xl|3xl)"},backdropBrightness:{classes:u.map([0,50,75,90,95,100,105,110,125,150,200],t=>`backdrop-brightness-${t}`),regExp:"backdrop-brightness-(\\d+)"},backdropContrast:{classes:u.map([0,50,75,100,125,150,200],t=>`backdrop-contrast-${t}`),regExp:"backdrop-contrast-(\\d+)"},backdropGrayScale:{classes:["backdrop-grayscale-0","backdrop-grayscale"],regExp:"backdrop-grayscale(-0)?"},backdropHueRotate:{classes:u.map([0,15,30,60,90,180],t=>`backdrop-hue-rotate-${t}`),regExp:"-?backdrop-hue-rotate-(\\d+)"},backdropInvert:{classes:["backdrop-invert-0","backdrop-invert"],regExp:"backdrop-invert(-0)?"},backdropOpacity:{classes:u.map([0,5,10,20,25,30,40,50,60,70,75,80,90,95,100],t=>`backdrop-opacity-${t}`),regExp:"backdrop-opacity-(\\d+)"},backdropSaturate:{classes:u.map([0,50,100,150,200],t=>`backdrop-saturate-${t}`),regExp:"backdrop-saturate-(\\d+)"},backdropSepia:{classes:["backdrop-sepia-0, backdrop-sepia"],regExp:"backdrop-sepia(-0)?"},backgroundOrigin:{classes:["bg-origin-border","bg-origin-padding","bg-origin-content"],regExp:"bg-origin-(border|padding|content)"},transformOrigin:{classes:u.map(P.origin,t=>`origin-${t}`),regExp:"origin-(\\d+|\\S+)"},padding:{classes:u.map(P.padding,t=>`p-${t}`),regExp:"p-(\\d+|\\S+|\\[.*\\])"},paddingX:{classes:u.map(P.padding,t=>`px-${t}`),regExp:"px-(\\d+|\\S+|\\[.*\\])"},paddingY:{classes:u.map(P.padding,t=>`py-${t}`),regExp:"py-(\\d+|\\S+|\\[.*\\])"},paddingTop:{classes:u.map(P.padding,t=>`pt-${t}`),regExp:"pt-(\\d+|\\S+|\\[.*\\])"},paddingRight:{classes:u.map(P.padding,t=>`pr-${t}`),regExp:"pr-(\\d+|\\S+|\\[.*\\])"},paddingBottom:{classes:u.map(P.padding,t=>`pb-${t}`),regExp:"pb-(\\d+|\\S+|\\[.*\\])"},paddingLeft:{classes:u.map(P.padding,t=>`pl-${t}`),regExp:"pl-(\\d+|\\S+|\\[.*\\])"},textDecorationStyle:{classes:["decoration-solid","decoration-double","decoration-dotted","decoration-dashed","decoration-wavy"],regExp:"decoration-(solid|double|dotted|dashed|wavy)"},textDecorationThickness:{classes:u.map(["auto","from-font","0",1,2,4,8],t=>`decoration-${t}`),regExp:"decoration-(auto|from-font|\\d+|\\S+)"},fromColor:{classes:[],regExp:"from-(black|transparent|current|white|__THEME_COLORS_REGEXP__|\\S+-\\d+)"},margin:{classes:u.map(P.margin,t=>`m-${t}`),regExp:"-?m-(\\d+|\\S+|\\[.*\\])"},marginX:{classes:u.map(P.margin,t=>`mx-${t}`),regExp:"-?mx-(\\d+|\\S+|\\[.*\\])"},marginY:{classes:u.map(P.margin,t=>`my-${t}`),regExp:"-?my-(\\d+|\\S+|\\[.*\\])"},marginTop:{classes:u.map(P.margin,t=>`mt-${t}`),regExp:"-?mt-(\\d+|\\S+|\\[.*\\])"},marginRight:{classes:u.map(P.margin,t=>`mr-${t}`),regExp:"-?mr-(\\d+|\\S+|\\[.*\\])"},marginBottom:{classes:u.map(P.margin,t=>`mb-${t}`),regExp:"-?mb-(\\d+|\\S+|\\[.*\\])"},marginLeft:{classes:u.map(P.margin,t=>`ml-${t}`),regExp:"-?ml-(\\d+|\\S+|\\[.*\\])"},spaceX:{classes:u.map(P.space,t=>`space-x-${t}`),regExp:"-?space-x-(\\d+|\\S+|\\[.*\\])"},spaceY:{classes:u.map(P.space,t=>`space-y-${t}`),regExp:"-?space-y-(\\d+|\\S+|\\[.*\\])"},boxShadow:{classes:u.map(["sm","md","lg","xl","2xl","inner","none"],t=>`shadow-${t}`),regExp:"shadow-(sm|md|lg|xl|2xl|inner|none)"},minWidth:{classes:["min-w-0","min-w-full","min-w-min","min-w-max","min-w-fit"],regExp:"min-w-(\\d+|\\S+|\\[.*\\])"},maxWidth:{classes:u.map(P.maxWidth,t=>`max-w-${t}`),regExp:"max-w-(\\d+|\\S+|\\[.*\\])"},width:{classes:u.map([...P.width,"full","screen","min","max","fit"],t=>`w-${t}`),regExp:"w-(\\d+.\\d+|\\d+|px|auto|full|screen|min|max|fit|\\[.*\\])$"},minHeight:{classes:["min-h-0","min-h-full","min-h-screen","min-h-min","min-h-max","min-h-fit"],regExp:"min-h-(\\d+|\\S+|\\[.*\\])"},maxHeight:{classes:u.map(P.maxHeight,t=>`max-h-${t}`),regExp:"max-h-(\\d+|\\S+|\\[.*\\])"},height:{classes:u.map(P.height,t=>`h-${t}`),regExp:"h-(\\d+.\\d+|\\d+|px|auto|full|screen|min|max|fit|\\[.*\\])"},fontFamily:{classes:["font-heading","font-body","font-sans","font-serif","font-mono"],regExp:"font-(heading|body|sans|serif|mono)"},textAlign:{classes:["text-left","text-center","text-right","text-justify"],regExp:"text-(left|center|right|justify)"},textOverflow:{classes:["truncate","text-ellipsis","text-clip"],regExp:"truncate|text-ellipsis|text-clip"},verticalAlign:{classes:["align-baseline","align-top","align-middle","align-bottom","align-text-top","align-text-bottom","align-sub","align-super"],regExp:"align-(baseline|top|middle|bottom|text-top|text-bottom|sub|super)"},fontSize:{classes:["text-xs","text-sm","text-base","text-lg","text-xl","text-2xl","text-3xl","text-4xl","text-5xl","text-6xl","text-7xl","text-8xl","text-9xl"],regExp:"text-(\\d+|\\S+|\\[.*\\])"},fontSmoothing:{classes:["antialiased","subpixel-antialiased"],regExp:"antialiased|subpixel-antialiased"},fontStyle:{classes:["italic","not-italic"],regExp:"not-italic|italic"},fontWeight:{classes:["font-thin","font-extralight","font-light","font-normal","font-medium","font-semibold","font-bold","font-extrabold","font-black"],regExp:"font-(thin|extralight|light|normal|medium|semibold|bold|extrabold|black)"},fontVariantNum:{classes:["normal-nums","ordinal","diagonal-fractions","stacked-fractions","tabular-nums","oldstyle-nums","proportional-nums","lining-nums","slashed-zero"],regExp:"normal-nums|ordinal|diagonal-fractions|stacked-fractions|tabular-nums|oldstyle-nums|proportional-nums|lining-nums|slashed-zero"},letterSpacing:{classes:["tracking-tighter","tracking-tight","tracking-normal","tracking-wide","tracking-wider","tracking-widest"],regExp:"-?tracking-(tighter|tight|normal|wide|wider|widest|\\[.*\\])"},lineHeight:{classes:["leading-none","leading-tight","leading-snug","leading-normal","leading-relaxed","leading-loose","leading-3","leading-4","leading-5","leading-6","leading-7","leading-8","leading-9","leading-10"],regExp:"leading-(none|tight|snug|normal|relaxed|loose|\\[.*\\]|\\d+)"},listStyleType:{classes:["list-none","list-disc","list-decimal"],regExp:"list-(none|disc|decimal)"},listStylePosition:{classes:["list-inside","list-outside"],regExp:"list-(inside|outside)"},textUnderlineOffset:{classes:["underline-offset-auto","underline-offset-0","underline-offset-1","underline-offset-2","underline-offset-4","underline-offset-8"],regExp:"underline-offset-(auto|\\d+|\\S+)"},textDecoration:{classes:["underline","overline","line-through","no-underline"],regExp:"underline|overline|line-through|no-underline"},textDecorationColor:{classes:[],regExp:"decoration-(black|transparent|current|white|__THEME_COLORS_REGEXP__|\\S+-\\d+)"},textTransform:{classes:["uppercase","lowercase","capitalize","normal-case"],regExp:"uppercase|lowercase|capitalize|normal-case"},textIndent:{classes:u.map(P.indent,t=>`indent-${t}`),regExp:"-?indent-(\\d+|\\S+)"},whitespace:{classes:["whitespace-normal","whitespace-nowrap","whitespace-pre","whitespace-pre-line","whitespace-pre-wrap"],regExp:"whitespace-(normal|nowrap|pre|pre-line|pre-wrap)"},wordBreak:{classes:["break-normal","break-words","break-all"],regExp:"break-(normal|words|all)"},content:{classes:["content-none"],regExp:"content-none"},backgroundAttachment:{classes:u.map(["fixed","local","scroll"],t=>`bg-${t}`),regExp:"bg-(fixed|local|scroll)"},backgroundColor:{classes:[],regExp:"bg-(black|transparent|current|white|__THEME_COLORS_REGEXP__|\\S+-\\d+)"},backgroundPosition:{classes:["bg-bottom","bg-center","bg-left","bg-left-bottom","bg-left-top","bg-right","bg-right-bottom","bg-right-top","bg-top"],regExp:"bg-(bottom|center|left|left-bottom|left-top|right|right-bottom|right-top|top)"},backgroundRepeat:{classes:["bg-repeat","bg-repeat-x","bg-repeat-y","bg-no-repeat","bg-repeat-round","bg-repeat-space"],regExp:"bg-(repeat|repeat-x|repeat-y|no-repeat|repeat-round|repeat-space)"},backgroundSize:{classes:["bg-auto","bg-cover","bg-contain"],regExp:"bg-(auto|cover|contain)"},backgroundGradient:{classes:["bg-gradient-none","bg-gradient-to-t","bg-gradient-to-tr","bg-gradient-to-r","bg-gradient-to-br","bg-gradient-to-b","bg-gradient-to-bl","bg-gradient-to-l","bg-gradient-to-tl"],regExp:"bg-gradient-(none|to-(t|tr|r|br|b|bl|l|tl))"},viaColor:{classes:[],regExp:"via-(black|transparent|current|white|__THEME_COLORS_REGEXP__|\\S+-\\d+)"},toColor:{classes:[],regExp:"to-(black|transparent|current|white|__THEME_COLORS_REGEXP__|\\S+-\\d+)"},position:{classes:["static","fixed","absolute","relative","sticky"],regExp:"(static|fixed|absolute|relative|sticky)"},borderRadiusTopLeft:{classes:["rounded-tl",...u.map(P.borderRadius,t=>`rounded-tl-${t}`)],regExp:"rounded-tl-?(\\d+|\\S+)?"},borderRadiusTopRight:{classes:["rounded-tr",...u.map(P.borderRadius,t=>`rounded-tr-${t}`)],regExp:"rounded-tr-?(\\d+|\\S+)?"},borderRadiusBottomRight:{classes:["rounded-br",...u.map(P.borderRadius,t=>`rounded-br-${t}`)],regExp:"rounded-br-?(\\d+|\\S+)?"},borderRadiusBottomLeft:{classes:["rounded-bl",...u.map(P.borderRadius,t=>`rounded-bl-${t}`)],regExp:"rounded-bl-?(\\d+|\\S+)?"},borderRadiusTop:{classes:["rounded-t",...u.map(P.borderRadius,t=>`rounded-t-${t}`)],regExp:"rounded-t-?(\\d+|\\S+)?"},borderRadiusRight:{classes:["rounded-r",...u.map(P.borderRadius,t=>`rounded-r-${t}`)],regExp:"rounded-r-?(\\d+|\\S+)?"},borderRadiusBottom:{classes:["rounded-b",...u.map(P.borderRadius,t=>`rounded-b-${t}`)],regExp:"rounded-b-?(\\d+|\\S+)?"},borderRadiusLeft:{classes:["rounded-l",...u.map(P.borderRadius,t=>`rounded-l-${t}`)],regExp:`(rounded-l-(${P.borderRadius.join("|")})|rounded-l$)`},borderRadius:{classes:["rounded",...u.map(P.borderRadius,t=>`rounded-${t}`)],regExp:`(rounded-(${P.borderRadius.join("|")}$)|rounded)`},borderX:{classes:["border-x",...u.map(P.borderWidth,t=>`border-x-${t}`)],regExp:"border-x-?(\\d+|\\S+|\\[.*\\])?"},borderY:{classes:["border-y",...u.map(P.borderWidth,t=>`border-y-${t}`)],regExp:"border-y-?(\\d+|\\S+|\\[.*\\])?"},borderTop:{classes:["border-t",...u.map(P.borderWidth,t=>`border-t-${t}`)],regExp:"border-t-?(\\d+|\\S+|\\[.*\\])?"},borderRight:{classes:["border-r",...u.map(P.borderWidth,t=>`border-r-${t}`)],regExp:"border-r-?(\\d+|\\S+|\\[.*\\])?"},borderBottom:{classes:["border-b",...u.map(P.borderWidth,t=>`border-b-${t}`)],regExp:"border-b-?(\\d+|\\S+|\\[.*\\])?"},borderLeft:{classes:["border-l",...u.map(P.borderWidth,t=>`border-l-${t}`)],regExp:"border-l-?(\\d+|\\S+|\\[.*\\])?"},borderColor:{classes:[],regExp:"^border-(black|transparent|current|white|__THEME_COLORS_REGEXP__|\\w+-\\d+|\\[#[0-9a-fA-F]+\\])$"},border:{classes:["border",...u.map(P.borderWidth,t=>`border-${t}`)],regExp:"^border(-\\d+|\\[\\d+px\\])?$"},order:{classes:u.map([...u.range(0,13),"first","last","none"],t=>`order-${t}`),regExp:"-?order-(\\d+|first|last|none)"},divideXWidth:{classes:u.map(["0",2,4,8],t=>`divide-x-${t}`),regExp:"divide-x-(\\d+|\\[.*\\])"},divideYWidth:{classes:u.map(["0",2,4,8],t=>`divide-y-${t}`),regExp:"divide-y-(\\d+|\\[.*\\])"},divideColor:{classes:[],regExp:"divide-(black|transparent|current|white|__THEME_COLORS_REGEXP__|\\S+-\\d+)"},divideStyle:{classes:u.map(["solid","dashed","dotted","double","none"],t=>`divide-${t}`),regExp:"divide-(solid|dashed|dotted|double|none)"},outlineWidth:{classes:u.map([0,1,2,4,8],t=>`outline-${t}`),regExp:"outline-(\\d+)"},outlineOffset:{classes:u.map([0,1,2,4,8],t=>`outline-offset-${t}`),regExp:"outline-offset-(\\d+)"},outlineColor:{classes:[],regExp:"outline-(black|transparent|current|white|__THEME_COLORS_REGEXP__|\\S+-\\d+)"},ringWidth:{classes:u.map([0,1,2,4,8,"inset"],t=>`ring-${t}`),regExp:"ring-(\\d+|inset)"},ringOffsetWidth:{classes:u.map([0,1,2,4,8],t=>`ring-offset-${t}`),regExp:"ring-offset-(\\d+)"},ringOffsetColor:{classes:[],regExp:"ring-offset-(black|transparent|current|white|__THEME_COLORS_REGEXP__|\\S+-\\d+)"},ringColor:{classes:[],regExp:"ring-(black|transparent|current|white|__THEME_COLORS_REGEXP__|\\S+-\\d+)"},boxShadowColor:{classes:[],regExp:"shadow-(black|transparent|current|white|__THEME_COLORS_REGEXP__|\\S+-\\d+)"},opacity:{classes:u.map([0,5,10,20,25,30,40,50,60,70,75,80,90,95,100],t=>`opacity-${t}`),regExp:"opacity-(\\d+|\\[.*\\])"},mixBlendMode:{classes:u.map(P.blendEffect,t=>`mix-blend-${t}`),regExp:"mix-blend-(\\d+|\\S+)"},bgBlendMode:{classes:u.map(P.blendEffect,t=>`bg-blend-${t}`),regExp:"bg-blend-(\\d+|\\S+)"},blur:{classes:u.map(["none","sm","md","lg","xl","2xl","3xl"],t=>`blur-${t}`),regExp:"blur-(none|sm|md|lg|xl|2xl|3xl)"},brightness:{classes:u.map([0,50,75,90,95,100,105,110,125,150,200],t=>`brightness-${t}`),regExp:"brightness-(\\d+)"},contrast:{classes:u.map([0,50,75,100,125,150,200],t=>`contrast-${t}`),regExp:"contrast-(\\d+)"},grayScale:{classes:["grayscale-0","grayscale"],regExp:"grayscale(-0)?"},hueRotate:{classes:u.map([0,15,30,60,90,180],t=>`hue-rotate-${t}`),regExp:"-?hue-rotate-(\\d+)"},invert:{classes:["invert-0","invert"],regExp:"invert(-0)?"},saturate:{classes:u.map([0,50,100,150,200],t=>`saturate-${t}`),regExp:"saturate-(\\d+)"},sepia:{classes:["sepia-0","sepia"],regExp:"sepia(-0)?"},transition:{classes:["transition-none","transition-all","transition-colors","transition-opacity","transition-shadow","transition-transform"],regExp:"transition-(none|all|colors|opacity|shadow|transform)"},duration:{classes:u.map([75,100,150,200,300,500,700,1e3],t=>`duration-${t}`),regExp:"duration-(\\d+|\\[.*\\])"},transitionEase:{classes:["ease-linear","ease-in","ease-out","ease-in-out"],regExp:"eas(e-linear|e-in|e-out|e-in-out)"},transitionDelay:{classes:u.map([75,100,150,200,300,500,700,1e3],t=>`delay-${t}`),regExp:"delay-(\\d+|\\[.*\\])"},animation:{classes:["animate-none","animate-spin","animate-ping"],regExp:"animate-(none|spin|ping)"},scaleX:{classes:u.map(P.scale,t=>`scale-x-${t}`),regExp:"-?scale-x-(\\d+|\\S+|\\[.*\\])"},scaleY:{classes:u.map(P.scale,t=>`scale-y-${t}`),regExp:"-?scale-y-(\\d+|\\S+|\\[.*\\])"},scale:{classes:u.map(P.scale,t=>`scale-${t}`),regExp:"-?scale-(\\d+|\\S+|\\[.*\\])"},rotate:{classes:u.map([0,1,2,3,6,12,45,90,180],t=>`rotate-${t}`),regExp:"-?rotate-(\\d+|\\S+|\\[.*\\])"},translateX:{classes:u.map([0,"px","0.5",1],t=>`translate-x-${t}`),regExp:"-?translate-x-(\\d+|\\S+|\\[.*\\])"},translateY:{classes:u.map([0,"px","0.5",1],t=>`translate-y-${t}`),regExp:"-?translate-y-(\\d+|\\S+|\\[.*\\])"},skewX:{classes:u.map([0,1,2,3,6,12],t=>`skew-x-${t}`),regExp:"-?skew-x-(\\d+|\\S+|\\[.*\\])"},skewY:{classes:u.map([0,1,2,3,6,12],t=>`skew-y-${t}`),regExp:"-?skew-y-(\\d+|\\S+|\\[.*\\])"},accentColor:{classes:[],regExp:"accent-(black|transparent|current|white|__THEME_COLORS_REGEXP__|\\S+-\\d+)"},appearance:{classes:["appearance-none"],regExp:"appearance-none"},cursor:{classes:["cursor-auto","cursor-default","cursor-pointer","cursor-wait","cursor-text","cursor-move","cursor-help","cursor-not-allowed"],regExp:"cursor-(auto|default|pointer|wait|text|move|help|not-allowed)"},caretColor:{classes:[],regExp:"caret-(black|transparent|current|white|__THEME_COLORS_REGEXP__|\\S+-\\d+)"},pointerEvents:{classes:["pointer-events-none","pointer-events-auto"],regExp:"pointer-events-(none|auto)"},userSelect:{classes:["select-none","select-text","select-all","select-auto"],regExp:"select-(none|text|all|auto)"},fill:{classes:[],regExp:"caret-(black|transparent|current|white|__THEME_COLORS_REGEXP__|\\S+-\\d+)"},stroke:{classes:[],regExp:"caret-(black|transparent|current|white|__THEME_COLORS_REGEXP__|\\S+-\\d+)"},strokeWidth:{classes:["stroke-0","stroke-1","stroke-2"],regExp:"stroke-(\\d+|\\[.*\\])"}},ex={backgroundColor:"bg",textColor:"text",borderColor:"border",boxShadowColor:"shadow",outlineColor:"outline",divideColor:"divide",fromColor:"from",viaColor:"via",toColor:"to",ringColor:"ring",ringOffsetColor:"ring-offset"},tx=["current","inherit","transparent","black","white"],nx=["slate","gray","zinc","neutral","stone","red","orange","amber","yellow","lime","green","emerald","teal","cyan","sky","blue","indigo","violet","purple","fuchsia","pink","rose"],sx=["50","100","200","300","400","500","600","700","800","900"],Er=u.map(u.values(ex),t=>t),rx=u.flattenDeep([...u.map(tx,t=>u.flatten(u.map(Er,e=>`${e}-${t}`))),...u.map(nx,t=>u.flattenDeep(u.map(Er,e=>u.flattenDeep(u.map(sx,n=>`${e}-${t}-${n}`)))))]),ox=u.map(u.flattenDeep(u.values(Xt).map(t=>t.classes).concat(rx)),t=>({name:t})),ix=()=>{const t=Bn(),e=g.useMemo(()=>{let n=[];if(t.colors){const s=u.flattenDeep(u.map(t.colors,({items:r})=>u.keys(r)));n=u.flattenDeep(u.map(s,r=>u.flatten(u.map(Er,o=>`${o}-${r}`))))}return t.fontFamily&&(n=[...n,...u.map(u.keys(t.fontFamily),s=>`${s}`)]),u.map(n,s=>({name:s}))},[t]);return g.useMemo(()=>new ia([...ox,...e],{isCaseSensitive:!1,threshold:.2,minMatchCharLength:2,keys:["name"]}),[e])},Vs=()=>{const t=Bn(),e=g.useMemo(()=>{if(t.colors){const r=u.flattenDeep(u.map(t.colors,({items:o})=>u.keys(o)));u.each(Xt,(o,a)=>{u.set(Xt,`${a}.regExp`,o.regExp.replace("__THEME_COLORS_REGEXP__",r.join("|")))})}return Xt},[t]),n=g.useCallback((r,o)=>{const a=u.get(e,`${r}.regExp`,"");return o.match(new RegExp(a))},[e]),s=g.useCallback((r,o=[])=>u.get(e,`${r}.classes`,o),[e]);return{match:n,getClasses:s}},mc=({label:t,property:e,onChange:n})=>{const{getClasses:s}=Vs(),r=s(e),o=zn(e),a=g.useMemo(()=>u.get(o,"cls",""),[o]),{canChange:l}=g.useContext($n),c=/\[.*\]/g.test(a);return i.jsx("div",{className:t?"w-full rounded":"grow",children:c?i.jsxs("div",{className:"flex items-center",children:[i.jsx(vt,{className:"w-[70%] rounded py-1",readOnly:!0,value:a}),i.jsxs(pe,{delayDuration:100,children:[i.jsx(fe,{asChild:!0,children:i.jsx("button",{type:"button",className:"invisible ml-3 mt-1 text-blue-600 group-hover:visible",children:i.jsx(v.InfoCircledIcon,{})})}),i.jsx(ue,{children:"Current value is using a Tailwind arbitrary value."})]})]}):i.jsx(Ar,{rounded:t,onChange:d=>n(d,e),selected:a,options:r,disabled:!l})})};function Ar({selected:t,onChange:e,rounded:n=!1,options:s,disabled:r=!1}){const o=t.replace(/.*:/g,"").trim(),{undo:a,redo:l}=Pn();return i.jsxs("select",{disabled:!s.length||r,className:`${n?"rounded-md border border-border":"border-0"} disable:bg-gray-500 h-full w-full truncate rounded bg-background px-2 py-1 text-xs outline-none disabled:cursor-not-allowed`,onChange:c=>e(c.target.value),onKeyDown:c=>{c.ctrlKey&&(c.key==="z"&&a(),c.key==="y"&&l())},value:o,children:[i.jsx("option",{className:"bg-transparent",value:""}),s.map((c,d)=>i.jsx("option",{className:"bg-transparent",value:c,children:c},`option-${d}`))]})}const ax={backgroundColor:"bg",textColor:"text",borderColor:"border",boxShadowColor:"shadow",outlineColor:"outline",divideColor:"divide",fromColor:"from",viaColor:"via",toColor:"to",ringColor:"ring",ringOffsetColor:"ring-offset"},lx=({property:t,onChange:e})=>{const n=zn(t),s=g.useMemo(()=>u.get(n,"cls",""),[n]),{canChange:r}=g.useContext($n),[o,a]=g.useState([]),[l,c]=g.useState({color:"",shade:""}),d=s.split("-"),p=u.get(d,"1",""),f=u.get(d,"2",""),m=g.useCallback(x=>{["current","inherit","transparent","black","white"].includes(x)?(a([]),c({color:x})):(a(["50","100","200","300","400","500","600","700","800","900"]),c(y=>({...y,color:x,shade:y.shade?y.shade:"500"})))},[a,c]);g.useEffect(()=>{if(["current","inherit","transparent","black","white"].includes(p))return a([]);a(["50","100","200","300","400","500","600","700","800","900"])},[p]);const h=g.useCallback(x=>{c({color:p,shade:x})},[p]);g.useEffect(()=>{c({color:"",shade:""})},[n]);const{match:b}=Vs();return g.useEffect(()=>{const y=`${u.get(ax,t,"")}-${l.color}${l.shade?`-${l.shade}`:""}`;b(t,y)&&e(y,t)},[b,l,e,t]),i.jsxs("div",{className:"flex flex-row divide-x divide-solid divide-border rounded-lg border border-transparent text-xs",children:[i.jsx("div",{className:"grow text-center",children:i.jsx(Ar,{disabled:!r,rounded:!0,selected:p,onChange:m,options:["current","transparent","primary","secondary","black","white","slate","gray","zinc","neutral","stone","red","orange","amber","yellow","lime","green","emerald","teal","cyan","sky","blue","indigo","violet","purple","fuchsia","pink","rose"]})}),i.jsx("button",{type:"button",className:"grow text-center",children:i.jsx(Ar,{rounded:!0,selected:f,disabled:!p||!r,onChange:h,options:o})})]})},gc={"not-italic":()=>i.jsx("svg",{width:"16",height:"16",viewBox:"0 0 16 16",fill:"none",xmlns:"http://www.w3.org/2000/svg",children:i.jsx("path",{fillRule:"evenodd",clipRule:"evenodd",d:"M9 3H11V5H9V11H11V13H5V11H7V5H5V3H9Z",fill:"white"})}),visible:v.EyeOpenIcon,invisible:v.EyeClosedIcon,hidden:v.EyeClosedIcon,gap:v.BorderAllIcon,gapX:v.WidthIcon,gapY:v.HeightIcon,spaceX:v.WidthIcon,spaceY:v.HeightIcon,overscroll:v.BorderAllIcon,overscrollX:v.WidthIcon,overscrollY:v.HeightIcon,overflow:v.BorderAllIcon,overflowX:v.WidthIcon,overflowY:v.HeightIcon,top:v.ArrowUpIcon,right:v.ArrowRightIcon,bottom:v.ArrowDownIcon,left:v.ArrowLeftIcon,inset:v.BorderAllIcon,insetX:v.WidthIcon,insetY:v.HeightIcon,border:v.BorderAllIcon,borderX:v.WidthIcon,borderY:v.HeightIcon,borderTop:v.ArrowUpIcon,borderRight:v.ArrowRightIcon,borderBottom:v.ArrowDownIcon,borderLeft:v.ArrowLeftIcon,borderRadius:v.BorderAllIcon,borderRadiusX:v.WidthIcon,borderRadiusY:v.HeightIcon,borderRadiusTop:v.ArrowUpIcon,borderRadiusRight:v.ArrowRightIcon,borderRadiusBottom:v.ArrowDownIcon,borderRadiusLeft:v.ArrowLeftIcon,borderRadiusTopLeft:v.ArrowTopLeftIcon,borderRadiusTopRight:v.ArrowTopRightIcon,borderRadiusBottomRight:v.ArrowBottomRightIcon,borderRadiusBottomLeft:v.ArrowBottomLeftIcon,divideXWidth:v.WidthIcon,divideYWidth:v.HeightIcon,scale:v.BorderAllIcon,scaleX:v.WidthIcon,scaleY:v.HeightIcon,skewX:v.WidthIcon,skewY:v.HeightIcon,translateX:v.WidthIcon,translateY:v.HeightIcon,padding:v.BorderAllIcon,paddingX:v.WidthIcon,paddingY:v.HeightIcon,paddingTop:v.ArrowUpIcon,paddingRight:v.ArrowRightIcon,paddingBottom:v.ArrowDownIcon,paddingLeft:v.ArrowLeftIcon,margin:v.BorderAllIcon,marginX:v.WidthIcon,marginY:v.HeightIcon,marginTop:v.ArrowUpIcon,marginRight:v.ArrowRightIcon,marginBottom:v.ArrowDownIcon,marginLeft:v.ArrowLeftIcon,textLeft:v.AlignLeftIcon,textCenter:v.AlignCenterHorizontallyIcon,textRight:v.AlignRightIcon,textJustify:v.StretchHorizontallyIcon,italic:v.FontItalicIcon,underline:v.UnderlineIcon,overline:v.OverlineIcon,uppercase:v.LetterCaseUppercaseIcon,block:()=>i.jsxs("svg",{width:"16",height:"16",viewBox:"0 0 16 16",fill:"none",xmlns:"http://www.w3.org/2000/svg",children:[i.jsx("path",{opacity:"0.6",fillRule:"evenodd",clipRule:"evenodd",d:"M2 2H14V14H2V2ZM1 1H15V15H1V1Z",fill:"currentColor"}),i.jsx("path",{fillRule:"evenodd",clipRule:"evenodd",d:"M7 4H4V12H7V4ZM9 4H12V12H9V4Z",fill:"currentColor"})]}),"float-right":()=>i.jsxs("svg",{width:"16",height:"16",viewBox:"0 0 16 16",fill:"none",xmlns:"http://www.w3.org/2000/svg",children:[i.jsx("path",{d:"M8 4H16V12H8V4Z",fill:"currentColor"}),i.jsx("path",{opacity:"0.6",fillRule:"evenodd",clipRule:"evenodd",d:"M0 4H6V6H0V4ZM0 7H6V9H0V7ZM4 10H0V12H4V10Z",fill:"currentColor"})]}),"float-left":()=>i.jsxs("svg",{width:"16",height:"16",viewBox:"0 0 16 16",fill:"none",xmlns:"http://www.w3.org/2000/svg",children:[i.jsx("path",{d:"M0 4H8V12H0V4Z",fill:"currentColor"}),i.jsx("path",{opacity:"0.6",fillRule:"evenodd",clipRule:"evenodd",d:"M10 4H16V6H10V4ZM10 7H16V9H10V7ZM14 10H10V12H14V10Z",fill:"currentColor"})]}),"float-none":v.Cross2Icon,fixed:()=>i.jsxs("svg",{width:"16",height:"16",viewBox:"0 0 16 16",fill:"none",xmlns:"http://www.w3.org/2000/svg",children:[i.jsx("path",{opacity:"0.6",fillRule:"evenodd",clipRule:"evenodd",d:"M15 2H14V4H13V5H14V6H15V2ZM10 5V4H9V2H1V8H2V5H10ZM7 4V3H5V4H7ZM4 4V3H2V4H4ZM1 13H7V14H1V13Z",fill:"currentColor"}),i.jsx("path",{fillRule:"evenodd",clipRule:"evenodd",d:"M11 2H10V3H11V6H12V3H13V2H11ZM2 9H1V12H2V11H7V10H2V9ZM15 7H8V14H15V7Z",fill:"currentColor"})]}),absolute:()=>i.jsxs("svg",{width:"16",height:"16",viewBox:"0 0 16 16",fill:"none",xmlns:"http://www.w3.org/2000/svg",children:[i.jsx("path",{opacity:"0.6",fillRule:"evenodd",clipRule:"evenodd",d:"M14 2H15V6H14V2ZM9 3V2H1V8H2V3H9ZM7 13H1V14H7V13Z",fill:"currentColor"}),i.jsx("path",{fillRule:"evenodd",clipRule:"evenodd",d:"M11 2H10V3H11V6H12V3H13V2H11ZM2 9H1V12H2V11H7V10H2V9ZM15 7H8V14H15V7Z",fill:"currentColor"})]}),relative:()=>i.jsx("svg",{width:"16",height:"16",viewBox:"0 0 16 16",fill:"none",xmlns:"http://www.w3.org/2000/svg",children:i.jsx("path",{fillRule:"evenodd",clipRule:"evenodd",d:"M11 2H9V3H11V6H12V3H14V2H11ZM2 8H1V13H2V11H7V10H2V8ZM15 7H8V14H15V7Z",fill:"currentColor"})}),sticky:()=>i.jsxs("svg",{width:"16",height:"16",viewBox:"0 0 16 16",fill:"none",xmlns:"http://www.w3.org/2000/svg",children:[i.jsx("path",{d:"M12.9998 7C13.6558 7 14.2937 6.78498 14.8158 6.38787C15.338 5.99076 15.7156 5.43345 15.8908 4.80128C16.066 4.16912 16.0292 3.49694 15.7859 2.8877C15.5427 2.27846 15.1065 1.76573 14.5441 1.42804C13.9817 1.09034 13.3241 0.946293 12.672 1.01795C12.02 1.08961 11.4094 1.37303 10.9337 1.8248C10.4581 2.27658 10.1436 2.8718 10.0385 3.51932C9.93341 4.16685 10.0434 4.83097 10.3518 5.41L6.88176 8.88C6.80034 8.96122 6.73572 9.05769 6.69158 9.16388C6.64744 9.27008 6.62465 9.38393 6.62451 9.49894C6.62437 9.61395 6.64689 9.72785 6.69077 9.83416C6.73465 9.94046 6.79904 10.0371 6.88026 10.1185C6.96149 10.1999 7.05795 10.2645 7.16415 10.3087C7.27035 10.3528 7.3842 10.3756 7.4992 10.3758C7.61421 10.3759 7.72812 10.3534 7.83442 10.3095C7.94072 10.2656 8.03734 10.2012 8.11876 10.12L11.5888 6.648C12.0088 6.873 12.4888 7 12.9988 7H12.9998Z",fill:"currentColor"}),i.jsx("path",{opacity:"0.6",fillRule:"evenodd",clipRule:"evenodd",d:"M9.535 2H1V14H15V7.465C14.69 7.645 14.355 7.783 14 7.875V13H2V5H9.126C8.86504 3.98486 9.01223 2.90789 9.536 2H9.535ZM7 3V4H5V3H7ZM4 3V4H2V3H4Z",fill:"currentColor"})]}),static:v.Cross1Icon},cx=({property:t,onChange:e})=>{const{getClasses:n}=Vs(),s=n(t),{canChange:r}=g.useContext($n),o=zn(t),a=g.useMemo(()=>u.get(o,"cls",""),[o]);return i.jsx("div",{className:"flex grow flex-wrap gap-1",children:u.map(s,l=>i.jsxs(pe,{children:[i.jsx(fe,{asChild:!0,children:i.jsx("button",{type:"button",disabled:!r,onClick:()=>e(l,t),className:`cursor-pointer rounded border border-border p-1 disabled:cursor-not-allowed ${a===l?"bg-primary text-white":"disabled:bg-gray-600 disabled:text-gray-400"}`,children:g.createElement(u.get(gc,l,v.BoxIcon))})}),i.jsx(ue,{children:u.startCase(u.toLower(l))})]}))})},dx=({property:t,onChange:e})=>{const{canReset:n,canChange:s}=g.useContext($n),r=zn(t),o=g.useMemo(()=>u.get(r,"cls",""),[r]),{getClasses:a}=Vs(),l=a(t,[""]),c=l.indexOf(o)>-1?l.indexOf(o):0,d=/\[.*\]/g.test(o);return i.jsx("div",{className:"flex flex-row divide-x divide-solid divide-border rounded border border-border text-xs",children:d?i.jsx("div",{className:"px-2 py-[5px]",children:o}):i.jsxs(i.Fragment,{children:[i.jsx("button",{type:"button",className:"hover:bg-bg-gray-700 box-border w-2/12 rounded-bl rounded-tl bg-background px-1 text-center disabled:cursor-not-allowed disabled:bg-gray-600",disabled:!s&&(!n||c-1<0),onClick:()=>e(u.nth(l,c-1),t),children:i.jsx("span",{className:"flex items-center justify-center",children:i.jsx(v.MinusIcon,{className:!s&&(!n||c-1<0)?"text-gray-500":"text-black/60 dark:text-white/60"})})}),i.jsx("div",{className:"w-8/12 text-center",children:i.jsx(mc,{label:!1,property:t,onChange:e})}),i.jsx("button",{type:"button",className:"hover:bg-bg-gray-700 w-2/12 rounded-br rounded-tr bg-background px-1 text-center disabled:cursor-not-allowed disabled:bg-gray-600",disabled:!s&&(!n||c+1>=l.length),onClick:()=>e(u.nth(l,c+1),t),children:i.jsx("span",{className:"flex items-center justify-center",children:i.jsx(v.PlusIcon,{className:!s&&(!n||c+1>=l.length)?"text-gray-500":"text-black/60 dark:text-white/60"})})})]})})};function ux(t){if(u.isEmpty(t.trim()))return"";const e=t.match(/sm:|md:|lg:|xl:|2xl:/g);return u.get(e,0,"xs").replace(":","")}function px(t){const e=u.map(zu,s=>`${s}:`).join("|"),n=new RegExp(e,"g");return u.get(n.exec(t.trim()),0,"").replace(":","")}function fx(t){return t.trim().split(":").pop()||""}const pr={};function hx(t){if(u.isEmpty(t))return"";if(pr[t])return pr[t];let e="";for(const n in Xt){const s=u.get(Xt,`${n}.regExp`,"");if(new RegExp(s,"g").test(t)){e=n,pr[t]=e;break}}return e}function Go(t){return u.isEmpty(t)?null:{dark:u.startsWith(t,"dark:"),mq:ux(t),mod:px(t),cls:fx(t),fullCls:t,property:hx(t)}}function mx(t){let e="";return t.dark&&(e+="dark:"),t.mq.toLowerCase()!=="xs"&&(e+=`${t.mq}:`),t.mod&&(e+=`${t.mod}:`),e+=t.cls,e}function xc(t){t=t.replace(/\s+/g," ");const e=t.split(" ").map(Go),n=["xs","sm","md","lg","xl","2xl"];return e.sort((s,r)=>n.indexOf(s.mq)-n.indexOf(r.mq)).map(s=>s.fullCls).join(" ")}function bc(t){if(t=t.replace(/\s+/g," "),!t)return"";const e=["xs","sm","md","lg","xl","2xl"],n=t.split(" ").map(Go);let s=t;if(n.length===1)return n[0].fullCls;for(const r of n){const o=r.property,a=e.indexOf(r.mq);for(let l=a+1;l<e.length;l++){const c=e[l],d=n.find(p=>p.property===o&&p.mq===c);if(d&&d.cls===r.cls)s=s.replace(d.fullCls,"");else if(d&&d.cls!==r.cls)break}}return s.replace(/\s+/g," ").trim()}const gx=S.atom(null,(t,e,{blockIds:n,newClasses:s})=>{const r=u.filter(t(In),a=>n.includes(t(a)._id)),o=u.first(t(Mn));return u.map(r,a=>{const l=t(a),c=u.get(l,o.prop,`${$.STYLES_KEY},`),{classes:d}=$.getSplitChaiClasses(c);return{ids:[l._id],props:{[o.prop]:`${$.STYLES_KEY},${xc(bc($r.twMerge(d,s)))}`}}})}),yc=()=>{const t=S.useSetAtom(gx),{updateBlocks:e,updateBlocksRuntime:n}=Ne();return g.useCallback((s,r,o=!1)=>{const a=t({blockIds:s,newClasses:r});if(!o){n(s,a[0].props);return}e(s,a[0].props)},[t,e,n])},xx=t=>{const e=["xs","sm","md","lg","xl","2xl"],n=e.indexOf(t);return n===-1?["xs"]:e.slice(0,n+1)},bx=S.atom(t=>{const e=u.first(t(Mn)),n=t(_s);if(!e||e.blockId!==u.get(n,"_id",null))return[];const s=u.get(n,e.prop,`${$.STYLES_KEY},`),{classes:r}=$.getSplitChaiClasses(s);return u.filter(u.map(r.trim().split(" "),Go),o=>!u.isNull(o))}),Vi={xs:0,sm:1,md:2,lg:3,xl:4,"2xl":5},yx=S.atom(t=>{const e=t(tc),n=t(Xr),s=t(tl),r=xx(e);let o=u.filter(t(bx),{mod:n});return u.startsWith(n,"_")||(o=u.filter(o,a=>r.includes(a.mq))),o=o.sort((a,l)=>Vi[a.mq]-Vi[l.mq]),s||(o=u.filter(o,{dark:!1})),o}),Ws=()=>S.useAtomValue(yx),vx=()=>S.useAtom(Xr),zn=t=>{const e=Ws();return u.findLast(e,{property:t})},kx=(t,e)=>{const n={xs:0,sm:1,md:2,lg:3,xl:4,"2xl":5};return n[u.get(t,"mq","xs")]<=n[e]},wx={width:"w-",height:"h-",minWidth:"min-w-",minHeight:"min-h-",maxWidth:"max-w-",maxHeight:"max-h-",zIndex:"z-",gap:"gap-",gapX:"gap-x-",gapY:"gap-y-",margin:"m-",marginX:"mx-",marginY:"my-",marginTop:"mt-",marginBottom:"mb-",marginLeft:"ml-",marginRight:"mr-",padding:"p-",paddingX:"px-",paddingY:"py-",paddingTop:"pt-",paddingBottom:"pb-",paddingLeft:"pl-",paddingRight:"pr-",spaceX:"space-x-",spaceY:"space-y-",border:"border-",borderTop:"border-t-",borderBottom:"border-b-",borderLeft:"border-l-",borderRight:"border-r-",borderX:"border-x-",borderY:"border-y-",borderRadius:"rounded-",borderRadiusTop:"rounded-t-",borderRadiusRight:"rounded-r-",borderRadiusBottom:"rounded-b-",borderRadiusLeft:"rounded-l-",borderRadiusTopLeft:"rounded-tl-",borderRadiusTopRight:"rounded-tr-",borderRadiusBottomRight:"rounded-br-",borderRadiusBottomLeft:"rounded-bl-",fontSize:"text-",lineHeight:"leading-",letterSpacing:"tracking-",textIndent:"indent-",rotate:"rotate-",duration:"duration-",transitionDelay:"delay-",scale:"scale-",scaleX:"scale-x-",scaleY:"scale-y-",translateX:"translate-x-",translateY:"translate-y-",skewX:"skew-x-",skewY:"skew-y-",top:"top-",bottom:"bottom-",left:"left-",right:"right-",inset:"inset-",insetX:"inset-x-",insetY:"inset-y-",opacity:"opacity-",flexBasis:"basis-"},Wi={xs:"",sm:"640px",md:"768px",lg:"1024px",xl:"1280px","2xl":"1536px"},Cx=t=>`${t.toUpperCase()} ${Wi[t]?`(${Wi[t]} & up)`:""}`,ks=t=>{const{t:e}=F.useTranslation(),{type:n="icons",label:s,property:r,onEmitChange:o=()=>{},units:a,negative:l=!1}=t,[c]=Dn(),[d]=vx(),[,p]=bs(),f=zn(r),m=yc(),h=Uo(),[b]=K(),x=g.useMemo(()=>u.get(f,"fullCls",""),[f]),y=g.useCallback((I,j=!0)=>{const N={dark:c,mq:p,mod:d,cls:I};(c||d!=="")&&(N.mq="xs");const C=mx(N);m(b,[C],j)},[b,c,p,d,r,m]),k=g.useCallback(()=>{h(b,[x],!0)},[b,x,h]),w=g.useMemo(()=>kx(f,p),[f,p]);g.useEffect(()=>{o(w,f)},[w,o,f]);const[,,E]=bs(),A=g.useCallback(I=>{E({xs:400,sm:640,md:800,lg:1024,xl:1420,"2xl":1920}[I])},[E]),_=u.get(f,"dark",null)===c&&u.get(f,"mod",null)===d&&u.get(f,"mq",null)===p;return i.jsx(Qg,{canChange:w,canReset:f&&_,children:i.jsxs("div",{className:"group flex flex-row items-center py-2 first:pt-0 last:pb-0",children:[i.jsx("div",{className:"relative w-[70px] truncate text-xs text-foreground",children:i.jsx("span",{className:`text-[11px] ${f&&!_?"text-foreground":""}`,children:e(s)})}),i.jsxs("div",{className:"flex flex-row items-center",children:[i.jsxs("div",{className:"w-[150px]",children:[n==="arbitrary"?i.jsx(Zg,{currentClass:u.get(f,"cls",""),classPrefix:u.get(wx,r,""),units:a||[],onChange:y,negative:l,cssProperty:r}):null,n==="icons"&&i.jsx(cx,{property:r,onChange:y}),n==="range"&&i.jsx(dx,{property:r,onChange:y}),n==="color"&&i.jsx(lx,{property:r,onChange:y}),n==="dropdown"&&i.jsx(mc,{label:s,property:r,onChange:y})]}),i.jsx("div",{className:`w-[30px] cursor-pointer ${x?"visible":"invisible"}`,children:_?i.jsx("button",{type:"button",onClick:()=>k(),title:"Reset",className:"flex px-1.5 text-xs",children:i.jsx(v.CrossCircledIcon,{className:"h-5 w-5 text-blue-500 hover:opacity-80"})}):w&&f?i.jsxs(pe,{delayDuration:100,children:[i.jsx(fe,{asChild:!0,children:i.jsx("button",{type:"button",className:"invisible ml-3 mt-1 rounded-full bg-primary text-white group-hover:visible",children:i.jsx(v.InfoCircledIcon,{})})}),i.jsx(ue,{children:i.jsx("div",{className:"text-right",children:i.jsxs("div",{children:["Current style is set at  ",i.jsxs("span",{className:"font-bold",children:[Cx(u.get(f,"mq")),c&&!f.dark?"(Light mode)":""]}),i.jsx("br",{}),i.jsxs("button",{type:"button",onClick:()=>A(u.get(f,"mq")),className:"block w-full cursor-default text-right font-semibold text-blue-500",children:["Switch to ",u.get(f,"mq").toUpperCase()]})]})})})]}):null})]})]})})},jx=["px","%","em","rem","ch","vh","vw"],_r=({label:t,options:e,borderB:n=!1,borderT:s=!1,type:r="arbitrary",units:o=jx,negative:a=!1})=>{const{t:l}=F.useTranslation(),[c,d]=g.useState(e[0].key),p=Ws(),f=g.useCallback(m=>u.map(p,"property").includes(m),[p]);return i.jsxs("div",{className:`mb-2 border-border py-2 first:pt-0 last:pb-0 ${n?"border-b":""} ${s?"border-t":""}`,children:[i.jsxs("div",{className:"flex flex-row text-xs",children:[t&&i.jsx("span",{className:"relative w-[70px] flex-none text-xs text-foreground",children:l(t)}),i.jsx("div",{className:"mb-3 flex grow flex-row flex-wrap gap-x-px",children:e.map(({label:m,key:h},b)=>i.jsx("div",{className:"first:rounded-l last:rounded-r",children:i.jsxs(pe,{children:[i.jsx(fe,{asChild:!0,children:i.jsxs("button",{type:"button",onClick:()=>d(h),className:`relative cursor-pointer rounded-full p-1 text-[8px] ${h===c?"bg-[#3E57F0] text-white":"text-gray-600 dark:text-gray-300"}`,children:[g.createElement("div",{className:f(h)?"-bottom-1.5 absolute bg-[#3E57F0] h-[2px] left-0 w-full":""}),g.createElement(u.get(gc,h,v.BoxIcon),{className:"text-inherit w-3 h-3"})]})}),i.jsx(ue,{children:u.startCase(u.toLower(m))})]})},`option-${b}`))})]}),i.jsx("div",{className:"mt-0 flex items-center",children:i.jsx(ks,{type:r,units:[...o],label:"",property:c,negative:a})})]})},Ui=({heading:t,items:e})=>{const{t:n}=F.useTranslation(),s=Ws(),r=g.useMemo(()=>{const o=c=>u.flatten(c.map(d=>d.styleType==="multiple"?u.map(d.options,"key"):d.property)),a=u.flatten(e.map(c=>c.styleType==="accordion"?o(c.items):c.styleType==="multiple"?u.map(c.options,"key"):c.property)),l=u.map(s,"property");return u.intersection(a,l).length>0},[s,e]);return i.jsxs("details",{children:[i.jsx("summary",{className:"my-px cursor-default rounded-md bg-gray-50 p-px px-2 text-[11px] text-foreground dark:bg-gray-800",children:i.jsxs("div",{className:"inline",children:[u.startCase(n(t.toLowerCase())),r?i.jsx("span",{className:`ml-1 mr-2 inline-block h-[8px] w-[8px] rounded-full ${r?"bg-primary":"bg-gray-300"}`}):null]})}),i.jsx("div",{className:"p-2",children:e.map(o=>o.styleType==="multiple"?i.jsx(_r,{...o},o.label):i.jsx(ks,{...o},o.label))})]})},Sx=g.createContext({}),fr=({section:t,showAccordian:e})=>{const{t:n}=F.useTranslation(),s=Ws(),r=g.useCallback((a=[])=>{const l={};for(let d=0;d<s.length;d++)l[s[d].property]=s[d].cls;let c=!0;for(const d in a)if(!u.has(l,d)||l[d]!==a[d]){c=!1;break}return c},[s]),o=g.useMemo(()=>({}),[]);return i.jsx(Sx.Provider,{value:o,children:e?i.jsxs(Ho,{value:t.heading,className:"border-none",children:[i.jsx(Vo,{className:"border-slate-150 border-t py-2 text-xs",children:i.jsx("div",{className:"flex items-center py-2",children:i.jsx("div",{className:"flex items-center gap-x-2 text-xs font-medium",children:u.startCase(n(t.heading))})})}),i.jsx(Wo,{className:"py-2",children:t.items.map(a=>u.has(a,"component")?g.createElement(a.component,{key:a.label}):u.has(a,"styleType")?a.styleType==="multiple"?i.jsx(_r,{...a},a.label+"multiple-choices"):a.styleType==="accordion"&&r(a==null?void 0:a.conditions)?i.jsx(Ui,{...a},a.label+"nested-options"):null:i.jsx(ks,{...a},a.label+"block-style"))})]}):i.jsx("div",{className:"py-2",children:t.items.map((a,l)=>u.has(a,"component")?g.createElement(a.component,{key:a.label}):u.has(a,"styleType")?a.styleType==="multiple"?i.jsx(_r,{...a},a.label+"multiple-choices"+l):a.styleType==="accordion"&&r(a==null?void 0:a.conditions)?i.jsx(Ui,{...a},a.label+"nested-options"+l):null:i.jsx(ks,{...a},a.label+"block-style"+l))})})},vc=Es.Root,kc=Es.Trigger,qo=M.forwardRef(({className:t,align:e="center",sideOffset:n=4,...s},r)=>i.jsx(Es.Content,{ref:r,align:e,sideOffset:n,className:L("z-50 w-64 origin-[--radix-hover-card-content-transform-origin] rounded-md border bg-popover p-4 text-popover-foreground shadow-md outline-none data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0 data-[state=closed]:zoom-out-95 data-[state=open]:zoom-in-95 data-[side=bottom]:slide-in-from-top-2 data-[side=left]:slide-in-from-right-2 data-[side=right]:slide-in-from-left-2 data-[side=top]:slide-in-from-bottom-2",t),...s}));qo.displayName=Es.Content.displayName;const Nx=we.atomWithStorage("selectedBreakpoints",["XS","MD","XL"]),Ex=()=>{const[t,e]=S.useAtom(Nx);return[t,e]},Gi=({landscape:t=!1,className:e=""})=>i.jsx("svg",{className:ve.cn("h-3 w-3",t?"rotate-90":"",e),stroke:"currentColor",fill:"currentColor",strokeWidth:"0",viewBox:"0 0 448 512",xmlns:"http://www.w3.org/2000/svg",children:i.jsx("path",{d:"M400 0H48C21.5 0 0 21.5 0 48v416c0 26.5 21.5 48 48 48h352c26.5 0 48-21.5 48-48V48c0-26.5-21.5-48-48-48zM224 480c-17.7 0-32-14.3-32-32s14.3-32 32-32 32 14.3 32 32-14.3 32-32 32zm176-108c0 6.6-5.4 12-12 12H60c-6.6 0-12-5.4-12-12V60c0-6.6 5.4-12 12-12h328c6.6 0 12 5.4 12 12v312z"})}),Ir=[{title:"Mobile (Base)",content:"Styles set here are applied to all screen unless edited at higher breakpoint",breakpoint:"xs",icon:i.jsx(v.MobileIcon,{className:"h-4 w-4"}),width:400},{title:"Mobile landscape (SM)",content:"Styles set here are applied at 640px and up unless edited at higher breakpoint",breakpoint:"sm",icon:i.jsx(v.MobileIcon,{className:"h-4 w-4 rotate-90"}),width:640},{title:"Tablet (MD)",content:"Styles set here are applied at 768px and up",breakpoint:"md",icon:i.jsx(Gi,{}),width:800},{title:"Tablet Landscape (LG)",content:"Styles set here are applied at 1024px and up unless edited at higher breakpoint",breakpoint:"lg",icon:i.jsx(Gi,{landscape:!0}),width:1024},{title:"Desktop (XL)",content:"Styles set here are applied at 1280px and up unless edited at higher breakpoint",breakpoint:"xl",icon:i.jsx(v.LaptopIcon,{className:"h-4 w-4"}),width:1420},{title:"Large Desktop (2XL)",content:"Styles set here are applied at 1536px and up",breakpoint:"2xl",icon:i.jsx(v.DesktopIcon,{className:"h-4 w-4"}),width:1920}],qi=({canvas:t=!1,openDelay:e=400,tooltip:n=!0,title:s,content:r,currentBreakpoint:o,breakpoint:a,width:l,icon:c,onClick:d,buttonClass:p="",activeButtonClass:f=""})=>{const{t:m}=F.useTranslation();return n?i.jsxs(vc,{openDelay:e,children:[i.jsx(kc,{asChild:!0,children:i.jsx(q,{onClick:()=>d(l),size:"sm",className:ve.cn("h-7 w-7 rounded-md p-1",a===o?f:p),variant:a===o?"outline":"ghost",children:c})}),i.jsx(qo,{className:"w-fit max-w-52 border-border",children:i.jsx("div",{className:"flex justify-between space-x-4",children:i.jsxs("div",{className:"space-y-1",children:[i.jsx("h4",{className:"text-sm font-semibold",children:m(s)}),t&&i.jsx("p",{className:"text-xs",children:m(r)})]})})})]}):i.jsx(q,{onClick:()=>d(l),size:"sm",className:"h-7 w-7 rounded-md p-1",variant:a===o?"outline":"ghost",children:c})},Ko=({openDelay:t=400,canvas:e=!1,tooltip:n=!0,buttonClass:s="",activeButtonClass:r=""})=>{const[o,,a]=bs(),[l,c]=Ao(),[d,p]=Ex(),f=d,m=p,{t:h}=F.useTranslation(),b=O("breakpoints",Ir),x=w=>{f.includes(w)?f.length>2&&m(f.filter(E=>E!==w)):m(E=>[...E,w])},y=w=>{e||a(w),c(w)},k=ve.getBreakpointValue(e?l:o).toLowerCase();return b.length<4?i.jsx("div",{className:"flex items-center rounded-md",children:u.map(b,w=>g.createElement(qi,{canvas:e,...w,onClick:y,key:w.breakpoint,currentBreakpoint:k}))}):i.jsxs("div",{className:"flex w-full items-center justify-between rounded-md",children:[i.jsx("div",{className:"flex items-center",children:u.map(b.filter(w=>u.includes(f,u.toUpper(w.breakpoint))),w=>g.createElement(qi,{canvas:e,openDelay:t,tooltip:n,...w,onClick:y,key:w.breakpoint,currentBreakpoint:k,buttonClass:s,activeButtonClass:r}))}),i.jsxs(Qe,{children:[i.jsx(et,{asChild:!0,children:i.jsx("span",{className:"cursor-pointer rounded-md p-1 hover:bg-background",children:i.jsx(v.ChevronDownIcon,{className:"scale-90 transform"})})}),i.jsxs(Ue,{className:"w-56 border-border text-xs",children:[i.jsx(ua,{children:h("Screen sizes")}),i.jsx(Hr,{}),u.map(b,w=>i.jsx(da,{disabled:w.breakpoint==="xs",onCheckedChange:()=>x(u.toUpper(w.breakpoint)),checked:u.includes(f,u.toUpper(w.breakpoint)),onSelect:E=>E.preventDefault(),children:h(w.title)},w.breakpoint))]})]})]})};function Ax(){const[,t]=bs(),{t:e}=F.useTranslation(),n=g.useMemo(()=>{const s=Ir.find(r=>r.breakpoint===t);return s==null?void 0:s.content},[t,Ir]);return i.jsxs(i.Fragment,{children:[i.jsxs("div",{className:"sticky top-0 z-10 flex items-center justify-start bg-muted px-2 py-1 shadow-sm",children:[i.jsxs("p",{className:"text-xs text-muted-foreground",children:[e("Screen")," "]}),i.jsx(Ko,{openDelay:1e3,tooltip:!1})]}),i.jsx("div",{className:"mb-2 flex items-center justify-between rounded-md rounded-t-none border border-border p-1",children:i.jsx("p",{className:"flex flex-1 items-center space-x-2 text-[10px] text-foreground",children:i.jsxs("span",{className:"text-xs text-foreground",children:[i.jsx("span",{className:"rounded-md bg-muted px-1 py-px text-xs font-bold uppercase text-muted-foreground",children:t==="xs"?"Base":t}),"  ",e(n)]})})})]})}const _x=_n.cva("text-sm font-medium leading-none peer-disabled:cursor-not-allowed peer-disabled:opacity-70"),ut=M.forwardRef(({className:t,...e},n)=>i.jsx(la.Root,{ref:n,className:L(_x(),t),...e}));ut.displayName=la.Root.displayName;const Tr=({className:t=""})=>i.jsx(v.TokensIcon,{className:t});function Yo({from:t="default",classFromProps:e,onAddNew:n,onRemove:s}){var ft;const r=g.useRef(null),[o,a]=g.useState(""),[l,c]=g.useState(!1),[d,p]=g.useState(-1),[,f]=so(),m=ix(),{t:h}=F.useTranslation(),[b]=Ee(),x=Z(),y=yc(),k=Uo(),[w]=K(),[E,A]=g.useState(""),_=S.useAtomValue(nn),I=(ft=u.first(b))==null?void 0:ft.prop,{classes:j}=$.getSplitChaiClasses(u.get(x,I,"")),C=(t==="default"?j:e??"").split(" ").filter(H=>!u.isEmpty(H)),T=g.useMemo(()=>[...C].sort((H,ce)=>{const Be=H.startsWith($.DESIGN_TOKEN_PREFIX),rt=ce.startsWith($.DESIGN_TOKEN_PREFIX);return Be&&!rt?-1:!Be&&rt?1:0}),[C]),R=O("flags.copyPaste",!0),B=H=>{if(H.startsWith($.DESIGN_TOKEN_PREFIX)){const ce=_[H];return ce?ce.name:H}return H},U=H=>{const ce=Object.entries(_).find(([,Be])=>Be.name===H);return ce?`${ce[0]}`:H},z=()=>{const H=E.trim().replace(/ +(?= )/g,"").split(" ").map(U);t==="designToken"?u.isFunction(n)&&n(H):y(w,H,!0),A("")},[G,he]=g.useState([]),ae=O("flags.designTokens",!1),le=({value:H})=>{const ce=H.trim().toLowerCase(),Be=ce.match(/.+:/g);let rt=[],Js=[];if(ae&&(ce===""?Js=Object.entries(_).map(([ht,un])=>({name:un.name,id:`${ht}`,isDesignToken:!0})):Js=Object.entries(_).filter(([,ht])=>ht.name.toLowerCase().includes(ce)).map(([ht,un])=>({name:un.name,id:`${ht}`,isDesignToken:!0}))),Be&&Be.length>0){const[ht]=Be,un=ce.replace(ht,"");rt=m.search(un).map(Zs=>({...Zs,item:{...Zs.item,name:ht+Zs.item.name}}))}else rt=m.search(ce);const Cd=[...Js,...u.map(rt,"item")];return he(Cd)},Ae=()=>{he([])},W=H=>H.name,Me=H=>i.jsxs("div",{className:"flex items-center gap-2 rounded-md p-1",children:[H.isDesignToken&&i.jsx(Tr,{className:"h-4 w-4 text-gray-600"}),i.jsx("span",{children:H.name})]}),pt=g.useMemo(()=>({ref:r,autoComplete:"off",autoCorrect:"off",autoCapitalize:"off",spellCheck:!1,placeholder:h("Enter classes separated by space"),value:E,onFocus:H=>{setTimeout(()=>{H.target&&H.target.select()},0)},onKeyDown:H=>{if(H.key==="Enter"&&E.trim()!==""&&(H.preventDefault(),z()),H.key==="Tab"&&G.length>0){H.preventDefault();const ce=new KeyboardEvent("keydown",{key:"ArrowDown",code:"ArrowDown",keyCode:40,bubbles:!0});H.target.dispatchEvent(ce)}},onChange:(H,{newValue:ce})=>A(ce),className:`w-full rounded-md text-xs px-2 hover:outline-0 bg-background border-border ${t==="default"?"py-1":"py-1.5"}`}),[E,h,r,G.length]),wt=H=>{const ce=o.trim().replace(/ +(?= )/g,"").split(" ").map(U);k(w,[H]),y(w,ce,!0),a(""),p(-1)},Wt=()=>{if(navigator.clipboard===void 0){me.toast.error(h("Clipboard not supported"));return}navigator.clipboard.writeText(C.join(" ")),me.toast.success(h("Classes copied to clipboard")),c(!0),setTimeout(()=>c(!1),2e3)};return i.jsxs("div",{className:`flex w-full flex-col gap-y-1.5 pb-4 ${t==="designToken"?"border-none":"border-b border-border"}`,children:[i.jsx("div",{className:"flex items-center justify-between gap-x-2",children:i.jsxs("div",{className:"flex w-full items-center justify-between gap-x-2 text-muted-foreground",children:[i.jsxs("span",{className:"flex items-center gap-x-1",children:[i.jsx("span",{children:t==="designToken"?i.jsx(ut,{className:"text-sm font-medium leading-tight text-gray-900 peer-disabled:cursor-not-allowed peer-disabled:opacity-70",children:h("Token Classes")}):h(ae?"Styles":"Classes")}),R&&i.jsxs(pe,{children:[i.jsx(fe,{asChild:!0,children:l?i.jsx(v.CheckIcon,{className:"rounded-full border border-green-500 bg-green-500/10 text-green-500"}):i.jsx(v.CopyIcon,{onClick:Wt,className:"cursor-pointer"})}),i.jsx(ue,{children:i.jsx("p",{children:h("Copy classes to clipboard")})})]})]}),ae&&t==="default"&&i.jsx(q,{variant:"link",className:"underline",onClick:()=>f("design-tokens"),children:h("Design Tokens")})]})}),i.jsxs("div",{className:"relative flex items-center gap-x-3",children:[i.jsx("div",{className:"relative flex w-full items-center gap-x-3",children:i.jsx(Gd,{suggestions:G,onSuggestionsFetchRequested:le,onSuggestionsClearRequested:Ae,getSuggestionValue:W,renderSuggestion:Me,inputProps:pt,onSuggestionSelected:(H,{suggestionValue:ce})=>{const rt=[U(ce)];t==="designToken"?u.isFunction(n)&&n(rt):y(w,rt,!0),A("")},containerProps:{className:"relative h-8 w-full gap-y-1 py-1 border-border text-xs"},theme:{suggestion:"bg-transparent",suggestionHighlighted:"!bg-gray-300 dark:!bg-gray-800 cursor-pointer",suggestionsContainerOpen:"absolute bg-background no-scrollbar z-50 max-h-[230px] overflow-y-auto w-full border border-border rounded-md"}})}),i.jsx(q,{variant:"outline",className:`border-border ${t==="default"?"h-6":"mt-1 h-7"}`,onClick:z,disabled:E.trim()==="",size:"sm",children:i.jsx(v.PlusIcon,{})})]}),i.jsx("div",{className:"flex w-full flex-wrap gap-2 overflow-x-hidden",children:T.map((H,ce)=>d===ce?i.jsx("input",{ref:r,value:o,onChange:Be=>a(Be.target.value),onBlur:()=>{wt(H)},onKeyDown:Be=>{Be.key==="Enter"&&wt(H)},onFocus:Be=>{setTimeout(()=>{Be.target.select()},0)},className:"group relative flex max-w-[260px] cursor-default items-center gap-x-1 truncate break-words rounded border border-border bg-gray-200 p-px px-1.5 pr-2 text-[11px] text-gray-600 hover:border-gray-300 dark:border-gray-700 dark:bg-gray-800 dark:text-gray-300"},H):i.jsx("div",{className:"group relative flex max-w-[260px] items-center",children:i.jsxs("button",{onDoubleClick:()=>{A(B(H)),t==="default"?k(w,[H]):(u.isFunction(s)&&s(H),A(H)),setTimeout(()=>{r.current&&r.current.focus()},10)},className:"flex h-max cursor-default items-center gap-x-1 truncate break-words rounded bg-gray-200 py-px pl-0.5 pr-1 text-[11px] text-gray-600 dark:bg-gray-800 dark:text-gray-300",children:[i.jsxs("div",{className:"z-10 flex h-full w-max items-center justify-center",children:[i.jsx(v.Cross2Icon,{onClick:()=>{t==="default"?k(w,[H]):u.isFunction(s)&&s(H)},className:"hidden h-max w-3.5 cursor-pointer rounded bg-gray-100 p-0.5 text-red-500 hover:bg-gray-50 group-hover:block"}),H.startsWith($.DESIGN_TOKEN_PREFIX)?i.jsx(Tr,{className:"text-[rgba(55, 65, 81, 0.4)] h-3.5 w-3.5 group-hover:hidden"}):i.jsxs("svg",{className:"h-3.5 w-3.5 group-hover:hidden",fill:"rgba(55, 65, 81, 0.4)",viewBox:"0 0 24 24",xmlns:"http://www.w3.org/2000/svg",xmlSpace:"preserve",children:[i.jsx("g",{id:"SVGRepo_bgCarrier",strokeWidth:"0"}),i.jsx("g",{id:"SVGRepo_tracerCarrier",strokeLinecap:"round",strokeLinejoin:"round"}),i.jsx("g",{id:"SVGRepo_iconCarrier",children:i.jsx("path",{fillRule:"evenodd",clipRule:"evenodd",d:"M12 6.036c-2.667 0-4.333 1.325-5 3.976 1-1.325 2.167-1.822 3.5-1.491.761.189 1.305.738 1.906 1.345C13.387 10.855 14.522 12 17 12c2.667 0 4.333-1.325 5-3.976-1 1.325-2.166 1.822-3.5 1.491-.761-.189-1.305-.738-1.907-1.345-.98-.99-2.114-2.134-4.593-2.134zM7 12c-2.667 0-4.333 1.325-5 3.976 1-1.326 2.167-1.822 3.5-1.491.761.189 1.305.738 1.907 1.345.98.989 2.115 2.134 4.594 2.134 2.667 0 4.333-1.325 5-3.976-1 1.325-2.167 1.822-3.5 1.491-.761-.189-1.305-.738-1.906-1.345C10.613 13.145 9.478 12 7 12z"})})]})]}),i.jsx("div",{children:B(H)})]})},H))})]})}const je=["px","%","em","rem","ch","vh","vw"],Ix={heading:"flex.heading",items:[{type:"arbitrary",label:"flex.basis",units:je,property:"flexBasis"},{type:"range",label:"flex.order",property:"order"},{type:"dropdown",label:"flex.flex",property:"flexGrowShrink"},{type:"dropdown",label:"flex.grow",property:"flexGrow"},{type:"dropdown",label:"flex.shrink",property:"flexShrink"}]},Tx={heading:"grid.heading",items:[{type:"range",label:"grid.col_span",property:"gridColSpan"},{type:"range",label:"grid.col_start",property:"gridColStart"},{type:"range",label:"grid.col_end",property:"gridColEnd"},{type:"range",label:"grid.row_span",property:"gridRowSpan"},{type:"range",label:"grid.row_start",property:"gridRowStart"},{type:"range",label:"grid.row_end",property:"gridRowEnd"},{type:"range",label:"grid.order",property:"order"}]},Bx=[{heading:"Styles",items:[{component:Yo},{component:Ax},{type:"arbitrary",label:"layout.width",units:je.concat("auto"),property:"width"},{type:"arbitrary",label:"layout.height",units:je.concat("auto"),property:"height"},{styleType:"multiple",label:"layout.margin",negative:!0,units:[...je,"auto"],options:[{key:"margin",label:"layout.margin_all"},{key:"marginX",label:"layout.margin_lr"},{key:"marginY",label:"layout.margin_tb"},{key:"marginTop",label:"layout.margin_top"},{key:"marginRight",label:"layout.margin_right"},{key:"marginBottom",label:"layout.margin_bottom"},{key:"marginLeft",label:"layout.margin_left"}]},{styleType:"multiple",label:"layout.padding",options:[{key:"padding",label:"layout.padding_all"},{key:"paddingX",label:"layout.padding_lr"},{key:"paddingY",label:"layout.padding_tb"},{key:"paddingTop",label:"layout.padding_top"},{key:"paddingRight",label:"layout.padding_right"},{key:"paddingBottom",label:"layout.padding_bottom"},{key:"paddingLeft",label:"layout.padding_left"}]},{styleType:"accordion",heading:"typography.heading",items:[{type:"dropdown",property:"textAlign",label:"typography.align"},{type:"dropdown",property:"fontFamily",label:"typography.font"},{type:"arbitrary",property:"fontSize",label:"typography.size",units:je},{type:"arbitrary",property:"lineHeight",label:"typography.height",units:je.concat("-")},{type:"range",property:"fontWeight",label:"typography.weight"},{type:"color",property:"textColor",label:"typography.color"}]},{styleType:"accordion",heading:"background.heading",items:[{type:"color",label:"background.bgcolor",property:"backgroundColor"},{type:"dropdown",label:"background.attachment",property:"backgroundAttachment"},{type:"dropdown",label:"background.clipping",property:"backgroundClip"},{type:"dropdown",label:"background.origin",property:"backgroundOrigin"},{type:"dropdown",label:"background.position",property:"backgroundPosition"},{type:"dropdown",label:"background.repeat",property:"backgroundRepeat"},{type:"dropdown",label:"background.size",property:"backgroundSize"}]}]}];je.concat("auto"),je.concat("auto"),[...je],je.concat("auto"),je.concat("auto"),je.concat("auto"),je.concat("auto"),je.concat("-");const Rx={px:1,"%":1,em:100,rem:100,ch:1,vw:1,vh:1,"-":1,deg:1,ms:.1};function Br(){const{flexChild:t,gridChild:e}=ju(),[n]=Ee(),[s,r]=g.useState(""),[o,a]=g.useState({onDrag:d=>d,onDragEnd:d=>d,dragStartY:0,dragging:!1,dragStartValue:0,dragUnit:"",negative:!1,cssProperty:""}),l=ke.useThrottledCallback(d=>{const p=!u.get(o,"negative",!1),f=u.get(o,"cssProperty","");let m=parseFloat(o.dragStartValue);m=isNaN(m)?0:m;let h=Rx[o.dragUnit];(u.startsWith(f,"scale")||f==="opacity")&&(h=10);let x=(o.dragStartY-d.pageY)/h+m;p&&x<0&&(x=0),f==="opacity"&&x>1&&(x=1),o.onDrag(`${x}`),r(`${x}`)},[o],50),c=g.useCallback(()=>{setTimeout(()=>o.onDragEnd(`${s}`),100),a({onDrag:d=>d,onDragEnd:d=>d,dragStartY:0,dragging:!1,dragStartValue:0,dragUnit:"",negative:!1,cssProperty:""})},[o,s,a]);return u.isEmpty(n)?null:i.jsxs(fc.Provider,{value:{setDragData:a},children:[o.dragging?i.jsx("div",{onMouseMove:l,onMouseUp:()=>c(),className:"absolute inset-0 z-30 cursor-row-resize bg-gray-300/10"}):null,i.jsxs("div",{className:"flex flex-col",children:[i.jsx(qg,{}),i.jsxs(uc,{defaultValue:["Styles"],type:"multiple",className:"w-full",children:[t&&i.jsx(fr,{section:Ix,showAccordian:t||e}),e&&i.jsx(fr,{section:Tx,showAccordian:t||e}),Bx.map(d=>i.jsx(fr,{section:d,showAccordian:t||e},d.heading))]})]})]})}const An=M.forwardRef(({className:t,children:e,...n},s)=>i.jsxs(It.Root,{ref:s,className:L("relative overflow-hidden",t),...n,children:[i.jsx(It.Viewport,{className:"h-full w-full rounded-[inherit]",children:e}),i.jsx(wc,{}),i.jsx(It.Corner,{})]}));An.displayName=It.Root.displayName;const wc=M.forwardRef(({className:t,orientation:e="vertical",...n},s)=>i.jsx(It.ScrollAreaScrollbar,{ref:s,orientation:e,className:L("flex touch-none select-none transition-colors",e==="vertical"&&"h-full w-2.5 border-l border-l-transparent p-[1px]",e==="horizontal"&&"h-2.5 flex-col border-t border-t-transparent p-[1px]",t),...n,children:i.jsx(It.ScrollAreaThumb,{className:"relative flex-1 rounded-full bg-border"})}));wc.displayName=It.ScrollAreaScrollbar.displayName;const Us=Ft.Root,Hn=M.forwardRef(({className:t,...e},n)=>i.jsx(Ft.List,{ref:n,className:L("inline-flex h-9 items-center justify-center rounded-lg bg-muted p-1 text-muted-foreground",t),...e}));Hn.displayName=Ft.List.displayName;const He=M.forwardRef(({className:t,...e},n)=>i.jsx(Ft.Trigger,{ref:n,className:L("inline-flex items-center justify-center whitespace-nowrap rounded-md px-3 py-1 text-sm font-medium ring-offset-background transition-all focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2 disabled:pointer-events-none disabled:opacity-50 data-[state=active]:bg-background data-[state=active]:text-foreground data-[state=active]:shadow",t),...e}));He.displayName=Ft.Trigger.displayName;const lt=M.forwardRef(({className:t,...e},n)=>i.jsx(Ft.Content,{ref:n,className:L("mt-2 ring-offset-background focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2",t),...e}));lt.displayName=Ft.Content.displayName;const Px=({block:t,disabled:e,parentId:n,position:s})=>{const{type:r,icon:o,label:a}=t,{addCoreBlock:l,addPredefinedBlock:c}=yt(),d=()=>{if(u.has(t,"blocks")){const b=u.isFunction(t.blocks)?t.blocks():t.blocks;c(J.syncBlocksWithDefaults(b),n||null,s)}else l(t,n||null,s);re.publish(Y.CLOSE_ADD_BLOCK)},p=Ye(),{t:f}=F.useTranslation(),{onDragStart:m,onDragEnd:h}=on();return i.jsx(i.Fragment,{children:i.jsxs(pe,{children:[i.jsx(fe,{asChild:!0,children:i.jsxs("button",{disabled:e,onClick:d,type:"button",onDragStart:b=>m(b,{...t,label:a,icon:o}),onDragEnd:h,draggable:p,className:`${u.kebabCase(`chai-block-${r}`)} ${p?"cursor-grab active:cursor-grabbing":"cursor-pointer"} space-y-2 rounded-lg border border-border p-3 text-center hover:bg-slate-300/50 disabled:cursor-not-allowed disabled:bg-gray-100 disabled:text-gray-400 dark:border-gray-700 dark:text-white dark:hover:bg-slate-800/50 dark:disabled:bg-gray-900 dark:disabled:text-foreground ${e?"opacity-50":""}`,children:[g.createElement(o||v.BoxIcon,{className:"w-4 h-4 mx-auto","data-add-core-block-icon":r}),i.jsx("p",{className:"truncate text-xs",children:u.capitalize(f(a||r))})]})}),i.jsx(ue,{children:i.jsx("p",{children:f(a||r)})})]})})},Cc=({parentId:t,position:e,gridCols:n="grid-cols-2",disableBlockGroupsSidebar:s=!1})=>{const r=J.useRegisteredChaiBlocks(),o=u.groupBy(r,"category"),a=u.uniq(u.map(o.core,"group"));return i.jsx(Mc,{gridCols:n,parentId:t,position:e,groups:a,blocks:o.core,disableBlockGroupsSidebar:s})},Xo=M.forwardRef(({className:t,...e},n)=>i.jsx("div",{ref:n,className:L("rounded-xl border bg-card text-card-foreground shadow",t),...e}));Xo.displayName="Card";const Jo=M.forwardRef(({className:t,...e},n)=>i.jsx("div",{ref:n,className:L("flex flex-col space-y-1.5 p-6",t),...e}));Jo.displayName="CardHeader";const jc=M.forwardRef(({className:t,...e},n)=>i.jsx("div",{ref:n,className:L("font-semibold leading-none tracking-tight",t),...e}));jc.displayName="CardTitle";const Sc=M.forwardRef(({className:t,...e},n)=>i.jsx("div",{ref:n,className:L("text-sm text-muted-foreground",t),...e}));Sc.displayName="CardDescription";const Zo=M.forwardRef(({className:t,...e},n)=>i.jsx("div",{ref:n,className:L("p-6 pt-0",t),...e}));Zo.displayName="CardContent";const Qo=M.forwardRef(({className:t,...e},n)=>i.jsx("div",{ref:n,className:L("flex items-center p-6 pt-0",t),...e}));Qo.displayName="CardFooter";const Vn=M.forwardRef(({className:t,...e},n)=>i.jsx("textarea",{className:L("flex min-h-[60px] w-full rounded-md border border-input bg-transparent px-3 py-2 text-base shadow-sm placeholder:text-muted-foreground focus-visible:outline-none focus-visible:ring-1 focus-visible:ring-ring disabled:cursor-not-allowed disabled:opacity-50 md:text-sm",t),ref:n,...e}));Vn.displayName="Textarea";let Nc=async t=>t;const Lx=t=>{Nc=t},Mx=async t=>await Nc(t),Ec=({parentId:t,position:e,fromSidebar:n})=>{const{t:s}=F.useTranslation(),[r,o]=g.useState(""),{addPredefinedBlock:a}=yt(),[l,c]=g.useState(!1),d=async()=>{c(!0);const p=await Mx(r),f=$.getBlocksFromHTML(p);a([...f],t,e),o(""),c(!1),re.publish(Y.CLOSE_ADD_BLOCK)};return i.jsxs(Xo,{className:`border-border/0 p-0 shadow-none ${n?"w-full":"max-w-full"}`,children:[i.jsx(Jo,{className:n?"p-0":"p-3",children:i.jsx(Sc,{className:n?"text-xs":"",children:s("Use HTML snippets from Tailwind CSS component libraries")})}),i.jsx(Zo,{className:`space-y-2 py-0 ${n?"p-0":"px-3"}`,children:i.jsxs("div",{className:"space-y-1",children:[i.jsx(ut,{htmlFor:"current",className:"text-sm",children:s("Tailwind HTML snippet")}),i.jsx(Vn,{onChange:p=>o(p.target.value),rows:12,value:r,placeholder:s("Enter your code snippet here"),className:"resize-none overflow-x-auto whitespace-pre bg-background font-mono text-xs font-normal"})]})}),i.jsx(Qo,{className:"flex flex-col justify-end p-3",children:i.jsx(q,{disabled:r.trim()===""||l,onClick:()=>d(),size:"sm",className:"w-fit",children:l?i.jsxs(i.Fragment,{children:[i.jsx(v.CircleIcon,{className:"mr-2 h-4 w-4 animate-spin"})," ",s("Importing...")]}):s("Import HTML")})})]})},Gs=ge.Root,ei=ge.Value,Wn=M.forwardRef(({className:t,children:e,...n},s)=>i.jsxs(ge.Trigger,{ref:s,className:L("flex h-9 w-full items-center justify-between whitespace-nowrap rounded-md border border-input bg-transparent px-3 py-2 text-sm shadow-sm ring-offset-background focus:outline-none focus:ring-1 focus:ring-ring disabled:cursor-not-allowed disabled:opacity-50 data-[placeholder]:text-muted-foreground [&>span]:line-clamp-1",t),...n,children:[e,i.jsx(ge.Icon,{asChild:!0,children:i.jsx(v.ChevronDownIcon,{className:"h-4 w-4 opacity-50"})})]}));Wn.displayName=ge.Trigger.displayName;const Ac=M.forwardRef(({className:t,...e},n)=>i.jsx(ge.ScrollUpButton,{ref:n,className:L("flex cursor-default items-center justify-center py-1",t),...e,children:i.jsx(v.ChevronUpIcon,{className:"h-4 w-4"})}));Ac.displayName=ge.ScrollUpButton.displayName;const _c=M.forwardRef(({className:t,...e},n)=>i.jsx(ge.ScrollDownButton,{ref:n,className:L("flex cursor-default items-center justify-center py-1",t),...e,children:i.jsx(v.ChevronDownIcon,{className:"h-4 w-4"})}));_c.displayName=ge.ScrollDownButton.displayName;const Un=M.forwardRef(({className:t,children:e,position:n="popper",...s},r)=>i.jsx(ge.Portal,{children:i.jsxs(ge.Content,{ref:r,className:L("relative z-50 max-h-[--radix-select-content-available-height] min-w-[8rem] origin-[--radix-select-content-transform-origin] overflow-y-auto overflow-x-hidden rounded-md border bg-popover text-popover-foreground shadow-md data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0 data-[state=closed]:zoom-out-95 data-[state=open]:zoom-in-95 data-[side=bottom]:slide-in-from-top-2 data-[side=left]:slide-in-from-right-2 data-[side=right]:slide-in-from-left-2 data-[side=top]:slide-in-from-bottom-2",n==="popper"&&"data-[side=bottom]:translate-y-1 data-[side=left]:-translate-x-1 data-[side=right]:translate-x-1 data-[side=top]:-translate-y-1",t),position:n,...s,children:[i.jsx(Ac,{}),i.jsx(ge.Viewport,{className:L("p-1",n==="popper"&&"h-[var(--radix-select-trigger-height)] w-full min-w-[var(--radix-select-trigger-width)]"),children:e}),i.jsx(_c,{})]})}));Un.displayName=ge.Content.displayName;const Dx=M.forwardRef(({className:t,...e},n)=>i.jsx(ge.Label,{ref:n,className:L("px-2 py-1.5 text-sm font-semibold",t),...e}));Dx.displayName=ge.Label.displayName;const Gn=M.forwardRef(({className:t,children:e,...n},s)=>i.jsxs(ge.Item,{ref:s,className:L("relative flex w-full cursor-default select-none items-center rounded-sm py-1.5 pl-2 pr-8 text-sm outline-none focus:bg-accent focus:text-accent-foreground data-[disabled]:pointer-events-none data-[disabled]:opacity-50",t),...n,children:[i.jsx("span",{className:"absolute right-2 flex h-3.5 w-3.5 items-center justify-center",children:i.jsx(ge.ItemIndicator,{children:i.jsx(v.CheckIcon,{className:"h-4 w-4"})})}),i.jsx(ge.ItemText,{children:e})]}));Gn.displayName=ge.Item.displayName;const Ox=M.forwardRef(({className:t,...e},n)=>i.jsx(ge.Separator,{ref:n,className:L("-mx-1 my-1 h-px bg-muted",t),...e}));Ox.displayName=ge.Separator.displayName;const Fx=({defaultValue:t="",onValueChange:e,options:n,placeholder:s="Select",className:r="",height:o=""})=>{const[a,l]=g.useState(t),c=d=>{const p=d.target.value;l(p),e(p)};return i.jsx("div",{className:ve.cn("relative inline-block w-full",r),children:i.jsxs("select",{className:ve.cn("mt-1 flex w-full rounded-md border border-border bg-background px-3 py-1 text-sm text-foreground 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",o),value:a,onChange:c,children:[i.jsx("option",{value:"",disabled:!0,children:s}),n.map(d=>i.jsx("option",{value:d.value,children:d.label},d.value))]})})};function $x({uiLibraries:t,library:e,setLibrary:n}){const{t:s}=F.useTranslation();return e?i.jsxs("div",{className:"h-12",children:[i.jsx("p",{className:"text-xs font-bold text-gray-500",children:s("Choose library")}),i.jsx(Fx,{className:"mb-1",options:t.map(r=>({value:r.id,label:r.name})),defaultValue:e,onValueChange:r=>n(r)})]}):null}let Ic={};const zx=(t,e)=>{Ic[t]={...e,id:t}},Tc=()=>u.values(Ic),Hx=S.atom({}),Bc=t=>{const[e,n]=S.useAtom(Hx),s=g.useMemo(()=>(t==null?void 0:t.getBlocksList)||(()=>[]),[t]),r=u.get(e,`${t==null?void 0:t.id}.blocks`,null),o=u.get(e,`${t==null?void 0:t.id}.loading`,"idle"),a=g.useRef("idle");g.useEffect(()=>{(async()=>{if(!(o==="complete"||a.current==="loading")){a.current="loading",n(c=>({...c,[t==null?void 0:t.id]:{loading:"loading",blocks:[]}}));try{const c=await s(t);a.current="idle",n(d=>({...d,[t==null?void 0:t.id]:{loading:"complete",blocks:c||[]}}))}catch{a.current="idle",n(c=>({...c,[t==null?void 0:t.id]:{loading:"complete",blocks:[]}}))}}})()},[t,r,o,a,n,s]);const l=g.useCallback(c=>{n(d=>({...d,[c]:{loading:"idle",blocks:[]}}))},[n]);return{data:r||[],isLoading:o==="loading",resetLibrary:l}},Vx=()=>S.useAtom(io),Rc=({block:t,html:e,blocks:n,children:s,onDragStart:r,onDragEnd:o,draggable:a,className:l="",type:c="Box"})=>{const{onDragStart:d,onDragEnd:p}=on(),f=Ye(),[,m]=K(),{clearHighlight:h}=nt(),b=a!==void 0?a:f,x=async k=>{try{if(r){r(k);return}let w=null;if(c==="Image"){if(!(t!=null&&t.image))return;w={type:"Image",blocks:[{_type:"Image",styles:"#styles:,w-full h-full object-cover",image:t==null?void 0:t.image,alt:(t==null?void 0:t.alt)||"",_name:(t==null?void 0:t.name)||"Image"}]}}else if(e){const E=typeof e=="function"?await e():e,A=$.getBlocksFromHTML(E);if(u.isEmpty(A))return;w={type:"Box",blocks:A,name:u.get(A,"0._type","Block")}}else if(n){const E=typeof n=="function"?await n():n;if(u.isEmpty(E))return;w={type:"Box",blocks:E,name:u.get(E,"0._type","Block")}}else if(t){const E=typeof t=="function"?await t():t;w=typeof E=="object"?u.omit(E,["component","icon"]):E}if(!w)return;d(k,w,!0),setTimeout(()=>{m([]),h()},200)}catch(w){console.error("Error in ChaiDraggableBlock drag start:",w)}},y=k=>{o?o(k):p()};return i.jsx("div",{draggable:b,onDragStart:x,onDragEnd:y,className:`${b?"cursor-grab active:cursor-grabbing":""} ${l}`.trim(),children:s})};function Pc({value:t,setValue:e}){const{t:n}=F.useTranslation();return i.jsx("div",{className:"flex py-2",children:i.jsxs("div",{className:"relative flex w-full max-w-md items-center rounded border px-2",children:[i.jsxs("div",{className:"flex w-full items-center gap-x-2",children:[i.jsx(v.MagnifyingGlassIcon,{className:"h-5 w-5 flex-shrink-0 stroke-[1px] text-muted-foreground"}),i.jsx(vt,{placeholder:n("Search blocks..."),value:t,onChange:s=>e(s.target.value),className:"w-full flex-1 border-none p-0 leading-tight outline-none"})]}),t&&i.jsx("button",{onClick:()=>e(""),className:"absolute right-2.5 top-2.5 text-muted-foreground hover:text-foreground",children:i.jsx(v.Cross1Icon,{className:"h-3.5 w-3.5"})})]})})}const Ki=({block:t,library:e,parentId:n=void 0,position:s=-1})=>{const[r,o]=g.useState(!1),a=g.useMemo(()=>(e==null?void 0:e.getBlock)||(()=>[]),[e]),{addCoreBlock:l,addPredefinedBlock:c}=yt(),d=u.get(t,"name",u.get(t,"label")),p=u.get(t,"description",""),{onDragStart:f,onDragEnd:m}=on(),h=Ye(),b=g.useCallback(async y=>{if(y.stopPropagation(),u.has(t,"component")){l(t,n,s),re.publish(Y.CLOSE_ADD_BLOCK);return}o(!0);let k=await a({library:e,block:t});typeof k=="string"&&(k=$.getBlocksFromHTML(k)),u.isEmpty(k)||c(J.syncBlocksWithDefaults(k),n,s),re.publish(Y.CLOSE_ADD_BLOCK),setTimeout(()=>o(!1),1e3)},[l,c,t,a,e,n,s]),x=async y=>{if(!h)return;let k=await a({library:e,block:t});typeof k=="string"&&(k=$.getBlocksFromHTML(k)),f(y,{type:"Box",blocks:k,name:d},!0)};return i.jsxs(pe,{children:[i.jsx(fe,{asChild:!0,children:i.jsx(Rc,{draggable:h,onDragStart:x,onDragEnd:m,children:i.jsxs("div",{onClick:r?()=>{}:b,className:Fr("relative mt-2 overflow-hidden rounded-md border border-border duration-200 hover:border-blue-500 hover:shadow-xl",h?"":"cursor-pointer"),children:[r&&i.jsxs("div",{className:"absolute flex h-full w-full items-center justify-center bg-black/70",children:[i.jsx(v.ReloadIcon,{className:"h-4 w-4 animate-spin text-white"}),i.jsx("span",{className:"pl-2 text-sm text-white",children:"Adding..."})]}),t.preview?i.jsx("img",{src:t.preview,className:"min-h-[45px] w-full rounded-md",alt:d}):i.jsxs("div",{className:"flex h-fit w-full flex-col items-center justify-center gap-1 rounded-md border border-border p-6 py-10 text-center",children:[i.jsx("p",{className:"font-medium text-gray-800",children:d}),p&&i.jsx("p",{className:"text-sm text-gray-600",children:p})]})]})})}),i.jsx(ue,{children:i.jsx("div",{className:"max-w-xs",children:i.jsx("p",{className:"font-medium",children:d})})})]})},Wx=({parentId:t,position:e,fromSidebar:n})=>{const[s,r]=Vx(),o=Tc(),a=o.find(R=>R.id===s)||u.first(o),{data:l,isLoading:c,resetLibrary:d}=Bc(a),[p,f]=g.useState(""),[m,h]=g.useState([]),b=g.useRef(null);g.useEffect(()=>{l&&l.length>0&&(b.current=new ia(l,{keys:["name","label","description","group"],threshold:.4,ignoreLocation:!0}))},[l]),g.useEffect(()=>{if(!p.trim()||!b.current){h([]);return}const R=b.current.search(p).map(B=>B.item);h(R)},[p]);const x=p.trim()&&!u.isEmpty(m)?m:l,y=u.groupBy(x,"group"),[k,w]=g.useState(null);g.useEffect(()=>{if(u.isEmpty(u.keys(y))){w(null);return}if(!k||!y[k]){w(u.first(u.keys(y)));return}},[y,k]);const E=u.get(y,k,[]),A=g.useRef(null),{t:_}=F.useTranslation(),I=g.useRef(null);g.useEffect(()=>{var B;const R=(B=I.current)==null?void 0:B.querySelector("[data-radix-scroll-area-viewport]");R&&R.scrollTo({top:0,behavior:"smooth"})},[a,k]);const j=R=>{A.current&&(clearTimeout(A.current),A.current=null),A.current=setTimeout(()=>{A.current&&w(R)},400)},N=()=>{a!=null&&a.id&&d(a.id)};if(c)return i.jsxs("div",{className:"mt-4 grid h-full w-full grid-cols-12 gap-2",children:[i.jsx(Mt,{className:"col-span-3 h-full"}),i.jsx(Mt,{className:"col-span-9 h-full"})]});const C=u.filter(E,(R,B)=>B%2===0),T=u.filter(E,(R,B)=>B%2===1);return i.jsx(i.Fragment,{children:i.jsxs("div",{className:"flex h-full max-h-full flex-col",children:[i.jsx(Pc,{value:p,setValue:f}),i.jsx("div",{className:"relative flex h-full max-h-full flex-1 overflow-hidden bg-background",children:i.jsxs("div",{className:`flex h-full flex-1 pt-2 ${n?"flex-col":""}`,children:[i.jsxs("div",{className:`flex max-h-full min-w-60 flex-col gap-1 ${n?"pb-2":"w-60 max-w-60 px-1 pr-2"}`,children:[i.jsx($x,{library:a==null?void 0:a.id,setLibrary:r,uiLibraries:o}),i.jsxs("div",{className:"mt-2 flex h-full max-h-full w-full flex-1 flex-col",children:[i.jsx("span",{className:"text-xs font-bold text-gray-500",children:_("Groups")}),!n&&i.jsx("hr",{className:"mt-1 border-border"}),i.jsx("div",{className:`no-scrollbar mt-2 h-full max-h-full flex-1 overflow-y-auto ${n?"":"pb-20"}`,children:u.isEmpty(y)?i.jsx("div",{className:"mt-4 flex flex-col items-center justify-center gap-3 p-4 text-center",children:p?i.jsx("p",{className:"text-sm",children:_("No matching blocks found")}):i.jsxs(i.Fragment,{children:[i.jsx("p",{className:"text-sm",children:_("Failed to load the UI library. Try again")}),i.jsxs(q,{onClick:N,variant:"outline",size:"sm",className:"gap-2",children:[i.jsx(v.ReloadIcon,{className:"h-4 w-4"}),_("Retry")]})]})}):n?i.jsxs(Gs,{value:k,onValueChange:w,children:[i.jsx(Wn,{className:"w-full",children:i.jsx(ei,{placeholder:_("Select a group")})}),i.jsx(Un,{children:u.map(y,(R,B)=>i.jsx(Gn,{value:B,children:u.capitalize(_(B.toLowerCase()))},B))})]}):u.map(y,(R,B)=>i.jsxs("div",{onMouseEnter:()=>j(B),onMouseLeave:()=>clearTimeout(A.current),role:"button",onClick:()=>w(B),className:L("flex w-full cursor-pointer items-center justify-between rounded-md p-2 text-sm text-foreground transition-all ease-in-out hover:bg-gray-200 dark:hover:bg-gray-800",B===k?"bg-primary text-primary-foreground hover:bg-primary/80":""),children:[i.jsx("span",{children:u.capitalize(_(B.toLowerCase()))}),i.jsx(v.CaretRightIcon,{className:"ml-2 h-5 w-5"})]},B))})]})]}),i.jsx("div",{className:`flex h-full max-h-full w-full flex-col border-border ${n?"":"border-l"}`,children:i.jsxs(An,{ref:I,onMouseEnter:()=>A.current?clearTimeout(A.current):null,className:"z-10 flex h-full max-h-full w-full flex-col gap-2 transition-all ease-linear",children:[u.isEmpty(E)&&!u.isEmpty(y)?i.jsx("div",{className:"flex h-full flex-col items-center justify-center p-6 text-center",children:i.jsx("p",{className:"text-sm",children:_("No blocks found in this group")})}):i.jsxs("div",{className:`grid w-full gap-2 ${n?"grid-cols-1 pb-20":"grid-cols-2 px-2"}`,children:[i.jsx("div",{className:"flex flex-col gap-1",children:C.map((R,B)=>i.jsx(Ki,{parentId:t,position:e,block:R,library:a},`block-${B}`))}),i.jsx("div",{className:"flex flex-col gap-1",children:T.map((R,B)=>i.jsx(Ki,{parentId:t,position:e,block:R,library:a},`block-second-${B}`))})]}),i.jsx("br",{}),i.jsx("br",{}),i.jsx("br",{})]})})]})})]})})},Lc=({parentId:t,position:e,fromSidebar:n})=>i.jsx(Wx,{parentId:t,position:e,fromSidebar:n}),Ux=S.atom({blocks:[],groups:[],isLoading:!0,error:null}),Gx=S.atom(!1),Yi=t=>{if(!t)return"";let e=t.replace(/[-_]/g," ");return e=e.replace(/([a-z])([A-Z])/g,"$1 $2"),e.split(" ").map(n=>n.charAt(0).toUpperCase()+n.slice(1).toLowerCase()).join(" ")},qx=({parentId:t,position:e,gridCols:n="grid-cols-2",disableBlockGroupsSidebar:s=!1})=>{const{data:r,isLoading:o,refetch:a,error:l}=Xa(),[c,d]=S.useAtom(Ux),[p,f]=S.useAtom(Gx);g.useEffect(()=>{if(!p||Object.keys(c.blocks).length===0)if(l)d({blocks:[],groups:[],isLoading:!1,error:l}),f(!0);else if(!o&&Object.keys(r||{}).length>0){const h=Object.entries(r).map(([x,y])=>{const k=y,w=k.type||"partial",E=Yi(w);return{type:"PartialBlock",label:Yi(k.name||x),description:k.description||"",icon:v.FrameIcon,group:E,category:"partial",partialBlockId:x,_name:k.name}}),b=u.uniq(u.map(h,"group"));d({blocks:h,groups:b,isLoading:!1,error:null}),f(!0)}else o?d(h=>({...h,isLoading:!0,error:null})):!o&&Object.keys(r||{}).length===0&&(d({blocks:[],groups:[],isLoading:!1,error:"No partial blocks available"}),f(!0))},[o,r,p,f,d,c.blocks,l]);const m=()=>{d(h=>({...h,isLoading:!0,error:null})),f(!1),a()};return c.isLoading?i.jsx("div",{className:"flex items-center justify-center p-8 text-center text-muted-foreground",children:"Loading partial blocks..."}):c.error||c.blocks.length===0?i.jsxs("div",{className:"flex flex-col items-center justify-center gap-4 p-8 text-center text-muted-foreground",children:[i.jsx("p",{children:c.error||"No partial blocks available"}),i.jsx("button",{onClick:m,className:"rounded-md bg-primary px-3 py-1 text-sm text-primary-foreground hover:bg-primary/90",children:"Refresh"})]}):i.jsx(Mc,{gridCols:n,parentId:t,position:e,groups:c.groups,blocks:c.blocks,disableBlockGroupsSidebar:s})},Rr={},Kx=(t,e)=>{u.has(Rr,t)&&console.warn(`Add block tab with id ${t} already registered`),u.set(Rr,t,{id:t,...e})},Yx=()=>g.useMemo(()=>u.values(Rr),[]),Xi=["basic","typography","media","layout","form","advanced","other"],Mc=({groups:t,blocks:e,parentId:n,position:s,gridCols:r="grid-cols-4",disableBlockGroupsSidebar:o})=>{var R;const{t:a}=F.useTranslation(),[l]=te(),[c,d]=g.useState(""),p=g.useRef(null),[f]=S.useAtom(Dc),m=(R=u.find(l,B=>B._id===n))==null?void 0:R._type,[h,b]=g.useState("all"),[x,y]=g.useState(null),k=g.useRef(null),w=O("flags.dragAndDrop",!1);g.useEffect(()=>{const B=setTimeout(()=>{var U;(U=p.current)==null||U.focus()},0);return()=>clearTimeout(B)},[f]),g.useEffect(()=>{c&&(b("all"),y(null))},[c]),g.useEffect(()=>(k.current=u.debounce(B=>{b(B)},500),()=>{k.current&&k.current.cancel()}),[]);const E=g.useCallback(B=>{y(B),k.current&&k.current(B)},[]),A=g.useCallback(()=>{y(null),k.current&&k.current.cancel()},[]),_=g.useCallback(B=>{k.current&&k.current.cancel(),b(B),y(null)},[]),I=g.useMemo(()=>c?u.values(e).filter(B=>{var U,z;return(((U=B.label)==null?void 0:U.toLowerCase())+" "+((z=B.type)==null?void 0:z.toLowerCase())).includes(c.toLowerCase())}):e,[e,c]),j=g.useMemo(()=>c?t.filter(B=>u.reject(u.filter(u.values(I),{group:B}),{hidden:!0}).length>0):t.filter(B=>u.reject(u.filter(u.values(e),{group:B}),{hidden:!0}).length>0),[e,I,t,c]),N=g.useMemo(()=>u.sortBy(j,B=>Xi.indexOf(B)===-1?99:Xi.indexOf(B)),[j]),C=g.useMemo(()=>h==="all"?I:u.filter(u.values(I),{group:h}),[I,h]),T=g.useMemo(()=>h==="all"?N:[h],[N,h]);return i.jsxs("div",{className:"mx-auto flex h-full w-full flex-col",children:[i.jsx(Pc,{value:c,setValue:d}),i.jsxs("div",{className:"sticky top-10 flex h-[calc(100%-48px)] overflow-hidden pt-2",children:[!o&&N.length>0&&i.jsx("div",{className:"w-1/4 min-w-[120px] border-r border-border",children:i.jsx(An,{className:"h-full",children:i.jsxs("div",{className:"space-y-1",children:[i.jsx("button",{onClick:()=>_("all"),onMouseEnter:()=>E("all"),onMouseLeave:A,className:`w-full rounded-md px-2 py-1.5 text-left text-sm font-medium ${h==="all"||x==="all"?"bg-primary text-primary-foreground":"hover:bg-primary/50 hover:text-primary-foreground"}`,children:a("All")},"sidebar-all"),N.map(B=>i.jsx("button",{onClick:()=>_(B),onMouseEnter:()=>E(B),onMouseLeave:A,className:`w-full rounded-md px-2 py-1.5 text-left text-sm ${h===B||x===B?"bg-primary text-primary-foreground":"hover:bg-primary/50 hover:text-primary-foreground"}`,children:u.capitalize(a(B.toLowerCase()))},`sidebar-${B}`))]})})}),i.jsx("div",{className:`h-full flex-1 overflow-hidden ${!o&&N.length>0?"w-3/4":"w-full"}`,children:i.jsx(An,{id:"add-blocks-scroll-area",className:"no-scrollbar h-full",children:j.length===0&&c?i.jsx("div",{className:"flex flex-col items-center justify-center p-8 text-center text-muted-foreground",children:i.jsxs("p",{children:[a("No blocks found matching"),' "',c,'"']})}):i.jsx("div",{className:`${o?"p-0":"p-4"} space-y-6`,children:T.map((B,U)=>i.jsxs("div",{className:"space-y-3",children:[i.jsx("h3",{className:"px-1 text-sm font-medium",children:u.capitalize(a(B.toLowerCase()))}),i.jsx("div",{className:"grid gap-2 "+r,children:u.reject(h==="all"?u.filter(u.values(C),{group:B}):u.values(C),{hidden:!0}).map((z,G)=>i.jsx(Px,{parentId:n,position:s,block:z,disabled:!w&&(!Ze(m,z.type)||!du(m,z.type))},z.type+"-"+U+"-"+G))})]},B))})})})]})]})},Dc=we.atomWithStorage("__add_block_tab","library"),ti=({className:t,showHeading:e=!0,parentId:n=void 0,position:s=-1,fromSidebar:r=!1})=>{const{t:o}=F.useTranslation(),[a,l]=S.useAtom(Dc),[,c]=S.useAtom(Ia),d=O("flags.importHtml",!0),{data:p}=Xa(),f=Object.keys(p||{}).length>0,{hasPermission:m}=qe();g.useEffect(()=>{a==="partials"&&!f&&l("library")},[a,f,l]);const h=g.useCallback(()=>{re.publish(Y.CLOSE_ADD_BLOCK)},[]),b=Yx(),x=d&&m(ne.IMPORT_HTML),k=Tc().length>0;return g.useEffect(()=>{a==="library"&&!k&&l("core")},[a,k,l]),i.jsxs("div",{className:ve.cn("flex h-full w-full flex-col overflow-hidden",t),children:[e?i.jsxs("div",{className:"mb-2 flex flex-col justify-between rounded-md bg-background/30 p-1",children:[i.jsx("h1",{className:"flex flex-col items-baseline px-1 text-xl font-semibold xl:flex-col",children:o("Add block")}),i.jsx("span",{className:"p-0 text-xs font-light leading-3 opacity-80 xl:pl-1",children:o(a==="html"?"Enter or paste TailwindCSS HTML snippet":"Click to add block to page")})]}):null,i.jsxs(Us,{onValueChange:w=>{c(""),l(w)},value:a,className:"flex h-full max-h-full flex-col overflow-hidden",children:[i.jsxs(Hn,{className:`flex items-center ${r?"h-max w-max justify-start p-1":"w-full"}`,children:[k&&i.jsx(He,{value:"library",className:r?"h-5 px-2 text-xs":"",children:o("Library")}),i.jsx(He,{value:"core",className:r?"h-5 px-2 text-xs":"",children:o("Blocks")}),f&&i.jsx(He,{value:"partials",className:r?"h-5 px-2 text-xs":"",children:o("Partials")}),x?i.jsx(He,{value:"html",className:r?"h-5 px-2 text-xs":"",children:o("Import")}):null,u.map(b,w=>i.jsx(He,{value:w.id,className:r?"h-5 px-2 text-xs":"",children:g.createElement(w.tab)},`tab-add-block-${w.id}`))]}),i.jsx(lt,{value:"core",className:"h-full max-h-full flex-1 pb-20",children:i.jsx("div",{className:"h-full max-h-full overflow-hidden",children:i.jsx("div",{className:"h-full w-full",children:i.jsx(Cc,{gridCols:r?"grid-cols-2":"grid-cols-4",parentId:n,position:s,disableBlockGroupsSidebar:r})})})}),k&&i.jsx(lt,{value:"library",className:"h-full max-h-full flex-1 pb-20",children:i.jsx(Lc,{fromSidebar:r,parentId:n,position:s})}),f&&i.jsx(lt,{value:"partials",className:"h-full max-h-full flex-1 pb-20",children:i.jsx("div",{className:"h-full max-h-full overflow-hidden",children:i.jsx("div",{className:"h-full w-full",children:i.jsx(qx,{gridCols:r?"grid-cols-2":"grid-cols-4",parentId:n,position:s,disableBlockGroupsSidebar:r})})})}),x?i.jsx(lt,{value:"html",className:"h-full max-h-full flex-1 pb-20 ",children:i.jsx(Ec,{parentId:n,position:s,fromSidebar:r})}):null,u.map(b,w=>i.jsx(lt,{value:w.id,children:g.createElement(w.tabContent,{close:h,parentId:n,position:s})},`panel-add-block-${w.id}`))]})]})},Xx={display:"flex",alignItems:"center",zIndex:1},Jx=g.memo(function({top:e,left:n}){const s={position:"absolute",pointerEvents:"none",top:e+"px",left:n+"px",right:0};return i.jsx("div",{style:{...Xx,...s},children:i.jsx("div",{className:"h-0.5 flex-1 rounded-[1px] bg-green-500"})})}),Ji="h-3 w-3 flex-shrink-0",ni=t=>{const e=J.useRegisteredChaiBlocks(),n=u.get(e,[t==null?void 0:t.type,"icon"]);return n?g.createElement(n,{className:Ji}):i.jsx(v.SquareIcon,{className:Ji})},Zx=g.memo(function({children:e,isDragging:n}){return n?i.jsx("div",{className:"pointer-events-none fixed left-0 top-0 z-[100] h-full w-full",children:e}):null}),Qx=g.memo(({id:t,isDragging:e,mouse:n})=>{const[s]=te(),r=g.useMemo(()=>s.find(a=>a._id===t),[s,t]),o=g.useMemo(()=>({transform:`translate(${(n==null?void 0:n.x)-10}px, ${(n==null?void 0:n.y)-10}px)`}),[n]);return n?i.jsx("div",{children:i.jsx(Zx,{isDragging:e,children:i.jsx("div",{className:"pointer-events-none absolute z-50 rounded border border-border bg-gray-100/80 font-semibold text-blue-600 shadow-md dark:border-gray-700 dark:bg-gray-800",style:o,children:i.jsxs("button",{type:"button",className:"flex !cursor-grab items-center p-0.5","aria-label":`Type: ${r==null?void 0:r._type}`,children:[i.jsx("div",{className:"-mt-0.5 h-3 w-3",children:i.jsx(ni,{type:r==null?void 0:r._type})}),i.jsx("div",{className:"ml-2 truncate text-[11px]",children:(r==null?void 0:r._name)||(r==null?void 0:r._type)})]})})})}):i.jsx("div",{className:"hidden"})}),eb=[{key:"ArrowDown",command:"selectNext"},{key:"ArrowUp",command:"selectPrev"},{key:"ArrowLeft",command:"selectParent",when:"isLeaf || isClosed"},{key:"ArrowLeft",command:"close",when:"isOpen"},{key:"ArrowRight",command:"open",when:"isClosed"},{key:"ArrowRight",command:"selectNext",when:"isOpen"},{key:"Home",command:"selectFirst"},{key:"End",command:"selectLast"}];function tb(t){t.firstNode&&t.select(t.firstNode.id)}function nb(t){t.lastNode&&t.select(t.lastNode.id)}function sb(t){const e=t.selectedNodes[0].next||t.firstNode;t.select(e.id)}function rb(t){const e=t.selectedNodes[0].prev||t.lastNode;t.select(e.id)}const ob=(t,e)=>{var s;const n=((s=t.selectedIds[0])==null?void 0:s.parent)||null;n&&e&&t.select(n.id)},ib=(t,e)=>{const n=t.selectedNodes[0];n.isInternal&&e&&n.open()},ab=(t,e)=>{const n=t.selectedNodes[0];n.isInternal&&e&&n.close()},si=Pe.Root,Oc=Pe.Trigger,lb=Pe.Portal,Fc=M.forwardRef(({className:t,...e},n)=>i.jsx(Pe.Overlay,{className:L("fixed inset-0 z-50 bg-black/80 data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0",t),...e,ref:n}));Fc.displayName=Pe.Overlay.displayName;const qs=M.forwardRef(({className:t,...e},n)=>i.jsxs(lb,{children:[i.jsx(Fc,{}),i.jsx(Pe.Content,{ref:n,className:L("fixed left-[50%] top-[50%] z-50 grid w-full max-w-lg translate-x-[-50%] translate-y-[-50%] gap-4 border bg-background p-6 shadow-lg duration-200 data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0 data-[state=closed]:zoom-out-95 data-[state=open]:zoom-in-95 data-[state=closed]:slide-out-to-left-1/2 data-[state=closed]:slide-out-to-top-[48%] data-[state=open]:slide-in-from-left-1/2 data-[state=open]:slide-in-from-top-[48%] sm:rounded-lg",t),...e})]}));qs.displayName=Pe.Content.displayName;const Ks=({className:t,...e})=>i.jsx("div",{className:L("flex flex-col space-y-2 text-center sm:text-left",t),...e});Ks.displayName="AlertDialogHeader";const ri=({className:t,...e})=>i.jsx("div",{className:L("flex flex-col-reverse sm:flex-row sm:justify-end sm:space-x-2",t),...e});ri.displayName="AlertDialogFooter";const Ys=M.forwardRef(({className:t,...e},n)=>i.jsx(Pe.Title,{ref:n,className:L("text-lg font-semibold",t),...e}));Ys.displayName=Pe.Title.displayName;const oi=M.forwardRef(({className:t,...e},n)=>i.jsx(Pe.Description,{ref:n,className:L("text-sm text-muted-foreground",t),...e}));oi.displayName=Pe.Description.displayName;const ii=M.forwardRef(({className:t,...e},n)=>i.jsx(Pe.Action,{ref:n,className:L(Bo(),t),...e}));ii.displayName=Pe.Action.displayName;const ai=M.forwardRef(({className:t,...e},n)=>i.jsx(Pe.Cancel,{ref:n,className:L(Bo({variant:"outline"}),"mt-2 sm:mt-0",t),...e}));ai.displayName=Pe.Cancel.displayName;const $c=({children:t})=>{const{t:e}=F.useTranslation(),{setNewBlocks:n}=Ne(),[,s]=K(),[,r]=Ee(),o=g.useCallback(()=>{n([]),s([]),r([])},[n]);return i.jsx("div",{className:"flex items-center",children:i.jsxs(si,{children:[i.jsx(Oc,{asChild:!0,children:t||i.jsxs(q,{size:"sm",variant:"ghost",className:"flex items-center",children:[i.jsx(v.EraserIcon,{})," ",e("Clear")]})}),i.jsxs(qs,{className:"border-border",children:[i.jsxs(Ks,{children:[i.jsx(Ys,{className:"text-foreground",children:e("Clear whole canvas?")}),i.jsx(oi,{children:e("Are you sure you want to clear the page?")})]}),i.jsxs(ri,{children:[i.jsx(ai,{className:"text-foreground",children:e("Cancel")}),i.jsx(ii,{onClick:o,children:e("Yes")})]})]})]})})};let zc=null;const cb=t=>{zc=t},Hc=()=>g.useMemo(()=>zc,[]),Vc=S.atom({isOpen:!1,blockId:null}),Wc=(t,e)=>{const n=u.filter(t,{_parent:e});if(n.length===0)return[];const s=[...n];return n.forEach(r=>{s.push(...Wc(t,r==null?void 0:r._id))}),s},db=()=>{const[t,e]=S.useAtom(Vc),{t:n}=F.useTranslation(),[s]=te(),r=()=>e({isOpen:!1,blockId:null}),o=Hc(),a=g.useMemo(()=>{if(!t.blockId)return[];const l=u.find(s,{_id:t.blockId});return l==null||delete l._parent,[l,...Wc(s,l==null?void 0:l._id)]},[t.blockId,s]);return i.jsx(On,{open:t.isOpen,onOpenChange:l=>!l&&r(),children:i.jsxs(ln,{className:"p-4 sm:max-w-[450px]",children:[i.jsx(Fn,{className:"pb-2",children:i.jsx(cn,{children:n("Save to Library")})}),o&&!u.isEmpty(t.blockId)&&i.jsx(o,{blockId:t.blockId,blocks:a,close:r})]})})},ub=()=>{const t=Z(),{t:e}=F.useTranslation(),[,n]=S.useAtom(Vc),s=Hc(),r=()=>{t&&n({isOpen:!0,blockId:t._id})};return s?i.jsxs(de,{className:"flex items-center gap-x-4 text-xs",onClick:r,children:[i.jsx(v.CheckIcon,{className:"h-4 w-4"})," ",t!=null&&t._libBlockId?e("Update library block"):e("Save to library")]}):null},pb=()=>{const{t}=F.useTranslation(),e=Z(),n=tt(),s=()=>{n([e._id],{_libBlockId:null})};return i.jsxs(de,{onClick:s,className:"flex items-center gap-x-4 text-xs",children:[i.jsx(v.LinkBreak2Icon,{className:"h-4 w-4"})," ",t("Unlink from library")]})},Zi=()=>{const{t}=F.useTranslation(),[e]=K();return O("flags.exportCode",!1)?i.jsxs(de,{className:"flex items-center gap-x-4 text-xs",onClick:()=>re.publish(Y.OPEN_EXPORT_CODE,e),children:[i.jsx(v.DownloadIcon,{})," ",t("Export")]}):null},Qi=({isFromBody:t=!1})=>{const[e]=te(),[n]=K(),{pasteBlocks:s}=mo(),[,r,o]=Za(),{t:a}=F.useTranslation(),l=Z(),c=O("flags.copyPaste",!0),d=g.useCallback(()=>{var m;const f=(t?(m=e==null?void 0:e.filter(h=>!(h!=null&&h._parent)))==null?void 0:m.map(h=>h==null?void 0:h._id):n).map(h=>{const b=e.find(x=>x._id===h);return{id:h,data:b}});o(f.map(h=>h.id))?me.toast.warning("Partial blocks detected. Clone partial blocks?",{cancel:{label:a("No"),onClick:()=>{r(f.map(h=>h.id)),me.toast.dismiss()}},action:{label:a("Yes"),onClick:()=>{r(f.map(h=>h.id),!0),me.toast.dismiss()}},position:"top-center"}):r(f.map(h=>h.id))},[n,e,r,o]);return i.jsxs(i.Fragment,{children:[c&&i.jsxs(de,{disabled:!Vr(l==null?void 0:l._type),onClick:d,className:"flex items-center gap-x-4 text-xs",children:[i.jsx(v.CopyIcon,{})," ",a("Copy")]}),c&&i.jsxs(de,{className:"flex items-center gap-x-4 text-xs",onClick:()=>{s(n)},children:[i.jsx(v.CardStackIcon,{})," ",a("Paste")]})]})},fb=()=>{const[t]=K(),[,e]=Ms(),{t:n}=F.useTranslation(),s=O("flags.copyPaste",!0);return i.jsx(i.Fragment,{children:s&&i.jsxs(de,{className:"flex items-center gap-x-4 text-xs",onClick:()=>e(t),children:[i.jsx(v.ScissorsIcon,{})," ",n("Cut")]})})},hb=()=>{const[t]=K(),e=Is(),n=Z(),{t:s}=F.useTranslation();return i.jsxs(de,{disabled:!Wr(n==null?void 0:n._type),className:"flex items-center gap-x-4 text-xs",onClick:()=>e(t),children:[i.jsx(v.TrashIcon,{})," ",s("Remove")]})},mb=({node:t})=>{const{t:e}=F.useTranslation();return i.jsxs(de,{onClick:n=>{n.stopPropagation(),t.edit(),t.deselect()},className:"flex items-center gap-x-4 text-xs",children:[i.jsx(v.Pencil2Icon,{className:"h-4 w-4"})," ",e("Rename")]})},gb=({node:t})=>{const{t:e}=F.useTranslation(),[n]=K(),s=fo(),r=Z(),{hasPermission:o}=qe(),{librarySite:a}=O("flags",{librarySite:!1}),l=Ye(),c=g.useCallback(()=>{s(n)},[n,s]),d=g.useMemo(()=>u.has(r,"_libBlockId")&&!u.isEmpty(r._libBlockId),[r==null?void 0:r._libBlockId]);return t==="BODY"?i.jsx(Ue,{side:"bottom",className:"border-border text-xs",children:o(ne.ADD_BLOCK)&&i.jsxs(i.Fragment,{children:[i.jsxs(de,{disabled:!1,className:"flex items-center gap-x-4 text-xs",onClick:()=>re.publish(Y.OPEN_ADD_BLOCK,r),children:[i.jsx(v.PlusIcon,{className:"h-3.5 w-3.5"})," ",e("Add block")]}),o(ne.ADD_BLOCK)&&i.jsx(Qi,{isFromBody:!0}),i.jsx(Zi,{}),i.jsx(de,{disabled:!1,onClick:p=>p.preventDefault(),className:"flex items-center gap-x-4 text-xs",children:i.jsx($c,{children:i.jsxs("div",{className:"flex items-center gap-x-4 text-xs",children:[i.jsx(v.EraserIcon,{})," ",e("Clear canvas")]})})})]})}):i.jsxs(Ue,{side:"bottom",className:"border-border text-xs",children:[o(ne.ADD_BLOCK)&&i.jsxs(i.Fragment,{children:[!l&&i.jsxs(de,{disabled:!ls(r==null?void 0:r._type),className:"flex items-center gap-x-4 text-xs",onClick:()=>re.publish(Y.OPEN_ADD_BLOCK,r),children:[i.jsx(v.PlusIcon,{className:"h-3.5 w-3.5"})," ",e("Add block")]}),i.jsxs(de,{disabled:!Vr(r==null?void 0:r._type),className:"flex items-center gap-x-4 text-xs",onClick:c,children:[i.jsx(v.CardStackPlusIcon,{})," ",e("Duplicate")]})]}),i.jsx(mb,{node:t}),o(ne.MOVE_BLOCK)&&i.jsx(fb,{}),o(ne.ADD_BLOCK)&&i.jsx(Qi,{}),d&&a&&i.jsx(pb,{}),o(ne.CREATE_LIBRARY_BLOCK)&&a&&i.jsx(ub,{}),i.jsx(Zi,{}),o(ne.DELETE_BLOCK)&&i.jsx(hb,{})]})},Uc=({children:t,id:e,node:n})=>{const[,s]=K();return i.jsx(i.Fragment,{children:i.jsxs(Qe,{onOpenChange:r=>{r&&s([e])},children:[i.jsx(et,{children:t}),i.jsx(gb,{node:n})]})})},ne={ADD_BLOCK:"add_block",DELETE_BLOCK:"delete_block",EDIT_BLOCK:"edit_block",MOVE_BLOCK:"move_block",EDIT_THEME:"edit_theme",SAVE_PAGE:"save_page",EDIT_STYLES:"edit_styles",IMPORT_HTML:"import_html",CREATE_LIBRARY_BLOCK:"create_library_block",CREATE_LIBRARY_GROUP:"create_library_group",EDIT_LIBRARY_BLOCK:"edit_library_block",DELETE_LIBRARY_BLOCK:"delete_library_block"};Object.values(ne);const Gc=()=>{const[t]=S.useAtom(tn),[e]=S.useAtom(Gr),[n]=S.useAtom(qr),[s]=S.useAtom(Kr),[r]=S.useAtom(ma),[o]=S.useAtom(ga),[a]=S.useAtom(xa);return{errors:t,isValid:e,hasErrors:n,hasWarnings:s,errorCount:r,warningCount:o,errorsByBlock:a,getBlockErrors:l=>a[l]||[],getErrorsBySeverity:l=>t.filter(c=>c.severity===l),getErrorMessages:()=>t.map(l=>l.message),getErrorMessagesBySeverity:l=>t.filter(c=>c.severity===l).map(c=>c.message),getAllErrorMessages:()=>({errors:t.filter(l=>l.severity==="error").map(l=>l.message),warnings:t.filter(l=>l.severity==="warning").map(l=>l.message)})}},xb=({node:t})=>{var e,n;return i.jsx("input",{autoFocus:!0,className:be("ml-2 !h-4 w-full rounded-sm border border-border bg-background px-1 text-[11px] leading-tight outline-none",t.isSelected?"text-black dark:text-white":""),type:"text",defaultValue:((e=t.data)==null?void 0:e._name)||((n=t.data)==null?void 0:n._type),onFocus:s=>s.currentTarget.select(),onBlur:s=>t.submit(s.currentTarget.value),onKeyDown:s=>{s.key==="Enter"&&t.submit(s.currentTarget.value)}})},bb=S.atom(null),hr=t=>{var e;return t!=null&&t._name?t._name:(t==null?void 0:t._type)==="Box"&&(t!=null&&t.tag)&&(t==null?void 0:t.tag)!=="div"?u.startCase(t.tag):((e=t==null?void 0:t._type)==null?void 0:e.split("/").pop())||""},yb=(t,e)=>t.length>e?t.substring(0,e)+"...":t,vb=g.memo(({node:t,style:e,dragHandle:n})=>{var Ae;const{t:s}=F.useTranslation(),r=tt(),[o]=S.useAtom(Rs),{hasPermission:a}=qe();let l=null;const c=t.children.length>0,{highlightBlock:d,clearHighlight:p}=nt(),f=Ye(),{id:m,data:h,isSelected:b,willReceiveDrop:x,isDragging:y,isEditing:k,handleClick:w}=t,E=Gc(),A=g.useMemo(()=>E.getBlockErrors(m),[E,m]),_=u.get(h,"_show",!0),I=W=>{W.stopPropagation(),_&&t.toggle()},j=W=>{W.isInternal&&(l=W.isOpen,W.isOpen&&W.close())},N=W=>{W.isInternal&&l!==null&&(l?W.open():W.close(),l=null)},[C,T]=S.useAtom(bb),R=()=>{var W;B(),t.parent.isSelected||T((W=t==null?void 0:t.parent)==null?void 0:W.id)},B=()=>{T(null)},U=W=>{B(),W.stopPropagation(),!t.isOpen&&_&&t.toggle(),w(W)};g.useEffect(()=>{const W=setTimeout(()=>{x&&!t.isOpen&&!y&&_&&t.toggle()},500);return()=>clearTimeout(W)},[x,t,y]);const z=(W,Me)=>{const pt=o.contentDocument||o.contentWindow.document,wt=pt.querySelector(`[data-block-id=${W}]`);wt&&wt.setAttribute("data-drop",Me);const Wt=wt.getBoundingClientRect(),ft=o.getBoundingClientRect();Wt.top>=ft.top&&Wt.left>=ft.left&&Wt.bottom<=ft.bottom&&Wt.right<=ft.right||(pt.documentElement.scrollTop=wt.offsetTop-ft.top)},G=W=>{B();const Me=u.get(t,"parent.id");Me!=="__REACT_ARBORIST_INTERNAL_ROOT__"?re.publish(Y.OPEN_ADD_BLOCK,{_id:Me,position:W}):re.publish(Y.OPEN_ADD_BLOCK,{position:W})};if(m===$.ROOT_TEMP_KEY)return i.jsxs("div",{className:"group relative mt-2 w-full cursor-pointer",children:[i.jsx("br",{}),a(ne.ADD_BLOCK)&&i.jsx("div",{role:"button",onClick:()=>G(-1),className:"h-1 rounded bg-primary opacity-0 duration-200 group-hover:opacity-100",children:i.jsxs("div",{className:"absolute left-1/2 top-1/2 flex -translate-x-1/2 -translate-y-1/2 transform items-center gap-x-1 rounded-full bg-primary px-3 py-1 text-[9px] leading-tight text-white hover:bg-primary",children:[i.jsx(v.PlusIcon,{className:"w-2.4 h-2.5 stroke-[5] text-white"})," ",s("Add block")]})}),i.jsx("br",{})]});const{librarySite:he}=O("flags",{librarySite:!1}),ae=g.useMemo(()=>he&&u.has(h,"_libBlockId")&&!u.isEmpty(h._libBlockId)&&(a(ne.CREATE_LIBRARY_BLOCK)||a(ne.EDIT_LIBRARY_BLOCK)),[h,a,he]),le=g.useMemo(()=>(h==null?void 0:h._type)==="PartialBlock"||(h==null?void 0:h._type)==="GlobalBlock",[h]);return i.jsx("div",{className:"w-full",children:i.jsxs("div",{onMouseEnter:()=>d(m),onMouseLeave:()=>p(),onClick:U,style:e,"data-node-id":m,ref:n,onDragStart:()=>j(t),onDragEnd:()=>N(t),onDragOver:W=>{W.preventDefault(),z(m,"yes")},onDragLeave:W=>{W.preventDefault(),z(m,"no")},onDrop:W=>{W.preventDefault(),z(m,"no")},children:[a(ne.ADD_BLOCK)&&!f&&(t==null?void 0:t.rowIndex)>0&&(t.parent.isOpen&&ls(u.get(t,"parent.data._type"))||((Ae=t==null?void 0:t.parent)==null?void 0:Ae.id)==="__REACT_ARBORIST_INTERNAL_ROOT__")&&i.jsx("div",{className:"group relative ml-5 h-full w-full cursor-pointer",children:i.jsx("div",{onClick:W=>{W.stopPropagation(),G(t.childIndex)},onMouseEnter:R,onMouseLeave:B,className:"absolute -top-0.5 h-0.5 w-[90%] rounded bg-primary/80 opacity-0 delay-200 duration-200 group-hover:opacity-100",children:i.jsx("div",{className:"absolute left-1/2 top-1/2 flex h-4 w-4 -translate-x-1/2 -translate-y-1/2 transform items-center justify-center rounded-full bg-primary/80 p-1 outline outline-2 outline-white hover:bg-primary/80",children:i.jsx(v.PlusIcon,{className:"h-2 w-2 stroke-[2] text-white"})})})}),i.jsxs("div",{className:be("group flex w-full cursor-pointer items-center justify-between space-x-px !rounded p-1 py-0 outline-none",b?"bg-primary/20":"hover:bg-primary/10",x&&Ze(h._type,"Icon")?"bg-green-200":"",(t==null?void 0:t.id)===C?"bg-primary/10":"",y&&"opacity-20",_?"":"line-through opacity-50",ae&&b&&"bg-primary/20 text-primary"),children:[i.jsxs("div",{className:"flex items-center",children:[i.jsx("div",{className:`flex h-4 w-4 rotate-0 transform cursor-pointer items-center justify-center transition-transform duration-100 ${t.isOpen?"rotate-90":""}`,children:c&&i.jsx("button",{onClick:I,type:"button",children:i.jsx(v.ChevronRightIcon,{className:"h-3 w-3"})})}),i.jsxs("div",{className:be("leading-1 flex items-center",ae&&"text-orange-600/90",ae&&b&&"text-orange-800",le&&"text-purple-600/90",le&&b&&"text-purple-800"),children:[A.length>0?i.jsx("div",{className:"text-red-500",children:i.jsx(v.ExclamationTriangleIcon,{className:"h-3 w-3"})}):i.jsx(ni,{type:h==null?void 0:h._type}),k?i.jsx(xb,{node:t}):i.jsx("div",{className:"ml-1.5 flex items-center gap-x-1 truncate text-[13px]",onDoubleClick:W=>{W.stopPropagation(),t.edit(),t.deselect()},children:i.jsx("span",{title:hr(h).length>17?hr(h):"",children:yb(hr(h),17)})})]})]}),i.jsxs("div",{className:"invisible flex items-center space-x-1.5 pr-px group-hover:visible",children:[ls(h==null?void 0:h._type)&&_&&a(ne.ADD_BLOCK)?i.jsxs(pe,{children:[i.jsx(fe,{onClick:()=>re.publish(Y.OPEN_ADD_BLOCK,{_id:m}),className:"cursor-pointer rounded bg-transparent p-px hover:bg-primary/10",asChild:!0,children:i.jsx(v.PlusIcon,{className:"h-4 w-4"})}),i.jsx(ue,{className:"isolate z-[9999]",side:"bottom",children:s("Add block inside")})]}):null,i.jsxs(pe,{children:[i.jsx(fe,{onClick:W=>{W.stopPropagation(),r([m],{_show:!_}),t.isOpen&&t.toggle()},className:"cursor-pointer rounded bg-transparent p-0.5 hover:bg-primary/10",asChild:!0,children:_?i.jsx(v.EyeClosedIcon,{className:"h-4 w-4"}):i.jsx(v.EyeOpenIcon,{className:"h-4 w-4"})}),i.jsx(ue,{className:"isolate z-[9999] text-xs",side:"bottom",children:s(_?"Hide the block from page":"Show the block on page")})]}),i.jsx(Uc,{node:t,id:m,children:i.jsx("div",{className:"cursor-pointer rounded bg-transparent p-px hover:bg-primary/10",children:i.jsx(v.DotsVerticalIcon,{className:"h-3 w-3"})})})]})]})]})})}),kb=({parentContext:t,setParentContext:e})=>{const{t:n}=F.useTranslation(),{canPaste:s,pasteBlocks:r}=mo(),o=O("flags.copyPaste",!0);return g.useEffect(()=>{s("root")||e(null)},[s("root")]),!t||!s("root")||!o?null:i.jsx("div",{className:"absolute inset-0",children:i.jsxs(Qe,{open:!0,onOpenChange:()=>e(null),children:[i.jsx(et,{className:"hidden"}),i.jsx(Ue,{className:"absolute w-28 p-1 text-xs",style:{top:t.y,left:t.x},children:i.jsxs(de,{className:"flex items-center gap-x-4 text-xs",onClick:()=>{r("root"),e(null)},children:[i.jsx(v.CardStackIcon,{})," ",n("Paste")]})})]})})},wb=()=>{const[t]=te();return(e,n)=>{var o;const s=(o=u.find(t,{_id:n}))==null?void 0:o._type,r=u.first(e.map(a=>{var l;return(l=u.find(t,{_id:a}))==null?void 0:l._type}));return Ze(s,r)}},qc=()=>{const[t]=S.useAtom(fa),[e,n]=K(),[s]=Ms(),r=tt(),[,o]=Ee(),{moveBlocks:a}=Ne(),l=wb(),c=g.useRef(null),[,d]=S.useAtom(oo),{t:p}=F.useTranslation(),[f,m]=g.useState(null),h=()=>{n([]),o([])},b=g.useMemo(()=>{const j=(C,T)=>C.filter(R=>!T.includes(R._id)).map(R=>({...R,children:R.children?j(R.children,T):[]}));return[...j(t,s),{_type:$.ROOT_TEMP_KEY,_id:$.ROOT_TEMP_KEY,children:[]}]},[t,s]),x=({id:j,name:N,node:C})=>{r([j],{_name:N},C.data._name)},y=({dragIds:j,parentId:N,index:C})=>{l(j,N)&&a(j,N,C)},k=j=>{if(j.length===0)return;const N=j[0]?j[0].id:"";o([]),n([N])},w=j=>{var T;j.preventDefault(),f&&m(null);const N=j.target,C=N.getAttribute("data-node-id")||((T=N.closest("[data-node-id]"))==null?void 0:T.getAttribute("data-node-id"));C?(o([]),n([C])):(o([]),n([]),m({x:j.clientX,y:j.clientY}))},E=ke.useDebouncedCallback(({parentNode:j,dragNodes:N})=>{var C;return(j==null?void 0:j.data._type)===$.ROOT_TEMP_KEY||!Ze(j==null?void 0:j.data._type,(C=N[0])==null?void 0:C.data._type)},[],300),A=(j,N)=>{if(!j)return!0;const C={isLeaf:!N.isInternal,isClosed:!N.isOpen,isOpen:N.isOpen};try{let T=j;return Object.keys(C).forEach(R=>{const B=new RegExp(`\\b${R}\\b`,"g");T=T.replace(B,C[R])}),new Function(`return ${T}`)()}catch{return console.warn("Invalid condition expression:",j),!1}},_=j=>{if(!c.current)return;const N=c.current,C=N.selectedNodes[0];if(!C)return;n[C.id],o([]);const T=!C.isInternal,R=!C.isOpen,B=C.isOpen,U=eb.find(z=>z.key===j.key&&(!z.when||A(z.when,C)));if(U)switch(j.preventDefault(),U.command){case"selectNext":sb(N);break;case"selectPrev":rb(N);break;case"selectParent":ob(N,T||R);break;case"close":ab(N,B);break;case"open":ib(N,R);break;case"selectFirst":tb(N);break;case"selectLast":nb(N);break}};g.useEffect(()=>{const j=()=>{c.current&&d(c.current)};j();const N=new MutationObserver(j);return N.observe(document.body,{childList:!0,subtree:!0}),()=>N.disconnect()},[d]);const{hasPermission:I}=qe();return u.isEmpty(t)?i.jsx("div",{children:i.jsx("div",{className:"mt-10 flex h-full w-full items-center justify-center p-8",children:i.jsxs("div",{className:"flex flex-col items-center space-y-6 text-center",children:[i.jsx("div",{className:"rounded-full bg-muted p-6",children:i.jsx(v.StackIcon,{className:"h-12 w-12 text-muted-foreground"})}),i.jsxs("div",{className:"space-y-2",children:[i.jsx("h3",{className:"text-lg font-semibold text-foreground",children:p("This page is empty")}),i.jsx("p",{className:"max-w-sm text-sm text-muted-foreground",children:p("Get started by adding your first block to begin building your page")})]}),I(ne.ADD_BLOCK)&&i.jsxs(q,{onClick:()=>re.publish(Y.OPEN_ADD_BLOCK),className:"bg-primary shadow-sm hover:bg-primary/90",size:"sm",children:[i.jsx(v.PlusIcon,{className:"h-4 w-4"}),p("Add Block")]})]})})}):i.jsxs(i.Fragment,{children:[i.jsx("div",{className:ve.cn("flex h-full select-none flex-col space-y-1"),onClick:()=>h(),children:i.jsxs("div",{id:"outline-view ",className:"no-scrollbar h-full overflow-y-auto text-sm",onKeyDown:j=>{c.current.isEditing||_(j)},children:[i.jsxs("div",{className:"mb-2 flex items-center justify-end gap-x-1 pb-2 text-sm text-muted-foreground",children:[i.jsxs(pe,{children:[i.jsx(fe,{asChild:!0,children:i.jsx(q,{className:"h-fit p-1",onClick:()=>{var j;return(j=c==null?void 0:c.current)==null?void 0:j.openAll()},variant:"ghost",size:"sm",children:i.jsx(v.DoubleArrowDownIcon,{className:"h-2 w-2"})})}),i.jsx(ue,{className:"isolate z-[9999]",children:p("Expand all")})]}),i.jsxs(pe,{children:[i.jsx(fe,{asChild:!0,children:i.jsx(q,{className:"h-fit p-1",onClick:()=>{var j;return(j=c==null?void 0:c.current)==null?void 0:j.closeAll()},variant:"ghost",size:"sm",children:i.jsx(v.DoubleArrowUpIcon,{className:"h-2 w-2"})})}),i.jsx(ue,{className:"isolate z-[9999]",children:p("Collapse all")})]})]}),i.jsx("div",{className:"group relative z-30 ml-5 w-full cursor-pointer",children:i.jsx("div",{onClick:()=>re.publish(Y.OPEN_ADD_BLOCK,{position:0}),className:"h-1 w-[90%] rounded bg-primary opacity-0 duration-200 group-hover:opacity-100",children:i.jsx("div",{className:"absolute left-[45%] top-1/2 flex h-4 w-4 -translate-x-1/2 -translate-y-1/2 transform items-center justify-center rounded-full bg-primary p-1 outline outline-2 outline-white hover:bg-primary",children:i.jsx(v.PlusIcon,{className:"h-3 w-3 stroke-[3] text-white"})})})}),i.jsx("div",{children:i.jsx("div",{role:"treeitem","aria-level":0,"aria-selected":!0,"aria-expanded":!1,onClick:()=>n([]),className:"flex h-full items-center border-b border-transparent",children:i.jsxs("div",{className:ve.cn("group flex w-full cursor-pointer items-center justify-between space-x-px !rounded p-1 py-0 outline-none",e.length===0?"bg-primary/20":""),children:[i.jsxs("div",{className:"leading-1 flex items-center",children:[i.jsx(v.CardStackIcon,{className:"h-3 w-3 flex-shrink-0 rotate-180"}),i.jsx("div",{className:"ml-1.5 flex items-center gap-x-1 truncate text-[13px]",children:"Body"})]}),i.jsx(Uc,{node:"BODY",id:"BODY",children:i.jsx("div",{className:"hidden cursor-pointer rounded bg-transparent p-px hover:bg-primary/10 group-hover:block",children:i.jsx(v.DotsVerticalIcon,{className:"h-3 w-3"})})})]})})}),i.jsx(Jd.Tree,{ref:c,height:window.innerHeight-160,className:"no-scrollbar !h-full max-w-full space-y-1 !overflow-y-auto !overflow-x-hidden",rowClassName:"flex items-center h-full border-b border-transparent",selection:e[0]||"",onRename:x,openByDefault:!1,onMove:y,data:[...b],renderCursor:Jx,onSelect:k,childrenAccessor:j=>j.children,width:"100%",rowHeight:25,renderDragPreview:Qx,indent:10,onContextMenu:w,disableDrop:E,idAccessor:"_id",children:vb})]})}),i.jsx(db,{}),i.jsx(kb,{parentContext:f,setParentContext:m})]})},Pt=M.forwardRef(({className:t,orientation:e="horizontal",decorative:n=!0,...s},r)=>i.jsx(ca.Root,{ref:r,decorative:n,orientation:e,className:L("shrink-0 bg-border",e==="horizontal"?"h-[1px] w-full":"h-full w-[1px]",t),...s}));Pt.displayName=ca.Root.displayName;const dn=M.forwardRef(({className:t,thumbClassName:e,...n},s)=>i.jsx(br.Root,{className:L("peer inline-flex h-5 w-9 shrink-0 cursor-pointer items-center rounded-full border-2 border-transparent shadow-sm transition-colors focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2 focus-visible:ring-offset-background disabled:cursor-not-allowed disabled:opacity-50 data-[state=checked]:bg-primary data-[state=unchecked]:bg-input",t),...n,ref:s,children:i.jsx(br.Thumb,{className:L("pointer-events-none block h-4 w-4 rounded-full bg-background shadow-lg ring-0 transition-transform",e,"data-[state=checked]:translate-x-3 data-[state=unchecked]:translate-x-0")})}));dn.displayName=br.Root.displayName;const Kc=M.forwardRef(({className:t,...e},n)=>i.jsxs(fn.Root,{ref:n,className:L("relative flex w-full touch-none select-none items-center",t),...e,children:[i.jsx(fn.Track,{className:"relative h-1.5 w-full grow overflow-hidden rounded-full bg-neutral-300",children:i.jsx(fn.Range,{className:"absolute h-full bg-neutral-900"})}),i.jsx(fn.Thumb,{className:"block h-4 w-4 rounded-full border border-neutral-900 bg-neutral-900 shadow transition-colors focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-neutral-900 disabled:pointer-events-none disabled:opacity-50"})]}));Kc.displayName=fn.Root.displayName;const Cb=({value:t,onChange:e,disabled:n})=>{const[s,r]=g.useState(t),o=ke.useThrottledCallback(e,[t],200,!0);return i.jsx(Kc,{min:0,step:1,max:50,disabled:n,value:[Number(s.replace("px",""))],onValueChange:a=>{r(a[0].toString()+"px"),o(a[0].toString())},className:"flex-1 cursor-pointer"})},jb=({value:t,onChange:e})=>{const n=u.debounce(s=>e(s),200);return i.jsx("div",{className:"relative flex h-6 w-6 cursor-pointer rounded-lg border border-border",style:{backgroundColor:t},children:i.jsx("input",{type:"color",value:t.startsWith("#")?t:"#000000",onChange:s=>{const r=s.target.value;/^#[0-9A-F]{6}$/i.test(r)&&n(r)},className:"absolute inset-0 h-full w-full cursor-pointer rounded-lg border-0 opacity-0"})})},Sb=({label:t,value:e,onChange:n})=>{const s=aa.useRegisteredFonts(),{t:r}=F.useTranslation();return g.useEffect(()=>{s.some(o=>o.family===e)||n(s[0].family)},[e,n]),i.jsxs("div",{className:"space-y-0.5",children:[i.jsx(ut,{className:"mb-1 block text-xs text-gray-600",children:r(u.startCase(t))}),i.jsxs(Gs,{value:e,onValueChange:n,children:[i.jsx(Wn,{className:"h-8 w-full text-xs text-black",children:i.jsx(ei,{placeholder:r("Select font")})}),i.jsx(Un,{children:s.map(o=>i.jsx(Gn,{value:o.family,children:o.family},o.family))})]})]})},Nb={fontFamily:{heading:"Poppins",body:"Poppins"},borderRadius:"6px",colors:{background:["#ffffff","#0a0a0a"],foreground:["#0a0a0a","#fafafa"],primary:["#171717","#e5e5e5"],"primary-foreground":["#fafafa","#171717"],secondary:["#f5f5f5","#262626"],"secondary-foreground":["#171717","#fafafa"],muted:["#f5f5f5","#262626"],"muted-foreground":["#737373","#a1a1a1"],accent:["#f5f5f5","#404040"],"accent-foreground":["#171717","#fafafa"],destructive:["#e7000b","#ff6467"],"destructive-foreground":["#ffffff","#fafafa"],border:["#e5e5e5","#282828"],input:["#e5e5e5","#343434"],ring:["#a1a1a1","#737373"],card:["#ffffff","#171717"],"card-foreground":["#0a0a0a","#fafafa"],popover:["#ffffff","#262626"],"popover-foreground":["#0a0a0a","#fafafa"]}},Eb={fontFamily:{heading:"Poppins",body:"Poppins"},borderRadius:"4px",colors:{background:["#ffffff","#000000"],foreground:["#0f1419","#e7e9ea"],primary:["#1e9df1","#1c9cf0"],"primary-foreground":["#ffffff","#ffffff"],secondary:["#0f1419","#f0f3f4"],"secondary-foreground":["#ffffff","#0f1419"],muted:["#e5e5e6","#181818"],"muted-foreground":["#0f1419","#72767a"],accent:["#e3ecf6","#061622"],"accent-foreground":["#1e9df1","#1c9cf0"],destructive:["#f4212e","#f4212e"],"destructive-foreground":["#ffffff","#ffffff"],border:["#e1eaef","#242628"],input:["#f7f9fa","#22303c"],ring:["#1da1f2","#1da1f2"],card:["#f7f8f8","#17181c"],"card-foreground":["#0f1419","#d9d9d9"],popover:["#ffffff","#000000"],"popover-foreground":["#0f1419","#e7e9ea"],sidebar:["#f7f8f8","#17181c"],"sidebar-foreground":["#0f1419","#d9d9d9"],"sidebar-primary":["#1e9df1","#1da1f2"],"sidebar-primary-foreground":["#ffffff","#ffffff"],"sidebar-accent":["#e3ecf6","#061622"],"sidebar-accent-foreground":["#1e9df1","#1c9cf0"],"sidebar-border":["#e1e8ed","#38444d"],"sidebar-ring":["#1da1f2","#1da1f2"]}},Ab={fontFamily:{heading:"Geist",body:"Geist"},borderRadius:"4px",colors:{background:["#fdf6e3","#002b36"],foreground:["#073642","#93a1a1"],primary:["#d33682","#d33682"],"primary-foreground":["#ffffff","#ffffff"],secondary:["#2aa198","#2aa198"],"secondary-foreground":["#ffffff","#ffffff"],muted:["#93a1a1","#586e75"],"muted-foreground":["#073642","#93a1a1"],accent:["#cb4b16","#cb4b16"],"accent-foreground":["#ffffff","#ffffff"],destructive:["#dc322f","#dc322f"],"destructive-foreground":["#ffffff","#ffffff"],border:["#839496","#586e75"],input:["#839496","#586e75"],ring:["#d33682","#d33682"],card:["#eee8d5","#073642"],"card-foreground":["#073642","#93a1a1"],popover:["#eee8d5","#073642"],"popover-foreground":["#073642","#93a1a1"]}},_b={fontFamily:{heading:"Poppins",body:"Poppins"},borderRadius:"6px",colors:{background:["#faf9f5","#262624"],foreground:["#3d3929","#c3c0b6"],primary:["#c96442","#d97757"],"primary-foreground":["#ffffff","#ffffff"],secondary:["#e9e6dc","#faf9f5"],"secondary-foreground":["#535146","#30302e"],muted:["#ede9de","#1b1b19"],"muted-foreground":["#83827d","#b7b5a9"],accent:["#e9e6dc","#1a1915"],"accent-foreground":["#28261b","#f5f4ee"],destructive:["#141413","#ef4444"],"destructive-foreground":["#ffffff","#ffffff"],border:["#dad9d4","#3e3e38"],input:["#b4b2a7","#52514a"],ring:["#c96442","#d97757"],card:["#faf9f5","#262624"],"card-foreground":["#141413","#faf9f5"],popover:["#ffffff","#30302e"],"popover-foreground":["#28261b","#e5e5e2"]}},Ib={fontFamily:{heading:"Inter",body:"Inter"},borderRadius:"6px",colors:{background:["#fff9f5","#2a2024"],foreground:["#3d3436","#f2e9e4"],primary:["#ff7e5f","#ff7e5f"],"primary-foreground":["#ffffff","#ffffff"],secondary:["#ffedea","#463a41"],"secondary-foreground":["#b35340","#f2e9e4"],muted:["#fff0eb","#392f35"],"muted-foreground":["#78716c","#d7c6bc"],accent:["#feb47b","#feb47b"],"accent-foreground":["#3d3436","#2a2024"],destructive:["#e63946","#e63946"],"destructive-foreground":["#ffffff","#ffffff"],border:["#ffe0d6","#463a41"],input:["#ffe0d6","#463a41"],ring:["#ff7e5f","#ff7e5f"],card:["#ffffff","#392f35"],"card-foreground":["#3d3436","#f2e9e4"],popover:["#ffffff","#392f35"],"popover-foreground":["#3d3436","#f2e9e4"]}},Tb=g.lazy(()=>Promise.resolve().then(()=>require("./css-import-modal-CyqkXWCO.cjs")).then(t=>({default:t.CssImportModal}))),Yc="chai-builder-previous-theme",Bb=[{shadcn_default:Nb},{twitter_theme:Eb},{solarized_theme:Ab},{claude_theme:_b},{supabase_theme:Ib}],Rb=t=>{if(!(typeof window>"u"))try{localStorage.setItem(Yc,JSON.stringify(t))}catch(e){console.warn("Failed to save previous theme to localStorage:",e)}},Pb=()=>{if(!(typeof window>"u"))try{localStorage.removeItem(Yc)}catch(t){console.warn("Failed to clear previous theme from localStorage:",t)}},Xc=M.memo(({className:t=""})=>{const[e,n]=Dn(),[s,r]=M.useState(""),[o,a]=M.useState(!1),l=O("themePresets",[]),c=O("themePanelComponent",null),{hasPermission:d}=qe(),p=O("flags.importTheme",!0),f=O("flags.darkMode",!0),m=ro();(!l||l.length===0)&&Bb.map(N=>{l.push(N)});const[h,b]=Tn(),x=Bn(),{t:y}=F.useTranslation(),k=M.useCallback(N=>{const C={...h};Rb(C),b(N),m(),me.toast.success("Theme updated",{action:{label:i.jsxs("span",{className:"flex items-center gap-2",children:[i.jsx(v.ResetIcon,{className:"h-4 w-4"})," Undo"]}),onClick:()=>{b(C),Pb(),me.toast.dismiss()}},closeButton:!0,duration:15e3})},[h,b,m]),w=()=>{const N=l.find(C=>Object.keys(C)[0]===s);if(N){const C=Object.values(N)[0];C&&typeof C=="object"&&"fontFamily"in C&&"borderRadius"in C&&"colors"in C?(k(C),r(""),m()):console.error("Invalid preset structure:",C)}else console.error("Preset not found:",s)},E=N=>{k(N),r(""),m()},A=ke.useDebouncedCallback((N,C)=>{b(()=>({...h,fontFamily:{...h.fontFamily,[N.replace(/font-/g,"")]:C}})),m()},[h,m],200),_=M.useCallback(N=>{b(()=>({...h,borderRadius:`${N}px`})),m()},[h,m]),I=ke.useDebouncedCallback((N,C)=>{b(()=>{const T=u.get(h,`colors.${N}`);return e?u.set(T,1,C):u.set(T,0,C),m(),{...h,colors:{...h.colors,[N]:T}}})},[h,m],200),j=N=>i.jsx("div",{className:"grid grid-cols-1",children:Object.entries(N.items).map(([C])=>{const T=u.get(h,`colors.${C}.${e?1:0}`);return T?i.jsxs("div",{id:`theme-${C}`,className:"mt-1 flex items-center gap-x-2",children:[i.jsx(jb,{value:T,onChange:R=>I(C,R)}),i.jsx(ut,{className:"text-xs font-normal leading-tight",children:C.split(/(?=[A-Z])/).join(" ").replace(/-/g," ").split(" ").map(R=>R.charAt(0).toUpperCase()+R.slice(1)).join(" ")+(!C.toLowerCase().includes("foreground")&&!C.toLowerCase().includes("border")&&!C.toLowerCase().includes("input")&&!C.toLowerCase().includes("ring")&&!C.toLowerCase().includes("background")?" Background":"")})]},C):null})});return d("edit_theme")?i.jsxs("div",{className:"relative w-full",children:[i.jsxs("div",{className:ve.cn("no-scrollbar h-full w-full overflow-y-auto",t),children:[l.length>0&&i.jsxs("div",{className:"mx-0 my-2 flex flex-col gap-1 py-2",children:[i.jsxs("div",{className:"flex w-full items-center justify-between",children:[i.jsx(ut,{className:"text-sm",children:y("Presets")}),i.jsx("div",{className:"flex gap-2",children:p&&i.jsxs(q,{className:"px-1",variant:"link",size:"sm",onClick:()=>a(!0),children:[i.jsx(v.UploadIcon,{className:"h-4 w-4"}),y("Import theme")]})})]}),i.jsxs("div",{className:"flex items-center gap-2 px-0",children:[i.jsx("div",{className:"w-[70%]",children:i.jsxs(Gs,{value:s,onValueChange:r,children:[i.jsx(Wn,{className:"h-9 w-full text-sm",children:i.jsx(ei,{placeholder:y("Select preset")})}),i.jsx(Un,{children:Array.isArray(l)&&l.map(N=>{const C=Object.keys(N)[0],T=C.replaceAll("_"," ");return i.jsx(Gn,{value:C,children:u.capitalize(T)},C)})})]})}),i.jsx("div",{className:"w-[25%]",children:i.jsx(q,{className:"w-full text-sm",disabled:!s,onClick:w,children:y("Apply")})})]})]}),i.jsx(Pt,{}),i.jsxs("div",{className:ve.cn("my-2 space-y-3",t),children:[i.jsxs("div",{className:"flex items-center gap-2",children:[i.jsx(v.TextIcon,{className:"h-3 w-3 text-gray-600"}),i.jsx("span",{className:"text-xs font-medium text-gray-700",children:y("Typography")})]}),(x==null?void 0:x.fontFamily)&&i.jsx("div",{className:"space-y-2",children:Object.entries(x.fontFamily).map(([N,C])=>i.jsx(Sb,{label:N,value:h.fontFamily[N.replace(/font-/g,"")]||C[Object.keys(C)[0]],onChange:T=>A(N,T)},N))}),i.jsx(Pt,{}),(x==null?void 0:x.borderRadius)&&i.jsxs("div",{className:"space-y-0.5",children:[i.jsxs("div",{className:"flex items-center justify-between",children:[i.jsxs("div",{className:"flex items-center gap-2",children:[i.jsx(v.CornerTopRightIcon,{className:"h-3 w-3 text-gray-600"}),i.jsx("span",{className:"text-xs font-medium text-gray-700",children:y("Border Radius")})]}),i.jsx(Hs,{variant:"secondary",className:"text-xs",children:h.borderRadius})]}),i.jsx("div",{className:"flex items-center gap-4 py-2",children:i.jsx(Cb,{value:h.borderRadius,onChange:_})})]}),i.jsx(Pt,{}),(x==null?void 0:x.colors)&&i.jsxs("div",{className:"space-y-3",children:[i.jsxs("div",{className:"flex items-center justify-between",children:[i.jsxs("div",{className:"flex items-center gap-2",children:[i.jsx(v.MixerHorizontalIcon,{className:"h-3 w-3 text-gray-600"}),i.jsx("span",{className:"text-xs font-medium text-gray-700",children:y("Colors")})]}),f&&i.jsxs("div",{className:"flex items-center gap-2",children:[i.jsx(v.SunIcon,{className:"h-4 w-4"}),i.jsx(dn,{checked:e,onCheckedChange:N=>n(N),"aria-label":y("Toggle dark mode"),className:"mx-1"}),i.jsx(v.MoonIcon,{className:"h-4 w-4"})]})]}),i.jsx("div",{className:"space-y-2",children:x.colors.map(N=>j(N))})]}),i.jsx(g.Suspense,{fallback:i.jsx("div",{children:y("Loading...")}),children:o&&p&&i.jsx(Tb,{open:o,onOpenChange:a,onImport:E})})]}),i.jsx("br",{}),i.jsx("br",{}),i.jsx("br",{}),i.jsx("br",{})]}),c&&i.jsx("div",{className:"absolute bottom-4 w-full",children:M.createElement(c)})]}):i.jsx("div",{className:"relative w-full",children:i.jsx("div",{className:ve.cn("no-scrollbar h-full w-full overflow-y-auto text-center",t),children:i.jsx("div",{className:"mt-10 h-full items-center justify-center gap-2 text-muted-foreground",children:i.jsx("p",{className:"text-sm",children:y("You don't have permission to edit the theme. Please contact your administrator to get access.")})})})})}),Lb="Core",Mb="Import",Db="Breakpoints",Ob="Clear",Fb="Cancel",$b="Yes",zb="Preview",Hb="Settings",Vb="Style",Wb="Enter SVG code here",Ub="Remove",Gb="Choose",qb="Cut",Kb="Copy",Yb="Paste",Xb="Delete",Jb="classes",Zb="Theme",Qb="Outline",ey="Copied",ty="Stop",ny="Edit",sy="Tag",ry="Value",oy="URL",iy="Images",ay="Library",ly="Blocks",cy="Basic",dy="Media",uy="Advanced",py="Form",fy="Groups",hy="Accordions",my="Buttons",gy="Layouts",xy="FAQ",by="Hero",yy="Features",vy="Footer",ky="Navbar",wy="Icons",Cy="Testimonials",jy="Blog",Sy="Saved",Ny="Unsaved",Ey="Randomize",Ay="Classes",_y="All",Iy="Undo",Ty="Redo",By="Duplicate",Ry="Close",Py="Selected",Ly="Select",My="Attributes",Dy="apply",Oy="presets",Fy="Orientation",$y="Color",zy="Upload",Hy="Apply",Vy="Back",Wy="Insert",Uy="Rename",Gy="Partials",qy="Happy",Ky="Sad",Yy="Retry",Xy="Canvas is empty",Jy="Presets",Zy="No",Qy="Saving",e0={heading_font:"Heading Font",body_font:"Body Font",rounded_corner:"Rounded Corners",primary:"Primary",secondary:"Secondary",background:"Background",text_color:"Text Color",background_dark_mode:"Background (Dark Mode)",text_color_dark_mode:"Text Color (Dark Mode)"},t0={box:"box",tag:"Tag",div:"div",level:"Level",header:"header",footer:"footer",section:"section",article:"article",aside:"aside",main:"main",nav:"navigation",figure:"figure",details:"details",summary:"summary",dialog:"dialog",strike:"strike",caption:"caption",legend:"legend",figcaption:"figure caption",mark:"mark",background_image:"Background Image",label:"Label",default:"default",icon_size:"Icon Size",icon_position:"Icon Position",start:"Start",end:"End",button:"Button",custom_html:"Custom HTML",html_code:"HTML Code",default_snippet:"The HTML snippet goes here...",placeholder:"Enter custom HTML code here",custom_script:"Custom Script",dark_mode:"Dark Mode",divider:"Divider",empty_box:"Empty Box",heading:"Heading",image:"Image",alt:"Alt",width:"Width",height:"Height",video:"Video",span:"Span",content:"Content",icon:"Icon",richtext:"Rich Text",list:"List",list_type:"List Type",listitem:"List Item",link:"Link",list_item:"List Item",none:"None",disc:"Disc",number:"Number",paragraph:"Paragraph",lightbox_link:"Lightbox Link",href:"Link",type:"Type",iframe:"iframe",inline:"inline",ajax:"ajax",autoplay:"Video autoplay",max_width:"Max Width",backdrop_color:"Background Color",gallery_name:"Gallery Name",slot:"Slot",empty_slot:"Empty Slot",text:"Text",video_url:"Video URL",controls:"Show Controls",loop:"Loop",muted:"Muted",checkbox:"Checkbox",required:"Required",checked:"Checked",submit_button:"Submit Button",form:"Form",submit_url:"Submit URL",error_message:"Error Message",success_message:"Success Message",input:"Input",value:"Value",show_label:"Show Label",field_name:"Field Name",radio:"Radio",multiple:"Multiple",options:"Options",select:"Select",multiple_choice:"Multiple Choice",textarea:"Textarea",rows:"Rows"},n0="Add",s0="Save",r0="Screen",o0={"Add block":"Add Block","Add Block":"Add Block","Add blocks":"Add blocks","Add inside":"Add inside","Add before":"Add before","Add after":"Add after","Add block inside":"Add block inside","Add field":"Add field","Enter or paste TailwindCSS HTML snippet":"Enter or paste TailwindCSS HTML snippet","Click to add block to page":"Click to add block to page",Core:Lb,"Custom Blocks":"Custom Blocks","UI Library":"UI Library",Import:Mb,"Use HTML snippets from Tailwind CSS component libraries":"Use HTML snippets from Tailwind CSS component libraries","Tailwind HTML snippet":"Tailwind HTML snippet","Enter your code snippet here":"Enter your code snippet here","Import HTML":"Import HTML","Imported HTML Note":"NOTE: Imported html will be added to the currently selected block. If no block is selected, the html will be added to the page.","Dark Mode":"Dark Mode","This page has no blocks. Add a block by clicking the + button":"This page has no blocks. Add a block by clicking the + button","This page is empty":"This page is empty","Please select a block to edit settings or styles":"Please select a block to edit settings or styles","Please select a block to Ask AI":"Please select a block to ask AI","Please select a styling block":"Please select a styling block","Drop your block here":"Drop your block here","Use setting":"Use setting","Mobile (XS)":"Mobile (XS)","Styles set here are applied to all screen unless edited at higher breakpoint":"Styles set here are applied to all screen unless edited at higher breakpoint","Mobile landscape (SM)":"Mobile landscape (SM)","Styles set here are applied at 640px and up unless edited at higher breakpoint":"Styles set here are applied at 640px and up unless edited at higher breakpoint","Tablet (MD)":"Tablet (MD)","Styles set here are applied at 768px and up":"Styles set here are applied at 768px and up","Tablet Landscape (LG)":"Tablet Landscape (LG)","Styles set here are applied at 1024px and up unless edited at higher breakpoint":"Styles set here are applied at 1024px and up unless edited at higher breakpoint","Desktop (XL)":"Desktop (XL)","Styles set here are applied at 1280px and up unless edited at higher breakpoint":"Styles set here are applied at 1280px and up unless edited at higher breakpoint","Large Desktop (2XL)":"Large Desktop (2XL)","Styles set here are applied at 1536px and up":"Styles set here are applied at 1536px and up",Breakpoints:Db,Clear:Ob,"Clear whole canvas?":"Clear whole canvas?","Are you sure you want to clear the whole canvas?":"Are you sure you want to clear the whole canvas?",Cancel:Fb,Yes:$b,Preview:zb,Settings:Hb,Styling:Vb,SVG_code:Wb,"Paste SVG_code":"Choose icon or paste SVG code","Enter Key":"Enter Key","Data Provider":"Data Provider","Remove Provider Confirmation":"Are you sure you want to remove <span class='text-blue-500'>{name}</span> provider?","Your data provider will be removed from this page and all added data binding will be not visible on blocks.":"Your data provider will be removed from this page and all added data binding will be not visible on blocks.",Remove:Ub,"You have no data providers registered. Please add a data provider to your project.":"You have no data providers registered. Please add a data provider to your project.","Learn more":"Learn more","Add data providers:":"Add data providers:","Select a provider":"Select a provider",Choose:Gb,"Page data providers:":"Page data providers:","View Data":"View Data","Mark as Global":"Mark as Global","Note: Global blocks are single instances. Editing global blocks will be reflected on all pages using these blocks.":"Note: Global blocks are single instances. Editing global blocks will be reflected on all pages using these blocks.","Global blocks are indicated with":"Global blocks are indicated with","Global blocks are available under 'Global' category":"Global blocks are available under 'Global' category","Enter global block name":"Enter global block name","Eg: Header, Footer":"Eg: Header, Footer","{length} blocks selected.":"{length} blocks selected.",Cut:qb,Copy:Kb,Paste:Yb,Delete:Xb,"Clear Selection":"Clear Selection","This is dev mode. Visit":"This is dev mode. Visit","to see page preview":"to see page preview",classes:Jb,Theme:Zb,Outline:Qb,"Not supported":"Not supported","Please use Chrome, Firefox or Safari":"Please use Chrome, Firefox or Safari","Download Complete":"Download complete",Copied:ey,"Enter Classes":"Add classes or design tokens (space-separated)","Ask AI":"Ask AI","Edit with AI":"Edit with AI","Generating... Please wait...":"Generating... Please wait...","Saving... Please wait...":"Saving... Please wait...","Deleting... Please wait...":"Deleting... Please wait...",Stop:ty,"E.g.: This page is about an AI assistant app called Chai Studio. It allows users to create beautiful webpages and edit content with AI":"E.g.: This page is about an AI assistant app called Chai Studio. It allows users to create beautiful webpages and edit content with AI.","Ask AI to edit styles":"Ask AI to edit styles","Ask AI to edit content":"Ask AI to edit content","AI Context":"AI Context","Select Block for AI":"Select a block to edit with AI","Select Block to Edit":"Please select a block to edit",Edit:ny,"Describe this page. E.g.: This page is about...":"Describe this page. E.g.: This page is about...",Tag:sy,Value:ry,"Background Image":"Background Image","Enter image URL":"Enter image URL","Enter URL":"Enter URL",URL:oy,"Replace image":"Replace image","Choose image":"Choose image",Images:iy,Library:ay,Blocks:ly,Basic:cy,Media:dy,Advanced:uy,Form:py,"Choose Icon or SVG":"Choose an icon or enter SVG",Groups:fy,"UI Libraries":"UI Libraries",Accordions:hy,Buttons:my,Layouts:gy,"Choose Library":"Choose library","No Library Found":"No library found.",FAQ:xy,Hero:by,Features:yy,Footer:vy,Navbar:ky,Icons:wy,Testimonials:Cy,Blog:jy,"Remove context":"Remove context","Yes, Delete":"Yes, Delete","AI Context Updated":"AI Context Updated","You can now ask AI to edit your content.":"You can now ask AI to edit your content.",Saved:Sy,Unsaved:Ny,"Saving...":"Saving...","Improve writing":"Improve writing","Replace placeholder content":"Replace placeholder content","Discard current placeholder content and replace with meaningful relevant content.":"Discard current placeholder content and replace with meaningful relevant content.","Fix grammar":"Fix grammar","Fix grammar in all text elements. Ensuring the text is grammatically correct and free of errors.":"Fix grammar in all text elements. Ensuring the text is grammatically correct and free of errors.","Make longer":"Make longer","Make all text elements longer.":"Make all text elements longer.","Make shorter":"Make shorter","Make all text elements shorter.":"Make all text elements shorter.","Add emojis":"Add emojis","Add emojis to text elements if relevant.":"Add emojis to text elements if relevant.",Randomize:Ey,"Randomize all text elements.":"Randomize all text elements.","Edit Block":"Edit Block","AI Assistant":"AI Assistant","Theme Config":{"Heading Font":"Heading Font","Body Font":"Body Font","Rounded Corner":"Rounded Corners",Primary:"Primary",Secondary:"Secondary",Background:"Background","Text Color":"Text Color","Background Dark Mode":"Background (Dark Mode)","Text Color Dark Mode":"Text Color (Dark Mode)","Reset styles":"Reset styles"},"Copy classes to clipboard":"Copy classes to clipboard","Classes copied to clipboard":"Classes copied to clipboard",Classes:Ay,All:_y,"Enter classes separated by space":"Add classes or design tokens (space-separated)","Show hidden blocks":"Show hidden blocks","Expand all":"Expand all","Collapse all":"Collapse all","Choose library":"Choose library","Close Preview":"Close Preview",Error:"Error","Failed to copy template":"Failed to copy template","Total tokens used":"Total tokens used","Updated AI Context":"Updated AI Context","You can now Ask AI to edit your content":"You can now Ask AI to edit your content","Tell about this page eg this page is about":"Tell about this page eg this page is about..","Delete Context":"Delete Context","Keyboard shortcuts":"Keyboard shortcuts",Undo:Iy,Redo:Ty,Duplicate:By,"Deselect blocks":"Deselect blocks","Delete block":"Delete block","Save page":"Save page","Scripts will be only executed in preview and live mode.":"Scripts will be only executed in preview and live mode.","HTML Code Editor |":"HTML Code Editor |",Close:Ry,"Coming soon":"Coming soon",Selected:Py,Select:Ly,"Choose Builder Layout":"Choose Builder Layout","Single side panel":"Single side panel","Suitable for smaller screens. Bigger canvas size.":"Suitable for smaller screens. Bigger canvas size.","Dual side panel":"Dual side panel","Suitable for larger screens. Smaller canvas size.":"Suitable for larger screens. Smaller canvas size.","Dual side panel advanced":"Dual side panel advanced","Suitable for heavy styling & block editing. Setting are always visible.":"Suitable for heavy styling & block editing. Setting are always visible.","Block Settings":"Block Settings","Visibility settings":"Visibility settings","Show on canvas":"Show on canvas",Attributes:My,"Apply Presets":"Apply Presets",apply:Dy,presets:Oy,"Global presets":"Global presets",Orientation:Fy,Color:$y,"Please select an image":"Please select an image","click to upload":"click to upload","SVG, PNG, JPG or GIF (Max. 2mb)":"SVG, PNG, JPG or GIF (Max. 2mb)","Uploading...":"Uploading...",Upload:zy,"Something went wrong":"Something went wrong","Fetching...":"Fetching...","No images found":"No images found","It looks like you haven't uploaded any images yet. Start by clicking the upload button above.":"It looks like you haven't uploaded any images yet. Start by clicking the upload button above.","Open Code Editor":"Open Code Editor","Clear search":"Clear search","No results found for":"No results found for","Search {{pageTypeName}}":"Search {{pageTypeName}}","Goto Page":"Goto Page","Open URL":"Open URL","Compose Email":"Compose Email","Call Phone":"Call Phone","Scroll to element":"Scroll to element","#ElementID":"#ElementID","Enter details":"Enter details","Open in new tab":"Open in new tab",Apply:Hy,Back:Vy,Insert:Wy,Rename:Uy,"Unlink from library":"Unlink from library","Save to Library":"Save to Library","No blocks found in this group":"No blocks found in this group","No blocks found matching":"No blocks found matching","No matching blocks found":"No matching blocks found","Search blocks...":"Search blocks...",Partials:Gy,Happy:qy,Sad:Ky,"Importing...":"Importing...","Failed to load the UI library. Try again":"Failed to load the UI library. Try again",Retry:Yy,"Oops! Something went wrong.":"Oops! Something went wrong.","Please try again.":"Please try again.","No option found.":"No option found.","Clipboard not supported":"Clipboard not supported","Are you sure you want to clear the page?":"Are you sure you want to clear the page?",canvas_empty:Xy,Presets:Jy,"Reset style":"Reset style","Reset styles":"Reset styles","Clear styles":"Clear styles","Open code editor":"Open code editor","Style element":"Style element","Repeater Data":"Repeater Data","Toggle Data Binding":"Toggle Data Binding",No:Zy,Saving:Qy,"Screen sizes":"Screen sizes","Theme Settings":"Theme Settings","Import CSS Theme":"Import CSS Theme","Import theme":"Import theme","Import Theme":"Import Theme","CSS Variables":"CSS Variables","You don't have permission to edit settings or styles":"You don't have permission to edit settings or styles","Please contact your administrator to get access":"Please contact your administrator to get access","flex.heading":"Flex Child","flex.basis":"Basis","flex.order":"Order","flex.flex":"Flex","flex.grow":"Grow","flex.shrink":"Shrink","grid.heading":"Grid Child","grid.col_span":"Col Span","grid.col_start":"Col Start","grid.col_end":"Col End","grid.row_span":"Row Span","grid.row_start":"Row Start","grid.row_end":"Row End","grid.order":"Order","layout.heading":"Layout","layout.width":"Width","layout.height":"Height","layout.margin":"Margin","layout.margin_all":"All","layout.margin_lr":"Left-Right","layout.margin_tb":"Top-Bottom","layout.margin_top":"Top","layout.margin_right":"Right","layout.margin_bottom":"Bottom","layout.margin_left":"Left","layout.padding":"Padding","layout.padding_all":"All","layout.padding_lr":"Left-Right","layout.padding_tb":"Top-Bottom","layout.padding_top":"Top","layout.padding_right":"Right","layout.padding_bottom":"Bottom","layout.padding_left":"Left","layout.space_bt":"Space Bt.","layout.space_lr":"Left-Right","layout.space_tb":"Top-Bottom","size.heading":"Size","size.min_width_height":"Min width & height","size.min_width":"Min Width","size.min_height":"Min Height","size.max_width_height":"Max width & height","size.max_width":"Max Width","size.max_height":"Max Height","size.object_options_aspect_ratio":"Object options & aspect ratio","size.aspect":"Aspect","size.fit":"Fit","size.position":"Position","display.heading":"Display","display.display":"Display","display.flex_options":"Flex options","display.flex_direction":"Direction","display.flex_wrap":"Wrap","display.justify_content":"Justify","display.align_content":"Content","display.align_items":"Items","display.gap":"Gap","display.gap_all":"All","display.gap_lr":"Left-Right","display.gap_tb":"Top-Bottom","display.grid_options":"Grid options","display.grid_columns":"Columns","display.grid_rows":"Rows","display.grid_auto_flow":"Auto Flow","display.grid_auto_cols":"Auto Cols","display.grid_auto_rows":"Auto Rows","display.visibility_opacity":"Visibility & Opacity","display.visibility":"Visibility","display.opacity":"Opacity","position.heading":"Position","position.position":"Position","position.options":"Position options","position.direction":"Direction","position.top":"Top","position.right":"Right","position.bottom":"Bottom","position.left":"Left","position.inset":"Inset","position.all":"All","position.lr":"Left Right","position.tb":"Top Bottom","position.z_index":"Z-Index","position.float_clear":"Float & Clear","position.float":"Float","position.clear":"Clear","position.overflow_overscroll":"Overflow & Overscroll","position.overflow":"Overflow","position.overscroll":"Overscroll","typography.heading":"Typography","typography.font":"Font","typography.size":"Size","typography.height":"Height","typography.weight":"Weight","typography.color":"Color","typography.alignments":"Alignments","typography.align":"Align","typography.valign":"V. Align","typography.spacing_decoration_more":"Spacing, decoration & more","typography.spacing":"Spacing","typography.decoration":"Decoration","typography.thickness":"Thickness","typography.transform":"Transform","typography.whitespace_breaks":"White space & breaks","typography.whitespace":"Whitespace","typography.wordbreak":"Wordbreak","background.heading":"Background","background.bgcolor":"Bg. Color","background.position_size_more":"Position, Size & more","background.attachment":"Attachment","background.clipping":"Clipping","background.origin":"Origin","background.position":"Position","background.repeat":"Repeat","background.size":"Size","background.gradient":"Gradient","background.gradient_colors":"Gradient colors","background.from_color":"From","background.via_color":"Via","background.to_color":"To","border.heading":"Border & Outline","border.width":"Width","border.all":"All","border.lr":"Left Right","border.tb":"Top bottom","border.top":"Top","border.right":"Right","border.bottom":"Bottom","border.left":"Left","border.corners":"Corners","border.top_left":"Top Left","border.top_right":"Top right","border.bottom_right":"Bottom right","border.bottom_left":"Bottom left","border.color":"Color","border.style":"Style","border.divide_options":"Divide options","border.divide_color":"Color","border.divide_style":"Style","border.outline_styling":"Outline styling","border.outline_width":"Width","border.outline_offset":"Offset","border.outline_style":"Style","border.ring_options":"Ring options","border.ring_width":"Width","border.ring_color":"Color","border.ring_offset_width":"Offset","border.ring_offset_color":"Off. color","effect.heading":"Effect & Animation","effect.shadow":"Shadow","effect.color":"Color","effect.cursor":"Cursor","effect.blend_cursor":"Blend & Cursor","effect.mix_blend":"Mix Blend","effect.bg_blend":"Bg. Blend","effect.transform":"Transform","effect.origin":"Origin","effect.scale":"Scale","effect.all":"All","effect.lr":"Left-Right","effect.tb":"Top-Bottom","effect.skew":"Skew","effect.translate":"Translate","effect.rotate":"Rotate","effect.animation":"Animation","effect.transition":"Transition","effect.easing":"Easing","effect.duration":"Duration","effect.delay":"Delay","classes.heading":"Classes",theme_config:e0,web_blocks:t0,"Export Code":"Export Code","Exporting {{count}} blocks":"Exporting {{count}} blocks","Exporting all blocks":"Exporting all blocks","Export code copied!":"Export code copied!","Failed to copy export code":"Failed to copy export code","Export code downloaded successfully!":"Export code downloaded successfully!","Failed to generate export HTML":"Failed to generate export HTML","Enter value":"Enter value","Attribute keys cannot start with @":"Attribute keys cannot start with @","Enter key":"Enter key",Add:n0,Save:s0,Screen:r0};xt.use(F.initReactI18next).init({resources:{en:{translation:o0}},lng:"en",fallbackLng:"en",interpolation:{escapeValue:!1}});function i0(t,e,n){n.push(u.find(t,{_id:e}));const s=u.filter(t,{_parent:e});for(const r of s)n.push(...Jc(r._id,t));return n}const Jc=(t,e)=>{let n=[];return n=u.flattenDeep([...n,...i0(e,t,n)]),n},a0=(t,e,n)=>u.compact(t.map(s=>{const r=["_id","_type","_parent"],o=u.pick(s,r),a=J.getRegisteredChaiBlock(s._type),l={},c=u.get(a,"aiProps",[]);for(const d in s)if(!r.includes(d)&&c.includes(d)){const p=u.get(s,`${d}-${e}`,""),f=u.get(s,d,"");l[d]=u.isString(p)&&p.trim()||f,n&&(l[d]=f)}return u.isEmpty(l)?!1:(u.has(o,"_parent")&&u.isEmpty(o._parent)&&delete o._parent,{...o,...l})})),l0=(t,e,n)=>!e||n!=="content"?t:`${t}. Generate content in ${u.get(Qt,e,e)} language.`,c0=S.atom(!1),Zc=()=>{const[t,e]=S.useAtom(c0),[n,s]=g.useState(null),r=O("askAiCallBack",null),o=Ca(),a=Eu(),[l]=te(),{selectedLang:c,fallbackLang:d}=Le(),p=c.length?c:d,f=(m,h)=>{const b=u.cloneDeep(h.find(x=>x._id===m));for(const x in b){const y=b[x];if(typeof y=="string"&&u.startsWith(y,$.STYLES_KEY)){const{baseClasses:k,classes:w}=$.getSplitChaiClasses(y);b[x]=u.compact(u.flattenDeep([k,w])).join(" ")}else x!=="_id"&&delete b[x]}return b};return{askAi:g.useCallback(async(m,h,b,x)=>{if(r){e(!0),s(null);try{const y=c===d?"":c,k=b.toLowerCase().includes("translate the content"),w=m==="content"?a0(u.cloneDeep(Jc(h,l)),c,k):[f(h,l)],E=await r(m,l0(b,p,m),w,y),{blocks:A,error:_}=E;if(_){s(_);return}if(m==="styles"){const I=A.map(j=>{for(const N in j)N!=="_id"&&(j[N]=`${$.STYLES_KEY},${j[N]}`);return j});a(I)}else o(A);x&&x(E)}catch(y){s(y)}finally{e(!1),x&&x()}}},[r,e,c,d,l,p,a,o]),loading:t,error:n}};function d0({onClick:t}){const{loading:e}=Zc(),{t:n}=F.useTranslation(),{selectedLang:s,fallbackLang:r}=Le(),a=[...[{name:n("Improve writing"),icon:v.Pencil2Icon,prompt:n("Improving writing in all text elements. Replacing placeholder content with meaningful relevant content.")},{name:n("Replace placeholder content"),icon:v.LoopIcon,prompt:n("Discard current placeholder content and replace with meaningful relevant content.")},{name:n("Fix grammar"),icon:v.CheckIcon,prompt:n("Fix grammar in all text elements. Ensuring the text is grammatically correct and free of errors.")},{name:n("Make longer"),icon:v.ArrowUpIcon,prompt:n("Make all text elements longer.")},{name:n("Make shorter"),icon:v.ArrowDownIcon,prompt:n("Make all text elements shorter.")},{name:n("Add emojis"),icon:v.FaceIcon,prompt:n("Add emojis to text elements if relevant.")},{name:n("Randomize"),icon:v.ShuffleIcon,prompt:n("Randomize all text elements.")}]];return s&&s!==r&&a.splice(0,0,{name:n("Translate to {{lang}}",{lang:u.get(Qt,s,s)}),icon:v.ChatBubbleIcon,prompt:n("Translate the content to {{lang}}. Maintain same tone, style and length.",{lang:u.get(Qt,s,s)})}),i.jsx("div",{className:e?"pointer-events-none opacity-50":"",children:i.jsx("ul",{className:"space-y-1",children:a.map(({name:l,icon:c,subMenus:d,prompt:p})=>d?i.jsxs(Oo,{children:[i.jsx(Fo,{asChild:!0,children:i.jsxs("li",{className:"flex cursor-pointer items-center space-x-2 rounded p-1 pl-2 text-sm hover:bg-gray-100 dark:hover:bg-gray-800",children:[i.jsx(c,{className:"h-4 w-4"}),i.jsx("span",{children:l})]},l)}),i.jsx(zs,{side:"right",children:i.jsx("ul",{children:i.jsx("li",{children:n("Happy")})})})]}):i.jsxs("li",{onClick:()=>t(p),className:"flex cursor-pointer items-center space-x-2 rounded p-1 text-xs hover:bg-primary/10 hover:text-primary dark:hover:bg-gray-800",children:[i.jsx(c,{className:"h-3.5 w-3.5"}),i.jsx("span",{children:n(l)})]},l))})})}const Qc=({blockId:t})=>{const{t:e}=F.useTranslation(),{askAi:n,loading:s,error:r}=Zc(),[o,a]=g.useState(""),l=g.useRef(null),c=g.useRef(null),d=Z();g.useEffect(()=>{var f;(f=l.current)==null||f.focus()},[]);const p=()=>{r||a("")};return i.jsx("div",{className:"",children:t?i.jsxs("div",{className:"",children:[i.jsx("label",{className:"text-xs font-medium text-gray-500",children:e("Selected block")}),d&&i.jsxs("div",{className:"flex items-center gap-x-1 rounded border border-primary/20 bg-primary/10 p-1.5 text-xs text-primary",children:[i.jsx(ni,{type:d._type})," ",i.jsx("p",{className:"truncate whitespace-nowrap leading-none",children:d._name||d._type})]}),i.jsx("br",{}),i.jsx("label",{className:"text-xs font-medium text-gray-500",children:e("Quick actions")}),i.jsx("div",{className:"rounded border p-2 text-sm",children:i.jsx(d0,{onClick:f=>{c.current&&clearTimeout(c.current),n("content",t,f,p)}})}),i.jsx("br",{}),i.jsx("label",{className:"text-xs font-medium text-gray-500",children:e("Ask AI")}),i.jsxs("div",{className:"rounded border p-2 text-xs focus-within:border-gray-300",children:[i.jsx(Vn,{ref:l,value:o,onChange:f=>a(f.target.value),placeholder:e("Ask AI to edit content"),className:"w-full resize-none border-none p-0 text-xs shadow-none outline-none",rows:3,onKeyDown:f=>{f.key==="Enter"&&(f.preventDefault(),c.current&&clearTimeout(c.current),n("content",t,o,p))}}),i.jsxs("div",{className:"flex items-center justify-end",children:[s&&i.jsx(q,{variant:"destructive",onClick:()=>stop(),className:"hidden h-4 w-4",size:"icon",children:i.jsx(v.StopIcon,{className:"h-4 w-4"})}),i.jsx(q,{onClick:()=>{c.current&&clearTimeout(c.current),n("content",t,o,p)},variant:"default",className:"h-7 w-7",disabled:s||o.trim().length<1,size:"icon",children:s?i.jsx(v.ReloadIcon,{className:"h-4 w-4 animate-spin"}):i.jsx(v.ArrowTopRightIcon,{className:"h-4 w-4"})})]})]}),i.jsx("div",{className:"max-w-full pt-2",children:r&&i.jsx("p",{className:"break-words rounded border border-red-500 bg-red-100 p-1 text-xs text-red-500",children:r.message})})]}):i.jsx("div",{className:"p-4 text-center",children:i.jsxs("div",{className:"space-y-4 rounded-xl p-4 text-muted-foreground",children:[i.jsx(zr,{className:"mx-auto h-7 w-7 text-muted-foreground"}),i.jsx("h1",{children:e("Please select a block to Ask AI")})]})})})},ed=()=>{const[t]=K();return i.jsx("div",{className:"no-scrollbar mt-2 flex-1 overflow-y-auto",children:i.jsx(Qc,{blockId:u.first(t)})})};function td(){const[t,e]=Dn();return i.jsxs("div",{className:"flex items-center",children:[t?i.jsx(v.MoonIcon,{className:"size-4 shrink-0"}):i.jsx(v.SunIcon,{className:"size-4 shrink-0"}),i.jsx(dn,{id:"dark-mode-switch",checked:t,onCheckedChange:()=>{e(!t)},className:`${t?"bg-violet-600":"bg-violet-300"} relative ml-2 inline-flex h-[20px] w-[32px] shrink-0 cursor-pointer rounded-full border-2 border-transparent transition-colors duration-200 ease-in-out focus:outline-none focus-visible:ring-2 focus-visible:ring-white focus-visible:ring-opacity-75`,children:i.jsx("span",{"aria-hidden":"true",className:`${t?"translate-x-5":"translate-x-0"} pointer-events-none -mt-px inline-block h-[18px] w-[20px] transform rounded-full bg-white shadow-lg ring-0 transition duration-200 ease-in-out`})})]})}const nd=()=>{const{hasUndo:t,hasRedo:e,undo:n,redo:s}=Pn();return i.jsxs("div",{className:"flex items-center",children:[i.jsx(q,{disabled:!t(),size:"sm",onClick:n,className:"rounded-full",variant:"ghost",children:i.jsx(v.ResetIcon,{})}),i.jsx(q,{disabled:!e(),onClick:s,size:"sm",className:"rounded-full",variant:"ghost",children:i.jsx(v.ResetIcon,{className:"rotate-180 scale-y-[-1] transform"})})]})},sd=ie.Root,u0=ie.Trigger,p0=ie.Portal,rd=M.forwardRef(({className:t,...e},n)=>i.jsx(ie.Overlay,{className:L("fixed inset-0 z-50 bg-black/80 data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0",t),...e,ref:n}));rd.displayName=ie.Overlay.displayName;const f0=_n.cva("fixed z-50 gap-4 bg-background p-6 shadow-lg transition ease-in-out data-[state=closed]:duration-300 data-[state=open]:duration-500 data-[state=open]:animate-in data-[state=closed]:animate-out",{variants:{side:{top:"inset-x-0 top-0 border-b data-[state=closed]:slide-out-to-top data-[state=open]:slide-in-from-top",bottom:"inset-x-0 bottom-0 border-t data-[state=closed]:slide-out-to-bottom data-[state=open]:slide-in-from-bottom",left:"inset-y-0 left-0 h-full w-3/4 border-r data-[state=closed]:slide-out-to-left data-[state=open]:slide-in-from-left sm:max-w-sm",right:"inset-y-0 right-0 h-full w-3/4 border-l data-[state=closed]:slide-out-to-right data-[state=open]:slide-in-from-right sm:max-w-sm"}},defaultVariants:{side:"right"}}),li=M.forwardRef(({side:t="right",className:e,children:n,...s},r)=>i.jsxs(p0,{children:[i.jsx(rd,{}),i.jsxs(ie.Content,{ref:r,className:L(f0({side:t}),e),...s,children:[i.jsxs(ie.Close,{className:"absolute right-4 top-4 rounded-sm opacity-70 ring-offset-background transition-opacity hover:opacity-100 focus:outline-none focus:ring-2 focus:ring-ring focus:ring-offset-2 disabled:pointer-events-none data-[state=open]:bg-secondary",children:[i.jsx(v.Cross1Icon,{className:"h-4 w-4"}),i.jsx("span",{className:"sr-only",children:"Close"})]}),n]})]}));li.displayName=ie.Content.displayName;const ci=({className:t,...e})=>i.jsx("div",{className:L("flex flex-col space-y-2 text-center sm:text-left",t),...e});ci.displayName="SheetHeader";const di=M.forwardRef(({className:t,...e},n)=>i.jsx(ie.Title,{ref:n,className:L("text-lg font-semibold text-foreground",t),...e}));di.displayName=ie.Title.displayName;const od=M.forwardRef(({className:t,...e},n)=>i.jsx(ie.Description,{ref:n,className:L("text-sm text-muted-foreground",t),...e}));od.displayName=ie.Description.displayName;const h0=()=>{const[t]=Ql();return i.jsxs("div",{className:"flex w-12 cursor-not-allowed items-center justify-center gap-x-1 space-x-0 font-medium text-gray-400",children:[i.jsx(v.ZoomInIcon,{className:"h-3.5 w-3.5 flex-shrink-0"})," ",i.jsxs("div",{className:"text-xs leading-3",children:[u.round(t,0),"%"]})]})},m0=()=>{const{hasErrors:t,hasWarnings:e,errorCount:n,warningCount:s,errors:r}=Gc(),[,o]=K(),{t:a}=F.useTranslation();if(!t&&!e)return null;const l=()=>t?"text-red-500":e?"text-orange-500":"text-gray-500",c=()=>t?i.jsx(v.ExclamationTriangleIcon,{className:"h-4 w-4"}):e?i.jsx(v.InfoCircledIcon,{className:"h-4 w-4"}):null,d=()=>t&&e?`${n} error${n>1?"s":""}, ${s} warning${s>1?"s":""}`:t?`${n} error${n>1?"s":""}`:e?`${s} warning${s>1?"s":""}`:"";return i.jsxs(Qe,{children:[i.jsx(et,{asChild:!0,children:i.jsxs("div",{className:`ml-2 flex cursor-pointer items-center gap-2 ${l()}`,children:[c(),i.jsx("span",{className:"text-xs font-medium",children:d()})]})}),i.jsx(Ue,{side:"bottom",className:"max-w-xs p-2",align:"end",children:i.jsxs("div",{className:"space-y-2",children:[i.jsx("h4",{className:"text-sm font-semibold",children:a("Invalid structure")}),r.length===0?i.jsx("p",{className:"text-xs",children:a("No validation issues found.")}):i.jsxs("div",{className:"space-y-1",children:[r.slice(0,5).map(p=>i.jsxs("div",{onClick:()=>{p.blockId&&o([p.blockId])},className:`cursor-pointer rounded p-2 text-xs transition-opacity hover:opacity-80 ${p.severity==="error"?"border border-red-200 bg-red-50 text-red-700":"border border-orange-200 bg-orange-50 text-orange-700"}`,children:[i.jsx("div",{className:"font-medium",children:p.severity==="error"?"Error:":"Warning:"}),i.jsx("div",{children:p.message})]},p.id)),r.length>5&&i.jsxs("p",{className:"text-xs italic text-gray-500",children:["... and ",r.length-5," more issues"]})]})]})})]})},g0=()=>{const t=O("flags.darkMode",!0),e=O("flags.dataBinding",!0),[n,s]=S.useAtom(ao),{t:r}=F.useTranslation(),o=t,a=e;return i.jsxs("div",{className:"flex h-10 items-center justify-between border-b border-border bg-background/70 px-2 shadow-xl",children:[i.jsx("div",{className:"flex h-full space-x-2",children:o?i.jsx(td,{}):null}),i.jsxs("div",{className:"flex h-full items-center space-x-2",children:[i.jsx(Ko,{canvas:!0,openDelay:400}),i.jsx(Pt,{orientation:"vertical"}),i.jsx(h0,{}),i.jsx(Pt,{orientation:"vertical"}),i.jsx(nd,{})]}),i.jsxs("div",{className:"flex h-full items-center",children:[a?i.jsxs(Qe,{children:[i.jsx(et,{asChild:!0,children:i.jsx(q,{size:"sm",variant:"ghost",className:"h-7 w-7 rounded-md p-1",children:i.jsx(v.DotsHorizontalIcon,{className:"h-4 w-4"})})}),i.jsx(Ue,{className:"w-56 border-border text-xs",children:i.jsxs(de,{className:"flex items-center gap-2",onSelect:l=>l.preventDefault(),children:[i.jsx(v.LightningBoltIcon,{className:"h-4 w-4 text-gray-500"}),i.jsx("span",{className:"flex-1",children:r("Data Binding")}),i.jsx(dn,{checked:n,onCheckedChange:()=>s(!n)})]})})]}):null,i.jsx(m0,{}),i.jsx($c,{})]})]})},id=()=>{const{t}=F.useTranslation(),[e,n]=g.useState(""),[s,r]=g.useState(-1),[o,a]=g.useState(!1),l=Ye(),[,c]=Ls();return Yt(Y.OPEN_ADD_BLOCK,d=>{l?c("add-block"):(n(d?d._id:null),r(isNaN(d==null?void 0:d.position)?-1:d==null?void 0:d.position),a(!0))}),Yt(Y.CLOSE_ADD_BLOCK,()=>{n(""),r(-1),a(!1)}),i.jsx(si,{open:o,onOpenChange:()=>o?a(!1):"",children:i.jsxs(qs,{className:"max-w-5xl overflow-hidden border-border",children:[i.jsxs(Ks,{className:"flex flex-row items-center justify-between",children:[i.jsx(Ys,{className:"text-foreground",children:t("Add blocks")}),i.jsx("button",{onClick:()=>a(!1),className:"text-gray-500 hover:text-gray-600 dark:text-gray-400 dark:hover:text-gray-300",children:i.jsx(v.Cross2Icon,{className:"h-6 w-6"})})]}),i.jsx("div",{className:"no-scrollbar h-[500px] max-h-full overflow-hidden",children:i.jsx(ti,{parentId:e,position:s,showHeading:!1})})]})})},x0=g.memo(function({preloadedAttributes:e=[],onAttributesChange:n}){const[s,r]=g.useState([]),[o,a]=g.useState(""),[l,c]=g.useState(""),[d,p]=g.useState(null),[f,m]=g.useState(""),h=g.useRef(null),b=g.useRef(null),x=sn(),{t:y}=F.useTranslation();g.useEffect(()=>{r(e)},[e]);const k=()=>{if(o.startsWith("@")){m(y("Attribute keys cannot start with @"));return}if(o){const j=[...s,{key:o,value:l}];n(j),r(s),a(""),c(""),m("")}},w=j=>{const N=s.filter((C,T)=>T!==j);n(N),r(N)},E=j=>{p(j),a(s[j].key),c(s[j].value)},A=()=>{if(o.startsWith("@")){m(y("Attribute keys cannot start with @"));return}if(d!==null&&o){const j=[...s];j[d]={key:o,value:l},n(j),r(j),p(null),a(""),c(""),m("")}},_=j=>{j.key==="Enter"&&!j.shiftKey&&(j.preventDefault(),d!==null?A():k())},I=g.useCallback(j=>{const N=R=>/[.,!?;:]/.test(R),C=(R,B,U)=>{let z="",G="";const he=B>0?R[B-1]:"",ae=B<R.length?R[B]:"";return B>0&&(he==="."||!N(he)&&he!==" ")&&(z=" "),B<R.length&&!N(ae)&&ae!==" "&&(G=" "),{text:z+U+G,prefixLength:z.length,suffixLength:G.length}},T=b.current;if(T){const R=T.selectionStart||0,B=T.value||"",U=T.selectionEnd||R;if(U>R){const le=`{{${j}}}`,{text:Ae}=C(B,R,le),W=B.slice(0,R)+Ae+B.slice(U);c(W);return}const G=`{{${j}}}`,{text:he}=C(B,R,G),ae=B.slice(0,R)+he+B.slice(R);c(ae)}},[]);return i.jsxs("div",{className:"flex max-h-full flex-1 flex-col",children:[i.jsxs("form",{onSubmit:j=>{j.preventDefault(),d!==null?A():k()},className:"space-y-3",children:[i.jsxs("div",{className:"flex flex-col gap-y-1",children:[i.jsxs("div",{className:"w-full",children:[i.jsx(ut,{htmlFor:"attrKey",className:"text-[11px] font-normal leading-tight text-slate-600",children:y("Key")}),i.jsx(vt,{autoCapitalize:"off",autoCorrect:"off",spellCheck:"false",id:"attrKey",ref:h,value:o,onChange:j=>a(j.target.value),placeholder:y("Enter key"),className:"py-0 text-xs font-normal leading-tight placeholder:text-slate-400"})]}),i.jsxs("div",{className:"w-full",children:[i.jsxs("div",{className:"flex items-center justify-between",children:[i.jsx(ut,{htmlFor:"attrValue",className:"text-[11px] font-normal text-slate-600",children:y("Value")}),!u.isEmpty(x)&&i.jsx($o,{data:x,onSelect:I})]}),i.jsx(Vn,{autoCapitalize:"off",autoCorrect:"off",spellCheck:"false",id:"attrValue",ref:b,value:l,onChange:j=>c(j.target.value),onKeyDown:_,placeholder:y("Enter value"),className:"text-xs font-normal leading-tight placeholder:text-slate-400"})]})]}),i.jsx("div",{className:"flex justify-end",children:i.jsx(q,{type:"submit",disabled:!o.length,variant:"default",size:"sm",className:"h-8 w-24 text-xs",children:y(d!==null?"Save":"Add")})}),f&&i.jsx("p",{className:"text-xs text-red-500",children:f})]}),i.jsx("div",{className:"space-y-1 py-4",children:s.map((j,N)=>i.jsxs("div",{className:"flex items-center justify-between rounded border p-2 text-sm",children:[i.jsxs("div",{className:"flex flex-col text-xs leading-tight",children:[i.jsx("span",{className:"truncate text-[12px] font-light text-muted-foreground",children:j.key}),i.jsx("span",{className:"max-w-[200px] text-wrap font-normal",children:j.value.toString()})]}),i.jsxs("div",{className:"flex-shrink-0 text-slate-400",children:[i.jsx(q,{variant:"ghost",size:"icon",className:"h-6 w-6",onClick:()=>E(N),children:i.jsx(v.Pencil2Icon,{className:"h-3 w-3"})}),i.jsx(q,{variant:"ghost",size:"icon",className:"h-6 w-6",onClick:()=>w(N),children:i.jsx(v.Cross1Icon,{className:"h-3 w-3"})})]})]},N))})]})}),ad=M.memo(()=>{const t=Z(),[e,n]=g.useState([]),[s]=Ee(),r=tt(),o=`${u.get(s,"0.prop")}_attrs`;M.useEffect(()=>{const l=u.map(u.get(t,o),(c,d)=>({key:d,value:c}));u.isEmpty(l)?n([]):n(l)},[u.get(t,o)]);const a=M.useCallback((l=[])=>{const c={};u.forEach(l,d=>{u.isEmpty(d.key)||u.set(c,d.key,d.value)}),r([u.get(t,"_id")],{[o]:c})},[t,r,o]);return i.jsx("div",{className:"flex-col gap-y-2",children:i.jsx("div",{className:"flex flex-col",children:i.jsx("div",{children:i.jsx(x0,{preloadedAttributes:e,onAttributesChange:a})})})})}),Ut=()=>null,ea=()=>{const{resetAll:t}=pc(),e=Z(),[n]=Ee(),s=Gg(),{t:r}=F.useTranslation();return!e||u.isEmpty(n)?null:i.jsxs(Qe,{children:[i.jsx(et,{asChild:!0,children:i.jsx("div",{className:"inline-flex rounded-sm p-0.5 hover:bg-gray-300",onClick:o=>o.stopPropagation(),children:i.jsx(v.DotsVerticalIcon,{className:"h-3 w-3"})})}),i.jsxs(Ue,{side:"bottom",className:"border-border text-xs",children:[i.jsxs(de,{className:"flex items-center gap-1 text-xs",onClick:()=>{t()},children:[i.jsx(v.ResetIcon,{className:"h-3 w-3"}),r("Reset styles")]}),i.jsxs(de,{className:"text-xs",onClick:()=>{e&&s(e,!0)},children:[i.jsx(v.Cross2Icon,{className:"h-3 w-3"}),r("Clear styles")]})]})]})};function ta(){const{t}=F.useTranslation(),[e,n]=g.useState(!0),[s]=Ee();return u.isEmpty(s)?null:i.jsxs(i.Fragment,{children:[i.jsxs("div",{onClick:()=>n(!e),className:"flex cursor-pointer items-center justify-between border-t border-border py-3 text-xs font-medium hover:underline",children:[i.jsx("span",{children:t("Attributes")}),i.jsx("span",{children:i.jsx(v.ChevronDownIcon,{className:"h-4 w-4 text-gray-500 "+(e?"rotate-180":"")})})]}),e&&i.jsx(ad,{})]})}const b0=({partialBlockId:t})=>{const e=O("gotoPage",u.noop),{saveState:n}=Rn(),{selectedLang:s,fallbackLang:r}=Le(),o=g.useCallback(a=>{if(a.stopPropagation(),n!=="SAVED"){me.toast.error("You have unsaved changes. Please save the page first.");return}e({pageId:t,lang:s||r})},[n,e,t,s,r]);return i.jsx(i.Fragment,{children:i.jsx("div",{className:"hidden",children:i.jsx("div",{onDoubleClick:o,className:"h-full w-full items-center justify-center",children:i.jsx("p",{className:"rounded-md bg-white px-2 py-1 text-xs",children:"Partial block. Double click to edit."})})})})},y0=()=>{const t=Z(),{t:e}=F.useTranslation(),n=O("onError",u.noop),{hasPermission:s}=qe();let r=!s(ne.EDIT_BLOCK);const o=!s(ne.EDIT_STYLES),[a,l]=Aa();if(t&&t._type==="PartialBlock")return i.jsx(b0,{partialBlockId:t.partialBlockId});if(u.isNull(t))return i.jsx("div",{className:"p-4 text-center",children:i.jsxs("div",{className:"space-y-4 rounded-xl p-4 text-muted-foreground",children:[i.jsx(v.MixerHorizontalIcon,{className:"mx-auto text-3xl"}),i.jsx("h1",{children:e("Please select a block to edit settings or styles")})]})});if(r&&o)return i.jsx("div",{className:"p-4 text-center",children:i.jsxs("div",{className:"space-y-4 rounded-xl p-4 text-muted-foreground",children:[i.jsx(v.MixerHorizontalIcon,{className:"mx-auto text-3xl"}),i.jsx("h1",{children:e("You don't have permission to edit settings or styles")}),i.jsx("p",{children:e("Please contact your administrator to get access")})]})});if(o)return i.jsx(_t.ErrorBoundary,{fallback:i.jsx(kn,{}),onError:n,children:i.jsxs("div",{className:"no-scrollbar h-full max-h-min w-full overflow-y-auto",children:[i.jsx(Nr,{}),i.jsx("br",{}),i.jsx("br",{})]})});if(r)return i.jsx(_t.ErrorBoundary,{fallback:i.jsx(kn,{}),onError:n,children:i.jsxs("div",{className:"no-scrollbar h-full max-h-min w-full overflow-y-auto overflow-x-hidden",children:[i.jsx("div",{className:"flex w-full items-center justify-end",children:i.jsx(ea,{})}),i.jsx(Br,{}),i.jsx(ta,{}),i.jsx("br",{}),i.jsx("br",{}),i.jsx("br",{})]})});const d=p=>{(p==="settings"||p==="styles")&&l(p)};return i.jsx(_t.ErrorBoundary,{fallback:i.jsx(kn,{}),onError:n,children:i.jsxs(Us,{value:a,onValueChange:d,className:"flex flex-1 flex-col",children:[i.jsx("div",{className:"flex items-center justify-between",children:i.jsxs(Hn,{className:"grid h-auto w-full grid-cols-2 p-1 py-1",children:[i.jsx(He,{value:"settings",className:"text-xs",children:e("Settings")}),i.jsx(He,{value:"styles",className:"text-xs",children:i.jsxs("div",{className:"flex w-full items-center justify-between",children:[i.jsx("span",{className:"w-[90%] text-center",children:e("Styling")}),i.jsx("span",{className:"w-[10%]",children:i.jsx(ea,{})})]})})]})}),i.jsxs(lt,{value:"settings",className:"no-scrollbar h-full max-h-min overflow-y-auto",children:[i.jsx(Nr,{}),i.jsx("br",{}),i.jsx("br",{})]}),i.jsxs(lt,{value:"styles",className:"no-scrollbar h-full max-h-min max-w-full overflow-y-auto overflow-x-hidden",children:[i.jsx(Br,{}),i.jsx(ta,{}),i.jsx("br",{}),i.jsx("br",{}),i.jsx("br",{})]})]})})},ws={},Xs=(t,e)=>{u.has(ws,t)&&console.warn(`Panel ${t} already registered. Overriding...`),u.set(ws,t,{id:t,...e})},na=t=>g.useMemo(()=>u.filter(u.values(ws),e=>e.position===t),[t,ws]),v0=()=>i.jsx("div",{}),ld={component:v0},k0=t=>{ld.component=t},w0=()=>g.useMemo(()=>ld.component,[]),C0=g.lazy(()=>Promise.resolve().then(()=>require("./manage-design-tokens-CrmLe7UT.cjs"))),gt=280,j0=({isActive:t,show:e})=>i.jsx(q,{variant:t?"default":"ghost",size:"icon",onClick:e,children:i.jsx(v.StackIcon,{className:"h-5 w-5"})}),S0=({isActive:t,show:e})=>Ye()&&i.jsx(q,{variant:t?"default":"ghost",size:"icon",onClick:e,children:i.jsx(v.PlusCircledIcon,{className:"h-5 w-5"})}),N0=({isActive:t,show:e})=>i.jsx(q,{variant:t?"default":"ghost",size:"icon",onClick:e,children:i.jsx(zr,{})});Xs("add-block",{button:S0,label:"Add Blocks",position:"top",isInternal:!0,width:gt,panel:()=>i.jsx(ti,{showHeading:!1,fromSidebar:!0,parentId:void 0,position:-1})});Xs("chai-chat-panel",{button:N0,label:"Ask AI",position:"top",isInternal:!0,width:gt,panel:()=>i.jsx("div",{className:"",children:i.jsx(ed,{})})});Xs("outline",{button:j0,label:"Outline",position:"top",isInternal:!0,width:gt,panel:()=>i.jsx("div",{className:"-mt-8",children:i.jsx(qc,{})})});const E0=()=>{const t=w0(),[e,n]=Ls(),s=g.useRef("outline"),[r,o]=g.useState(gt),[a,l]=so(),[,c]=Aa(),d=na("top"),p=na("bottom"),f=u.reverse([...p??[]]),m=g.useCallback(N=>{N.preventDefault()},[]),h=g.useMemo(()=>[d].flat(),[d]),b=g.useCallback(N=>{console.log("handleMenuItemClick",N,e),n(e===N?null:N)},[e,n]),{t:x}=F.useTranslation(),y=g.useMemo(()=>[...d,...p],[d,p]),k=O("htmlDir","ltr"),w=u.find(y,{id:e})??u.first(y),E=u.get(w,"width",gt);g.useEffect(()=>{if(e!==null){const N=u.find(y,{id:e});N&&u.get(N,"view","standard")==="standard"&&(s.current=e,o(u.get(N,"width",gt)))}},[e,y]);const A=g.useMemo(()=>{if(e===null)return 0;const N=u.find(y,{id:e});return u.get(N,"view","standard")==="standard"?E:r},[e,E,r,y]),_=g.useCallback(()=>{n(s.current)},[n,e]),I=g.useCallback(()=>{n("outline")},[n]);g.useEffect(()=>{e!==null&&!u.find(y,{id:e})&&n("outline")},[e,y]);const j=g.useCallback(N=>{b(N)},[b]);return i.jsx("div",{dir:k,className:"h-screen max-h-full w-screen overflow-x-hidden bg-background text-foreground",children:i.jsxs(vs,{children:[i.jsxs("div",{onContextMenu:m,className:"flex h-full max-h-full flex-col bg-background text-foreground",children:[i.jsx("div",{className:"flex h-[50px] w-screen items-center border-b border-border",children:i.jsx(g.Suspense,{children:i.jsx(t,{})})}),i.jsxs("main",{className:"relative flex h-[calc(100vh-56px)] max-w-full flex-1 flex-row",children:[i.jsxs("div",{id:"sidebar",className:"flex w-12 flex-col items-center justify-between border-r border-border py-2",children:[i.jsx("div",{className:"flex flex-col gap-y-1",children:h.map((N,C)=>i.jsxs(pe,{children:[i.jsx(fe,{asChild:!0,children:g.createElement(u.get(N,"button",Ut),{position:"top",panelId:N.id,isActive:e===N.id,show:()=>j(N.id)})}),i.jsx(ue,{side:"right",children:i.jsx("p",{children:x(N.label)})})]},"button-top-"+C))}),i.jsx("div",{className:"flex flex-col space-y-1"}),i.jsx("div",{className:"flex flex-col",children:f==null?void 0:f.map((N,C)=>i.jsxs(pe,{children:[i.jsx(fe,{asChild:!0,children:g.createElement(u.get(N,"button",Ut),{position:"bottom",panelId:N.id,isActive:e===N.id,show:()=>j(N.id)})}),i.jsx(ue,{side:"right",children:i.jsx("p",{children:x(N.label)})})]},"button-bottom-"+C))})]}),i.jsx(qn.motion.div,{id:"left-panel",className:"h-full max-h-full border-r border-border",initial:{width:A},animate:{width:A},transition:{duration:.3,ease:"easeInOut"},children:e!==null&&u.get(w,"view","standard")==="standard"&&i.jsxs("div",{className:"no-scrollbar flex h-full flex-col overflow-hidden px-3 py-2",children:[i.jsx("div",{className:`absolute top-2 flex h-10 items-center space-x-1 py-2 text-base font-bold ${u.get(w,"isInternal",!1)?"":"w-64"}`,children:i.jsx("span",{children:x(u.get(w,"label",""))})}),i.jsx("div",{className:"no-scrollbar h-full max-h-full overflow-y-auto pt-10",children:i.jsx(g.Suspense,{fallback:i.jsx("div",{children:"Loading..."}),children:g.createElement(u.get(w,"panel",Ut),{})})})]})}),i.jsxs("div",{id:"canvas-container",className:"flex h-full max-h-full flex-1 flex-col bg-slate-800/20",children:[i.jsx(g0,{}),i.jsx(g.Suspense,{children:i.jsx(nc,{})})]}),i.jsx(qn.motion.div,{id:"right-panel",className:"h-full max-h-full border-l border-border",initial:{width:e==="ai"?0:gt},animate:{width:e==="ai"?0:gt},transition:{duration:.3,ease:"easeInOut"},children:i.jsx("div",{className:"no-scrollbar overflow h-full max-h-full overflow-hidden",children:i.jsxs("div",{className:"flex h-full max-h-full flex-col overflow-hidden p-3",children:[i.jsx("h2",{className:"-mt-1 flex items-center space-x-1 text-base font-bold",children:i.jsx("div",{className:"flex grow items-center gap-2",children:i.jsx("div",{className:"flex w-full items-center justify-between gap-2",children:a==="ai"?i.jsx(i.Fragment,{children:i.jsxs("div",{className:"flex items-center gap-2",children:[i.jsx(v.LightningBoltIcon,{className:"rtl:ml-2"})," ",x("AI Assistant")]})}):a==="design-tokens"?i.jsxs("div",{className:"mb-1 flex w-full items-center justify-between gap-2",children:[i.jsxs("span",{className:"flex items-center gap-2",children:[i.jsx(Tr,{className:"h-4 w-4 text-gray-600"}),x("Design Tokens")]}),i.jsx(q,{onClick:()=>{c("styles"),l("block")},variant:"ghost",size:"icon",className:"text-xs",children:i.jsx(v.Cross1Icon,{className:"h-4 w-4 rtl:ml-2"})})]}):a==="theme"?i.jsxs("div",{className:"flex w-full items-center justify-between gap-2",children:[i.jsxs("span",{className:"flex items-center gap-2",children:[i.jsx(v.MixerHorizontalIcon,{className:"h-4 w-4 text-gray-600"}),x("Theme Settings")]}),i.jsx(q,{onClick:()=>l("block"),variant:"ghost",size:"icon",className:"text-xs",children:i.jsx(v.Cross1Icon,{className:"h-4 w-4 rtl:ml-2"})})]}):null})})}),i.jsx("div",{className:"flex h-full max-h-full w-full",children:i.jsx(g.Suspense,{fallback:i.jsx("div",{children:"Loading..."}),children:a==="ai"?i.jsx(ed,{}):a==="design-tokens"?i.jsx(g.Suspense,{fallback:i.jsx("div",{className:"h-1/2 w-full animate-pulse"}),children:i.jsx(C0,{})}):a==="theme"?i.jsx(Xc,{}):i.jsx(y0,{})})})]})})})]})]}),i.jsx(id,{}),e!==null&&u.get(w,"view")==="drawer"&&i.jsx(sd,{open:!0,onOpenChange:()=>_(),children:i.jsxs(li,{side:"left",className:"flex flex-col gap-0 p-0 sm:max-w-full",style:{width:`${E}px`},children:[i.jsx(ci,{className:"border-b border-border px-2 py-2.5",children:i.jsxs(di,{className:"flex items-center gap-2",children:[i.jsx("span",{className:"inline-block",children:u.get(w,"icon",null)}),i.jsx("span",{children:x(u.get(w,"label",""))})]})}),i.jsx("div",{className:"h-full max-h-full overflow-y-auto p-4",children:i.jsx(g.Suspense,{fallback:i.jsx("div",{children:"Loading..."}),children:g.createElement(u.get(w,"panel",Ut),{close:I})})})]})})," ",e!==null&&u.get(w,"view")==="modal"&&i.jsx(On,{open:!0,onOpenChange:()=>_(),children:i.jsxs(ln,{className:"gap-0 p-0",style:{maxWidth:`${E}px`},children:[i.jsx(Fn,{className:"border-b border-border px-2 py-3.5",children:i.jsxs(cn,{className:"flex items-center gap-2",children:[i.jsx("span",{className:"inline-block",children:u.get(w,"icon",null)}),i.jsx("span",{children:x(u.get(w,"label",""))})]})}),i.jsx("div",{className:"max-h-[70vh] overflow-y-auto p-4",children:i.jsx(g.Suspense,{fallback:i.jsx("div",{children:"Loading..."}),children:g.createElement(u.get(w,"panel",Ut),{close:I})})})]})}),e!==null&&u.get(w,"view")==="overlay"&&i.jsx(qn.motion.div,{className:"absolute bottom-0 left-12 right-0 top-0 z-50",initial:{opacity:0},animate:{opacity:1},exit:{opacity:0},transition:{duration:.3},children:i.jsx("div",{className:"h-full w-full",children:i.jsxs(qn.motion.div,{className:"flex h-full w-full flex-col bg-background",initial:{y:-20,opacity:0},animate:{y:0,opacity:1},exit:{y:20,opacity:0},transition:{duration:.3,delay:.1},children:[i.jsxs("div",{className:"flex h-[50px] items-center justify-between border-b border-border p-4",children:[i.jsxs("div",{className:"-ml-2 flex items-center gap-2 text-lg font-bold",children:[i.jsx("span",{className:"rtl:ml-2 rtl:inline-block",children:u.get(w,"icon",null)}),i.jsx("span",{children:x(u.get(w,"label",""))})]}),i.jsx(q,{onClick:()=>_(),variant:"ghost",size:"icon",className:"",children:i.jsx(v.Cross1Icon,{className:"h-5 w-5"})})]}),i.jsx("div",{className:"flex-1 overflow-y-auto p-4",children:i.jsx(g.Suspense,{fallback:i.jsx("div",{children:"Loading..."}),children:g.createElement(u.get(w,"panel",Ut),{close:I})})})]})})})]})})},A0=S.atom(!1),_0=()=>{const[t,e]=S.useAtom(A0);return[t,e]},I0=()=>{const[t,e]=_0(),{t:n}=F.useTranslation(),s=O("previewComponent",null);return t?i.jsxs("div",{className:ve.cn("fixed inset-0 z-[999] bg-background",t?"block":"hidden"),children:[i.jsxs(q,{size:"sm",className:"absolute right-0 top-0 m-4 space-x-2",onClick:()=>e(!1),children:[i.jsx(v.EyeClosedIcon,{}),i.jsx("span",{children:n("Close Preview")})]}),i.jsx("div",{children:s?i.jsx(g.Suspense,{fallback:i.jsx(Mt,{className:"h-96 w-full"}),children:g.createElement(s)}):null})]}):null},Pr={},T0=(t,e)=>{if(Pr[t])throw new Error(`Flag ${t} already exists`);Pr[t]={key:t,value:!1,...e}},B0=()=>Pr,cd=we.atomWithStorage("chai-feature-flags",[]),dd=t=>{const[e]=S.useAtom(cd);return e.includes(t)},R0=t=>{const[e,n]=S.useAtom(cd);return()=>{e.includes(t)?n(e.filter(r=>r!==t)):n([...e,t])}},P0=({featureKey:t,options:e})=>{const n=R0(t),s=dd(t);return i.jsxs("div",{className:"flex items-center space-x-3 rounded-md p-2 transition-colors hover:bg-gray-50 dark:hover:bg-gray-800",children:[i.jsx(dn,{checked:s,onCheckedChange:n}),i.jsxs("div",{className:"flex-1",children:[i.jsx("p",{className:"text-sm font-medium text-gray-900 dark:text-gray-100",children:e.key}),e.description&&i.jsx("p",{className:"mt-0.5 text-xs text-gray-500 dark:text-gray-400",children:e.description})]})]})},L0=we.atomWithStorage("show-feature-flag",null),M0=({close:t,position:e,updatePosition:n})=>{const s=B0(),[r,o]=g.useState(""),[a,l]=g.useState(!1),[c,d]=g.useState({x:0,y:0}),p=g.useMemo(()=>{if(!r.trim())return s;const b=r.toLowerCase();return Object.fromEntries(Object.entries(s).filter(([x,y])=>{var k;return(x==null?void 0:x.toLowerCase().includes(b))||((k=y==null?void 0:y.description)==null?void 0:k.toLowerCase().includes(b))}))},[s,r]),f=b=>{l(!0),d({x:b.clientX-e.x,y:b.clientY-e.y})},m=b=>{if(!a)return;const x=b.clientX-c.x,y=b.clientY-c.y,k=b.currentTarget,w=k.offsetWidth,E=k.offsetHeight,A=window.innerWidth-w,_=window.innerHeight-E,I=Math.max(0,Math.min(x,A)),j=Math.max(0,Math.min(y,_));n(I,j)},h=()=>{l(!1)};return g.useEffect(()=>{const b=()=>{a&&l(!1)};return window.addEventListener("mouseup",b),()=>window.removeEventListener("mouseup",b)},[a]),!e||e.x<0||e.y<0?null:i.jsxs("div",{onMouseDown:f,onMouseMove:m,onMouseUp:h,className:"fixed z-[9999999] select-none rounded-md border border-gray-300 bg-white p-3 shadow-2xl",style:{left:e.x,top:e.y,cursor:a?"grabbing":"grab",userSelect:"none"},children:[i.jsxs("div",{className:"relative sticky top-0 rounded-t-lg bg-white",children:[i.jsxs("div",{className:"mb-3 flex items-center justify-between",children:[i.jsxs("div",{children:[i.jsxs("h3",{className:"flex items-center gap-x-2 text-base font-semibold text-gray-900 dark:text-gray-100",children:[i.jsx(v.DragHandleDots2Icon,{})," Feature Flags"]}),i.jsxs("p",{className:"text-xs text-gray-400 dark:text-gray-400",children:["Toggle experimental features (",i.jsx("span",{className:"font-mono",children:"Ctrl+Shift+1"})," to toggle)"]})]}),i.jsx(q,{variant:"ghost",size:"sm",onClick:t,className:"absolute -right-2 -top-2 p-1 text-gray-500 hover:text-gray-700 dark:text-gray-400 dark:hover:text-gray-200",children:i.jsx(v.Cross1Icon,{className:"h-4 w-4"})})]}),i.jsxs("div",{className:"relative",children:[i.jsx(v.MagnifyingGlassIcon,{className:"absolute left-2.5 top-2.5 h-4 w-4 text-gray-400"}),i.jsx(vt,{type:"search",placeholder:"Search features...",className:"w-full pl-8",value:r,onChange:b=>o(b.target.value),autoFocus:!0})]})]}),i.jsx("div",{className:"max-h-96 overflow-y-auto py-2",children:Object.keys(p).length>0?i.jsx("div",{className:"space-y-1",children:Object.entries(p).map(([b,x])=>i.jsx(P0,{featureKey:b,options:x},b))}):i.jsx("div",{className:"py-8 text-center",children:i.jsxs("p",{className:"text-sm text-gray-500 dark:text-gray-400",children:['No features found matching "',r,'"']})})})]})},D0=()=>{const[t,e]=S.useAtom(L0);return Xe.useHotkeys("ctrl+shift+1,meta+shift+1",()=>e(n=>n?{...n,show:!n.show}:{x:0,y:0,show:!0}),{enableOnFormTags:!0}),t!=null&&t.show?i.jsx(M0,{position:t,close:()=>e(n=>({...n,show:!1})),updatePosition:(n,s)=>e(r=>({...r,x:n,y:s}))}):null},O0=t=>{},F0=()=>{const{clear:t}=Pn(),[,e]=K(),{clearHighlight:n}=nt(),[,s]=Ee(),[,r]=S.useAtom(Ta),{reset:o}=Ds(),{setSaveState:a}=Rn(),[,l]=ja(),[,c]=S.useAtom(Bs);return()=>{l({}),e([]),s([]),n(),t(),r(!1),o(),a("SAVED"),c(0)}},$0=(t,e)=>{const n=[];let s=u.find(t,{_id:e}),r=u.get(s,"_parent","");for(;u.isString(r)&&!u.isEmpty(r);)n.push(s==null?void 0:s._parent),s=u.find(t,{_id:r}),r=s==null?void 0:s._parent;return u.flatten(n)},z0=S.atom([]),H0=()=>{const[t]=K(),e=S.useAtomValue(Se),[,n]=S.useAtom(z0);g.useEffect(()=>{let s=[];const r=u.first(t);u.isString(r)&&(s=[r,...$0(e,r)]),n(s)},[t,e,n])},V0=["data-block-index","draggable","data-drop","data-style-id","data-block-parent","data-style-prop","data-highlighted"],W0=["Box","Button","Checkbox","Divider","EmptyBox","Form","FormButton","Heading","Image","Input","Label","LineBreak","Link","List","ListItem","Paragraph","Radio","RichText","Select","Span","Text","TextArea","Video"],ud=t=>t.type==="element"&&["script","style","link"].includes(t.tagName||"")||t.type==="comment"?null:t.type==="text"?t:t.type==="element"&&t.attributes&&t.attributes.find(e=>e.key==="id"&&e.value==="add-block-bottom")?null:(t.type==="element"&&t.attributes&&(t.attributes=t.attributes.filter(e=>!V0.includes(e.key))),t.children&&(t.children=t.children.map(ud).filter(e=>e!==null)),t),rs=(t,e,n={})=>{var o,a,l,c,d,p;if(t.type!=="element"||!t.attributes)return t;if(t.tagName==="span"&&t.attributes.find(m=>m.key==="role"&&m.value==="link")){t.tagName="a",t.attributes=t.attributes.filter(b=>b.key!=="role");const m=(o=t.attributes.find(b=>b.key==="data-block-id"))==null?void 0:o.value,h=e==null?void 0:e.find(b=>(b==null?void 0:b._id)===m);if(h!=null&&h.link&&((l=(a=h==null?void 0:h.link)==null?void 0:a.href)==null?void 0:l.length)>0){const b=(c=h==null?void 0:h.link)==null?void 0:c.href,x=(d=h==null?void 0:h.link)==null?void 0:d.target;t.attributes.push({key:"href",value:b}),typeof x=="string"&&x.length>0&&t.attributes.push({key:"target",value:x})}}const s=t.attributes.find(f=>f.key==="data-block-type"),r=t.attributes.find(f=>f.key==="data-block-id");if(s){const f=s.value;if(W0.includes(f)||(p=n==null?void 0:n.additionalCoreBlocks)!=null&&p.includes(f))t.attributes=t.attributes.filter(m=>m.key!=="data-block-type"),t.children&&(t.children=t.children.map(m=>rs(m,e,n)));else{const m=`chai-${u.kebabCase(f)}`;t.tagName=m,t.attributes=[],t.attributes.push({key:"chai-type",value:f});const h=J.getRegisteredChaiBlock(f),b=e.find(x=>x._id===(r==null?void 0:r.value));if(b&&t.attributes.push(...Object.entries(b).filter(([x])=>!["_id","_type","_parent","_index","_name"].includes(x)).map(([x,y])=>({key:x,value:typeof y=="string"?y:JSON.stringify(y)}))),h&&(h!=null&&h.description)&&t.attributes.push({key:"about-this-component",value:h.description}),h){if(h.canMove){const x=typeof h.canMove=="function"?h.canMove():h.canMove;t.attributes.push({key:"can-move",value:String(x)})}if(h.canDelete){const x=typeof h.canDelete=="function"?h.canDelete():h.canDelete;t.attributes.push({key:"can-delete",value:String(x)})}}f==="Icon"&&(t.attributes=t.attributes.filter(x=>x.key!=="icon")),h&&h.canAcceptBlock?t.children&&(t.children=t.children.map(x=>rs(x,e,n))):t.children=[]}}else t.children&&(t.children=t.children.map(f=>rs(f,e,n)));return r&&t.attributes.push({key:"bid",value:r.value}),t.attributes=t.attributes.filter(f=>f.key!=="data-block-type"&&f.key!=="data-block-id"),t},pd=()=>{const[t]=rn();return g.useCallback(e=>{var d,p;if(!t)return"";const n=e!=null&&e.blockId?`[data-block-id="${e.blockId}"]`:"#canvas",s=(p=(d=t.contentDocument)==null?void 0:d.querySelector(n))==null?void 0:p[n==="#canvas"?"innerHTML":"outerHTML"];if(!s)return"";const o=pi.parse(s).map(ud).filter(f=>f!==null),a=hu(),l=o.map(f=>rs(f,a,e));let c=pi.stringify(l);return c=c.replace(/#styles:,/g,"#styles:"),c.replace(/\s+/g," ").trim()},[t])};function sa(t){const e={class:"className",for:"htmlFor",tabindex:"tabIndex",readonly:"readOnly",maxlength:"maxLength",minlength:"minLength",autocomplete:"autoComplete",autofocus:"autoFocus",autoplay:"autoPlay",formaction:"formAction",formenctype:"formEncType",formmethod:"formMethod",formnovalidate:"formNoValidate",formtarget:"formTarget",novalidate:"noValidate",crossorigin:"crossOrigin",datetime:"dateTime",rowspan:"rowSpan",colspan:"colSpan",usemap:"useMap",frameborder:"frameBorder",allowfullscreen:"allowFullScreen"};if(e[t.toLowerCase()])return e[t.toLowerCase()];const n={"accent-height":"accentHeight","alignment-baseline":"alignmentBaseline","arabic-form":"arabicForm","baseline-shift":"baselineShift","cap-height":"capHeight","clip-path":"clipPath","clip-rule":"clipRule","color-interpolation":"colorInterpolation","color-interpolation-filters":"colorInterpolationFilters","color-profile":"colorProfile","color-rendering":"colorRendering","dominant-baseline":"dominantBaseline","enable-background":"enableBackground","fill-opacity":"fillOpacity","fill-rule":"fillRule","flood-color":"floodColor","flood-opacity":"floodOpacity","font-family":"fontFamily","font-size":"fontSize","font-size-adjust":"fontSizeAdjust","font-stretch":"fontStretch","font-style":"fontStyle","font-variant":"fontVariant","font-weight":"fontWeight","glyph-name":"glyphName","glyph-orientation-horizontal":"glyphOrientationHorizontal","glyph-orientation-vertical":"glyphOrientationVertical","horiz-adv-x":"horizAdvX","horiz-origin-x":"horizOriginX","image-rendering":"imageRendering","letter-spacing":"letterSpacing","lighting-color":"lightingColor","marker-end":"markerEnd","marker-mid":"markerMid","marker-start":"markerStart","overline-position":"overlinePosition","overline-thickness":"overlineThickness","paint-order":"paintOrder","panose-1":"panose1","pointer-events":"pointerEvents","rendering-intent":"renderingIntent","shape-rendering":"shapeRendering","stop-color":"stopColor","stop-opacity":"stopOpacity","strikethrough-position":"strikethroughPosition","strikethrough-thickness":"strikethroughThickness","stroke-dasharray":"strokeDasharray","stroke-dashoffset":"strokeDashoffset","stroke-linecap":"strokeLinecap","stroke-linejoin":"strokeLinejoin","stroke-miterlimit":"strokeMiterlimit","stroke-opacity":"strokeOpacity","stroke-width":"strokeWidth","text-anchor":"textAnchor","text-decoration":"textDecoration","text-rendering":"textRendering","underline-position":"underlinePosition","underline-thickness":"underlineThickness","unicode-bidi":"unicodeBidi","unicode-range":"unicodeRange","units-per-em":"unitsPerEm","v-alphabetic":"vAlphabetic","v-hanging":"vHanging","v-ideographic":"vIdeographic","v-mathematical":"vMathematical","vector-effect":"vectorEffect","vert-adv-y":"vertAdvY","vert-origin-x":"vertOriginX","vert-origin-y":"vertOriginY","word-spacing":"wordSpacing","writing-mode":"writingMode","x-height":"xHeight"};return n[t]?n[t]:t}function is(t,e=0){var d;if(Array.isArray(t)){if(t.length===0)return"";if(t.length===1)return is(t[0],e);const p=" ".repeat(e);let f=`${p}<>
136
136
  `;for(const m of t)f+=is(m,e+1);return f+=`${p}</>
137
137
  `,f}const n=" ".repeat(e);if(t.nodeType===Node.TEXT_NODE){const p=(d=t.textContent)==null?void 0:d.trim();return p?`${n}${p}
138
138
  `:""}if(t.nodeType!==Node.ELEMENT_NODE)return"";const s=t.tagName.toLowerCase();if(["img","br","hr","input","meta","link","area","base","col","embed","source","track","wbr"].includes(s)){const p=[];for(const m of t.attributes)if(m.name.startsWith("on")&&m.name!=="on"){const h=m.name.toLowerCase().replace(/on(\w)/,(b,x)=>"on"+x.toUpperCase());p.push(`${h}={${m.value}}`)}else if(m.name==="style"&&m.value){const h=m.value.split(";").reduce((b,x)=>{const[y,k]=x.split(":").map(w=>w.trim());if(y&&k){const w=y.replace(/-([a-z])/g,E=>E[1].toUpperCase());b[w]=k.replace(/['"]/g,"")}return b},{});p.push(`style={${JSON.stringify(h)}}`)}else{const h=sa(m.name);p.push(`${h}="${m.value}"`)}const f=p.length>0?` ${p.join(" ")}`:"";return`${n}<${s}${f} />
@@ -143,7 +143,7 @@
143
143
  `):o.match(/\/>$/)?e+=s.repeat(n)+o+`
144
144
  `:o.match(/^<\w[^>]*[^\/]>$/)?(e+=s.repeat(n)+o+`
145
145
  `,n++):o.trim()&&(e+=s.repeat(n)+o.trim()+`
146
- `)}),e.trim()}const G0=g.lazy(()=>Promise.resolve().then(()=>require("./code-display-Q3_sK_Ta.cjs")));async function q0(t){try{const e=document.createElement("div");e.innerHTML=t;const n=Array.from(e.children);return{jsx:is(n.length===1?n[0]:n),html:e.innerHTML}}catch{return{html:t,jsx:t}}}const K0=async({selectedBlock:t,html:e,isTypeScript:n=!1})=>{let s=(t==null?void 0:t._name)||(t==null?void 0:t._type)||"Component";s=u.camelCase(s).replace(/^./,d=>d.toUpperCase());const r=" ";let{jsx:o,html:a}=await q0(e);return o=o==null?void 0:o.split(`
146
+ `)}),e.trim()}const G0=g.lazy(()=>Promise.resolve().then(()=>require("./code-display-BnqzqzoP.cjs")));async function q0(t){try{const e=document.createElement("div");e.innerHTML=t;const n=Array.from(e.children);return{jsx:is(n.length===1?n[0]:n),html:e.innerHTML}}catch{return{html:t,jsx:t}}}const K0=async({selectedBlock:t,html:e,isTypeScript:n=!1})=>{let s=(t==null?void 0:t._name)||(t==null?void 0:t._type)||"Component";s=u.camelCase(s).replace(/^./,d=>d.toUpperCase());const r=" ";let{jsx:o,html:a}=await q0(e);return o=o==null?void 0:o.split(`
147
147
  `).join(`
148
148
  ${r}${r}`),o=`${n?`import React from 'react';
149
149