From e0739e3a916193eaee838bb81480e7c1d8a62ac8 Mon Sep 17 00:00:00 2001 From: Aloento Date: Wed, 17 Jan 2024 09:40:43 +0000 Subject: [PATCH] deploy: 029f5ee7839f6e5fa52972bb0a5c10d08ec77438 --- assets/{Columns-iLzEQjYF.js => Columns-Qu8-yOAT.js} | 2 +- .../{Component-aAfnRv22.js => Component-4YKDN3nt.js} | 2 +- .../{Component-RuL62tq9.js => Component-uOG8IUJI.js} | 2 +- assets/{Lazy-vvLq-Rxx.js => Lazy-XJRXDq2K.js} | 4 ++-- ...-yIpoQP8r.js => LexicalNestedComposer-zwgIQe1H.js} | 2 +- assets/{index-iGJtzlF3.js => index-0T8GTba5.js} | 2 +- assets/index-7dlI38O5.js | 11 +++++++++++ assets/{index-fE5hFxdC.js => index-AaZE75L8.js} | 2 +- assets/{index-M75ftWWX.js => index-YN3820jC.js} | 2 +- assets/index-YSLnLPU4.js | 11 ----------- assets/{index-5nAmJIOp.js => index-qK3m2KiI.js} | 8 ++++---- assets/{index-Or5Q2pDR.js => index-wo2xrWSk.js} | 2 +- index.html | 2 +- 13 files changed, 26 insertions(+), 26 deletions(-) rename assets/{Columns-iLzEQjYF.js => Columns-Qu8-yOAT.js} (98%) rename assets/{Component-aAfnRv22.js => Component-4YKDN3nt.js} (99%) rename assets/{Component-RuL62tq9.js => Component-uOG8IUJI.js} (97%) rename assets/{Lazy-vvLq-Rxx.js => Lazy-XJRXDq2K.js} (65%) rename assets/{LexicalNestedComposer-yIpoQP8r.js => LexicalNestedComposer-zwgIQe1H.js} (96%) rename assets/{index-iGJtzlF3.js => index-0T8GTba5.js} (59%) create mode 100644 assets/index-7dlI38O5.js rename assets/{index-fE5hFxdC.js => index-AaZE75L8.js} (94%) rename assets/{index-M75ftWWX.js => index-YN3820jC.js} (99%) delete mode 100644 assets/index-YSLnLPU4.js rename assets/{index-5nAmJIOp.js => index-qK3m2KiI.js} (99%) rename assets/{index-Or5Q2pDR.js => index-wo2xrWSk.js} (99%) diff --git a/assets/Columns-iLzEQjYF.js b/assets/Columns-Qu8-yOAT.js similarity index 98% rename from assets/Columns-iLzEQjYF.js rename to assets/Columns-Qu8-yOAT.js index f7bd177..54100a3 100644 --- a/assets/Columns-iLzEQjYF.js +++ b/assets/Columns-Qu8-yOAT.js @@ -1 +1 @@ -import{m as D,t as E,x as R,j as e,F as c,L as u,y as w,T as v,b as S,B as N,r as I,ah as L,aN as z,aO as B,o as M,aG as $,ac as q,ad as Q,ae as U,af as W,ag as V,a5 as i,a6 as d,a7 as h,J,a8 as _,a9 as K}from"./vendor-DpqXKvKY.js";import{L as X,F as P,a as H,A as Y,H as f,c as F,e as A,f as Z,M as ee}from"./index-YSLnLPU4.js";const re=D({flex:P,box:{...H,flexBasis:"50%",rowGap:E.spacingVerticalM}}),k=new X("Order","Info");function se({OrderId:r,Order:s,Admin:n}){const a=re(),{data:j}=R(()=>Y.User.Get.OrderUser(r),{manual:!n,onError:k.error}),m=f.User.Get.useMe(k),l=n?j:m;return e.jsxs(e.Fragment,{children:[e.jsxs("div",{className:a.flex,children:[e.jsx("div",{className:a.box,children:e.jsx(c,{label:"Name",size:"large",children:e.jsx(u,{children:l?.Name})})}),e.jsx("div",{className:a.box,children:e.jsx(c,{label:"Phone",size:"large",children:e.jsx(u,{children:l?.Phone})})})]}),e.jsxs("div",{className:a.flex,children:[e.jsx("div",{className:a.box,children:e.jsx(c,{label:"Order Date",size:"large",children:e.jsx(u,{children:s?.CreateAt.toLocaleDateString()})})}),e.jsx("div",{className:a.box,children:e.jsx(c,{label:"Status",size:"large",children:e.jsx(u,{children:s?.Status})})})]}),e.jsxs("div",{className:a.flex,children:[e.jsx("div",{className:a.box,children:e.jsx(c,{label:"E-Mail",size:"large",children:e.jsx(u,{children:l?.EMail})})}),!n&&e.jsx("div",{className:a.box,children:e.jsx(c,{label:"Tracking Number",size:"large",children:e.jsx(u,{children:s?.TrackingNumber})})})]}),e.jsx(c,{label:"Address",size:"large",children:e.jsx(u,{children:l?.Address})})]})}const ne=D({body:{...H,alignItems:"flex-start"}});function ae({OrderId:r,Status:s,Refresh:n,ParentLog:a}){const j=w(()=>a.With("Action")),m=ne(),{Reload:l}=F(),{dispatch:o,dispatchToast:p}=A(j),{run:C}=f.Order.Post.useReceived({manual:!0,onError(g,t){o({Message:"Failed Mark Receive",Request:t,Error:g})},onSuccess(){p(e.jsx(v,{children:e.jsx(S,{children:"Order Received"})}),{intent:"success"}),n()}}),{run:y}=f.Order.Delete.useDelete({manual:!0,onError(g,t){o({Message:"Failed Delete Order",Request:t,Error:g})},onSuccess(){p(e.jsx(v,{children:e.jsx(S,{children:"Order Deleted"})}),{intent:"success"}),l("History")}});switch(s){case"Pending":case"Processing":case"Finished":case"Returning":return null}return e.jsx(c,{label:"Action",size:"large",children:e.jsxs("div",{className:m.body,children:[s==="Cancelled"&&e.jsx(N,{appearance:"subtle",onClick:()=>y(r),children:"Delete Order"}),s==="Shipping"&&e.jsx(N,{appearance:"subtle",onClick:()=>C(r),children:"I Received Order"})]})})}const le=D({body:{...P,justifyContent:"space-between"}});function te({OrderId:r,Status:s,Refresh:n,ParentLog:a}){const j=w(()=>a.With("Append")),m=le(),[l,o]=I.useState(),{dispatch:p,dispatchToast:C}=A(j),{run:y}=f.Order.Post.useAppend({manual:!0,onError(t,b){p({Message:"Failed Append Comment",Request:b,Error:t})},onSuccess(){C(e.jsx(v,{children:e.jsx(S,{children:"Comment Appended"})}),{intent:"success"}),n()}}),{run:g}=f.Order.Post.useCancel({manual:!0,onError(t,b){p({Message:"Failed Cancel Order",Request:b,Error:t})},onSuccess(){C(e.jsx(v,{children:e.jsx(S,{children:"Order Canceled"})}),{intent:"success"}),n()}});switch(s){case"Cancelled":case"Finished":return null}return e.jsxs(e.Fragment,{children:[e.jsx(c,{label:"Append",size:"large",children:e.jsx(L,{value:l,onChange:(t,b)=>o(b.value),maxLength:1e3})}),e.jsxs("div",{className:m.body,children:[!(s==="Finished"||s==="Returning")&&e.jsxs(N,{onClick:()=>g(r,l),children:[s==="Shipping"?"Ask Return":"Cancel Order"," with Reason"]}),e.jsx(N,{appearance:"primary",onClick:()=>y(r,l),children:"Add Comment"})]})]})}function ce({Comments:r}){return e.jsx(c,{label:"Comment",size:"large",children:r?.length===0?e.jsx(u,{children:"No Comment"}):r?.map((s,n)=>e.jsxs("div",{children:[e.jsxs(z,{children:[s.User," ",s.Time.toLocaleString()]}),e.jsx("br",{}),e.jsx(B,{children:s.Content})]},n))})}const O=D({body:{...H,rowGap:E.spacingVerticalL},prod:{...H,alignItems:"flex-start",justifyContent:"center"},qua:{flexBasis:"10%",flexGrow:0,justifyContent:"center"}}),de=[i({columnId:"Product",renderHeaderCell(){return e.jsx(d,{children:"Product Name & Types"})},renderCell(r){return e.jsxs(h,{className:O().prod,children:[e.jsx(J,{href:`/Product/${r.ProdId}`,appearance:"subtle",children:e.jsx(_,{children:r.Name})}),e.jsx(K,{children:Object.values(r.Type).reduce((s,n)=>`${s} ${n},`,"")})]})}}),i({columnId:"Quantity",renderHeaderCell(){return e.jsx(d,{className:O().qua,children:"Quantity"})},renderCell(r){return e.jsx(h,{className:O().qua,children:r.Quantity})}})];function ie({OrderId:r,ParentLog:s}){const n=w(()=>s.With("Detail")),a=O(),[j,{setTrue:m,setFalse:l}]=M(),{Nav:o,Paths:p}=F(),C=parseInt(p.at(1)),{data:y,run:g}=R(()=>f.Order.Get.Detail(r,n),{manual:!0,onError:n.error}),{data:t,run:b}=R(()=>f.Order.Get.Order(r),{onError(G){o("History"),n.error(G)},manual:!0});function T(){b(),g()}return I.useEffect(()=>{C===r?(T(),m()):l()},[C]),e.jsxs(e.Fragment,{children:[e.jsx(N,{appearance:"subtle",icon:e.jsx($,{}),onClick:()=>o("History",r)}),e.jsxs(q,{open:j,position:"end",size:"medium",modalType:"alert",children:[e.jsx(Q,{children:e.jsx(U,{action:e.jsx(N,{appearance:"subtle",icon:e.jsx(W,{}),onClick:()=>o("History")}),children:"Order Detail"})}),e.jsx(V,{children:e.jsxs("div",{className:a.body,children:[e.jsx(se,{OrderId:r,Order:t}),e.jsx(Z,{Items:y?.ShopCart,Columns:[ee(44,n),...de]}),e.jsx(ce,{Comments:y?.Comments}),e.jsx(te,{OrderId:r,Status:t?.Status,Refresh:T,ParentLog:n}),e.jsx(ae,{OrderId:r,Status:t?.Status,Refresh:T,ParentLog:n})]})})]})]})}const x=D({five:{flexBasis:"5%",flexGrow:0},ten:{flexBasis:"10%",flexGrow:0},two:{flexBasis:"2.5%",flexGrow:0}}),oe=[i({columnId:"OrderId",renderHeaderCell:()=>e.jsx(d,{className:x().five,children:"Order Id"}),renderCell(r){return e.jsx(h,{className:x().five,children:r.Id})}}),i({columnId:"Products",renderHeaderCell:()=>e.jsx(d,{children:"Products"}),renderCell(r){return e.jsxs(h,{children:[r.Items[0]," ",r.Items.length>1&&`& +${r.Items.length-1}`]})}}),i({columnId:"OrderDate",renderHeaderCell:()=>e.jsx(d,{children:"Order Date"}),renderCell(r){return e.jsx(d,{children:r.OrderDate.toLocaleDateString()})}}),i({columnId:"TrackNumber",renderHeaderCell:()=>e.jsx(d,{children:"Track Number"}),renderCell(r){return e.jsx(h,{children:r.TrackNumber})}}),i({columnId:"Quantity",renderHeaderCell:()=>e.jsx(d,{className:x().ten,children:"Quantity"}),renderCell(r){return e.jsx(h,{className:x().ten,children:r.Quantity})}}),i({columnId:"Status",renderHeaderCell:()=>e.jsx(d,{className:x().ten,children:"Order State"}),renderCell(r){return e.jsx(h,{className:x().ten,children:r.Status})}})];function he(r){return[...oe,i({columnId:"Detail",renderHeaderCell:()=>e.jsx(d,{className:x().two,children:"Detail"}),renderCell(s){return e.jsx(h,{className:x().two,children:e.jsx(ie,{OrderId:s.Id,ParentLog:r})})}})]}export{he as H,se as O,ce as a}; +import{m as D,t as E,x as R,j as e,F as c,L as u,y as w,T as v,b as S,B as N,r as I,ah as L,aN as z,aO as B,o as M,aG as $,ac as q,ad as Q,ae as U,af as W,ag as V,a5 as i,a6 as d,a7 as h,J,a8 as _,a9 as K}from"./vendor-DpqXKvKY.js";import{L as X,F as P,a as H,A as Y,H as f,c as F,e as A,f as Z,M as ee}from"./index-7dlI38O5.js";const re=D({flex:P,box:{...H,flexBasis:"50%",rowGap:E.spacingVerticalM}}),k=new X("Order","Info");function se({OrderId:r,Order:s,Admin:n}){const a=re(),{data:j}=R(()=>Y.User.Get.OrderUser(r),{manual:!n,onError:k.error}),m=f.User.Get.useMe(k),l=n?j:m;return e.jsxs(e.Fragment,{children:[e.jsxs("div",{className:a.flex,children:[e.jsx("div",{className:a.box,children:e.jsx(c,{label:"Name",size:"large",children:e.jsx(u,{children:l?.Name})})}),e.jsx("div",{className:a.box,children:e.jsx(c,{label:"Phone",size:"large",children:e.jsx(u,{children:l?.Phone})})})]}),e.jsxs("div",{className:a.flex,children:[e.jsx("div",{className:a.box,children:e.jsx(c,{label:"Order Date",size:"large",children:e.jsx(u,{children:s?.CreateAt.toLocaleDateString()})})}),e.jsx("div",{className:a.box,children:e.jsx(c,{label:"Status",size:"large",children:e.jsx(u,{children:s?.Status})})})]}),e.jsxs("div",{className:a.flex,children:[e.jsx("div",{className:a.box,children:e.jsx(c,{label:"E-Mail",size:"large",children:e.jsx(u,{children:l?.EMail})})}),!n&&e.jsx("div",{className:a.box,children:e.jsx(c,{label:"Tracking Number",size:"large",children:e.jsx(u,{children:s?.TrackingNumber})})})]}),e.jsx(c,{label:"Address",size:"large",children:e.jsx(u,{children:l?.Address})})]})}const ne=D({body:{...H,alignItems:"flex-start"}});function ae({OrderId:r,Status:s,Refresh:n,ParentLog:a}){const j=w(()=>a.With("Action")),m=ne(),{Reload:l}=F(),{dispatch:o,dispatchToast:p}=A(j),{run:C}=f.Order.Post.useReceived({manual:!0,onError(g,t){o({Message:"Failed Mark Receive",Request:t,Error:g})},onSuccess(){p(e.jsx(v,{children:e.jsx(S,{children:"Order Received"})}),{intent:"success"}),n()}}),{run:y}=f.Order.Delete.useDelete({manual:!0,onError(g,t){o({Message:"Failed Delete Order",Request:t,Error:g})},onSuccess(){p(e.jsx(v,{children:e.jsx(S,{children:"Order Deleted"})}),{intent:"success"}),l("History")}});switch(s){case"Pending":case"Processing":case"Finished":case"Returning":return null}return e.jsx(c,{label:"Action",size:"large",children:e.jsxs("div",{className:m.body,children:[s==="Cancelled"&&e.jsx(N,{appearance:"subtle",onClick:()=>y(r),children:"Delete Order"}),s==="Shipping"&&e.jsx(N,{appearance:"subtle",onClick:()=>C(r),children:"I Received Order"})]})})}const le=D({body:{...P,justifyContent:"space-between"}});function te({OrderId:r,Status:s,Refresh:n,ParentLog:a}){const j=w(()=>a.With("Append")),m=le(),[l,o]=I.useState(),{dispatch:p,dispatchToast:C}=A(j),{run:y}=f.Order.Post.useAppend({manual:!0,onError(t,b){p({Message:"Failed Append Comment",Request:b,Error:t})},onSuccess(){C(e.jsx(v,{children:e.jsx(S,{children:"Comment Appended"})}),{intent:"success"}),n()}}),{run:g}=f.Order.Post.useCancel({manual:!0,onError(t,b){p({Message:"Failed Cancel Order",Request:b,Error:t})},onSuccess(){C(e.jsx(v,{children:e.jsx(S,{children:"Order Canceled"})}),{intent:"success"}),n()}});switch(s){case"Cancelled":case"Finished":return null}return e.jsxs(e.Fragment,{children:[e.jsx(c,{label:"Append",size:"large",children:e.jsx(L,{value:l,onChange:(t,b)=>o(b.value),maxLength:1e3})}),e.jsxs("div",{className:m.body,children:[!(s==="Finished"||s==="Returning")&&e.jsxs(N,{onClick:()=>g(r,l),children:[s==="Shipping"?"Ask Return":"Cancel Order"," with Reason"]}),e.jsx(N,{appearance:"primary",onClick:()=>y(r,l),children:"Add Comment"})]})]})}function ce({Comments:r}){return e.jsx(c,{label:"Comment",size:"large",children:r?.length===0?e.jsx(u,{children:"No Comment"}):r?.map((s,n)=>e.jsxs("div",{children:[e.jsxs(z,{children:[s.User," ",s.Time.toLocaleString()]}),e.jsx("br",{}),e.jsx(B,{children:s.Content})]},n))})}const O=D({body:{...H,rowGap:E.spacingVerticalL},prod:{...H,alignItems:"flex-start",justifyContent:"center"},qua:{flexBasis:"10%",flexGrow:0,justifyContent:"center"}}),de=[i({columnId:"Product",renderHeaderCell(){return e.jsx(d,{children:"Product Name & Types"})},renderCell(r){return e.jsxs(h,{className:O().prod,children:[e.jsx(J,{href:`/Product/${r.ProdId}`,appearance:"subtle",children:e.jsx(_,{children:r.Name})}),e.jsx(K,{children:Object.values(r.Type).reduce((s,n)=>`${s} ${n},`,"")})]})}}),i({columnId:"Quantity",renderHeaderCell(){return e.jsx(d,{className:O().qua,children:"Quantity"})},renderCell(r){return e.jsx(h,{className:O().qua,children:r.Quantity})}})];function ie({OrderId:r,ParentLog:s}){const n=w(()=>s.With("Detail")),a=O(),[j,{setTrue:m,setFalse:l}]=M(),{Nav:o,Paths:p}=F(),C=parseInt(p.at(1)),{data:y,run:g}=R(()=>f.Order.Get.Detail(r,n),{manual:!0,onError:n.error}),{data:t,run:b}=R(()=>f.Order.Get.Order(r),{onError(G){o("History"),n.error(G)},manual:!0});function T(){b(),g()}return I.useEffect(()=>{C===r?(T(),m()):l()},[C]),e.jsxs(e.Fragment,{children:[e.jsx(N,{appearance:"subtle",icon:e.jsx($,{}),onClick:()=>o("History",r)}),e.jsxs(q,{open:j,position:"end",size:"medium",modalType:"alert",children:[e.jsx(Q,{children:e.jsx(U,{action:e.jsx(N,{appearance:"subtle",icon:e.jsx(W,{}),onClick:()=>o("History")}),children:"Order Detail"})}),e.jsx(V,{children:e.jsxs("div",{className:a.body,children:[e.jsx(se,{OrderId:r,Order:t}),e.jsx(Z,{Items:y?.ShopCart,Columns:[ee(44,n),...de]}),e.jsx(ce,{Comments:y?.Comments}),e.jsx(te,{OrderId:r,Status:t?.Status,Refresh:T,ParentLog:n}),e.jsx(ae,{OrderId:r,Status:t?.Status,Refresh:T,ParentLog:n})]})})]})]})}const x=D({five:{flexBasis:"5%",flexGrow:0},ten:{flexBasis:"10%",flexGrow:0},two:{flexBasis:"2.5%",flexGrow:0}}),oe=[i({columnId:"OrderId",renderHeaderCell:()=>e.jsx(d,{className:x().five,children:"Order Id"}),renderCell(r){return e.jsx(h,{className:x().five,children:r.Id})}}),i({columnId:"Products",renderHeaderCell:()=>e.jsx(d,{children:"Products"}),renderCell(r){return e.jsxs(h,{children:[r.Items[0]," ",r.Items.length>1&&`& +${r.Items.length-1}`]})}}),i({columnId:"OrderDate",renderHeaderCell:()=>e.jsx(d,{children:"Order Date"}),renderCell(r){return e.jsx(d,{children:r.OrderDate.toLocaleDateString()})}}),i({columnId:"TrackNumber",renderHeaderCell:()=>e.jsx(d,{children:"Track Number"}),renderCell(r){return e.jsx(h,{children:r.TrackNumber})}}),i({columnId:"Quantity",renderHeaderCell:()=>e.jsx(d,{className:x().ten,children:"Quantity"}),renderCell(r){return e.jsx(h,{className:x().ten,children:r.Quantity})}}),i({columnId:"Status",renderHeaderCell:()=>e.jsx(d,{className:x().ten,children:"Order State"}),renderCell(r){return e.jsx(h,{className:x().ten,children:r.Status})}})];function he(r){return[...oe,i({columnId:"Detail",renderHeaderCell:()=>e.jsx(d,{className:x().two,children:"Detail"}),renderCell(s){return e.jsx(h,{className:x().two,children:e.jsx(ie,{OrderId:s.Id,ParentLog:r})})}})]}export{he as H,se as O,ce as a}; diff --git a/assets/Component-aAfnRv22.js b/assets/Component-4YKDN3nt.js similarity index 99% rename from assets/Component-aAfnRv22.js rename to assets/Component-4YKDN3nt.js index 8a9237d..c0f63e5 100644 --- a/assets/Component-aAfnRv22.js +++ b/assets/Component-4YKDN3nt.js @@ -1 +1 @@ -import{j as g,W as Te,_ as W,bE as ne,m as pe,s as Ie,r as N,b1 as ae,Q as we,R as Ae,B as je,bH as Le,V as $e}from"./vendor-DpqXKvKY.js";import{a as e,h as ue,i as he,j as de,C as xe,u as Pe,L as ke,b as Ye,T as Ke,I as fe,k as se,l as We,m as Se,n as ze,o as ve,p as He}from"./index-5nAmJIOp.js";import{L as Be}from"./LexicalNestedComposer-yIpoQP8r.js";import"./index-YSLnLPU4.js";function Je({cell:t,rows:s,cellCoordMap:c,updateCellsByID:a,onClose:C,updateTableNode:y,setSortingOptions:x,sortingOptions:n}){const j=c.get(t.id);if(!j)return null;const[_,w]=j,S=[];return t.type==="header"&&w===0&&(n&&n.x===_&&S.push(g.jsx(W,{onClick:()=>{x(null),C()},children:"Remove Sorting"})),(!n||n.x!==_||n.type==="descending")&&S.push(g.jsx(W,{onClick:()=>{x({type:"ascending",x:_}),C()},children:"Sort Ascending"})),(!n||n.x!==_||n.type==="ascending")&&S.push(g.jsx(W,{onClick:()=>{x({type:"descending",x:_}),C()},children:"Sort Descending"})),S.push(g.jsx(ne,{}))),g.jsxs(Te,{children:[g.jsx(W,{onClick:()=>{y(E=>{E.updateCellType(_,w,t.type==="normal"?"header":"normal")}),C()},children:t.type==="normal"?"Make header":"Remove header"}),g.jsx(W,{onClick:()=>{a([t.id],()=>{const E=e.$getRoot();E.clear(),E.append(e.$createParagraphNode())}),C()},children:"Clear Cell"}),g.jsx(ne,{}),S,g.jsx(W,{onClick:()=>{y(E=>{E.insertRowAt(w)}),C()},children:"Insert row above"}),g.jsx(W,{onClick:()=>{y(E=>{E.insertRowAt(w+1)}),C()},children:"Insert row below"}),g.jsx(ne,{}),g.jsx(W,{onClick:()=>{y(E=>{E.insertColumnAt(_)}),C()},children:"Insert column left"}),g.jsx(W,{onClick:()=>{y(E=>{E.insertColumnAt(_+1)}),C()},children:"Insert column right"}),g.jsx(ne,{}),s[0].cells.length!==1&&g.jsx(W,{onClick:()=>{y(E=>{E.deleteColumnAt(_)}),C()},children:"Delete column"}),s.length!==1&&g.jsx(W,{onClick:()=>{y(E=>{E.deleteRowAt(w)}),C()},children:"Delete row"}),g.jsx(W,{onClick:()=>{y(E=>{E.selectNext(),E.remove()}),C()},children:"Delete table"})]})}function Xe(t){return`


`}function Fe(t,s){const c=s.parseEditorState(t);let a=ue.get(t);if(!a){a=c.read(()=>he.$generateHtmlFromNodes(s,null));const C=c.read(()=>e.$getRoot().getTextContent());ue.set(t,a),de.set(t,C)}return a}function Ue({cellEditor:t}){const{cellEditorConfig:s,cellEditorPlugins:c}=N.useContext(xe);return!c||!s?null:g.jsx(Be.LexicalNestedComposer,{initialEditor:t,initialTheme:s.theme,initialNodes:s.nodes,skipCollabChecks:!0,children:c})}function qe({cell:t,cellCoordMap:s,cellEditor:c,isEditing:a,isSelected:C,isPrimarySelected:y,theme:x,updateCellsByID:n,updateTableNode:j,rows:_,setSortingOptions:w,sortingOptions:S}){const[E,Y]=N.useState(!1),u=t.type!=="normal",v=t.json,J=u?"th":"td",oe=t.width,P=s.get(t.id),z=S&&P&&P[0]===S.x&&P[1]===0;N.useEffect(()=>{(a||!y)&&Y(!1)},[a,y]);const H=Ge();return g.jsxs(J,{className:ae(x.tableCell,u&&x.tableCellHeader,C&&x.tableCellSelected),"data-id":t.id,tabIndex:-1,style:{width:oe},children:[y&&g.jsx("div",{className:ae(x.tableCellPrimarySelected,a&&x.tableCellEditing)}),y&&a?g.jsx(Ue,{cellEditor:c}):g.jsxs(g.Fragment,{children:[g.jsx("div",{className:H.prim,dangerouslySetInnerHTML:{__html:v?Fe(v,c):Xe(x)}}),g.jsx("div",{className:x.tableCellResizer,"data-table-resize":"true"})]}),y&&!a&&g.jsx("div",{className:x.tableCellActionButtonContainer,children:g.jsxs(we,{open:E,children:[g.jsx(Ae,{disableButtonEnhancement:!0,children:g.jsx(je,{size:"small",shape:"circular",className:H.btn,children:g.jsx(Le,{}),onClick:Q=>{Y(!E),Q.stopPropagation()}})}),g.jsx($e,{children:g.jsx(Je,{cell:t,updateCellsByID:n,onClose:()=>Y(!1),updateTableNode:j,cellCoordMap:s,rows:_,setSortingOptions:w,sortingOptions:S})})]})}),z&&g.jsx("div",{className:x.tableCellSortedIndicator})]})}const Ge=pe({prim:{position:"relative",zIndex:3},btn:{maxWidth:"unset",minWidth:"unset",...Ie.padding("4px")}}),X=[];function Qe(){const t=e.$createRangeSelection();return t.focus.set("root",e.$getRoot().getChildrenSize(),"element"),t}function ie(t,s){const c=t.querySelector(`[data-id=${s}]`);c&&c.focus()}function Ve(t){return t.nodeType===1&&t.hasAttribute("data-table-resize")}function ge(t){const s=t.getRootElement();return s?s.ownerDocument:document}function Ze(t,s,c,a){return s?!1:t===67?fe?c:a:!1}function et(t,s,c,a){return s?!1:t===88?fe?c:a:!1}function tt(t,s,c,a){return s?!1:t===86?fe?c:a:!1}function ce(t){let s=t;for(;s;){const c=s.getAttribute("data-id");if(c)return c;s=s.parentElement}return null}function nt(t){let s=t;for(;s;){if(s.nodeName==="TH"||s.nodeName==="TD")return s.getBoundingClientRect().width;s=s.parentElement}return 0}function G(t,s,c,a,C,y){for(const x of s){const n=re(t,x,c);if(n&&a){const j=a.parseEditorState(n.json);a._headless=!0,a.setEditorState(j),a.update(y,{discrete:!0}),a._headless=!1;const _=JSON.stringify(a.getEditorState());C(w=>{const[S,E]=c.get(x);w.updateCellJSON(S,E,_)})}}}function st(t){let s=t;for(;s;){const c=s.nodeName;if(c==="BUTTON"||c==="INPUT"||c==="TEXTAREA")return!0;s=s.parentElement}return!1}function Re(t,s,c){const a=c.get(t),C=c.get(s);if(!a||!C)return null;const y=Math.min(a[0],C[0]),x=Math.max(a[0],C[0]),n=Math.min(a[1],C[1]),j=Math.max(a[1],C[1]);return{endX:x,endY:j,startX:y,startY:n}}function Ce(t,s,c,a){const C=Re(s,c,a);if(!C)return[];const{startX:y,endY:x,endX:n,startY:j}=C,_=[];for(let w=y;w<=n;w++)for(let S=j;S<=x;S++)_.push(t[S].cells[w].id);return _}function rt(t,s){const{startX:c,endY:a,endX:C,startY:y}=s,x=[];for(let n=y;n<=a;n++){const j=t[n],_=Se();for(let w=c;w<=C;w++){const S={...j.cells[w]};S.id=ze(),_.cells.push(S)}x.push(_)}return x}function re(t,s,c){const a=c.get(s);if(!a)return null;const[C,y]=a;return t[y].cells[C]}function ot(t){const s=t.querySelectorAll("tr"),c=[];for(let a=0;a{const i=new Map;for(let R=0;R{if(!J)return s;const i=s.slice(1);return i.sort((R,L)=>{const A=R.cells,m=L.cells,b=J.x,k=de.get(A[b].json),T=de.get(m[b].json);return!k||!T?1:J.type==="ascending"?k.localeCompare(T):T.localeCompare(k)}),i.unshift(s[0]),i},[s,J]),M=N.useMemo(()=>{if(!x)return null;const i=e.createEditor({namespace:x.namespace,nodes:x.nodes,onError:R=>x.onError(R,i),theme:x.theme});return i},[x]),me=N.useMemo(()=>new Set(P),[P]),$=N.useCallback(i=>{n.update(()=>{const R=e.$getNodeByKey(t);lt(R)&&i(R)})},[n,t]),F=N.useCallback((i,R,L)=>{const A=O[R].cells[i].id;if(S.current=A,L){const m=Ce(O,u,A,D);z(m)}else v(A),z(X),ie(E.current,A)},[D,u,O]),q=N.useCallback(()=>{if(M&&u){const i=JSON.stringify(M.getEditorState());$(R=>{const L=D.get(u);if(L===void 0)return;const[A,m]=L;R.updateCellJSON(A,m,i)})}},[D,M,u,$]),V=N.useCallback(()=>{setTimeout(()=>{const i=n.getRootElement();i&&(i.focus({preventScroll:!0}),window.getSelection()?.removeAllRanges())},20)},[n]),le=N.useCallback((i,R)=>{G(O,i,D,M,$,R)},[D,M,O,$]),Z=N.useCallback(()=>u&&!I?(le([u,...P],()=>{const i=e.$getRoot();i.clear(),i.append(e.$createParagraphNode())}),!0):(a&&$(i=>{i.selectNext(),i.remove()}),!1),[I,a,u,P,le,$]);N.useEffect(()=>{const i=E.current;a&&document.activeElement===document.body&&i&&i.focus()},[a]),N.useEffect(()=>{const i=E.current;if(!i)return;const R=ge(n);function L(T){const r=T.clientX-m.x,o=T.clientY-m.y;return r<5||o<5}function A(T){const r=ce(T.target);if(r&&n.isEditable()&&i.contains(T.target)){if(L(T)){C(!0),v(null),V();return}if(C(!1),Ve(T.target)){Q(r),i.style.userSelect="none",j.current={point:T.clientX,size:nt(T.target)};return}Y.current=!0,u!==r?(I&&q(),v(r),U(!1),S.current=r):S.current=null,z(X)}else u&&!st(T.target)&&(C(!1),Y.current=!1,I&&q(),v(null),z(X),U(!1),S.current=null)}const m=i.getBoundingClientRect();function b(T){if(H){const o=_.current;if(o){const{size:l,point:d}=j.current,p=T.clientX-d,h=l+p;let f=T.clientX-m.x;f<10?f=10:f>m.width-10?f=m.width-10:h<20&&(f=d-l+20-m.x),o.style.left=`${f}px`}return}if(!I){const{clientX:o,clientY:l}=T,{width:d,x:p,y:h,height:f}=m,B=o>p+d*.9&&oh+f*.85&&l{const[h]=D.get(H);p.updateColumnWidth(h,d)}),Q(null)}i&&P.length>1&&Y.current&&(i.style.userSelect="text",window.getSelection()?.removeAllRanges()),Y.current=!1}return R.addEventListener("pointerdown",A),R.addEventListener("pointermove",b),R.addEventListener("pointerup",k),()=>{R.removeEventListener("pointerdown",A),R.removeEventListener("pointermove",b),R.removeEventListener("pointerup",k)}},[M,n,I,O,q,u,me,P,D,H,$,C,V]),N.useEffect(()=>{if(!I&&u){let i=function(m){if(m&&M){const b=m.json,k=M.parseEditorState(b);M.setEditorState(k)}},R=function(m){const b=ce(m.target);if(b===u&&n.isEditable()){const k=re(O,b,D);i(k),U(!0),z(X)}},L=function(m){const b=m.keyCode;if(b===16||b===27||b===9||b===37||b===38||b===39||b===40||b===8||b===46||!n.isEditable())return;if(b===13&&m.preventDefault(),!I&&u&&n.getEditorState().read(()=>!e.$getSelection())&&m.target.contentEditable!=="true"){if(Ze(b,m.shiftKey,m.metaKey,m.ctrlKey)){n.dispatchCommand(e.COPY_COMMAND,m);return}if(et(b,m.shiftKey,m.metaKey,m.ctrlKey)){n.dispatchCommand(e.CUT_COMMAND,m);return}if(tt(b,m.shiftKey,m.metaKey,m.ctrlKey)){n.dispatchCommand(e.PASTE_COMMAND,m);return}}if(m.metaKey||m.ctrlKey||m.altKey)return;const k=re(O,u,D);i(k),U(!0),z(X)};const A=ge(n);return A.addEventListener("dblclick",R),A.addEventListener("keydown",L),()=>{A.removeEventListener("dblclick",R),A.removeEventListener("keydown",L)}}},[M,n,I,O,u,D]),N.useEffect(()=>{const i=E.current;if(!i)return;function R(r,o,l,d){const p=r instanceof KeyboardEvent?null:r.clipboardData;if(r.preventDefault(),p)p.setData("text/html",o),p.setData("text/plain",d),p.setData("application/x-lexical-editor",l);else{const h=navigator.clipboard;if(h){const f=[new ClipboardItem({"text/html":new Blob([o],{type:"text/html"})})];h.write(f)}}}async function L(r,o){try{return r instanceof DataTransfer?r.getData(o):r instanceof ClipboardItem?await(await r.getType(o)).text():""}catch{return""}}async function A(r){let o=(r instanceof InputEvent?null:r.clipboardData)||null;if(u&&M){if(r.preventDefault(),!o)try{o=(await navigator.clipboard.read())[0]}catch{}const l=o?await L(o,"application/x-lexical-editor"):"";if(l)try{const h=JSON.parse(l);if(h.namespace===n._config.namespace&&Array.isArray(h.nodes)){G(O,[u],D,M,$,()=>{const f=e.$getRoot();f.clear(),f.append(e.$createParagraphNode()),f.selectEnd();const B=se.$generateNodesFromSerializedNodes(h.nodes),K=e.$getSelection();e.$isRangeSelection(K)&&se.$insertGeneratedNodes(M,B,K)});return}}catch{}const d=o?await L(o,"text/html"):"";if(d)try{const f=new DOMParser().parseFromString(d,"text/html"),B=f.querySelector("table");if(B){const K=ot(B);$(ee=>{const[te,_e]=D.get(u);ee.mergeRows(te,_e,K)});return}G(O,[u],D,M,$,()=>{const K=e.$getRoot();K.clear(),K.append(e.$createParagraphNode()),K.selectEnd();const ee=he.$generateNodesFromDOM(n,f),te=e.$getSelection();e.$isRangeSelection(te)&&se.$insertGeneratedNodes(M,ee,te)});return}catch{}const p=o?await L(o,"text/plain"):"";p&&G(O,[u],D,M,$,()=>{const h=e.$getRoot();h.clear(),h.selectEnd();const f=e.$getSelection();f&&f.insertRawText(p)})}}function m(r){if(u&&M){const l=re(O,u,D).json,d=ue.get(l)||null;if(!d)return;const p=M.parseEditorState(l),h=p.read(()=>e.$getRoot().getTextContent()),f=p.read(()=>JSON.stringify(se.$generateJSONFromSelectedNodes(M,null)));R(r,d,f,h)}}function b(r){const o=S.current;if(u&&M&&o){const l=Re(u,o,D);if(!l)return;const d=We(O,l),p=d.outerHTML,h=d.outerText,f=n.getEditorState().read(()=>e.$getNodeByKey(t).exportJSON());f.rows=rt(O,l);const B={namespace:M._config.namespace,nodes:[f]},K=JSON.stringify(B);R(r,p,K,h)}}function k(r,o){const l=e.$getSelection();return u&&!I&&!l&&o===n?(A(r),Y.current=!1,z(X),!0):!1}function T(r,o){const l=e.$getSelection();return u&&!I&&!l&&o===n?(P.length===0?m(r):b(r),!0):!1}return Ye.mergeRegister(n.registerCommand(e.CLICK_COMMAND,r=>{const o=e.$getSelection();return!!e.$isNodeSelection(o)},e.COMMAND_PRIORITY_LOW),n.registerCommand(e.PASTE_COMMAND,k,e.COMMAND_PRIORITY_LOW),n.registerCommand(e.COPY_COMMAND,T,e.COMMAND_PRIORITY_LOW),n.registerCommand(e.CUT_COMMAND,(r,o)=>T(r,o)?(Z(),!0):!1,e.COMMAND_PRIORITY_LOW),n.registerCommand(e.KEY_BACKSPACE_COMMAND,Z,e.COMMAND_PRIORITY_LOW),n.registerCommand(e.KEY_DELETE_COMMAND,Z,e.COMMAND_PRIORITY_LOW),n.registerCommand(e.FORMAT_TEXT_COMMAND,r=>u&&!I?(G(O,[u,...P],D,M,$,()=>{Qe().formatText(r)}),!0):!1,e.COMMAND_PRIORITY_LOW),n.registerCommand(e.KEY_ENTER_COMMAND,(r,o)=>{const l=e.$getSelection();if(!u&&!I&&e.$isNodeSelection(l)&&l.has(t)&&l.getNodes().length===1&&o===n){const d=O[0].cells[0].id;return v(d),ie(i,d),r.preventDefault(),r.stopPropagation(),y(),!0}return!1},e.COMMAND_PRIORITY_LOW),n.registerCommand(e.KEY_TAB_COMMAND,r=>{const o=e.$getSelection();if(!I&&!o&&u){const l=r.shiftKey,[d,p]=D.get(u);r.preventDefault();let h=null,f=null;if(d===0&&l?p!==0&&(f=p-1,h=O[f].cells.length-1):d===O[p].cells.length-1&&!l?p!==O.length-1&&(f=p+1,h=0):l?(h=d-1,f=p):(h=d+1,f=p),h&&f)return F(h,f,!1),!0}return!1},e.COMMAND_PRIORITY_LOW),n.registerCommand(e.KEY_ARROW_UP_COMMAND,(r,o)=>{const l=e.$getSelection();if(!I&&!l){const d=r.shiftKey,p=d&&S.current||u;if(p){const[h,f]=D.get(p);if(f!==0)return F(h,f-1,d),!0}}return!e.$isRangeSelection(l)||o!==M?!1:l.isCollapsed()&&!l.anchor.getNode().getTopLevelElementOrThrow().getPreviousSibling()?(r.preventDefault(),!0):!1},e.COMMAND_PRIORITY_LOW),n.registerCommand(e.KEY_ARROW_DOWN_COMMAND,(r,o)=>{const l=e.$getSelection();if(!I&&!l){const d=r.shiftKey,p=d&&S.current||u;if(p){const[h,f]=D.get(p);if(f!==O.length-1)return F(h,f+1,d),!0}}return!e.$isRangeSelection(l)||o!==M?!1:l.isCollapsed()&&!l.anchor.getNode().getTopLevelElementOrThrow().getNextSibling()?(r.preventDefault(),!0):!1},e.COMMAND_PRIORITY_LOW),n.registerCommand(e.KEY_ARROW_LEFT_COMMAND,(r,o)=>{const l=e.$getSelection();if(!I&&!l){const d=r.shiftKey,p=d&&S.current||u;if(p){const[h,f]=D.get(p);if(h!==0)return F(h-1,f,d),!0}}return!e.$isRangeSelection(l)||o!==M?!1:l.isCollapsed()&&l.anchor.offset===0?(r.preventDefault(),!0):!1},e.COMMAND_PRIORITY_LOW),n.registerCommand(e.KEY_ARROW_RIGHT_COMMAND,(r,o)=>{const l=e.$getSelection();if(!I&&!l){const d=r.shiftKey,p=d&&S.current||u;if(p){const[h,f]=D.get(p);if(h!==O[f].cells.length-1)return F(h+1,f,d),!0}}if(!e.$isRangeSelection(l)||o!==M)return!1;if(l.isCollapsed()){const d=l.anchor;if(d.type==="text"&&d.offset===d.getNode().getTextContentSize()||d.type==="element"&&d.offset===d.getNode().getChildrenSize())return r.preventDefault(),!0}return!1},e.COMMAND_PRIORITY_LOW),n.registerCommand(e.KEY_ESCAPE_COMMAND,(r,o)=>{const l=e.$getSelection();return!I&&!l&&o===n?(C(!0),v(null),V(),!0):e.$isRangeSelection(l)&&I?(q(),U(!1),u&&setTimeout(()=>{ie(i,u)},20),!0):!1},e.COMMAND_PRIORITY_LOW))},[D,M,Z,y,n,I,F,t,u,O,q,V,P,C,$]);function be(){$(i=>{i.addColumns(1)})}function De(){$(i=>{i.addRows(1)})}if(!M)return null;const Oe=it();return g.jsxs("div",{className:Oe.box,children:[g.jsx("table",{className:ae(c.table,a&&c.tableSelected),ref:E,tabIndex:-1,children:g.jsx("tbody",{children:O.map(i=>g.jsx("tr",{className:c.tableRow,children:i.cells.map(R=>{const{id:L}=R;return g.jsx(qe,{cell:R,theme:c,isSelected:me.has(L),isPrimarySelected:u===L,isEditing:I,sortingOptions:J,cellEditor:M,updateCellsByID:le,updateTableNode:$,cellCoordMap:D,rows:O,setSortingOptions:oe},L)})},i.id))})}),ye&&g.jsx("button",{className:c.tableAddColumns,onClick:be}),Ee&&g.jsx("button",{className:c.tableAddRows,onClick:De,ref:w}),H&&g.jsx("div",{className:c.tableResizeRuler,ref:_})]})}const it=pe({box:{position:"relative"}});export{ft as default}; +import{j as g,W as Te,_ as W,bE as ne,m as pe,s as Ie,r as N,b1 as ae,Q as we,R as Ae,B as je,bH as Le,V as $e}from"./vendor-DpqXKvKY.js";import{a as e,h as ue,i as he,j as de,C as xe,u as Pe,L as ke,b as Ye,T as Ke,I as fe,k as se,l as We,m as Se,n as ze,o as ve,p as He}from"./index-qK3m2KiI.js";import{L as Be}from"./LexicalNestedComposer-zwgIQe1H.js";import"./index-7dlI38O5.js";function Je({cell:t,rows:s,cellCoordMap:c,updateCellsByID:a,onClose:C,updateTableNode:y,setSortingOptions:x,sortingOptions:n}){const j=c.get(t.id);if(!j)return null;const[_,w]=j,S=[];return t.type==="header"&&w===0&&(n&&n.x===_&&S.push(g.jsx(W,{onClick:()=>{x(null),C()},children:"Remove Sorting"})),(!n||n.x!==_||n.type==="descending")&&S.push(g.jsx(W,{onClick:()=>{x({type:"ascending",x:_}),C()},children:"Sort Ascending"})),(!n||n.x!==_||n.type==="ascending")&&S.push(g.jsx(W,{onClick:()=>{x({type:"descending",x:_}),C()},children:"Sort Descending"})),S.push(g.jsx(ne,{}))),g.jsxs(Te,{children:[g.jsx(W,{onClick:()=>{y(E=>{E.updateCellType(_,w,t.type==="normal"?"header":"normal")}),C()},children:t.type==="normal"?"Make header":"Remove header"}),g.jsx(W,{onClick:()=>{a([t.id],()=>{const E=e.$getRoot();E.clear(),E.append(e.$createParagraphNode())}),C()},children:"Clear Cell"}),g.jsx(ne,{}),S,g.jsx(W,{onClick:()=>{y(E=>{E.insertRowAt(w)}),C()},children:"Insert row above"}),g.jsx(W,{onClick:()=>{y(E=>{E.insertRowAt(w+1)}),C()},children:"Insert row below"}),g.jsx(ne,{}),g.jsx(W,{onClick:()=>{y(E=>{E.insertColumnAt(_)}),C()},children:"Insert column left"}),g.jsx(W,{onClick:()=>{y(E=>{E.insertColumnAt(_+1)}),C()},children:"Insert column right"}),g.jsx(ne,{}),s[0].cells.length!==1&&g.jsx(W,{onClick:()=>{y(E=>{E.deleteColumnAt(_)}),C()},children:"Delete column"}),s.length!==1&&g.jsx(W,{onClick:()=>{y(E=>{E.deleteRowAt(w)}),C()},children:"Delete row"}),g.jsx(W,{onClick:()=>{y(E=>{E.selectNext(),E.remove()}),C()},children:"Delete table"})]})}function Xe(t){return`


`}function Fe(t,s){const c=s.parseEditorState(t);let a=ue.get(t);if(!a){a=c.read(()=>he.$generateHtmlFromNodes(s,null));const C=c.read(()=>e.$getRoot().getTextContent());ue.set(t,a),de.set(t,C)}return a}function Ue({cellEditor:t}){const{cellEditorConfig:s,cellEditorPlugins:c}=N.useContext(xe);return!c||!s?null:g.jsx(Be.LexicalNestedComposer,{initialEditor:t,initialTheme:s.theme,initialNodes:s.nodes,skipCollabChecks:!0,children:c})}function qe({cell:t,cellCoordMap:s,cellEditor:c,isEditing:a,isSelected:C,isPrimarySelected:y,theme:x,updateCellsByID:n,updateTableNode:j,rows:_,setSortingOptions:w,sortingOptions:S}){const[E,Y]=N.useState(!1),u=t.type!=="normal",v=t.json,J=u?"th":"td",oe=t.width,P=s.get(t.id),z=S&&P&&P[0]===S.x&&P[1]===0;N.useEffect(()=>{(a||!y)&&Y(!1)},[a,y]);const H=Ge();return g.jsxs(J,{className:ae(x.tableCell,u&&x.tableCellHeader,C&&x.tableCellSelected),"data-id":t.id,tabIndex:-1,style:{width:oe},children:[y&&g.jsx("div",{className:ae(x.tableCellPrimarySelected,a&&x.tableCellEditing)}),y&&a?g.jsx(Ue,{cellEditor:c}):g.jsxs(g.Fragment,{children:[g.jsx("div",{className:H.prim,dangerouslySetInnerHTML:{__html:v?Fe(v,c):Xe(x)}}),g.jsx("div",{className:x.tableCellResizer,"data-table-resize":"true"})]}),y&&!a&&g.jsx("div",{className:x.tableCellActionButtonContainer,children:g.jsxs(we,{open:E,children:[g.jsx(Ae,{disableButtonEnhancement:!0,children:g.jsx(je,{size:"small",shape:"circular",className:H.btn,children:g.jsx(Le,{}),onClick:Q=>{Y(!E),Q.stopPropagation()}})}),g.jsx($e,{children:g.jsx(Je,{cell:t,updateCellsByID:n,onClose:()=>Y(!1),updateTableNode:j,cellCoordMap:s,rows:_,setSortingOptions:w,sortingOptions:S})})]})}),z&&g.jsx("div",{className:x.tableCellSortedIndicator})]})}const Ge=pe({prim:{position:"relative",zIndex:3},btn:{maxWidth:"unset",minWidth:"unset",...Ie.padding("4px")}}),X=[];function Qe(){const t=e.$createRangeSelection();return t.focus.set("root",e.$getRoot().getChildrenSize(),"element"),t}function ie(t,s){const c=t.querySelector(`[data-id=${s}]`);c&&c.focus()}function Ve(t){return t.nodeType===1&&t.hasAttribute("data-table-resize")}function ge(t){const s=t.getRootElement();return s?s.ownerDocument:document}function Ze(t,s,c,a){return s?!1:t===67?fe?c:a:!1}function et(t,s,c,a){return s?!1:t===88?fe?c:a:!1}function tt(t,s,c,a){return s?!1:t===86?fe?c:a:!1}function ce(t){let s=t;for(;s;){const c=s.getAttribute("data-id");if(c)return c;s=s.parentElement}return null}function nt(t){let s=t;for(;s;){if(s.nodeName==="TH"||s.nodeName==="TD")return s.getBoundingClientRect().width;s=s.parentElement}return 0}function G(t,s,c,a,C,y){for(const x of s){const n=re(t,x,c);if(n&&a){const j=a.parseEditorState(n.json);a._headless=!0,a.setEditorState(j),a.update(y,{discrete:!0}),a._headless=!1;const _=JSON.stringify(a.getEditorState());C(w=>{const[S,E]=c.get(x);w.updateCellJSON(S,E,_)})}}}function st(t){let s=t;for(;s;){const c=s.nodeName;if(c==="BUTTON"||c==="INPUT"||c==="TEXTAREA")return!0;s=s.parentElement}return!1}function Re(t,s,c){const a=c.get(t),C=c.get(s);if(!a||!C)return null;const y=Math.min(a[0],C[0]),x=Math.max(a[0],C[0]),n=Math.min(a[1],C[1]),j=Math.max(a[1],C[1]);return{endX:x,endY:j,startX:y,startY:n}}function Ce(t,s,c,a){const C=Re(s,c,a);if(!C)return[];const{startX:y,endY:x,endX:n,startY:j}=C,_=[];for(let w=y;w<=n;w++)for(let S=j;S<=x;S++)_.push(t[S].cells[w].id);return _}function rt(t,s){const{startX:c,endY:a,endX:C,startY:y}=s,x=[];for(let n=y;n<=a;n++){const j=t[n],_=Se();for(let w=c;w<=C;w++){const S={...j.cells[w]};S.id=ze(),_.cells.push(S)}x.push(_)}return x}function re(t,s,c){const a=c.get(s);if(!a)return null;const[C,y]=a;return t[y].cells[C]}function ot(t){const s=t.querySelectorAll("tr"),c=[];for(let a=0;a{const i=new Map;for(let R=0;R{if(!J)return s;const i=s.slice(1);return i.sort((R,L)=>{const A=R.cells,m=L.cells,b=J.x,k=de.get(A[b].json),T=de.get(m[b].json);return!k||!T?1:J.type==="ascending"?k.localeCompare(T):T.localeCompare(k)}),i.unshift(s[0]),i},[s,J]),M=N.useMemo(()=>{if(!x)return null;const i=e.createEditor({namespace:x.namespace,nodes:x.nodes,onError:R=>x.onError(R,i),theme:x.theme});return i},[x]),me=N.useMemo(()=>new Set(P),[P]),$=N.useCallback(i=>{n.update(()=>{const R=e.$getNodeByKey(t);lt(R)&&i(R)})},[n,t]),F=N.useCallback((i,R,L)=>{const A=O[R].cells[i].id;if(S.current=A,L){const m=Ce(O,u,A,D);z(m)}else v(A),z(X),ie(E.current,A)},[D,u,O]),q=N.useCallback(()=>{if(M&&u){const i=JSON.stringify(M.getEditorState());$(R=>{const L=D.get(u);if(L===void 0)return;const[A,m]=L;R.updateCellJSON(A,m,i)})}},[D,M,u,$]),V=N.useCallback(()=>{setTimeout(()=>{const i=n.getRootElement();i&&(i.focus({preventScroll:!0}),window.getSelection()?.removeAllRanges())},20)},[n]),le=N.useCallback((i,R)=>{G(O,i,D,M,$,R)},[D,M,O,$]),Z=N.useCallback(()=>u&&!I?(le([u,...P],()=>{const i=e.$getRoot();i.clear(),i.append(e.$createParagraphNode())}),!0):(a&&$(i=>{i.selectNext(),i.remove()}),!1),[I,a,u,P,le,$]);N.useEffect(()=>{const i=E.current;a&&document.activeElement===document.body&&i&&i.focus()},[a]),N.useEffect(()=>{const i=E.current;if(!i)return;const R=ge(n);function L(T){const r=T.clientX-m.x,o=T.clientY-m.y;return r<5||o<5}function A(T){const r=ce(T.target);if(r&&n.isEditable()&&i.contains(T.target)){if(L(T)){C(!0),v(null),V();return}if(C(!1),Ve(T.target)){Q(r),i.style.userSelect="none",j.current={point:T.clientX,size:nt(T.target)};return}Y.current=!0,u!==r?(I&&q(),v(r),U(!1),S.current=r):S.current=null,z(X)}else u&&!st(T.target)&&(C(!1),Y.current=!1,I&&q(),v(null),z(X),U(!1),S.current=null)}const m=i.getBoundingClientRect();function b(T){if(H){const o=_.current;if(o){const{size:l,point:d}=j.current,p=T.clientX-d,h=l+p;let f=T.clientX-m.x;f<10?f=10:f>m.width-10?f=m.width-10:h<20&&(f=d-l+20-m.x),o.style.left=`${f}px`}return}if(!I){const{clientX:o,clientY:l}=T,{width:d,x:p,y:h,height:f}=m,B=o>p+d*.9&&oh+f*.85&&l{const[h]=D.get(H);p.updateColumnWidth(h,d)}),Q(null)}i&&P.length>1&&Y.current&&(i.style.userSelect="text",window.getSelection()?.removeAllRanges()),Y.current=!1}return R.addEventListener("pointerdown",A),R.addEventListener("pointermove",b),R.addEventListener("pointerup",k),()=>{R.removeEventListener("pointerdown",A),R.removeEventListener("pointermove",b),R.removeEventListener("pointerup",k)}},[M,n,I,O,q,u,me,P,D,H,$,C,V]),N.useEffect(()=>{if(!I&&u){let i=function(m){if(m&&M){const b=m.json,k=M.parseEditorState(b);M.setEditorState(k)}},R=function(m){const b=ce(m.target);if(b===u&&n.isEditable()){const k=re(O,b,D);i(k),U(!0),z(X)}},L=function(m){const b=m.keyCode;if(b===16||b===27||b===9||b===37||b===38||b===39||b===40||b===8||b===46||!n.isEditable())return;if(b===13&&m.preventDefault(),!I&&u&&n.getEditorState().read(()=>!e.$getSelection())&&m.target.contentEditable!=="true"){if(Ze(b,m.shiftKey,m.metaKey,m.ctrlKey)){n.dispatchCommand(e.COPY_COMMAND,m);return}if(et(b,m.shiftKey,m.metaKey,m.ctrlKey)){n.dispatchCommand(e.CUT_COMMAND,m);return}if(tt(b,m.shiftKey,m.metaKey,m.ctrlKey)){n.dispatchCommand(e.PASTE_COMMAND,m);return}}if(m.metaKey||m.ctrlKey||m.altKey)return;const k=re(O,u,D);i(k),U(!0),z(X)};const A=ge(n);return A.addEventListener("dblclick",R),A.addEventListener("keydown",L),()=>{A.removeEventListener("dblclick",R),A.removeEventListener("keydown",L)}}},[M,n,I,O,u,D]),N.useEffect(()=>{const i=E.current;if(!i)return;function R(r,o,l,d){const p=r instanceof KeyboardEvent?null:r.clipboardData;if(r.preventDefault(),p)p.setData("text/html",o),p.setData("text/plain",d),p.setData("application/x-lexical-editor",l);else{const h=navigator.clipboard;if(h){const f=[new ClipboardItem({"text/html":new Blob([o],{type:"text/html"})})];h.write(f)}}}async function L(r,o){try{return r instanceof DataTransfer?r.getData(o):r instanceof ClipboardItem?await(await r.getType(o)).text():""}catch{return""}}async function A(r){let o=(r instanceof InputEvent?null:r.clipboardData)||null;if(u&&M){if(r.preventDefault(),!o)try{o=(await navigator.clipboard.read())[0]}catch{}const l=o?await L(o,"application/x-lexical-editor"):"";if(l)try{const h=JSON.parse(l);if(h.namespace===n._config.namespace&&Array.isArray(h.nodes)){G(O,[u],D,M,$,()=>{const f=e.$getRoot();f.clear(),f.append(e.$createParagraphNode()),f.selectEnd();const B=se.$generateNodesFromSerializedNodes(h.nodes),K=e.$getSelection();e.$isRangeSelection(K)&&se.$insertGeneratedNodes(M,B,K)});return}}catch{}const d=o?await L(o,"text/html"):"";if(d)try{const f=new DOMParser().parseFromString(d,"text/html"),B=f.querySelector("table");if(B){const K=ot(B);$(ee=>{const[te,_e]=D.get(u);ee.mergeRows(te,_e,K)});return}G(O,[u],D,M,$,()=>{const K=e.$getRoot();K.clear(),K.append(e.$createParagraphNode()),K.selectEnd();const ee=he.$generateNodesFromDOM(n,f),te=e.$getSelection();e.$isRangeSelection(te)&&se.$insertGeneratedNodes(M,ee,te)});return}catch{}const p=o?await L(o,"text/plain"):"";p&&G(O,[u],D,M,$,()=>{const h=e.$getRoot();h.clear(),h.selectEnd();const f=e.$getSelection();f&&f.insertRawText(p)})}}function m(r){if(u&&M){const l=re(O,u,D).json,d=ue.get(l)||null;if(!d)return;const p=M.parseEditorState(l),h=p.read(()=>e.$getRoot().getTextContent()),f=p.read(()=>JSON.stringify(se.$generateJSONFromSelectedNodes(M,null)));R(r,d,f,h)}}function b(r){const o=S.current;if(u&&M&&o){const l=Re(u,o,D);if(!l)return;const d=We(O,l),p=d.outerHTML,h=d.outerText,f=n.getEditorState().read(()=>e.$getNodeByKey(t).exportJSON());f.rows=rt(O,l);const B={namespace:M._config.namespace,nodes:[f]},K=JSON.stringify(B);R(r,p,K,h)}}function k(r,o){const l=e.$getSelection();return u&&!I&&!l&&o===n?(A(r),Y.current=!1,z(X),!0):!1}function T(r,o){const l=e.$getSelection();return u&&!I&&!l&&o===n?(P.length===0?m(r):b(r),!0):!1}return Ye.mergeRegister(n.registerCommand(e.CLICK_COMMAND,r=>{const o=e.$getSelection();return!!e.$isNodeSelection(o)},e.COMMAND_PRIORITY_LOW),n.registerCommand(e.PASTE_COMMAND,k,e.COMMAND_PRIORITY_LOW),n.registerCommand(e.COPY_COMMAND,T,e.COMMAND_PRIORITY_LOW),n.registerCommand(e.CUT_COMMAND,(r,o)=>T(r,o)?(Z(),!0):!1,e.COMMAND_PRIORITY_LOW),n.registerCommand(e.KEY_BACKSPACE_COMMAND,Z,e.COMMAND_PRIORITY_LOW),n.registerCommand(e.KEY_DELETE_COMMAND,Z,e.COMMAND_PRIORITY_LOW),n.registerCommand(e.FORMAT_TEXT_COMMAND,r=>u&&!I?(G(O,[u,...P],D,M,$,()=>{Qe().formatText(r)}),!0):!1,e.COMMAND_PRIORITY_LOW),n.registerCommand(e.KEY_ENTER_COMMAND,(r,o)=>{const l=e.$getSelection();if(!u&&!I&&e.$isNodeSelection(l)&&l.has(t)&&l.getNodes().length===1&&o===n){const d=O[0].cells[0].id;return v(d),ie(i,d),r.preventDefault(),r.stopPropagation(),y(),!0}return!1},e.COMMAND_PRIORITY_LOW),n.registerCommand(e.KEY_TAB_COMMAND,r=>{const o=e.$getSelection();if(!I&&!o&&u){const l=r.shiftKey,[d,p]=D.get(u);r.preventDefault();let h=null,f=null;if(d===0&&l?p!==0&&(f=p-1,h=O[f].cells.length-1):d===O[p].cells.length-1&&!l?p!==O.length-1&&(f=p+1,h=0):l?(h=d-1,f=p):(h=d+1,f=p),h&&f)return F(h,f,!1),!0}return!1},e.COMMAND_PRIORITY_LOW),n.registerCommand(e.KEY_ARROW_UP_COMMAND,(r,o)=>{const l=e.$getSelection();if(!I&&!l){const d=r.shiftKey,p=d&&S.current||u;if(p){const[h,f]=D.get(p);if(f!==0)return F(h,f-1,d),!0}}return!e.$isRangeSelection(l)||o!==M?!1:l.isCollapsed()&&!l.anchor.getNode().getTopLevelElementOrThrow().getPreviousSibling()?(r.preventDefault(),!0):!1},e.COMMAND_PRIORITY_LOW),n.registerCommand(e.KEY_ARROW_DOWN_COMMAND,(r,o)=>{const l=e.$getSelection();if(!I&&!l){const d=r.shiftKey,p=d&&S.current||u;if(p){const[h,f]=D.get(p);if(f!==O.length-1)return F(h,f+1,d),!0}}return!e.$isRangeSelection(l)||o!==M?!1:l.isCollapsed()&&!l.anchor.getNode().getTopLevelElementOrThrow().getNextSibling()?(r.preventDefault(),!0):!1},e.COMMAND_PRIORITY_LOW),n.registerCommand(e.KEY_ARROW_LEFT_COMMAND,(r,o)=>{const l=e.$getSelection();if(!I&&!l){const d=r.shiftKey,p=d&&S.current||u;if(p){const[h,f]=D.get(p);if(h!==0)return F(h-1,f,d),!0}}return!e.$isRangeSelection(l)||o!==M?!1:l.isCollapsed()&&l.anchor.offset===0?(r.preventDefault(),!0):!1},e.COMMAND_PRIORITY_LOW),n.registerCommand(e.KEY_ARROW_RIGHT_COMMAND,(r,o)=>{const l=e.$getSelection();if(!I&&!l){const d=r.shiftKey,p=d&&S.current||u;if(p){const[h,f]=D.get(p);if(h!==O[f].cells.length-1)return F(h+1,f,d),!0}}if(!e.$isRangeSelection(l)||o!==M)return!1;if(l.isCollapsed()){const d=l.anchor;if(d.type==="text"&&d.offset===d.getNode().getTextContentSize()||d.type==="element"&&d.offset===d.getNode().getChildrenSize())return r.preventDefault(),!0}return!1},e.COMMAND_PRIORITY_LOW),n.registerCommand(e.KEY_ESCAPE_COMMAND,(r,o)=>{const l=e.$getSelection();return!I&&!l&&o===n?(C(!0),v(null),V(),!0):e.$isRangeSelection(l)&&I?(q(),U(!1),u&&setTimeout(()=>{ie(i,u)},20),!0):!1},e.COMMAND_PRIORITY_LOW))},[D,M,Z,y,n,I,F,t,u,O,q,V,P,C,$]);function be(){$(i=>{i.addColumns(1)})}function De(){$(i=>{i.addRows(1)})}if(!M)return null;const Oe=it();return g.jsxs("div",{className:Oe.box,children:[g.jsx("table",{className:ae(c.table,a&&c.tableSelected),ref:E,tabIndex:-1,children:g.jsx("tbody",{children:O.map(i=>g.jsx("tr",{className:c.tableRow,children:i.cells.map(R=>{const{id:L}=R;return g.jsx(qe,{cell:R,theme:c,isSelected:me.has(L),isPrimarySelected:u===L,isEditing:I,sortingOptions:J,cellEditor:M,updateCellsByID:le,updateTableNode:$,cellCoordMap:D,rows:O,setSortingOptions:oe},L)})},i.id))})}),ye&&g.jsx("button",{className:c.tableAddColumns,onClick:be}),Ee&&g.jsx("button",{className:c.tableAddRows,onClick:De,ref:w}),H&&g.jsx("div",{className:c.tableResizeRuler,ref:_})]})}const it=pe({box:{position:"relative"}});export{ft as default}; diff --git a/assets/Component-RuL62tq9.js b/assets/Component-uOG8IUJI.js similarity index 97% rename from assets/Component-RuL62tq9.js rename to assets/Component-uOG8IUJI.js index a8faf5b..6afbbf6 100644 --- a/assets/Component-RuL62tq9.js +++ b/assets/Component-uOG8IUJI.js @@ -1 +1 @@ -import{m as H,s as b,r as f,j as a,B as T,b1 as N}from"./vendor-DpqXKvKY.js";import{u as B,L as X,a as r,$,b as K,c as F,d as U,e as G,f as V,P as q,g as J}from"./index-5nAmJIOp.js";import{L as Q}from"./LexicalNestedComposer-yIpoQP8r.js";import"./index-YSLnLPU4.js";function k(h,C,p){return Math.min(Math.max(h,C),p)}const o={east:1,north:8,south:2,west:4};function Z({onResizeStart:h,onResizeEnd:C,buttonRef:p,imageRef:E,maxWidth:v,editor:S,showCaption:_,setShowCaption:M,captionsEnabled:z}){const O=f.useRef(null),y=f.useRef({priority:"",value:"default"}),P=f.useRef({currentHeight:0,currentWidth:0,direction:0,isResizing:!1,ratio:0,startHeight:0,startWidth:0,startX:0,startY:0}),l=S.getRootElement(),m=v||(l?l.getBoundingClientRect().width-20:100),j=l?l.getBoundingClientRect().height-20:100,L=100,A=100;function u(t){const n=t===o.east||t===o.west,s=t===o.north||t===o.south,w=t&o.north&&t&o.west||t&o.south&&t&o.east,g=n?"ew":s?"ns":w?"nwse":"nesw";l&&l.style.setProperty("cursor",`${g}-resize`,"important"),document.body&&(document.body.style.setProperty("cursor",`${g}-resize`,"important"),y.current.value=document.body.style.getPropertyValue("-webkit-user-select"),y.current.priority=document.body.style.getPropertyPriority("-webkit-user-select"),document.body.style.setProperty("-webkit-user-select","none","important"))}function I(){l&&l.style.setProperty("cursor","default"),document.body&&(document.body.style.setProperty("cursor","default"),document.body.style.setProperty("-webkit-user-select",y.current.value,y.current.priority))}function x(t,n){if(!S.isEditable())return;const s=E.current,w=O.current;if(s&&w){const{width:g,height:i}=s.getBoundingClientRect(),e=P.current;e.startWidth=g,e.startHeight=i,e.ratio=g/i,e.currentWidth=g,e.currentHeight=i,e.startX=t.clientX,e.startY=t.clientY,e.isResizing=!0,e.direction=n,u(n),h(),w.classList.add("image-control-wrapper--resizing"),s.style.height=`${i}px`,s.style.width=`${g}px`,document.addEventListener("pointermove",W),document.addEventListener("pointerup",D)}}function W(t){const n=E.current,s=P.current,w=s.direction&(o.east|o.west),g=s.direction&(o.south|o.north);if(n&&s.isResizing)if(w&&g){let i=Math.floor(s.startX-t.clientX);i=s.direction&o.east?-i:i;const e=k(s.startWidth+i,L,m),d=e/s.ratio;n.style.width=`${e}px`,n.style.height=`${d}px`,s.currentHeight=d,s.currentWidth=e}else if(g){let i=Math.floor(s.startY-t.clientY);i=s.direction&o.south?-i:i;const e=k(s.startHeight+i,A,j);n.style.height=`${e}px`,s.currentHeight=e}else{let i=Math.floor(s.startX-t.clientX);i=s.direction&o.east?-i:i;const e=k(s.startWidth+i,L,m);n.style.width=`${e}px`,s.currentWidth=e}}function D(){const t=E.current,n=P.current,s=O.current;if(t&&s&&n.isResizing){const w=n.currentWidth,g=n.currentHeight;n.startWidth=0,n.startHeight=0,n.ratio=0,n.startX=0,n.startY=0,n.currentWidth=0,n.currentHeight=0,n.isResizing=!1,s.classList.remove("image-control-wrapper--resizing"),I(),C(w,g),document.removeEventListener("pointermove",W),document.removeEventListener("pointerup",D)}}const c=ee();return a.jsxs("div",{ref:O,children:[!_&&z&&a.jsx(T,{className:c.button,ref:p,onClick:()=>M(!_),children:"Add Caption"}),a.jsx("div",{className:N(c.resizer,c.n),onPointerDown:t=>x(t,o.north)}),a.jsx("div",{className:N(c.resizer,c.ne),onPointerDown:t=>x(t,o.north|o.east)}),a.jsx("div",{className:N(c.resizer,c.e),onPointerDown:t=>x(t,o.east)}),a.jsx("div",{className:N(c.resizer,c.se),onPointerDown:t=>x(t,o.south|o.east)}),a.jsx("div",{className:N(c.resizer,c.s),onPointerDown:t=>x(t,o.south)}),a.jsx("div",{className:N(c.resizer,c.sw),onPointerDown:t=>x(t,o.south|o.west)}),a.jsx("div",{className:N(c.resizer,c.w),onPointerDown:t=>x(t,o.west)}),a.jsx("div",{className:N(c.resizer,c.nw),onPointerDown:t=>x(t,o.north|o.west)})]})}const ee=H({button:{minWidth:"unset",fontWeight:"unset",width:"fit-content",position:"absolute",bottom:"20px",marginLeft:"auto",left:0,right:0,...b.margin(0,"auto")},resizer:{display:"block",width:"7px",height:"7px",position:"absolute",backgroundColor:"rgb(60, 132, 244)",...b.border("1px","solid","#fff")},n:{top:"-6px",left:"48%",cursor:"n-resize"},ne:{top:"-6px",right:"-6px",cursor:"ne-resize"},e:{bottom:"48%",right:"-6px",cursor:"e-resize"},se:{bottom:"-2px",right:"-6px",cursor:"nwse-resize"},s:{bottom:"-2px",left:"48%",cursor:"s-resize"},sw:{bottom:"-2px",left:"-6px",cursor:"sw-resize"},w:{bottom:"48%",left:"-6px",cursor:"w-resize"},nw:{top:"-6px",left:"-6px",cursor:"nw-resize"}}),te=H({caption:{display:"block",position:"absolute",bottom:"4px",left:0,right:0,...b.padding(0),...b.margin(0),...b.borderTop("1px","solid","#fff"),backgroundColor:"rgba(255, 255, 255, 0.9)",minWidth:"100px",color:"#000",...b.overflow("hidden")},content:{minHeight:"20px",...b.border(0),resize:"none",cursor:"text",caretColor:"rgb(5, 5, 5)",display:"block",position:"relative",tabSize:1,...b.outline(0),...b.padding("10px"),userSelect:"text",fontSize:"12px",width:"calc(100% - 20px)",whiteSpace:"pre-wrap",wordBreak:"break-word"},placeholder:{fontSize:"12px",color:"#888",...b.overflow("hidden"),position:"absolute",textOverflow:"ellipsis",top:"10px",left:"10px",userSelect:"none",whiteSpace:"nowrap",display:"inline-block",pointerEvents:"none"}}),Y=new Set;function se(h){if(!Y.has(h))throw new Promise(C=>{const p=new Image;p.src=h,p.onload=()=>{Y.add(h),C(null)}})}function re({altText:h,className:C,imageRef:p,src:E,width:v,height:S,maxWidth:_}){return se(E),a.jsx("img",{className:C||void 0,src:E,alt:h,ref:p,style:{height:S,maxWidth:_,width:v},draggable:"false"})}function ce({src:h,altText:C,nodeKey:p,width:E,height:v,maxWidth:S,resizable:_,showCaption:M,caption:z,captionsEnabled:O}){const y=f.useRef(null),P=f.useRef(null),[l,m,j]=B.useLexicalNodeSelection(p),[L,A]=f.useState(!1),[u]=X.useLexicalComposerContext(),[I,x]=f.useState(null),W=f.useRef(null),D=f.useCallback(e=>{if(l&&r.$isNodeSelection(r.$getSelection())){e.preventDefault();const R=r.$getNodeByKey(p);$(R)&&R.remove(),m(!1)}return!1},[l,p,m]),c=f.useCallback(e=>{const d=r.$getSelection(),R=P.current;if(l&&r.$isNodeSelection(d)&&d.getNodes().length===1){if(M)return r.$setSelection(null),e.preventDefault(),z.focus(),!0;if(R!==null&&R!==document.activeElement)return e.preventDefault(),R.focus(),!0}return!1},[z,l,M]),t=f.useCallback(e=>W.current===z||P.current===e.target?(r.$setSelection(null),u.update(()=>{m(!0);const d=u.getRootElement();d!==null&&d.focus()}),!0):!1,[z,u,m]);f.useEffect(()=>K.mergeRegister(u.registerUpdateListener(({editorState:e})=>{x(e.read(()=>r.$getSelection()))}),u.registerCommand(r.SELECTION_CHANGE_COMMAND,(e,d)=>(W.current=d,!1),r.COMMAND_PRIORITY_LOW),u.registerCommand(r.CLICK_COMMAND,e=>{const d=e;return L?!0:d.target===y.current?(d.shiftKey?m(!l):(j(),m(!0)),!0):!1},r.COMMAND_PRIORITY_LOW),u.registerCommand(r.DRAGSTART_COMMAND,e=>e.target===y.current?(e.preventDefault(),!0):!1,r.COMMAND_PRIORITY_LOW),u.registerCommand(r.KEY_DELETE_COMMAND,D,r.COMMAND_PRIORITY_LOW),u.registerCommand(r.KEY_BACKSPACE_COMMAND,D,r.COMMAND_PRIORITY_LOW),u.registerCommand(r.KEY_ENTER_COMMAND,c,r.COMMAND_PRIORITY_LOW),u.registerCommand(r.KEY_ESCAPE_COMMAND,t,r.COMMAND_PRIORITY_LOW)),[j,u,L,l,p,D,c,t,m]);function n(){u.update(()=>{const e=r.$getNodeByKey(p);$(e)&&e.setShowCaption(!0)})}function s(e,d){setTimeout(()=>{A(!1)},200),u.update(()=>{const R=r.$getNodeByKey(p);$(R)&&R.setWidthAndHeight(e,d)})}const w=l&&r.$isNodeSelection(I)&&!L,g=l||L,i=te();return a.jsxs(f.Suspense,{children:[a.jsx("div",{draggable:w,children:a.jsx(re,{className:g?`focused ${r.$isNodeSelection(I)?"draggable":""}`:null,src:h,altText:C,imageRef:y,width:E,height:v,maxWidth:S})}),M&&a.jsx("div",{className:N("LexEditor_ImageCaption",i.caption),children:a.jsxs(Q.LexicalNestedComposer,{initialEditor:z,children:[a.jsx(F.AutoFocusPlugin,{}),a.jsx(U,{}),a.jsx(G.RichTextPlugin,{contentEditable:a.jsx(V,{className:i.content}),placeholder:a.jsx(q,{className:i.placeholder,children:"Enter a caption..."}),ErrorBoundary:J})]})}),_&&r.$isNodeSelection(I)&&g&&a.jsx(Z,{showCaption:M,setShowCaption:n,editor:u,buttonRef:P,imageRef:y,maxWidth:S,onResizeStart:()=>A(!0),onResizeEnd:s,captionsEnabled:O})]})}export{ce as default}; +import{m as H,s as b,r as f,j as a,B as T,b1 as N}from"./vendor-DpqXKvKY.js";import{u as B,L as X,a as r,$,b as K,c as F,d as U,e as G,f as V,P as q,g as J}from"./index-qK3m2KiI.js";import{L as Q}from"./LexicalNestedComposer-zwgIQe1H.js";import"./index-7dlI38O5.js";function k(h,C,p){return Math.min(Math.max(h,C),p)}const o={east:1,north:8,south:2,west:4};function Z({onResizeStart:h,onResizeEnd:C,buttonRef:p,imageRef:E,maxWidth:v,editor:S,showCaption:_,setShowCaption:M,captionsEnabled:z}){const O=f.useRef(null),y=f.useRef({priority:"",value:"default"}),P=f.useRef({currentHeight:0,currentWidth:0,direction:0,isResizing:!1,ratio:0,startHeight:0,startWidth:0,startX:0,startY:0}),l=S.getRootElement(),m=v||(l?l.getBoundingClientRect().width-20:100),j=l?l.getBoundingClientRect().height-20:100,L=100,A=100;function u(t){const n=t===o.east||t===o.west,s=t===o.north||t===o.south,w=t&o.north&&t&o.west||t&o.south&&t&o.east,g=n?"ew":s?"ns":w?"nwse":"nesw";l&&l.style.setProperty("cursor",`${g}-resize`,"important"),document.body&&(document.body.style.setProperty("cursor",`${g}-resize`,"important"),y.current.value=document.body.style.getPropertyValue("-webkit-user-select"),y.current.priority=document.body.style.getPropertyPriority("-webkit-user-select"),document.body.style.setProperty("-webkit-user-select","none","important"))}function I(){l&&l.style.setProperty("cursor","default"),document.body&&(document.body.style.setProperty("cursor","default"),document.body.style.setProperty("-webkit-user-select",y.current.value,y.current.priority))}function x(t,n){if(!S.isEditable())return;const s=E.current,w=O.current;if(s&&w){const{width:g,height:i}=s.getBoundingClientRect(),e=P.current;e.startWidth=g,e.startHeight=i,e.ratio=g/i,e.currentWidth=g,e.currentHeight=i,e.startX=t.clientX,e.startY=t.clientY,e.isResizing=!0,e.direction=n,u(n),h(),w.classList.add("image-control-wrapper--resizing"),s.style.height=`${i}px`,s.style.width=`${g}px`,document.addEventListener("pointermove",W),document.addEventListener("pointerup",D)}}function W(t){const n=E.current,s=P.current,w=s.direction&(o.east|o.west),g=s.direction&(o.south|o.north);if(n&&s.isResizing)if(w&&g){let i=Math.floor(s.startX-t.clientX);i=s.direction&o.east?-i:i;const e=k(s.startWidth+i,L,m),d=e/s.ratio;n.style.width=`${e}px`,n.style.height=`${d}px`,s.currentHeight=d,s.currentWidth=e}else if(g){let i=Math.floor(s.startY-t.clientY);i=s.direction&o.south?-i:i;const e=k(s.startHeight+i,A,j);n.style.height=`${e}px`,s.currentHeight=e}else{let i=Math.floor(s.startX-t.clientX);i=s.direction&o.east?-i:i;const e=k(s.startWidth+i,L,m);n.style.width=`${e}px`,s.currentWidth=e}}function D(){const t=E.current,n=P.current,s=O.current;if(t&&s&&n.isResizing){const w=n.currentWidth,g=n.currentHeight;n.startWidth=0,n.startHeight=0,n.ratio=0,n.startX=0,n.startY=0,n.currentWidth=0,n.currentHeight=0,n.isResizing=!1,s.classList.remove("image-control-wrapper--resizing"),I(),C(w,g),document.removeEventListener("pointermove",W),document.removeEventListener("pointerup",D)}}const c=ee();return a.jsxs("div",{ref:O,children:[!_&&z&&a.jsx(T,{className:c.button,ref:p,onClick:()=>M(!_),children:"Add Caption"}),a.jsx("div",{className:N(c.resizer,c.n),onPointerDown:t=>x(t,o.north)}),a.jsx("div",{className:N(c.resizer,c.ne),onPointerDown:t=>x(t,o.north|o.east)}),a.jsx("div",{className:N(c.resizer,c.e),onPointerDown:t=>x(t,o.east)}),a.jsx("div",{className:N(c.resizer,c.se),onPointerDown:t=>x(t,o.south|o.east)}),a.jsx("div",{className:N(c.resizer,c.s),onPointerDown:t=>x(t,o.south)}),a.jsx("div",{className:N(c.resizer,c.sw),onPointerDown:t=>x(t,o.south|o.west)}),a.jsx("div",{className:N(c.resizer,c.w),onPointerDown:t=>x(t,o.west)}),a.jsx("div",{className:N(c.resizer,c.nw),onPointerDown:t=>x(t,o.north|o.west)})]})}const ee=H({button:{minWidth:"unset",fontWeight:"unset",width:"fit-content",position:"absolute",bottom:"20px",marginLeft:"auto",left:0,right:0,...b.margin(0,"auto")},resizer:{display:"block",width:"7px",height:"7px",position:"absolute",backgroundColor:"rgb(60, 132, 244)",...b.border("1px","solid","#fff")},n:{top:"-6px",left:"48%",cursor:"n-resize"},ne:{top:"-6px",right:"-6px",cursor:"ne-resize"},e:{bottom:"48%",right:"-6px",cursor:"e-resize"},se:{bottom:"-2px",right:"-6px",cursor:"nwse-resize"},s:{bottom:"-2px",left:"48%",cursor:"s-resize"},sw:{bottom:"-2px",left:"-6px",cursor:"sw-resize"},w:{bottom:"48%",left:"-6px",cursor:"w-resize"},nw:{top:"-6px",left:"-6px",cursor:"nw-resize"}}),te=H({caption:{display:"block",position:"absolute",bottom:"4px",left:0,right:0,...b.padding(0),...b.margin(0),...b.borderTop("1px","solid","#fff"),backgroundColor:"rgba(255, 255, 255, 0.9)",minWidth:"100px",color:"#000",...b.overflow("hidden")},content:{minHeight:"20px",...b.border(0),resize:"none",cursor:"text",caretColor:"rgb(5, 5, 5)",display:"block",position:"relative",tabSize:1,...b.outline(0),...b.padding("10px"),userSelect:"text",fontSize:"12px",width:"calc(100% - 20px)",whiteSpace:"pre-wrap",wordBreak:"break-word"},placeholder:{fontSize:"12px",color:"#888",...b.overflow("hidden"),position:"absolute",textOverflow:"ellipsis",top:"10px",left:"10px",userSelect:"none",whiteSpace:"nowrap",display:"inline-block",pointerEvents:"none"}}),Y=new Set;function se(h){if(!Y.has(h))throw new Promise(C=>{const p=new Image;p.src=h,p.onload=()=>{Y.add(h),C(null)}})}function re({altText:h,className:C,imageRef:p,src:E,width:v,height:S,maxWidth:_}){return se(E),a.jsx("img",{className:C||void 0,src:E,alt:h,ref:p,style:{height:S,maxWidth:_,width:v},draggable:"false"})}function ce({src:h,altText:C,nodeKey:p,width:E,height:v,maxWidth:S,resizable:_,showCaption:M,caption:z,captionsEnabled:O}){const y=f.useRef(null),P=f.useRef(null),[l,m,j]=B.useLexicalNodeSelection(p),[L,A]=f.useState(!1),[u]=X.useLexicalComposerContext(),[I,x]=f.useState(null),W=f.useRef(null),D=f.useCallback(e=>{if(l&&r.$isNodeSelection(r.$getSelection())){e.preventDefault();const R=r.$getNodeByKey(p);$(R)&&R.remove(),m(!1)}return!1},[l,p,m]),c=f.useCallback(e=>{const d=r.$getSelection(),R=P.current;if(l&&r.$isNodeSelection(d)&&d.getNodes().length===1){if(M)return r.$setSelection(null),e.preventDefault(),z.focus(),!0;if(R!==null&&R!==document.activeElement)return e.preventDefault(),R.focus(),!0}return!1},[z,l,M]),t=f.useCallback(e=>W.current===z||P.current===e.target?(r.$setSelection(null),u.update(()=>{m(!0);const d=u.getRootElement();d!==null&&d.focus()}),!0):!1,[z,u,m]);f.useEffect(()=>K.mergeRegister(u.registerUpdateListener(({editorState:e})=>{x(e.read(()=>r.$getSelection()))}),u.registerCommand(r.SELECTION_CHANGE_COMMAND,(e,d)=>(W.current=d,!1),r.COMMAND_PRIORITY_LOW),u.registerCommand(r.CLICK_COMMAND,e=>{const d=e;return L?!0:d.target===y.current?(d.shiftKey?m(!l):(j(),m(!0)),!0):!1},r.COMMAND_PRIORITY_LOW),u.registerCommand(r.DRAGSTART_COMMAND,e=>e.target===y.current?(e.preventDefault(),!0):!1,r.COMMAND_PRIORITY_LOW),u.registerCommand(r.KEY_DELETE_COMMAND,D,r.COMMAND_PRIORITY_LOW),u.registerCommand(r.KEY_BACKSPACE_COMMAND,D,r.COMMAND_PRIORITY_LOW),u.registerCommand(r.KEY_ENTER_COMMAND,c,r.COMMAND_PRIORITY_LOW),u.registerCommand(r.KEY_ESCAPE_COMMAND,t,r.COMMAND_PRIORITY_LOW)),[j,u,L,l,p,D,c,t,m]);function n(){u.update(()=>{const e=r.$getNodeByKey(p);$(e)&&e.setShowCaption(!0)})}function s(e,d){setTimeout(()=>{A(!1)},200),u.update(()=>{const R=r.$getNodeByKey(p);$(R)&&R.setWidthAndHeight(e,d)})}const w=l&&r.$isNodeSelection(I)&&!L,g=l||L,i=te();return a.jsxs(f.Suspense,{children:[a.jsx("div",{draggable:w,children:a.jsx(re,{className:g?`focused ${r.$isNodeSelection(I)?"draggable":""}`:null,src:h,altText:C,imageRef:y,width:E,height:v,maxWidth:S})}),M&&a.jsx("div",{className:N("LexEditor_ImageCaption",i.caption),children:a.jsxs(Q.LexicalNestedComposer,{initialEditor:z,children:[a.jsx(F.AutoFocusPlugin,{}),a.jsx(U,{}),a.jsx(G.RichTextPlugin,{contentEditable:a.jsx(V,{className:i.content}),placeholder:a.jsx(q,{className:i.placeholder,children:"Enter a caption..."}),ErrorBoundary:J})]})}),_&&r.$isNodeSelection(I)&&g&&a.jsx(Z,{showCaption:M,setShowCaption:n,editor:u,buttonRef:P,imageRef:y,maxWidth:S,onResizeStart:()=>A(!0),onResizeEnd:s,captionsEnabled:O})]})}export{ce as default}; diff --git a/assets/Lazy-vvLq-Rxx.js b/assets/Lazy-XJRXDq2K.js similarity index 65% rename from assets/Lazy-vvLq-Rxx.js rename to assets/Lazy-XJRXDq2K.js index e16c361..63a9ffa 100644 --- a/assets/Lazy-vvLq-Rxx.js +++ b/assets/Lazy-XJRXDq2K.js @@ -1,7 +1,7 @@ -import{r as a,as as e,j as s,ar as t}from"./vendor-DpqXKvKY.js";function i(r){return s.jsx(a.Suspense,{fallback:s.jsx(t,{}),children:s.jsx(n,{...r})})}const n=a.lazy(()=>e(()=>import("./index-5nAmJIOp.js").then(r=>r.q),__vite__mapDeps([0,1,2,3])));export{i as L}; +import{r as a,as as e,j as s,ar as t}from"./vendor-DpqXKvKY.js";function i(r){return s.jsx(a.Suspense,{fallback:s.jsx(t,{}),children:s.jsx(n,{...r})})}const n=a.lazy(()=>e(()=>import("./index-qK3m2KiI.js").then(r=>r.q),__vite__mapDeps([0,1,2,3])));export{i as L}; function __vite__mapDeps(indexes) { if (!__vite__mapDeps.viteFileDeps) { - __vite__mapDeps.viteFileDeps = ["assets/index-5nAmJIOp.js","assets/vendor-DpqXKvKY.js","assets/index-YSLnLPU4.js","assets/index-mRiAC1cH.css"] + __vite__mapDeps.viteFileDeps = ["assets/index-qK3m2KiI.js","assets/vendor-DpqXKvKY.js","assets/index-7dlI38O5.js","assets/index-mRiAC1cH.css"] } return indexes.map((i) => __vite__mapDeps.viteFileDeps[i]) } diff --git a/assets/LexicalNestedComposer-yIpoQP8r.js b/assets/LexicalNestedComposer-zwgIQe1H.js similarity index 96% rename from assets/LexicalNestedComposer-yIpoQP8r.js rename to assets/LexicalNestedComposer-zwgIQe1H.js index f8c6500..1756b49 100644 --- a/assets/LexicalNestedComposer-yIpoQP8r.js +++ b/assets/LexicalNestedComposer-zwgIQe1H.js @@ -1 +1 @@ -import{r as u}from"./vendor-DpqXKvKY.js";import{L as y}from"./index-5nAmJIOp.js";var x={},b={},f=u;let p=[["Cat","rgb(125, 50, 0)"],["Dog","rgb(100, 0, 0)"],["Rabbit","rgb(150, 0, 0)"],["Frog","rgb(200, 0, 0)"],["Fox","rgb(200, 75, 0)"],["Hedgehog","rgb(0, 75, 0)"],["Pigeon","rgb(0, 125, 0)"],["Squirrel","rgb(75, 100, 0)"],["Bear","rgb(125, 100, 0)"],["Tiger","rgb(0, 0, 150)"],["Leopard","rgb(0, 0, 200)"],["Zebra","rgb(0, 0, 250)"],["Wolf","rgb(0, 100, 150)"],["Owl","rgb(0, 100, 100)"],["Gull","rgb(100, 0, 100)"],["Squid","rgb(150, 0, 150)"]],C=p[Math.floor(Math.random()*p.length)],m=f.createContext({clientID:0,color:C[1],isCollabActive:!1,name:C[0],yjsDocMap:new Map});b.CollaborationContext=m;b.useCollaborationContext=function(e,a){let r=f.useContext(m);return e!=null&&(r.name=e),a!=null&&(r.color=a),r};const N=b;var D=N,K=D,d=y,l=u;x.LexicalNestedComposer=function({initialEditor:e,children:a,initialNodes:r,initialTheme:h,skipCollabChecks:v}){let g=l.useRef(!1),i=l.useContext(d.LexicalComposerContext);if(i==null)throw Error("Minified Lexical error #9; visit https://lexical.dev/docs/error?code=9 for the full message or use the non-minified dev environment for full errors and additional helpful warnings.");let[t,{getTheme:L}]=i,_=l.useMemo(()=>{var o=h||L()||void 0;const M=d.createLexicalComposerContext(i,o);if(o!==void 0&&(e._config.theme=o),e._parentEditor=t,r)for(var n of r)o=n.getType(),e._nodes.set(o,{klass:n,replace:null,replaceWithKlass:null,transforms:new Set});else{n=e._nodes=new Map(t._nodes);for(const[k,c]of n)e._nodes.set(k,{klass:c.klass,replace:c.replace,replaceWithKlass:c.replaceWithKlass,transforms:new Set})}return e._config.namespace=t._config.namespace,e._editable=t._editable,[e,M]},[]),{isCollabActive:E,yjsDocMap:w}=K.useCollaborationContext(),s=v||g.current||w.has(e.getKey());return l.useEffect(()=>{s&&(g.current=!0)},[s]),l.useEffect(()=>t.registerEditableListener(o=>{e.setEditable(o)}),[e,t]),l.createElement(d.LexicalComposerContext.Provider,{value:_},!E||s?a:null)};const S=x;var j=S;export{j as L}; +import{r as u}from"./vendor-DpqXKvKY.js";import{L as y}from"./index-qK3m2KiI.js";var x={},b={},f=u;let p=[["Cat","rgb(125, 50, 0)"],["Dog","rgb(100, 0, 0)"],["Rabbit","rgb(150, 0, 0)"],["Frog","rgb(200, 0, 0)"],["Fox","rgb(200, 75, 0)"],["Hedgehog","rgb(0, 75, 0)"],["Pigeon","rgb(0, 125, 0)"],["Squirrel","rgb(75, 100, 0)"],["Bear","rgb(125, 100, 0)"],["Tiger","rgb(0, 0, 150)"],["Leopard","rgb(0, 0, 200)"],["Zebra","rgb(0, 0, 250)"],["Wolf","rgb(0, 100, 150)"],["Owl","rgb(0, 100, 100)"],["Gull","rgb(100, 0, 100)"],["Squid","rgb(150, 0, 150)"]],C=p[Math.floor(Math.random()*p.length)],m=f.createContext({clientID:0,color:C[1],isCollabActive:!1,name:C[0],yjsDocMap:new Map});b.CollaborationContext=m;b.useCollaborationContext=function(e,a){let r=f.useContext(m);return e!=null&&(r.name=e),a!=null&&(r.color=a),r};const N=b;var D=N,K=D,d=y,l=u;x.LexicalNestedComposer=function({initialEditor:e,children:a,initialNodes:r,initialTheme:h,skipCollabChecks:v}){let g=l.useRef(!1),i=l.useContext(d.LexicalComposerContext);if(i==null)throw Error("Minified Lexical error #9; visit https://lexical.dev/docs/error?code=9 for the full message or use the non-minified dev environment for full errors and additional helpful warnings.");let[t,{getTheme:L}]=i,_=l.useMemo(()=>{var o=h||L()||void 0;const M=d.createLexicalComposerContext(i,o);if(o!==void 0&&(e._config.theme=o),e._parentEditor=t,r)for(var n of r)o=n.getType(),e._nodes.set(o,{klass:n,replace:null,replaceWithKlass:null,transforms:new Set});else{n=e._nodes=new Map(t._nodes);for(const[k,c]of n)e._nodes.set(k,{klass:c.klass,replace:c.replace,replaceWithKlass:c.replaceWithKlass,transforms:new Set})}return e._config.namespace=t._config.namespace,e._editable=t._editable,[e,M]},[]),{isCollabActive:E,yjsDocMap:w}=K.useCollaborationContext(),s=v||g.current||w.has(e.getKey());return l.useEffect(()=>{s&&(g.current=!0)},[s]),l.useEffect(()=>t.registerEditableListener(o=>{e.setEditable(o)}),[e,t]),l.createElement(d.LexicalComposerContext.Provider,{value:_},!E||s?a:null)};const S=x;var j=S;export{j as L}; diff --git a/assets/index-iGJtzlF3.js b/assets/index-0T8GTba5.js similarity index 59% rename from assets/index-iGJtzlF3.js rename to assets/index-0T8GTba5.js index 51cc757..e818093 100644 --- a/assets/index-iGJtzlF3.js +++ b/assets/index-0T8GTba5.js @@ -1 +1 @@ -import{x as o,j as t,y as e}from"./vendor-DpqXKvKY.js";import{L as a,H as n,f as i}from"./index-YSLnLPU4.js";import{H as m}from"./Columns-iLzEQjYF.js";const s=new a("History");function l(){const{data:r}=o(()=>n.Order.Get.List(s),{onError:s.error});return t.jsx(i,{Items:r,Columns:e(()=>m(s))})}export{l as default}; +import{x as o,j as t,y as e}from"./vendor-DpqXKvKY.js";import{L as a,H as n,f as i}from"./index-7dlI38O5.js";import{H as m}from"./Columns-Qu8-yOAT.js";const s=new a("History");function l(){const{data:r}=o(()=>n.Order.Get.List(s),{onError:s.error});return t.jsx(i,{Items:r,Columns:e(()=>m(s))})}export{l as default}; diff --git a/assets/index-7dlI38O5.js b/assets/index-7dlI38O5.js new file mode 100644 index 0000000..be72054 --- /dev/null +++ b/assets/index-7dlI38O5.js @@ -0,0 +1,11 @@ +import{r as x,u as me,j as n,d as y,t as m,s as R,m as P,a as Fe,T as Z,b as ee,c as te,e as J,f as je,D as be,g as Te,h as ve,i as _e,k as Se,F as E,I as z,L as H,l as Ee,n as he,B as I,S as pe,o as k,A as W,X as We,P as Qe,p as we,H as _,q as Le,v as Ie,M as Ne,w as Ge,x as h,y as O,z as ke,C as Xe,E as qe,G as Ye,J as U,K as ae,N as Je,O as Ke,Q as Ze,R as et,U as tt,V as st,W as nt,Y as rt,Z as at,_ as B,$ as ot,a0 as it,a1 as ye,a2 as ct,a3 as ut,a4 as Oe,a5 as Q,a6 as lt,a7 as X,a8 as dt,a9 as ht,aa as mt,ab as pt,ac as gt,ad as xt,ae as ft,af as wt,ag as yt,ah as Pt,ai as Ct,aj as jt,ak as bt,al as Tt,am as vt,an as St,ao as Et,ap as Lt,aq as It,ar as q,as as se,at as Nt,au as Gt,av as kt,aw as Ot,ax as At}from"./vendor-DpqXKvKY.js";function oe(o){return`/${o.filter(s=>s).map(s=>s.toString().replace(/^\/+/,"")).join("/")}`}const Ae=x.createContext({});function V(){return x.useContext(Ae)}function $t({children:o}){const[e,s]=x.useState(()=>({Paths:location.pathname.split("/").filter(c=>c),Search:new URLSearchParams(location.search),Put:t,Nav:(...c)=>a(oe(c)),Rep:(...c)=>i(oe(c)),Reload:(...c)=>u(c)}));function t(c){history.replaceState(null,"",`${location.pathname}${c.size?"?":""}${c.toString()}`),e.Search=new URLSearchParams(c),s({...e})}function r(c){e.Paths=c.split("/").filter(l=>l),e.Search=new URLSearchParams(location.search),s({...e})}function a(c){history.pushState(null,"",c),r(c)}function i(c){history.replaceState(null,"",c),r(c)}function u(c){history.replaceState(null,"","/Reload"),r("/Reload"),setTimeout(()=>{const l=c.length?oe(c):location.pathname;history.pushState(null,"",l),r(l)},100)}return me(()=>{location.pathname==="/"&&location.search.startsWith("?/")&&i(location.search.substring(2)),addEventListener("click",c=>{const l=c.target?.closest("a");if(l){if(l.origin!==location.origin){l.target="_blank";return}c.preventDefault(),a(l.pathname)}}),addEventListener("popstate",c=>{c.preventDefault(),r(location.pathname)})}),n.jsx(Ae.Provider,{value:e,children:o})}class A{namespace;info;error;warn;debug;throw;constructor(...e){this.namespace=e.join(" > "),this.error=console.error.bind(this,this.baseColor(101,"error"),` + `),this.warn=console.warn.bind(this,this.baseColor(103,"warn"),` + `),this.info=console.info.bind(this,this.baseColor(104,"info"),` + `),this.debug=console.debug.bind(this,this.baseColor(102,"debug"),` + `),this.throw=console.log.bind(this,this.baseColor(105,"throw"),"↓ The Following Error is Thrown ↓")}With(...e){return new A(this.namespace,...e)}baseColor(e,s){return`\x1B[${e};30;1m ${s.toUpperCase()} \x1B[0m\x1B[100;97m ${y().format("YY-M-D H:m:s")} \x1B[1m\x1B[40;97m ${this.namespace} `}}const G={display:"flex"},Ut={flexDirection:"column"},D={...G,...Ut},Ws={...G,backgroundColor:m.colorNeutralBackground1,boxShadow:m.shadow4,...R.borderRadius(m.borderRadiusMedium)},Mt={whiteSpace:"pre-line"},ge=60,xe="1636px",Dt={objectFit:"cover",objectPosition:"center"},Rt=P({pre:Mt});function ne(o){const e=Rt(),{dispatchToast:s}=Fe();return{dispatch:t=>{const r=t.Error.message,a=r.indexOf("Exception:");let i=r;a!==-1&&(i=r.substring(a+10)),s(n.jsxs(Z,{children:[n.jsx(ee,{children:"Internal Error"}),n.jsx(te,{subtitle:n.jsxs(J,{className:e.pre,children:[i,n.jsx("br",{}),"More Info, See Console"]}),children:n.jsx(J,{className:e.pre,children:t.Message})})]}),{intent:"error",timeout:1e4}),o.error(t)},dispatchToast:s}}const Vt=P({box:{...D,rowGap:m.spacingVerticalM},one:{...G,columnGap:m.spacingVerticalXXXL}}),Pe=new A("Setting");function $e({Open:o,Toggle:e,New:s}){const t=Vt(),r=je().instance.getActiveAccount(),[a,i]=x.useState(),[u,c]=x.useState(),[l,d]=x.useState(),p=j.User.Get.useMe(Pe);x.useEffect(()=>{if(s||!p)return;const{Name:f,Phone:g,Address:ze}=p;i(f),c(g),d(ze)},[p]);const{dispatch:w,dispatchToast:T}=ne(Pe),{run:v}=j.User.Post.useUpdate({manual:!0,onError(f,[g]){w({Message:`Failed ${s?"Create":"Update"} Info`,Error:f,Request:g})},onSuccess(f,[g]){T(n.jsxs(Z,{children:[n.jsxs(ee,{children:["Info ",s?"Created":"Updated"]}),n.jsxs(te,{children:[g.Name,n.jsx("br",{}),g.Phone,n.jsx("br",{}),g.Address]})]}),{intent:"success"}),s&&(M.next(!1),M.complete(),M.closed=!0),e()}});return n.jsx(be,{open:o,onOpenChange:e,modalType:s?"alert":"modal",children:n.jsx(Te,{children:n.jsxs(ve,{children:[n.jsx(_e,{children:s?"Welcome! Fill in your info to get started.":"Personal Information"}),n.jsxs(Se,{className:t.box,children:[n.jsxs("div",{className:t.one,children:[n.jsx(E,{label:"Name",size:"large",required:!0,children:n.jsx(z,{size:"medium",value:a,maxLength:20,onChange:(f,g)=>i(g.value)})}),n.jsx(E,{label:"Phone",size:"large",required:!0,children:n.jsx(z,{size:"medium",value:u,maxLength:20,onChange:(f,g)=>c(g.value)})})]}),n.jsx(E,{label:"E-Mail",size:"large",children:n.jsx(H,{children:r?.username})}),n.jsx(E,{label:"Address",size:"large",required:!0,children:n.jsx(z,{size:"medium",value:l,maxLength:100,minLength:20,onChange:(f,g)=>d(g.value)})})]}),n.jsxs(Ee,{children:[!s&&n.jsx(he,{disableButtonEnhancement:!0,children:n.jsx(I,{appearance:"secondary",children:"Cancel"})}),n.jsx(I,{appearance:"primary",onClick:()=>v({EMail:r?.username,Name:a,Address:l,Phone:u}),children:"Submit"})]})]})})})}const M=new pe;function Bt(){const[o,{toggle:e}]=k();return me(()=>M.subscribe(s=>s&&e())),n.jsx(W,{children:n.jsx($e,{Open:o,Toggle:e,New:!0})})}class Ht{constructor(e,s){this.DB=e,this.Name=s,this.Sto=e.table(s),this.Trim()}Sto;async Get(e,s){const t=await this.Sto.get(e);return t?s&&await Promise.resolve(s(t))||typeof t.Exp=="number"&&t.Exptypeof e.Exp=="number"&&e.Exp{const s=setInterval(()=>{this.Hub.state===_.Connected&&(clearInterval(s),e())},100)}))}static async Invoke(e,...s){return await this.EnsureConnected(),this.Hub.invoke(e,...s)}static EnsureLogin(){if(!N.getActiveAccount())throw new Me}static EnsureTrue(e){if(!e)throw new zt}static Index(e,s){return`${s}_${e}`}static async UpdateCache(e,s,t,r){const a=this.Index(s,t),i=await S.Get(a);if(!i)return;const u=e(i);i.QueryExp?await S.Set(a,{...u,QueryExp:y().add(1,"m").unix()},null):await S.Set(a,u,r||null)}static async GetVersionCache(e,s){const t=this.Index(e,s),r=await S.Get(t);if(r&&r.QueryExp>y().unix())return r;const a=await Promise.resolve(this.Invoke(s,e,r?.Version));if(a===!0)return S.Set(t,{...r,QueryExp:y().add(1,"m").unix()},null),r;if(!a)throw S.Sto.delete(t),new TypeError("Empty Response");return await S.Set(t,{...a,QueryExp:y().add(1,"m").unix()},null),a}static async GetTimeCache(e,s,t,...r){return await S.GetOrSet(this.Index(e,s),async()=>await this.Invoke(s,...r),t(y()))}static async HandleFileStream(e,s,t){const a=Math.ceil(e.size/30720);let i=0;for(;i{d.onload=()=>w(new Uint8Array(d.result)),d.onerror=()=>T(d.error),d.readAsArrayBuffer(l)});s.next(p),t?.debug(`Sent chunk ${i+1}/${a}`),i++}s.complete()}}class b extends De{static Log=["|","ShopNet"];static Hub=new Le().withUrl("https://awaishop.aloen.to:3389/Hub",{skipNegotiation:!0,transport:Ie.WebSockets,logMessageContent:!1,async accessTokenFactory(){const e=await Ue();return e||""}}).withAutomaticReconnect().withStatefulReconnect().withHubProtocol(new Ne).configureLogging(Ge.Information).build()}b.Hub.on("OnNewUser",()=>{M.next(!0),console.debug("OnNewUser")});class Ft extends b{static Categories(){return this.GetTimeCache("","GalleryGetCategories",e=>e.add(1,"m"))}static async Products(e){const s=await this.GetTimeCache(e,"GalleryGetProducts",t=>t.add(1,"m"),e);return[s,4-s.length%4]}}const _t={Get:Ft};class Wt extends b{static async Get(e){if(!/^[0-9a-f]{8}-([0-9a-f]{4}-){3}[0-9a-f]{12}$/i.test(e))throw new Error(`Invalid ObjectId ${e}`);return await this.EnsureConnected(),this.Hub.stream("ObjectStorageGet",e)}static GetBySlice(e,s){const t=[];return S.GetOrSet(e,()=>new Promise((r,a)=>{this.Get(e).then(i=>i.subscribe({error(u){a(u)},next(u){t.push(u),s.debug("Received Slice",e,t.length)},complete(){r(t)}}))}))}}class Qt extends b{static useDelete(e){return h(async s=>{this.EnsureLogin();const t=await this.Invoke("OrderDeleteCancel",s);return this.EnsureTrue(t),t},e)}}class L extends b{static Product(e){return this.GetVersionCache(e,"ProductEntity")}static Lexical(e){return this.GetVersionCache(e,"LexicalEntity")}static Photo(e){return this.GetVersionCache(e,"PhotoEntity")}static Type(e){return this.GetVersionCache(e,"TypeEntity")}static Variant(e){return this.GetVersionCache(e,"VariantEntity")}}class $ extends L{static Log=[...super.Log,"Product","Get"];static async Basic(e,s){const t=s.With(...this.Log,"Basic"),r=await this.Product(e);if(!r)throw new Error(`Product ${e} Not Found`);const[a,i]=await this.PhotoList(e,s);return i?{Name:r.Name,Cover:i}:(t.warn(`Product ${e} has no photo`),{Name:r.Name,Cover:""})}static Limit(e){return this.Invoke("ProdGetLimit",e)}static async Combo(e,s){const t=s.With(...this.Log,"Combo"),r=await this.ComboList(e),a=[];for(const i of r){const u={};for(const c of i.Types){const l=await this.Type(c);if(!l){t.error(`[Mismatch] Type ${c} not found. Combo ${i.ComboId} : Product ${e}`);continue}const d=await this.Variant(l.VariantId);if(!d){t.error(`[Mismatch] Variant ${l.VariantId} not found. Combo ${i.ComboId} : Type ${c} : Product ${e}`);continue}u[d.Name]=l.Name}a.push({Id:i.ComboId,Stock:i.Stock,Combo:u})}return a}static ComboList(e){return this.GetTimeCache(e,"ProductGetComboList",s=>s.add(1,"m"),e)}static async PhotoList(e,s){const t=s.With(...this.Log,"PhotoList"),r=await this.GetTimeCache(e,"ProductGetPhotoList",u=>u.add(1,"m"),e).catch(t.error);let a=[],i="";for(const u of r||[]){const c=await this.Photo(u).catch(t.error);c?(a.push(c),c.Cover&&(i=c.ObjectId)):t.warn(`Photo ${u} not found in Product ${e}`)}return a=a.sort((u,c)=>u.Order-c.Order),!i&&a.length>0?(t.warn(`Product ${e} has no cover photo, using first photo instead`),[a,a[0].ObjectId]):[a,i]}}class ce extends b{static Order(e){return this.EnsureLogin(),this.GetVersionCache(e,"OrderEntity")}static Comment(e){return this.EnsureLogin(),this.GetVersionCache(e,"CommentEntity")}}class Xt extends b{static Log=[...super.Log,"Order","Get"];static async List(e){this.EnsureLogin();const s=e.With(...this.Log,"List"),t=await this.GetTimeCache("","OrderGetList",a=>a.add(1,"m")),r=[];for(const a of t){const i=await ce.Order(a.OrderId);if(!i){s.warn(`[Mismatch] Order ${a.OrderId} not found`);continue}const u=[];for(const c of a.Products){const l=await L.Product(c);if(!l){s.warn(`[Mismatch] Product ${c} not found`);continue}u.push(l.Name)}r.push({Id:a.OrderId,Items:u,Quantity:a.Quantity,Status:i.Status,TrackNumber:i.TrackingNumber,OrderDate:i.CreateAt})}return r.sort((a,i)=>i.OrderDate.getTime()-a.OrderDate.getTime())}static async Detail(e,s){this.EnsureLogin();const t=s.With(...this.Log,"Detail"),r=await this.GetTimeCache(e,"OrderGetDetail",c=>c.add(1,"m"),e),a=[];let i=0;for(const c of r.Items){const l={};let d=0;for(const v of c.Types){const f=await L.Type(v);if(!f){t.warn(`[Mismatch] Type ${v} not found. Order : ${e}`);continue}const g=await L.Variant(f.VariantId);if(!g){t.warn(`[Mismatch] Variant ${f.VariantId} not found. Type : ${v}, Order : ${e}`);continue}l[g.Name]=f.Name,d=g.ProductId}const p=await L.Product(d);if(!p){t.warn(`[Mismatch] Product ${d} not found. Order : ${e}`);continue}const[w,T]=await $.PhotoList(d,t);T||t.warn(`Product ${d} has no photo`),a.push({Id:i++,ProdId:d,Cover:T||"",Name:p.Name,Type:l,Quantity:c.Quantity})}const u=[];for(const c of r.Comments){const l=await ce.Comment(c);if(!l){t.warn(`[Mismatch] Comment ${c} not found. Order : ${e}`);continue}u.push({Content:l.Content,Time:l.CreateAt,User:l.Name||"You"})}return{ShopCart:a,Comments:u.sort((c,l)=>c.Time.getTime()-l.Time.getTime())}}static Order=ce.Order}class qt extends b{static useNew(e){return h((s,t)=>{this.EnsureLogin();const r=s.map(a=>({ProdId:a.ProdId,Type:Object.values(a.Type),Quantity:a.Quantity}));return this.Invoke("OrderPostNew",r,t)},e)}static useAppend(e){return h(async(s,t)=>{this.EnsureLogin();const r=await this.Invoke("OrderPostAppend",s,t);return this.EnsureTrue(r),r},e)}static useCancel(e){return h(async(s,t)=>{this.EnsureLogin();const r=await this.Invoke("OrderPostCancel",s,t);return this.EnsureTrue(r),r},e)}static useReceived(e){return h(async s=>{this.EnsureLogin();const t=await this.Invoke("OrderPostReceived",s);return this.EnsureTrue(t),t},e)}}const Yt={Get:Xt,Post:qt,Delete:Qt},Jt={Get:$};class Kt extends b{static useMe(e){const s=O(()=>e.With("|","Hub","User","Get","Me")),{dispatch:t}=ne(s),[r,{set:a}]=k();return me(()=>M.subscribe(a)),ke(()=>this.GetVersionCache(0,"UserGetMe").catch(u=>{r||u instanceof Me?s.info(u):t({Message:"Failed to Get Your Info",Error:u,Request:""})}))}}class Zt extends b{static useUpdate(e){return h(async s=>{this.EnsureLogin();const t=await this.Invoke("UserPostUpdate",s);return this.EnsureTrue(t),this.UpdateCache(r=>({...r,...s}),0,"UserGetMe"),t},e)}}const es={Get:Kt,Post:Zt},j={Gallery:_t,Product:Jt,User:es,Order:Yt,Storage:Wt},Re=x.createContext({});function F(){return x.useContext(Re)}const ue=new A("ShopCart","Context");function ts({children:o}){const[e,s]=x.useState([]);h(async()=>{const a=await ie.toArray(),i=[];for(const u of a){const c=await j.Product.Get.Basic(u.ProdId,ue);i.push({...u,...c})}s(i)},{onError:ue.error});async function t(a){for(let i=0;i({Id:i.Id,ProdId:i.ProdId,Type:i.Type,Quantity:i.Quantity})))}async function r(a,i,u){const c=await j.Product.Get.Basic(a,ue);e.push({...c,Id:e.length,ProdId:a,Type:i,Quantity:u}),t(e)}return n.jsx(Re.Provider,{value:{List:e,Add:r,Update:t},children:o})}const fe={Name:"AwaiShop"},ss=P({box:{width:"-webkit-fill-available",marginTop:m.spacingVerticalXXXL,...R.padding(m.spacingVerticalXXXL,0),backgroundColor:m.colorNeutralBackgroundInverted},main:{...G,maxWidth:xe,...R.margin(0,"auto")},logo:{width:"150px",filter:"invert(96%)"},otc:{color:"white"}});function ns(){const o=ss();return n.jsx("footer",{className:o.box,children:n.jsx("div",{className:o.main,children:n.jsx("img",{src:"/safari-pinned-tab.svg",className:o.logo})})})}function rs(){const{Paths:o,Search:e,Put:s}=V(),t=o.at(0),r=o.at(1),a=r==="User",i=r==="Order",u=a?"admin":"pending";return t==="Admin"&&(a||i)&&n.jsxs(n.Fragment,{children:[n.jsx(z,{placeholder:"Search in Any Field",contentBefore:n.jsx(Xe,{}),appearance:"underline",onChange:(c,l)=>{l.value?e.set("search",l.value):e.delete("search"),s(e)}}),n.jsx(qe,{label:`Only ${a?"Admin":"Pending"}`,checked:e.get(u)==="",onChange:(c,l)=>{l.checked?e.set(u,""):e.delete(u),s(e)}})]})}const as=P({box:{...G,flexGrow:1,height:"inherit",marginLeft:m.spacingHorizontalS,alignItems:"center"},div:{color:m.colorNeutralForegroundDisabled},link:{textDecorationLine:"unset !important"}});function os(){const o=as(),{Paths:e}=V(),s=e.at(0),t=e.at(1)||"Product";return s==="Admin"&&n.jsxs("div",{className:o.box,children:[n.jsx(J,{size:600,font:"monospace",className:o.div,children:"|"}),n.jsxs(Ye,{selectedValue:t,children:[n.jsx(U,{appearance:"subtle",href:"/Admin",className:o.link,children:n.jsx(ae,{value:"Product",children:"Product List"})}),n.jsx(U,{appearance:"subtle",href:"/Admin/Order",className:o.link,children:n.jsx(ae,{value:"Order",children:"Order List"})}),n.jsx(U,{appearance:"subtle",href:"/Admin/User",className:o.link,children:n.jsx(ae,{value:"User",children:"User List"})})]})]})}class C extends De{static Log=["|","AdminNet"];static Hub=new Le().withUrl("https://awaishop.aloen.to:3389/AdminHub",{skipNegotiation:!0,transport:Ie.WebSockets,logMessageContent:!1,async accessTokenFactory(){const e=await Ue();if(e)return e;throw new Error("Please Login First")}}).withAutomaticReconnect().withStatefulReconnect().withHubProtocol(new Ne).configureLogging(Ge.Information).build();static Index(e,s){return`${s}_Admin_${e}`}}class K extends C{static User(e){return this.EnsureLogin(),this.GetVersionCache(e,"UserEntity")}}class Y extends C{static Order(e){return this.EnsureLogin(),this.GetVersionCache(e,"OrderEntity")}static Comment(e){return this.EnsureLogin(),this.GetVersionCache(e,"CommentEntity")}}class is extends C{static Log=[...super.Log,"Order","Get"];static async List(e){this.EnsureLogin();const s=e.With(...this.Log,"List"),t=await this.GetTimeCache("","OrderGetList",a=>a.add(1,"m")),r=[];for(const a of t){const i=await Y.Order(a.OrderId);if(!i){s.warn(`[Mismatch] Order ${a.OrderId} not found`);continue}const u=[];for(const l of a.Products){const d=await L.Product(l);if(!d){s.warn(`[Mismatch] Product ${l} not found`);continue}u.push(d.Name)}const c=await K.User(i.UserId);if(!c){s.error(`[Mismatch] User ${i.UserId} not found`);continue}r.push({Id:a.OrderId,Items:u,Quantity:a.Quantity,Status:i.Status,TrackNumber:i.TrackingNumber,OrderDate:i.CreateAt,User:c.Name})}return r.sort((a,i)=>i.OrderDate.getTime()-a.OrderDate.getTime())}static async Detail(e,s){this.EnsureLogin();const t=s.With(...this.Log,"Detail"),r=await this.GetTimeCache(e,"OrderGetDetail",c=>c.add(1,"m"),e),a=[];let i=0;for(const c of r.Items){const l={};let d=0;for(const v of c.Types){const f=await L.Type(v);if(!f){t.warn(`[Mismatch] Type ${v} not found. Order : ${e}`);continue}const g=await L.Variant(f.VariantId);if(!g){t.warn(`[Mismatch] Variant ${f.VariantId} not found. Type : ${v}, Order : ${e}`);continue}l[g.Name]=f.Name,d=g.ProductId}const p=await L.Product(d);if(!p){t.warn(`[Mismatch] Product ${d} not found. Order : ${e}`);continue}const[w,T]=await $.PhotoList(d,t);T||t.warn(`Product ${d} has no photo`),a.push({Id:i++,ProdId:d,Cover:T||"",Name:p.Name,Type:l,Quantity:c.Quantity})}const u=[];for(const c of r.Comments){const l=await Y.Comment(c);if(!l){t.warn(`[Mismatch] Comment ${c} not found. Order : ${e}`);continue}let d="Client";if(l.UserId){const p=await K.User(l.UserId);p?d=p.Name:t.warn(`[Mismatch] User ${l.UserId} not found. Order : ${e}`)}u.push({Content:l.Content,Time:l.CreateAt,User:d})}return{ShopCart:a,Comments:u.sort((c,l)=>c.Time.getTime()-l.Time.getTime())}}static Order=Y.Order}class cs extends C{static useAppend(e){return h(async(s,t)=>{const r=await this.Invoke("OrderPostAppend",s,t);return this.EnsureTrue(r),r},e)}static useClose(e){return h(async(s,t)=>{const r=await this.Invoke("OrderPostClose",s,t);return this.EnsureTrue(r),r},e)}static useShip(e){return h(async(s,t)=>{const r=await this.Invoke("OrderPostShip",s,t);return this.EnsureTrue(r),r},e)}static useAccept(e){return h(async s=>{const t=await this.Invoke("OrderPostAccept",s);return this.EnsureTrue(t),t},e)}}const us={Get:is,Post:cs};class ls extends C{static usePhoto(e){return h(async s=>{const t=await this.Invoke("ProductDeletePhoto",s);return this.EnsureTrue(t),t},e)}static useVariant(e){return h(async s=>{const t=await this.Invoke("ProductDeleteVariant",s);return this.EnsureTrue(t),t},e)}static useType(e){return h(async(s,t)=>{const r=await this.Invoke("ProductDeleteType",s,t);return this.EnsureTrue(r),r},e)}static useCombo(e){return h(async s=>{const t=await this.Invoke("ProductDeleteCombo",s);return this.EnsureTrue(t),t},e)}static useProduct(e){return h(async s=>{const t=await this.Invoke("ProductDeleteProduct",s);return this.EnsureTrue(t),this.UpdateCache(r=>r.filter(a=>a!==s),"","ProductGetList",y().add(1,"m")),t},e)}}class ds extends C{static Log=[...super.Log,"Product","Get"];static useList(e){const s=O(()=>e.With(...this.Log,"List"));return ke(()=>this.GetTimeCache("","ProductGetList",r=>r.add(1,"m")).catch(s.error))}static Count(e){return this.GetTimeCache(e,"ProductGetCount",s=>s.add(1,"m"),e)}static async Name(e){const s=await $.Product(e);if(!s)throw new Error(`Product ${e} Not Found`);return s.Name}static async Category(e){const s=await $.Product(e);if(!s)throw new Error(`Product ${e} Not Found`);return s.Category}static async Variants(e,s){const t=s.With(...this.Log,"Variants"),r=await this.GetTimeCache(e,"ProductGetVariants",i=>i.add(1,"m"),e),a=[];for(const i of r){const u=await $.Variant(i.VariantId);if(!u){t.warn(`Variant ${i} Not Found. Product : ${e}`);continue}const c=[];for(const l of i.Types){const d=await $.Type(l);if(!d){t.warn(`Type ${l} Not Found. Variant : ${i.VariantId}, Product : ${e}`);continue}c.push(d.Name)}a.push({Id:i.VariantId,Name:u.Name,Types:c})}return a}}class hs extends C{static Log=[...super.Log,"Product","Patch"];static useName(e){return h(async(s,t)=>{const r=await this.Invoke("ProductPatchName",s,t);return this.EnsureTrue(r),r},e)}static useCategory(e){return h(async(s,t)=>{const r=await this.Invoke("ProductPatchCategory",s,t);return this.EnsureTrue(r),r},e)}static usePhoto(e,s){const t=O(()=>e.With(...this.Log,"Photo"));return h(async(r,a)=>{if(!a.type.startsWith("image/"))throw new TypeError("File is not an image");if(a.size>10*1024*1024)throw new RangeError("File is too large, max 10MB");await this.EnsureConnected();const i=new pe,u=this.Hub.invoke("ProductPatchPhoto",r,i);return await this.HandleFileStream(a,i,t),this.EnsureTrue(await u),!0},s)}static useCaption(e){return h(async(s,t)=>{const r=await this.Invoke("ProductPatchCaption",s,t);return this.EnsureTrue(r),r},e)}static useVariantName(e){return h(async(s,t)=>{const r=await this.Invoke("ProductPatchVariantName",s,t);return this.EnsureTrue(r),r},e)}static useType(e){return h(async(s,t,r)=>{const a=await this.Invoke("ProductPatchType",s,t,r);return this.EnsureTrue(a),a},e)}static useCombo(e){return h(async(s,t,r)=>{const a=await this.Invoke("ProductPatchCombo",s,t,r);return this.EnsureTrue(a),a},e)}}let Ve;function Qs(o){Ve=o}class ms extends C{static Log=[...super.Log,"Product","Post"];static useCreate(e){return h(async s=>{const t=await this.Invoke("ProductPostCreate",s);return this.UpdateCache(r=>[t,...r],"","ProductGetList",y().add(1,"m")),t},e)}static useMovePhoto(e){return h(async(s,t)=>{const r=await this.Invoke("ProductPostMovePhoto",s,t);return this.EnsureTrue(r),r},e)}static usePhoto(e,s){const t=O(()=>e.With(...this.Log,"Photo"));return h(async(r,a)=>{if(!a.type.startsWith("image/"))throw new TypeError("File is not an image");if(a.size>10*1024*1024)throw new RangeError("File is too large, max 10MB");const i=new pe,u=this.Invoke("ProductPostPhoto",r,i);return await this.HandleFileStream(a,i,t),this.EnsureTrue(await u),!0},s)}static useVariant(e){return h((s,t)=>this.Invoke("ProductPostVariant",s,t),e)}static useType(e){return h((s,t)=>this.Invoke("ProductPostType",s,t),e)}static useCombo(e){return h((s,t,r)=>this.Invoke("ProductPostCombo",s,t,r),e)}static useLexical(e){return h(async s=>{const t=Ve?.getEditorState();let r;t&&!t.isEmpty()&&(r=JSON.stringify(t.toJSON()));const a=await this.Invoke("ProductPostDescription",s,r);return this.EnsureTrue(a),a},e)}}const ps={Get:ds,Post:ms,Patch:hs,Delete:ls};class gs extends C{static useUser(e){return h(async s=>{const t=await this.Invoke("UserDeleteUser",s);return this.EnsureTrue(t),t},e)}static useAdmin(e){return h(async s=>{const t=await this.Invoke("UserDeleteAdmin",s);return this.EnsureTrue(t),t},e)}}class xs extends C{static async OrderUser(e){const s=await Y.Order(e);if(!s)throw new Error(`Order ${e} not found`);const t=await K.User(s.UserId);if(!t)throw new Error(`User ${s.UserId} not found in order ${e}`);return t}static async List(){const e=await this.GetTimeCache("","UserGetList",t=>t.add(1,"m")),s=[];for(const t of e){const r=await K.User(t);if(!r){console.warn(`User ${t} not found`);continue}s.push({Id:t,Name:r.Name,EMail:r.EMail,Admin:r.Admin})}return s}}class fs extends C{static useAdmin(e){return h(async s=>{const t=await this.Invoke("UserPostAdmin",s);return this.EnsureTrue(t),t},e)}}const ws={Get:xs,Post:fs,Delete:gs},ys={Product:ps,Order:us,User:ws},Ps=P({body:D}),Cs=new A("Admin","Product","AddButton");function js(){const{Nav:o,Paths:e}=V(),s=e.at(0),t=e.at(1),r=Ps(),[a,i]=x.useState(""),{dispatch:u,dispatchToast:c}=ne(Cs),{run:l,loading:d}=ys.Product.Post.useCreate({manual:!0,onError(p,w){u({Message:`Failed Create ${a}`,Request:w,Error:p})},onSuccess(p){c(n.jsxs(Z,{children:[n.jsx(ee,{children:"New Product Created"}),n.jsxs(te,{children:[p," ",a]})]}),{intent:"success"}),o("Admin",p),i("")}});return s==="Admin"&&!t&&n.jsxs(be,{children:[n.jsx(he,{disableButtonEnhancement:!0,children:n.jsx(I,{appearance:"primary",icon:n.jsx(Je,{}),children:"New Product"})}),n.jsx(Te,{children:n.jsxs(ve,{children:[n.jsx(Se,{className:r.body,children:n.jsx(z,{required:!0,size:"large",value:a,maxLength:15,appearance:"underline",onChange:(p,w)=>i(w.value),contentBefore:n.jsx(Ke,{children:"Give A Name"})})}),n.jsxs(Ee,{children:[n.jsx(he,{disableButtonEnhancement:!0,children:n.jsx(I,{appearance:"secondary",children:"Cancel"})}),n.jsx(I,{disabled:d,appearance:"primary",onClick:()=>l(a),children:"Create"})]})]})})]})}const bs=new A("Avatar","Menu");function Ts(){const[o,{toggle:e}]=k(),[s,{toggle:t}]=k(),{instance:r}=je(),[a,{set:i}]=k(!0);x.useEffect(()=>{M.subscribe(d=>i(!d))},[]);const u=j.User.Get.useMe(bs),c=r.getActiveAccount(),l=c?.name||c?.username;return n.jsxs(n.Fragment,{children:[n.jsxs(Ze,{open:o,onOpenChange:e,children:[n.jsx(et,{children:n.jsx(tt,{size:36,active:o?"active":"unset",name:l})}),n.jsx(st,{children:n.jsxs(nt,{children:[n.jsx(W,{children:n.jsxs(rt,{children:["Hi ",l]})}),n.jsx(at,{children:n.jsx(B,{onClick:()=>r.loginRedirect(),children:"Login"})}),n.jsxs(W,{children:[n.jsx(U,{appearance:"subtle",href:"/History",children:n.jsx(B,{children:"History"})}),u?.Admin&&n.jsx(U,{appearance:"subtle",href:"/Admin",children:n.jsx(B,{children:"Admin"})}),n.jsx(B,{onClick:t,children:"Setting"}),n.jsx(B,{onClick:()=>r.logoutRedirect(),children:"Logout"})]})]})})]}),a&&n.jsx(W,{children:n.jsx($e,{Open:s,Toggle:t})})]})}function Be({Items:o,Columns:e,NoHeader:s}){return n.jsxs(ot,{items:o||[],columns:e,getRowId:t=>t.Id,children:[!s&&n.jsx(it,{children:n.jsx(ye,{children:({renderHeaderCell:t})=>t()})}),n.jsx(ct,{children:({item:t,rowId:r})=>n.jsx(ye,{children:({renderCell:a})=>a(t)},r)}),!o&&n.jsx(ut,{size:48})]})}function vs({Guid:o,Log:e,...s}){const t=O(()=>e.With("GuidImage")),{data:r,run:a}=h(j.Storage.GetBySlice.bind(j.Storage),{manual:!0,onError:t.error});return x.useEffect(()=>{o&&a(o,t)},[o]),n.jsx(Oe,{...s,src:r?URL.createObjectURL(new Blob(r)):"https://placehold.co/400?text=Loading..."})}const Ce=P({unset:{flexBasis:"unset",flexGrow:0},img:{...Dt,aspectRatio:"1",marginTop:m.spacingVerticalXS,marginBottom:m.spacingVerticalXS}});function Ss(o,e){const s={width:`${o}px`};return Q({columnId:"Cover",renderHeaderCell:()=>{const t=Ce();return n.jsx(lt,{className:t.unset,children:n.jsx("div",{style:s})})},renderCell(t){const r=Ce();return n.jsx(X,{className:r.unset,children:n.jsx(vs,{className:r.img,style:s,Guid:t.Cover,Log:e})})}})}function Es(o){const{List:e}=F(),{data:s}=h(()=>j.Product.Get.Limit(o)),t=s||3;let r=0;for(const a of e)if(a.ProdId===o&&(r+=a.Quantity),r>=t)return[!0,t];return[!1,t]}const le=P({prod:{...D,alignItems:"flex-start",justifyContent:"center"},qua:{flexBasis:"12%",flexGrow:0},act:{flexBasis:"7%",flexGrow:0}}),Ls=[Q({columnId:"Product",renderCell(o){return n.jsxs(X,{className:le().prod,children:[n.jsx(U,{href:`/Product/${o.ProdId}`,appearance:"subtle",children:n.jsx(dt,{children:o.Name})}),n.jsx(ht,{children:Object.values(o.Type).reduce((e,s)=>`${e} ${s},`,"")})]})}}),Q({columnId:"Quantity",renderCell(o){const{List:e,Update:s}=F(),[t,r]=Es(o.ProdId);return n.jsx(X,{className:le().qua,children:n.jsx(mt,{min:1,max:r,value:o.Quantity,onChange:(a,i)=>{t&&i.value>=o.Quantity||(o.Quantity=i.value,s(e))}})})}}),Q({columnId:"Action",renderCell(o){const{List:e,Update:s}=F();return n.jsx(X,{className:le().act,children:n.jsx(I,{appearance:"subtle",icon:n.jsx(pt,{}),onClick:()=>s(e.filter(t=>t.Id!==o.Id))})})}})];function He(o){return[Ss(44,o),...Ls]}const Is=P({person:G,inf:{...D,flexBasis:"50%",rowGap:m.spacingVerticalM}});function Ns({Log:o}){const e=Is(),s=O(()=>o.With("PersonaInfo")),t=j.User.Get.useMe(s);return n.jsxs(n.Fragment,{children:[n.jsxs("div",{className:e.person,children:[n.jsx("div",{className:e.inf,children:n.jsx(E,{label:"Name",size:"large",children:n.jsx(H,{children:t?.Name})})}),n.jsx("div",{className:e.inf,children:n.jsx(E,{label:"Phone",size:"large",children:n.jsx(H,{children:t?.Phone})})})]}),n.jsx(E,{label:"E-Mail",size:"large",children:n.jsx(H,{children:t?.EMail})}),n.jsx(E,{label:"Address",size:"large",children:n.jsx(H,{children:t?.Address})})]})}const Gs=P({body:{...D,rowGap:m.spacingVerticalXL},sub:{width:"fit-content",alignSelf:"flex-end"}}),de=new A("TopNavBar","ShopCart","Confirm");function ks(){const[o,e]=x.useState(),[s,{toggle:t}]=k(),{List:r,Update:a}=F(),{Nav:i}=V(),u=Gs(),{dispatch:c,dispatchToast:l}=ne(de),{run:d}=j.Order.Post.useNew({manual:!0,onError(p,w){c({Message:"Failed Create Order",Request:w,Error:p})},onSuccess(p){l(n.jsxs(Z,{children:[n.jsx(ee,{children:"Order Placed"}),n.jsxs(te,{children:["Order Id: ",p]})]}),{intent:"success"}),a([]),t(),i("History",p)}});return n.jsxs(n.Fragment,{children:[n.jsx(I,{appearance:"primary",onClick:t,disabled:!r.length,children:"Checkout"}),n.jsxs(gt,{open:s,onOpenChange:t,position:"end",size:"medium",modalType:"alert",children:[n.jsx(xt,{children:n.jsx(ft,{action:n.jsx(I,{appearance:"subtle",icon:n.jsx(wt,{}),onClick:t}),children:"Confirm Order"})}),n.jsx(yt,{children:n.jsxs("div",{className:u.body,children:[n.jsx(Ns,{Log:de}),n.jsx(Be,{Items:r,Columns:O(()=>He(de)),NoHeader:!0}),n.jsx(E,{label:"Comment",size:"large",children:n.jsx(Pt,{value:o,onChange:(p,w)=>e(w.value),maxLength:1e3})}),n.jsx(I,{appearance:"primary",className:u.sub,disabled:!r.length,onClick:()=>d(r,o),children:"Submit"})]})})]})]})}const Os=P({conf:{...G,width:"100%",alignItems:"center",justifyContent:"space-between",marginTop:m.spacingVerticalS,columnGap:m.spacingHorizontalL},tooltip:{backgroundColor:m.colorBrandBackground,color:m.colorNeutralForegroundInverted,...R.borderRadius(m.borderRadiusCircular)}}),As=new A("TopNavBar","ShopCart");function $s(){const[o,{toggle:e}]=k(),[s,{toggle:t}]=k(),r=Os(),{List:a}=F();return Ct(()=>{if(o)return;t();const i=setTimeout(t,2e3);return()=>clearTimeout(i)},[a]),n.jsxs(jt,{withArrow:!0,open:o,onOpenChange:e,children:[n.jsx(bt,{disableButtonEnhancement:!0,children:n.jsx(Tt,{visible:s,withArrow:!0,content:{children:"↑",className:r.tooltip},relationship:"inaccessible",children:n.jsx(vt,{icon:n.jsx(St,{}),appearance:"subtle",size:"large",checked:o})})}),n.jsxs(Et,{children:[n.jsx(Be,{Items:a,Columns:O(()=>He(As)),NoHeader:!0}),n.jsxs("div",{className:r.conf,children:[a.map(i=>i.Quantity).reduce((i,u)=>i+u,0)," items in shopping cart",n.jsx(ks,{})]})]})]})}const Us=P({navBox:{position:"fixed",top:0,width:"100%",height:`${ge}px`,...R.padding(0,m.spacingHorizontalXXXL),backgroundColor:"#fff",boxSizing:"border-box",boxShadow:m.shadow4},navBar:{...G,maxWidth:xe,height:"100%",...R.margin(0,"auto"),alignItems:"center",justifyContent:"space-between"},logoBox:{...G,columnGap:m.spacingHorizontalL,alignItems:"center"},logoText:{color:m.colorBrandForeground2}});function Ms(){const o=Us();return n.jsx(Lt,{children:n.jsx("header",{className:o.navBox,children:n.jsxs("nav",{className:o.navBar,children:[n.jsxs(U,{className:o.logoBox,href:"/",appearance:"subtle",children:[n.jsx(Oe,{src:"/Awai.png",height:ge}),n.jsx(J,{size:600,font:"monospace",className:o.logoText,children:fe.Name})]}),n.jsx(os,{}),n.jsxs("div",{className:o.logoBox,children:[n.jsx(js,{}),n.jsx(rs,{}),n.jsx($s,{}),n.jsx(Ts,{})]})]})})})}function Ds(){const{Rep:o}=V();return setTimeout(()=>o("/"),3e3),n.jsxs(n.Fragment,{children:[n.jsxs(It,{children:[n.jsxs("title",{children:["Redirect - Not Found - ",fe.Name]}),n.jsx("meta",{name:"robots",content:"noindex, nofollow"})]}),n.jsx(q,{size:"huge",label:"Redirecting..."})]})}const Rs=P({body:{...D,minWidth:"1024px",position:"absolute",marginTop:`${ge}px`,width:"100%",minHeight:"-webkit-fill-available",justifyContent:"space-between",backgroundColor:m.colorNeutralBackground2},content:{...D,maxWidth:xe,width:"-webkit-fill-available",marginLeft:"auto",marginRight:"auto",paddingLeft:m.spacingHorizontalM,paddingRight:m.spacingHorizontalM,paddingTop:m.spacingVerticalXXXL}});function Vs(){const o=Rs(),{Paths:e}=V(),s=e.at(0),t=x.useMemo(()=>{switch(s){case"Product":return n.jsx(Bs,{});case"Admin":return n.jsx(Hs,{});case"History":return n.jsx(zs,{});case"Login":return n.jsx(q,{size:"huge",label:"Login Redirecting..."});case"Reload":return n.jsx(q,{size:"huge",label:"Reloading..."});case"":case void 0:return n.jsx(Fs,{});default:return n.jsx(Ds,{})}},[s]);return n.jsxs(n.Fragment,{children:[n.jsx(Ms,{}),n.jsxs("div",{className:o.body,children:[n.jsx("main",{className:o.content,children:n.jsx(x.Suspense,{fallback:n.jsx(q,{}),children:t})}),n.jsx(ns,{})]}),n.jsx(Bt,{})]})}const Bs=x.lazy(()=>se(()=>import("./index-YN3820jC.js"),__vite__mapDeps([0,1,2,3,4,5]))),Hs=x.lazy(()=>se(()=>import("./index-wo2xrWSk.js"),__vite__mapDeps([6,1,7,8,3,4]))),zs=x.lazy(()=>se(()=>import("./index-0T8GTba5.js"),__vite__mapDeps([9,1,7]))),Fs=x.lazy(()=>se(()=>import("./index-AaZE75L8.js"),__vite__mapDeps([10,1,2,3,8])));Nt.createRoot(document.getElementById(fe.Name)).render(n.jsx(Gt,{theme:kt,children:n.jsx($t,{children:n.jsx(Ot,{instance:N,children:n.jsxs(ts,{children:[n.jsx(At,{pauseOnHover:!0}),n.jsx(Vs,{})]})})})}));export{ys as A,Ws as B,Dt as C,fe as D,G as F,vs as G,j as H,A as L,Ss as M,Qs as S,D as a,Es as b,V as c,Ut as d,ne as e,Be as f,F as u}; +function __vite__mapDeps(indexes) { + if (!__vite__mapDeps.viteFileDeps) { + __vite__mapDeps.viteFileDeps = ["assets/index-YN3820jC.js","assets/vendor-DpqXKvKY.js","assets/isArrayLike--sVJAW2Y.js","assets/isObject-tyZXtoJz.js","assets/Lazy-XJRXDq2K.js","assets/index-scunr7sf.css","assets/index-wo2xrWSk.js","assets/Columns-Qu8-yOAT.js","assets/toFinite-GMFxiq4g.js","assets/index-0T8GTba5.js","assets/index-AaZE75L8.js"] + } + return indexes.map((i) => __vite__mapDeps.viteFileDeps[i]) +} diff --git a/assets/index-fE5hFxdC.js b/assets/index-AaZE75L8.js similarity index 94% rename from assets/index-fE5hFxdC.js rename to assets/index-AaZE75L8.js index 6d99d2d..3ad820f 100644 --- a/assets/index-fE5hFxdC.js +++ b/assets/index-AaZE75L8.js @@ -1 +1 @@ -import{m as c,t as i,x as m,j as n,aP as y,aQ as G,aR as h,J as j,aA as g,a3 as d,aS as v,aq as C}from"./vendor-DpqXKvKY.js";import{L as f,C as R,H as u,G as L,F,D as b,a as N}from"./index-YSLnLPU4.js";import{c as M,b as S,e as k}from"./isArrayLike--sVJAW2Y.js";import{i as P}from"./isObject-tyZXtoJz.js";import{t as x}from"./toFinite-GMFxiq4g.js";function $(e,a,s){if(!P(s))return!1;var r=typeof a;return(r=="number"?M(s)&&S(a,s.length):r=="string"&&a in s)?k(s[a],e):!1}var E=Math.floor,I=Math.random;function q(e,a){return e+E(I()*(a-e+1))}var z=parseFloat,A=Math.min,B=Math.random;function H(e,a,s){if(s&&typeof s!="boolean"&&$(e,a,s)&&(a=s=void 0),s===void 0&&(typeof a=="boolean"?(s=a,a=void 0):typeof e=="boolean"&&(s=e,e=void 0)),e===void 0&&a===void 0?(e=0,a=1):(e=x(e),a===void 0?(a=e,e=0):a=x(a)),e>a){var r=e;e=a,a=r}if(s||e%1||a%1){var t=B();return A(e+t*(a-e+z("1e-"+((t+"").length-1))),a)}return q(e,a)}const T=c({card:{flexBasis:"23%",flexGrow:0},img:{aspectRatio:"1",...R,borderTopLeftRadius:i.borderRadiusMedium,borderTopRightRadius:i.borderRadiusMedium}}),l=new f("Gallery","Category","Card");function V({Id:e}){const a=T(),{data:s}=m(()=>u.Product.Get.Basic(e,l),{onError:l.error});return n.jsxs(y,{className:a.card,children:[n.jsx(G,{children:n.jsx(L,{className:a.img,Guid:s?.Cover,Log:l})}),n.jsx(h,{children:n.jsx(j,{href:`/Product/${e}`,children:s?.Name||"Loading..."})})]})}const D=c({card:{flexBasis:"23%",flexGrow:0},cate:{...F,flexWrap:"wrap",justifyContent:"space-evenly",columnGap:i.spacingVerticalL,rowGap:i.spacingVerticalXL}}),X=new f("Gallery","Category");function J({Category:e}){const a=D(),{data:s,loading:r}=m(()=>u.Gallery.Get.Products(e),{onError:X.error});return n.jsxs(n.Fragment,{children:[n.jsx(g,{children:e}),n.jsx("div",{className:a.cate,children:r?n.jsx(d,{size:128}):s[0].map((t,o)=>n.jsx(V,{Id:t},o)).concat(Array(s[1]).fill(null).map((t,o)=>n.jsx("div",{className:a.card},o+H(10,100))))})]})}const O=c({main:{...N,rowGap:i.spacingVerticalXL}}),Q=new f("Gallery");function Z(){const e=O(),{data:a,loading:s}=m(()=>u.Gallery.Get.Categories(),{onError:Q.error});return s?n.jsxs(v,{className:e.main,children:[n.jsx(d,{appearance:"translucent",size:32}),n.jsx(d,{size:128})]}):n.jsxs("div",{className:e.main,children:[n.jsx(C,{children:n.jsxs("title",{children:["Gallery - ",b.Name]})}),a?.map((r,t)=>n.jsx(J,{Category:r},t))]})}export{Z as default}; +import{m as c,t as i,x as m,j as n,aP as y,aQ as G,aR as h,J as j,aA as g,a3 as d,aS as v,aq as C}from"./vendor-DpqXKvKY.js";import{L as f,C as R,H as u,G as L,F,D as b,a as N}from"./index-7dlI38O5.js";import{c as M,b as S,e as k}from"./isArrayLike--sVJAW2Y.js";import{i as P}from"./isObject-tyZXtoJz.js";import{t as x}from"./toFinite-GMFxiq4g.js";function $(e,a,s){if(!P(s))return!1;var r=typeof a;return(r=="number"?M(s)&&S(a,s.length):r=="string"&&a in s)?k(s[a],e):!1}var E=Math.floor,I=Math.random;function q(e,a){return e+E(I()*(a-e+1))}var z=parseFloat,A=Math.min,B=Math.random;function H(e,a,s){if(s&&typeof s!="boolean"&&$(e,a,s)&&(a=s=void 0),s===void 0&&(typeof a=="boolean"?(s=a,a=void 0):typeof e=="boolean"&&(s=e,e=void 0)),e===void 0&&a===void 0?(e=0,a=1):(e=x(e),a===void 0?(a=e,e=0):a=x(a)),e>a){var r=e;e=a,a=r}if(s||e%1||a%1){var t=B();return A(e+t*(a-e+z("1e-"+((t+"").length-1))),a)}return q(e,a)}const T=c({card:{flexBasis:"23%",flexGrow:0},img:{aspectRatio:"1",...R,borderTopLeftRadius:i.borderRadiusMedium,borderTopRightRadius:i.borderRadiusMedium}}),l=new f("Gallery","Category","Card");function V({Id:e}){const a=T(),{data:s}=m(()=>u.Product.Get.Basic(e,l),{onError:l.error});return n.jsxs(y,{className:a.card,children:[n.jsx(G,{children:n.jsx(L,{className:a.img,Guid:s?.Cover,Log:l})}),n.jsx(h,{children:n.jsx(j,{href:`/Product/${e}`,children:s?.Name||"Loading..."})})]})}const D=c({card:{flexBasis:"23%",flexGrow:0},cate:{...F,flexWrap:"wrap",justifyContent:"space-evenly",columnGap:i.spacingVerticalL,rowGap:i.spacingVerticalXL}}),X=new f("Gallery","Category");function J({Category:e}){const a=D(),{data:s,loading:r}=m(()=>u.Gallery.Get.Products(e),{onError:X.error});return n.jsxs(n.Fragment,{children:[n.jsx(g,{children:e}),n.jsx("div",{className:a.cate,children:r?n.jsx(d,{size:128}):s[0].map((t,o)=>n.jsx(V,{Id:t},o)).concat(Array(s[1]).fill(null).map((t,o)=>n.jsx("div",{className:a.card},o+H(10,100))))})]})}const O=c({main:{...N,rowGap:i.spacingVerticalXL}}),Q=new f("Gallery");function Z(){const e=O(),{data:a,loading:s}=m(()=>u.Gallery.Get.Categories(),{onError:Q.error});return s?n.jsxs(v,{className:e.main,children:[n.jsx(d,{appearance:"translucent",size:32}),n.jsx(d,{size:128})]}):n.jsxs("div",{className:e.main,children:[n.jsx(C,{children:n.jsxs("title",{children:["Gallery - ",b.Name]})}),a?.map((r,t)=>n.jsx(J,{Category:r},t))]})}export{Z as default}; diff --git a/assets/index-M75ftWWX.js b/assets/index-YN3820jC.js similarity index 99% rename from assets/index-M75ftWWX.js rename to assets/index-YN3820jC.js index 49a88a5..b2f16c7 100644 --- a/assets/index-M75ftWWX.js +++ b/assets/index-YN3820jC.js @@ -1,4 +1,4 @@ -import{r as D,ay as Kt,az as It,m as se,x as Pe,j as w,s as Ke,t as R,B as qt,aA as At,aB as Xt,aa as Yt,am as Vt,a3 as Qt,aq as Jt,aC as Zt,aD as Je}from"./vendor-DpqXKvKY.js";import{L as qe,H as re,C as er,B as Ct,a as ne,u as tr,b as Mt,F as ye,c as rr,D as nr,d as ir}from"./index-YSLnLPU4.js";import{i as ar,a as or,b as sr,c as ur,e as Lt}from"./isArrayLike--sVJAW2Y.js";import{r as F,i as lr,a as ie,b as Oe,f as fr,S as Ze}from"./isObject-tyZXtoJz.js";import{L as cr}from"./Lazy-vvLq-Rxx.js";var xt={},Te={},Xe={},Le={},et;function pr(){return et||(et=1,function(e){(function(t,n){n(e,D,Kt)})(It,function(t,n,i){Object.defineProperty(t,"__esModule",{value:!0}),t.setHasSupportToCaptureOption=P;var r=o(n),a=o(i);function o(c){return c&&c.__esModule?c:{default:c}}var s=Object.assign||function(c){for(var m=1;m=0||Object.prototype.hasOwnProperty.call(c,f)&&(S[f]=c[f]);return S}function l(c,m){if(!(c instanceof m))throw new TypeError("Cannot call a class as a function")}var p=function(){function c(m,S){for(var f=0;f0&&arguments[0]!==void 0?arguments[0]:{capture:!0};return g?c:c.capture}function L(c){if("touches"in c){var m=c.touches[0],S=m.pageX,f=m.pageY;return{x:S,y:f}}var O=c.screenX,x=c.screenY;return{x:O,y:x}}var C=function(c){h(m,c);function m(){var S;l(this,m);for(var f=arguments.length,O=Array(f),x=0;xO&&this.props.onSwipeRight(1,f),this.movePosition.deltaY<-O?this.props.onSwipeUp(1,f):this.movePosition.deltaY>O&&this.props.onSwipeDown(1,f)),this.moveStart=null,this.moving=!1,this.movePosition=null}},{key:"_setSwiperRef",value:function(f){this.swiper=f,this.props.innerRef(f)}},{key:"render",value:function(){var f=this.props;f.tagName;var O=f.className,x=f.style,b=f.children;f.allowMouseEvents,f.onSwipeUp,f.onSwipeDown,f.onSwipeLeft,f.onSwipeRight,f.onSwipeStart,f.onSwipeMove,f.onSwipeEnd,f.innerRef,f.tolerance;var pe=u(f,["tagName","className","style","children","allowMouseEvents","onSwipeUp","onSwipeDown","onSwipeLeft","onSwipeRight","onSwipeStart","onSwipeMove","onSwipeEnd","innerRef","tolerance"]);return r.default.createElement(this.props.tagName,s({ref:this._setSwiperRef,onMouseDown:this._onMouseDown,onTouchStart:this._handleSwipeStart,onTouchEnd:this._handleSwipeEnd,className:O,style:x},pe),b)}}]),m}(n.Component);C.displayName="ReactSwipe",C.propTypes={tagName:a.default.string,className:a.default.string,style:a.default.object,children:a.default.node,allowMouseEvents:a.default.bool,onSwipeUp:a.default.func,onSwipeDown:a.default.func,onSwipeLeft:a.default.func,onSwipeRight:a.default.func,onSwipeStart:a.default.func,onSwipeMove:a.default.func,onSwipeEnd:a.default.func,innerRef:a.default.func,tolerance:a.default.number.isRequired},C.defaultProps={tagName:"div",allowMouseEvents:!1,onSwipeUp:function(){},onSwipeDown:function(){},onSwipeLeft:function(){},onSwipeRight:function(){},onSwipeStart:function(){},onSwipeMove:function(){},onSwipeEnd:function(){},innerRef:function(){},tolerance:0},t.default=C})}(Le)),Le}(function(e){(function(t,n){n(e,pr())})(It,function(t,n){Object.defineProperty(t,"__esModule",{value:!0});var i=r(n);function r(a){return a&&a.__esModule?a:{default:a}}t.default=i.default})})(Xe);var ue={},Dt={exports:{}};/*! +import{r as D,ay as Kt,az as It,m as se,x as Pe,j as w,s as Ke,t as R,B as qt,aA as At,aB as Xt,aa as Yt,am as Vt,a3 as Qt,aq as Jt,aC as Zt,aD as Je}from"./vendor-DpqXKvKY.js";import{L as qe,H as re,C as er,B as Ct,a as ne,u as tr,b as Mt,F as ye,c as rr,D as nr,d as ir}from"./index-7dlI38O5.js";import{i as ar,a as or,b as sr,c as ur,e as Lt}from"./isArrayLike--sVJAW2Y.js";import{r as F,i as lr,a as ie,b as Oe,f as fr,S as Ze}from"./isObject-tyZXtoJz.js";import{L as cr}from"./Lazy-XJRXDq2K.js";var xt={},Te={},Xe={},Le={},et;function pr(){return et||(et=1,function(e){(function(t,n){n(e,D,Kt)})(It,function(t,n,i){Object.defineProperty(t,"__esModule",{value:!0}),t.setHasSupportToCaptureOption=P;var r=o(n),a=o(i);function o(c){return c&&c.__esModule?c:{default:c}}var s=Object.assign||function(c){for(var m=1;m=0||Object.prototype.hasOwnProperty.call(c,f)&&(S[f]=c[f]);return S}function l(c,m){if(!(c instanceof m))throw new TypeError("Cannot call a class as a function")}var p=function(){function c(m,S){for(var f=0;f0&&arguments[0]!==void 0?arguments[0]:{capture:!0};return g?c:c.capture}function L(c){if("touches"in c){var m=c.touches[0],S=m.pageX,f=m.pageY;return{x:S,y:f}}var O=c.screenX,x=c.screenY;return{x:O,y:x}}var C=function(c){h(m,c);function m(){var S;l(this,m);for(var f=arguments.length,O=Array(f),x=0;xO&&this.props.onSwipeRight(1,f),this.movePosition.deltaY<-O?this.props.onSwipeUp(1,f):this.movePosition.deltaY>O&&this.props.onSwipeDown(1,f)),this.moveStart=null,this.moving=!1,this.movePosition=null}},{key:"_setSwiperRef",value:function(f){this.swiper=f,this.props.innerRef(f)}},{key:"render",value:function(){var f=this.props;f.tagName;var O=f.className,x=f.style,b=f.children;f.allowMouseEvents,f.onSwipeUp,f.onSwipeDown,f.onSwipeLeft,f.onSwipeRight,f.onSwipeStart,f.onSwipeMove,f.onSwipeEnd,f.innerRef,f.tolerance;var pe=u(f,["tagName","className","style","children","allowMouseEvents","onSwipeUp","onSwipeDown","onSwipeLeft","onSwipeRight","onSwipeStart","onSwipeMove","onSwipeEnd","innerRef","tolerance"]);return r.default.createElement(this.props.tagName,s({ref:this._setSwiperRef,onMouseDown:this._onMouseDown,onTouchStart:this._handleSwipeStart,onTouchEnd:this._handleSwipeEnd,className:O,style:x},pe),b)}}]),m}(n.Component);C.displayName="ReactSwipe",C.propTypes={tagName:a.default.string,className:a.default.string,style:a.default.object,children:a.default.node,allowMouseEvents:a.default.bool,onSwipeUp:a.default.func,onSwipeDown:a.default.func,onSwipeLeft:a.default.func,onSwipeRight:a.default.func,onSwipeStart:a.default.func,onSwipeMove:a.default.func,onSwipeEnd:a.default.func,innerRef:a.default.func,tolerance:a.default.number.isRequired},C.defaultProps={tagName:"div",allowMouseEvents:!1,onSwipeUp:function(){},onSwipeDown:function(){},onSwipeLeft:function(){},onSwipeRight:function(){},onSwipeStart:function(){},onSwipeMove:function(){},onSwipeEnd:function(){},innerRef:function(){},tolerance:0},t.default=C})}(Le)),Le}(function(e){(function(t,n){n(e,pr())})(It,function(t,n){Object.defineProperty(t,"__esModule",{value:!0});var i=r(n);function r(a){return a&&a.__esModule?a:{default:a}}t.default=i.default})})(Xe);var ue={},Dt={exports:{}};/*! Copyright (c) 2018 Jed Watson. Licensed under the MIT License (MIT), see http://jedwatson.github.io/classnames diff --git a/assets/index-YSLnLPU4.js b/assets/index-YSLnLPU4.js deleted file mode 100644 index 743e78e..0000000 --- a/assets/index-YSLnLPU4.js +++ /dev/null @@ -1,11 +0,0 @@ -import{r as x,u as Ce,j as n,d as y,t as m,s as R,m as P,a as Fe,T as Z,b as ee,c as te,e as J,f as je,D as be,g as Te,h as ve,i as _e,k as Se,F as E,I as z,L as H,l as Ee,n as he,B as I,S as me,o as $,A as W,X as We,P as Qe,p as fe,H as _,q as Le,v as Ie,M as Ne,w as Ge,x as h,y as k,z as ke,C as Xe,E as qe,G as Ye,J as U,K as ae,N as Je,O as Ke,Q as Ze,R as et,U as tt,V as st,W as nt,Y as rt,Z as at,_ as B,$ as ot,a0 as it,a1 as we,a2 as ct,a3 as ut,a4 as Oe,a5 as Q,a6 as lt,a7 as X,a8 as dt,a9 as ht,aa as mt,ab as pt,ac as gt,ad as xt,ae as ft,af as wt,ag as yt,ah as Pt,ai as Ct,aj as jt,ak as bt,al as Tt,am as vt,an as St,ao as Et,ap as Lt,aq as It,ar as q,as as se,at as Nt,au as Gt,av as kt,aw as Ot,ax as At}from"./vendor-DpqXKvKY.js";function oe(o){return`/${o.filter(s=>s).map(s=>s.toString().replace(/^\/+/,"")).join("/")}`}const Ae=x.createContext({});function V(){return x.useContext(Ae)}function $t({children:o}){const[e,s]=x.useState(()=>({Paths:location.pathname.split("/").filter(c=>c),Search:new URLSearchParams(location.search),Put:t,Nav:(...c)=>a(oe(c)),Rep:(...c)=>i(oe(c)),Reload:(...c)=>l(c)}));function t(c){history.replaceState(null,"",`${location.pathname}${c.size?"?":""}${c.toString()}`),e.Search=new URLSearchParams(c),s({...e})}function r(c){e.Paths=c.split("/").filter(u=>u),e.Search=new URLSearchParams(location.search),s({...e})}function a(c){history.pushState(null,"",c),r(c)}function i(c){history.replaceState(null,"",c),r(c)}function l(c){history.replaceState(null,"","/Reload"),r("/Reload"),setTimeout(()=>{const u=c.length?oe(c):location.pathname;history.pushState(null,"",u),r(u)},100)}return Ce(()=>{location.pathname==="/"&&location.search.startsWith("?/")&&i(location.search.substring(2)),addEventListener("click",c=>{const u=c.target?.closest("a");if(u){if(u.origin!==location.origin){u.target="_blank";return}c.preventDefault(),a(u.pathname)}}),addEventListener("popstate",c=>{c.preventDefault(),r(location.pathname)})}),n.jsx(Ae.Provider,{value:e,children:o})}class O{namespace;info;error;warn;debug;throw;constructor(...e){this.namespace=e.join(" > "),this.error=console.error.bind(this,this.baseColor(101,"error"),` - `),this.warn=console.warn.bind(this,this.baseColor(103,"warn"),` - `),this.info=console.info.bind(this,this.baseColor(104,"info"),` - `),this.debug=console.debug.bind(this,this.baseColor(102,"debug"),` - `),this.throw=console.log.bind(this,this.baseColor(105,"throw"),"↓ The Following Error is Thrown ↓")}With(...e){return new O(this.namespace,...e)}baseColor(e,s){return`\x1B[${e};30;1m ${s.toUpperCase()} \x1B[0m\x1B[100;97m ${y().format("YY-M-D H:m:s")} \x1B[1m\x1B[40;97m ${this.namespace} `}}const G={display:"flex"},Ut={flexDirection:"column"},M={...G,...Ut},Ws={...G,backgroundColor:m.colorNeutralBackground1,boxShadow:m.shadow4,...R.borderRadius(m.borderRadiusMedium)},Mt={whiteSpace:"pre-line"},pe=60,ge="1636px",Dt={objectFit:"cover",objectPosition:"center"},Rt=P({pre:Mt});function ne(o){const e=Rt(),{dispatchToast:s}=Fe();return{dispatch:t=>{const r=t.Error.message,a=r.indexOf("Exception:");let i=r;a!==-1&&(i=r.substring(a+10)),s(n.jsxs(Z,{children:[n.jsx(ee,{children:"Internal Error"}),n.jsx(te,{subtitle:n.jsxs(J,{className:e.pre,children:[i,n.jsx("br",{}),"More Info, See Console"]}),children:n.jsx(J,{className:e.pre,children:t.Message})})]}),{intent:"error",timeout:1e4}),o.error(t)},dispatchToast:s}}const Vt=P({box:{...M,rowGap:m.spacingVerticalM},one:{...G,columnGap:m.spacingVerticalXXXL}}),ye=new O("Setting");function $e({Open:o,Toggle:e,New:s}){const t=Vt(),r=je().instance.getActiveAccount(),[a,i]=x.useState(),[l,c]=x.useState(),[u,d]=x.useState(),p=j.User.Get.useMe(ye);x.useEffect(()=>{if(s||!p)return;const{Name:f,Phone:g,Address:ze}=p;i(f),c(g),d(ze)},[p]);const{dispatch:w,dispatchToast:T}=ne(ye),{run:v}=j.User.Post.useUpdate({manual:!0,onError(f,[g]){w({Message:`Failed ${s?"Create":"Update"} Info`,Error:f,Request:g})},onSuccess(f,[g]){T(n.jsxs(Z,{children:[n.jsxs(ee,{children:["Info ",s?"Created":"Updated"]}),n.jsxs(te,{children:[g.Name,n.jsx("br",{}),g.Phone,n.jsx("br",{}),g.Address]})]}),{intent:"success"}),s&&(D.next(!1),D.complete(),D.closed=!0),e()}});return n.jsx(be,{open:o,onOpenChange:e,modalType:s?"alert":"modal",children:n.jsx(Te,{children:n.jsxs(ve,{children:[n.jsx(_e,{children:s?"Welcome! Fill in your info to get started.":"Personal Information"}),n.jsxs(Se,{className:t.box,children:[n.jsxs("div",{className:t.one,children:[n.jsx(E,{label:"Name",size:"large",required:!0,children:n.jsx(z,{size:"medium",value:a,maxLength:20,onChange:(f,g)=>i(g.value)})}),n.jsx(E,{label:"Phone",size:"large",required:!0,children:n.jsx(z,{size:"medium",value:l,maxLength:20,onChange:(f,g)=>c(g.value)})})]}),n.jsx(E,{label:"E-Mail",size:"large",children:n.jsx(H,{children:r?.username})}),n.jsx(E,{label:"Address",size:"large",required:!0,children:n.jsx(z,{size:"medium",value:u,maxLength:100,minLength:20,onChange:(f,g)=>d(g.value)})})]}),n.jsxs(Ee,{children:[!s&&n.jsx(he,{disableButtonEnhancement:!0,children:n.jsx(I,{appearance:"secondary",children:"Cancel"})}),n.jsx(I,{appearance:"primary",onClick:()=>v({EMail:r?.username,Name:a,Address:u,Phone:l}),children:"Submit"})]})]})})})}const D=new me;function Bt(){const[o,{toggle:e}]=$();return Ce(()=>{D.subscribe(s=>s&&e())}),n.jsx(W,{children:n.jsx($e,{Open:o,Toggle:e,New:!0})})}class Ht{constructor(e,s){this.DB=e,this.Name=s,this.Sto=e.table(s),this.Trim()}Sto;async Get(e,s){const t=await this.Sto.get(e);return t?s&&await Promise.resolve(s(t))||typeof t.Exp=="number"&&t.Exptypeof e.Exp=="number"&&e.Exp{const s=setInterval(()=>{this.Hub.state===_.Connected&&(clearInterval(s),e())},100)}))}static async Invoke(e,...s){return await this.EnsureConnected(),this.Hub.invoke(e,...s)}static EnsureLogin(){if(!N.getActiveAccount())throw new Me}static EnsureTrue(e){if(!e)throw new zt}static Index(e,s){return`${s}_${e}`}static async UpdateCache(e,s,t,r){const a=this.Index(s,t),i=await S.Get(a);if(!i)return;const l=e(i);i.QueryExp?await S.Set(a,{...l,QueryExp:y().add(1,"m").unix()},null):await S.Set(a,l,r||null)}static async GetVersionCache(e,s){const t=this.Index(e,s),r=await S.Get(t);if(r&&r.QueryExp>y().unix())return r;const a=await Promise.resolve(this.Invoke(s,e,r?.Version));if(a===!0)return S.Set(t,{...r,QueryExp:y().add(1,"m").unix()},null),r;if(!a)throw S.Sto.delete(t),new TypeError("Empty Response");return await S.Set(t,{...a,QueryExp:y().add(1,"m").unix()},null),a}static async GetTimeCache(e,s,t,...r){return await S.GetOrSet(this.Index(e,s),async()=>await this.Invoke(s,...r),t(y()))}static async HandleFileStream(e,s,t){const a=Math.ceil(e.size/30720);let i=0;for(;i{d.onload=()=>w(new Uint8Array(d.result)),d.onerror=()=>T(d.error),d.readAsArrayBuffer(u)});s.next(p),t?.debug(`Sent chunk ${i+1}/${a}`),i++}s.complete()}}class b extends De{static Log=["|","ShopNet"];static Hub=new Le().withUrl("https://awaishop.aloen.to:3389/Hub",{skipNegotiation:!0,transport:Ie.WebSockets,logMessageContent:!1,async accessTokenFactory(){const e=await Ue();return e||""}}).withAutomaticReconnect().withStatefulReconnect().withHubProtocol(new Ne).configureLogging(Ge.Information).build()}b.Hub.on("OnNewUser",()=>{D.next(!0),console.debug("OnNewUser")});class Ft extends b{static Categories(){return this.GetTimeCache("","GalleryGetCategories",e=>e.add(1,"m"))}static async Products(e){const s=await this.GetTimeCache(e,"GalleryGetProducts",t=>t.add(1,"m"),e);return[s,4-s.length%4]}}const _t={Get:Ft};class Wt extends b{static async Get(e){if(!/^[0-9a-f]{8}-([0-9a-f]{4}-){3}[0-9a-f]{12}$/i.test(e))throw new Error(`Invalid ObjectId ${e}`);return await this.EnsureConnected(),this.Hub.stream("ObjectStorageGet",e)}static GetBySlice(e,s){const t=[];return S.GetOrSet(e,()=>new Promise((r,a)=>{this.Get(e).then(i=>i.subscribe({error(l){a(l)},next(l){t.push(l),s.debug("Received Slice",e,t.length)},complete(){r(t)}}))}))}}class Qt extends b{static useDelete(e){return h(async s=>{this.EnsureLogin();const t=await this.Invoke("OrderDeleteCancel",s);return this.EnsureTrue(t),t},e)}}class L extends b{static Product(e){return this.GetVersionCache(e,"ProductEntity")}static Lexical(e){return this.GetVersionCache(e,"LexicalEntity")}static Photo(e){return this.GetVersionCache(e,"PhotoEntity")}static Type(e){return this.GetVersionCache(e,"TypeEntity")}static Variant(e){return this.GetVersionCache(e,"VariantEntity")}}class A extends L{static Log=[...super.Log,"Product","Get"];static async Basic(e,s){const t=s.With(...this.Log,"Basic"),r=await this.Product(e);if(!r)throw new Error(`Product ${e} Not Found`);const[a,i]=await this.PhotoList(e,s);return i?{Name:r.Name,Cover:i}:(t.warn(`Product ${e} has no photo`),{Name:r.Name,Cover:""})}static Limit(e){return this.Invoke("ProdGetLimit",e)}static async Combo(e,s){const t=s.With(...this.Log,"Combo"),r=await this.ComboList(e),a=[];for(const i of r){const l={};for(const c of i.Types){const u=await this.Type(c);if(!u){t.error(`[Mismatch] Type ${c} not found. Combo ${i.ComboId} : Product ${e}`);continue}const d=await this.Variant(u.VariantId);if(!d){t.error(`[Mismatch] Variant ${u.VariantId} not found. Combo ${i.ComboId} : Type ${c} : Product ${e}`);continue}l[d.Name]=u.Name}a.push({Id:i.ComboId,Stock:i.Stock,Combo:l})}return a}static ComboList(e){return this.GetTimeCache(e,"ProductGetComboList",s=>s.add(1,"m"),e)}static async PhotoList(e,s){const t=s.With(...this.Log,"PhotoList"),r=await this.GetTimeCache(e,"ProductGetPhotoList",l=>l.add(1,"m"),e).catch(t.error);let a=[],i="";for(const l of r||[]){const c=await this.Photo(l).catch(t.error);c?(a.push(c),c.Cover&&(i=c.ObjectId)):t.warn(`Photo ${l} not found in Product ${e}`)}return a=a.sort((l,c)=>l.Order-c.Order),!i&&a.length>0?(t.warn(`Product ${e} has no cover photo, using first photo instead`),[a,a[0].ObjectId]):[a,i]}}class ce extends b{static Order(e){return this.EnsureLogin(),this.GetVersionCache(e,"OrderEntity")}static Comment(e){return this.EnsureLogin(),this.GetVersionCache(e,"CommentEntity")}}class Xt extends b{static Log=[...super.Log,"Order","Get"];static async List(e){this.EnsureLogin();const s=e.With(...this.Log,"List"),t=await this.GetTimeCache("","OrderGetList",a=>a.add(1,"m")),r=[];for(const a of t){const i=await ce.Order(a.OrderId);if(!i){s.warn(`[Mismatch] Order ${a.OrderId} not found`);continue}const l=[];for(const c of a.Products){const u=await L.Product(c);if(!u){s.warn(`[Mismatch] Product ${c} not found`);continue}l.push(u.Name)}r.push({Id:a.OrderId,Items:l,Quantity:a.Quantity,Status:i.Status,TrackNumber:i.TrackingNumber,OrderDate:i.CreateAt})}return r.sort((a,i)=>i.OrderDate.getTime()-a.OrderDate.getTime())}static async Detail(e,s){this.EnsureLogin();const t=s.With(...this.Log,"Detail"),r=await this.GetTimeCache(e,"OrderGetDetail",c=>c.add(1,"m"),e),a=[];let i=0;for(const c of r.Items){const u={};let d=0;for(const v of c.Types){const f=await L.Type(v);if(!f){t.warn(`[Mismatch] Type ${v} not found. Order : ${e}`);continue}const g=await L.Variant(f.VariantId);if(!g){t.warn(`[Mismatch] Variant ${f.VariantId} not found. Type : ${v}, Order : ${e}`);continue}u[g.Name]=f.Name,d=g.ProductId}const p=await L.Product(d);if(!p){t.warn(`[Mismatch] Product ${d} not found. Order : ${e}`);continue}const[w,T]=await A.PhotoList(d,t);T||t.warn(`Product ${d} has no photo`),a.push({Id:i++,ProdId:d,Cover:T||"",Name:p.Name,Type:u,Quantity:c.Quantity})}const l=[];for(const c of r.Comments){const u=await ce.Comment(c);if(!u){t.warn(`[Mismatch] Comment ${c} not found. Order : ${e}`);continue}l.push({Content:u.Content,Time:u.CreateAt,User:u.Name||"You"})}return{ShopCart:a,Comments:l.sort((c,u)=>c.Time.getTime()-u.Time.getTime())}}static Order=ce.Order}class qt extends b{static useNew(e){return h((s,t)=>{this.EnsureLogin();const r=s.map(a=>({ProdId:a.ProdId,Type:Object.values(a.Type),Quantity:a.Quantity}));return this.Invoke("OrderPostNew",r,t)},e)}static useAppend(e){return h(async(s,t)=>{this.EnsureLogin();const r=await this.Invoke("OrderPostAppend",s,t);return this.EnsureTrue(r),r},e)}static useCancel(e){return h(async(s,t)=>{this.EnsureLogin();const r=await this.Invoke("OrderPostCancel",s,t);return this.EnsureTrue(r),r},e)}static useReceived(e){return h(async s=>{this.EnsureLogin();const t=await this.Invoke("OrderPostReceived",s);return this.EnsureTrue(t),t},e)}}const Yt={Get:Xt,Post:qt,Delete:Qt},Jt={Get:A};class Kt extends b{static useMe(e){const s=k(()=>e.With("|","Hub","User","Get","Me")),{dispatch:t}=ne(s);return ke(()=>this.GetVersionCache(0,"UserGetMe").catch(a=>{a instanceof Me?s.info(a):t({Message:"Failed to Get Your Info",Error:a,Request:""})}))}}class Zt extends b{static useUpdate(e){return h(async s=>{this.EnsureLogin();const t=await this.Invoke("UserPostUpdate",s);return this.EnsureTrue(t),this.UpdateCache(r=>({...r,...s}),0,"UserGetMe"),t},e)}}const es={Get:Kt,Post:Zt},j={Gallery:_t,Product:Jt,User:es,Order:Yt,Storage:Wt},Re=x.createContext({});function F(){return x.useContext(Re)}const ue=new O("ShopCart","Context");function ts({children:o}){const[e,s]=x.useState([]);h(async()=>{const a=await ie.toArray(),i=[];for(const l of a){const c=await j.Product.Get.Basic(l.ProdId,ue);i.push({...l,...c})}s(i)},{onError:ue.error});async function t(a){for(let i=0;i({Id:i.Id,ProdId:i.ProdId,Type:i.Type,Quantity:i.Quantity})))}async function r(a,i,l){const c=await j.Product.Get.Basic(a,ue);e.push({...c,Id:e.length,ProdId:a,Type:i,Quantity:l}),t(e)}return n.jsx(Re.Provider,{value:{List:e,Add:r,Update:t},children:o})}const xe={Name:"AwaiShop"},ss=P({box:{width:"-webkit-fill-available",marginTop:m.spacingVerticalXXXL,...R.padding(m.spacingVerticalXXXL,0),backgroundColor:m.colorNeutralBackgroundInverted},main:{...G,maxWidth:ge,...R.margin(0,"auto")},logo:{width:"150px",filter:"invert(96%)"},otc:{color:"white"}});function ns(){const o=ss();return n.jsx("footer",{className:o.box,children:n.jsx("div",{className:o.main,children:n.jsx("img",{src:"/safari-pinned-tab.svg",className:o.logo})})})}function rs(){const{Paths:o,Search:e,Put:s}=V(),t=o.at(0),r=o.at(1),a=r==="User",i=r==="Order",l=a?"admin":"pending";return t==="Admin"&&(a||i)&&n.jsxs(n.Fragment,{children:[n.jsx(z,{placeholder:"Search in Any Field",contentBefore:n.jsx(Xe,{}),appearance:"underline",onChange:(c,u)=>{u.value?e.set("search",u.value):e.delete("search"),s(e)}}),n.jsx(qe,{label:`Only ${a?"Admin":"Pending"}`,checked:e.get(l)==="",onChange:(c,u)=>{u.checked?e.set(l,""):e.delete(l),s(e)}})]})}const as=P({box:{...G,flexGrow:1,height:"inherit",marginLeft:m.spacingHorizontalS,alignItems:"center"},div:{color:m.colorNeutralForegroundDisabled},link:{textDecorationLine:"unset !important"}});function os(){const o=as(),{Paths:e}=V(),s=e.at(0),t=e.at(1)||"Product";return s==="Admin"&&n.jsxs("div",{className:o.box,children:[n.jsx(J,{size:600,font:"monospace",className:o.div,children:"|"}),n.jsxs(Ye,{selectedValue:t,children:[n.jsx(U,{appearance:"subtle",href:"/Admin",className:o.link,children:n.jsx(ae,{value:"Product",children:"Product List"})}),n.jsx(U,{appearance:"subtle",href:"/Admin/Order",className:o.link,children:n.jsx(ae,{value:"Order",children:"Order List"})}),n.jsx(U,{appearance:"subtle",href:"/Admin/User",className:o.link,children:n.jsx(ae,{value:"User",children:"User List"})})]})]})}class C extends De{static Log=["|","AdminNet"];static Hub=new Le().withUrl("https://awaishop.aloen.to:3389/AdminHub",{skipNegotiation:!0,transport:Ie.WebSockets,logMessageContent:!1,async accessTokenFactory(){const e=await Ue();if(e)return e;throw new Error("Please Login First")}}).withAutomaticReconnect().withStatefulReconnect().withHubProtocol(new Ne).configureLogging(Ge.Information).build();static Index(e,s){return`${s}_Admin_${e}`}}class K extends C{static User(e){return this.EnsureLogin(),this.GetVersionCache(e,"UserEntity")}}class Y extends C{static Order(e){return this.EnsureLogin(),this.GetVersionCache(e,"OrderEntity")}static Comment(e){return this.EnsureLogin(),this.GetVersionCache(e,"CommentEntity")}}class is extends C{static Log=[...super.Log,"Order","Get"];static async List(e){this.EnsureLogin();const s=e.With(...this.Log,"List"),t=await this.GetTimeCache("","OrderGetList",a=>a.add(1,"m")),r=[];for(const a of t){const i=await Y.Order(a.OrderId);if(!i){s.warn(`[Mismatch] Order ${a.OrderId} not found`);continue}const l=[];for(const u of a.Products){const d=await L.Product(u);if(!d){s.warn(`[Mismatch] Product ${u} not found`);continue}l.push(d.Name)}const c=await K.User(i.UserId);if(!c){s.error(`[Mismatch] User ${i.UserId} not found`);continue}r.push({Id:a.OrderId,Items:l,Quantity:a.Quantity,Status:i.Status,TrackNumber:i.TrackingNumber,OrderDate:i.CreateAt,User:c.Name})}return r.sort((a,i)=>i.OrderDate.getTime()-a.OrderDate.getTime())}static async Detail(e,s){this.EnsureLogin();const t=s.With(...this.Log,"Detail"),r=await this.GetTimeCache(e,"OrderGetDetail",c=>c.add(1,"m"),e),a=[];let i=0;for(const c of r.Items){const u={};let d=0;for(const v of c.Types){const f=await L.Type(v);if(!f){t.warn(`[Mismatch] Type ${v} not found. Order : ${e}`);continue}const g=await L.Variant(f.VariantId);if(!g){t.warn(`[Mismatch] Variant ${f.VariantId} not found. Type : ${v}, Order : ${e}`);continue}u[g.Name]=f.Name,d=g.ProductId}const p=await L.Product(d);if(!p){t.warn(`[Mismatch] Product ${d} not found. Order : ${e}`);continue}const[w,T]=await A.PhotoList(d,t);T||t.warn(`Product ${d} has no photo`),a.push({Id:i++,ProdId:d,Cover:T||"",Name:p.Name,Type:u,Quantity:c.Quantity})}const l=[];for(const c of r.Comments){const u=await Y.Comment(c);if(!u){t.warn(`[Mismatch] Comment ${c} not found. Order : ${e}`);continue}let d="Client";if(u.UserId){const p=await K.User(u.UserId);p?d=p.Name:t.warn(`[Mismatch] User ${u.UserId} not found. Order : ${e}`)}l.push({Content:u.Content,Time:u.CreateAt,User:d})}return{ShopCart:a,Comments:l.sort((c,u)=>c.Time.getTime()-u.Time.getTime())}}static Order=Y.Order}class cs extends C{static useAppend(e){return h(async(s,t)=>{const r=await this.Invoke("OrderPostAppend",s,t);return this.EnsureTrue(r),r},e)}static useClose(e){return h(async(s,t)=>{const r=await this.Invoke("OrderPostClose",s,t);return this.EnsureTrue(r),r},e)}static useShip(e){return h(async(s,t)=>{const r=await this.Invoke("OrderPostShip",s,t);return this.EnsureTrue(r),r},e)}static useAccept(e){return h(async s=>{const t=await this.Invoke("OrderPostAccept",s);return this.EnsureTrue(t),t},e)}}const us={Get:is,Post:cs};class ls extends C{static usePhoto(e){return h(async s=>{const t=await this.Invoke("ProductDeletePhoto",s);return this.EnsureTrue(t),t},e)}static useVariant(e){return h(async s=>{const t=await this.Invoke("ProductDeleteVariant",s);return this.EnsureTrue(t),t},e)}static useType(e){return h(async(s,t)=>{const r=await this.Invoke("ProductDeleteType",s,t);return this.EnsureTrue(r),r},e)}static useCombo(e){return h(async s=>{const t=await this.Invoke("ProductDeleteCombo",s);return this.EnsureTrue(t),t},e)}static useProduct(e){return h(async s=>{const t=await this.Invoke("ProductDeleteProduct",s);return this.EnsureTrue(t),this.UpdateCache(r=>r.filter(a=>a!==s),"","ProductGetList",y().add(1,"m")),t},e)}}class ds extends C{static Log=[...super.Log,"Product","Get"];static useList(e){const s=k(()=>e.With(...this.Log,"List"));return ke(()=>this.GetTimeCache("","ProductGetList",r=>r.add(1,"m")).catch(s.error))}static Count(e){return this.GetTimeCache(e,"ProductGetCount",s=>s.add(1,"m"),e)}static async Name(e){const s=await A.Product(e);if(!s)throw new Error(`Product ${e} Not Found`);return s.Name}static async Category(e){const s=await A.Product(e);if(!s)throw new Error(`Product ${e} Not Found`);return s.Category}static async Variants(e,s){const t=s.With(...this.Log,"Variants"),r=await this.GetTimeCache(e,"ProductGetVariants",i=>i.add(1,"m"),e),a=[];for(const i of r){const l=await A.Variant(i.VariantId);if(!l){t.warn(`Variant ${i} Not Found. Product : ${e}`);continue}const c=[];for(const u of i.Types){const d=await A.Type(u);if(!d){t.warn(`Type ${u} Not Found. Variant : ${i.VariantId}, Product : ${e}`);continue}c.push(d.Name)}a.push({Id:i.VariantId,Name:l.Name,Types:c})}return a}}class hs extends C{static Log=[...super.Log,"Product","Patch"];static useName(e){return h(async(s,t)=>{const r=await this.Invoke("ProductPatchName",s,t);return this.EnsureTrue(r),r},e)}static useCategory(e){return h(async(s,t)=>{const r=await this.Invoke("ProductPatchCategory",s,t);return this.EnsureTrue(r),r},e)}static usePhoto(e,s){const t=k(()=>e.With(...this.Log,"Photo"));return h(async(r,a)=>{if(!a.type.startsWith("image/"))throw new TypeError("File is not an image");if(a.size>10*1024*1024)throw new RangeError("File is too large, max 10MB");await this.EnsureConnected();const i=new me,l=this.Hub.invoke("ProductPatchPhoto",r,i);return await this.HandleFileStream(a,i,t),this.EnsureTrue(await l),!0},s)}static useCaption(e){return h(async(s,t)=>{const r=await this.Invoke("ProductPatchCaption",s,t);return this.EnsureTrue(r),r},e)}static useVariantName(e){return h(async(s,t)=>{const r=await this.Invoke("ProductPatchVariantName",s,t);return this.EnsureTrue(r),r},e)}static useType(e){return h(async(s,t,r)=>{const a=await this.Invoke("ProductPatchType",s,t,r);return this.EnsureTrue(a),a},e)}static useCombo(e){return h(async(s,t,r)=>{const a=await this.Invoke("ProductPatchCombo",s,t,r);return this.EnsureTrue(a),a},e)}}let Ve;function Qs(o){Ve=o}class ms extends C{static Log=[...super.Log,"Product","Post"];static useCreate(e){return h(async s=>{const t=await this.Invoke("ProductPostCreate",s);return this.UpdateCache(r=>[t,...r],"","ProductGetList",y().add(1,"m")),t},e)}static useMovePhoto(e){return h(async(s,t)=>{const r=await this.Invoke("ProductPostMovePhoto",s,t);return this.EnsureTrue(r),r},e)}static usePhoto(e,s){const t=k(()=>e.With(...this.Log,"Photo"));return h(async(r,a)=>{if(!a.type.startsWith("image/"))throw new TypeError("File is not an image");if(a.size>10*1024*1024)throw new RangeError("File is too large, max 10MB");const i=new me,l=this.Invoke("ProductPostPhoto",r,i);return await this.HandleFileStream(a,i,t),this.EnsureTrue(await l),!0},s)}static useVariant(e){return h((s,t)=>this.Invoke("ProductPostVariant",s,t),e)}static useType(e){return h((s,t)=>this.Invoke("ProductPostType",s,t),e)}static useCombo(e){return h((s,t,r)=>this.Invoke("ProductPostCombo",s,t,r),e)}static useLexical(e){return h(async s=>{const t=Ve?.getEditorState();let r;t&&!t.isEmpty()&&(r=JSON.stringify(t.toJSON()));const a=await this.Invoke("ProductPostDescription",s,r);return this.EnsureTrue(a),a},e)}}const ps={Get:ds,Post:ms,Patch:hs,Delete:ls};class gs extends C{static useUser(e){return h(async s=>{const t=await this.Invoke("UserDeleteUser",s);return this.EnsureTrue(t),t},e)}static useAdmin(e){return h(async s=>{const t=await this.Invoke("UserDeleteAdmin",s);return this.EnsureTrue(t),t},e)}}class xs extends C{static async OrderUser(e){const s=await Y.Order(e);if(!s)throw new Error(`Order ${e} not found`);const t=await K.User(s.UserId);if(!t)throw new Error(`User ${s.UserId} not found in order ${e}`);return t}static async List(){const e=await this.GetTimeCache("","UserGetList",t=>t.add(1,"m")),s=[];for(const t of e){const r=await K.User(t);if(!r){console.warn(`User ${t} not found`);continue}s.push({Id:t,Name:r.Name,EMail:r.EMail,Admin:r.Admin})}return s}}class fs extends C{static useAdmin(e){return h(async s=>{const t=await this.Invoke("UserPostAdmin",s);return this.EnsureTrue(t),t},e)}}const ws={Get:xs,Post:fs,Delete:gs},ys={Product:ps,Order:us,User:ws},Ps=P({body:M}),Cs=new O("Admin","Product","AddButton");function js(){const{Nav:o,Paths:e}=V(),s=e.at(0),t=e.at(1),r=Ps(),[a,i]=x.useState(""),{dispatch:l,dispatchToast:c}=ne(Cs),{run:u,loading:d}=ys.Product.Post.useCreate({manual:!0,onError(p,w){l({Message:`Failed Create ${a}`,Request:w,Error:p})},onSuccess(p){c(n.jsxs(Z,{children:[n.jsx(ee,{children:"New Product Created"}),n.jsxs(te,{children:[p," ",a]})]}),{intent:"success"}),o("Admin",p),i("")}});return s==="Admin"&&!t&&n.jsxs(be,{children:[n.jsx(he,{disableButtonEnhancement:!0,children:n.jsx(I,{appearance:"primary",icon:n.jsx(Je,{}),children:"New Product"})}),n.jsx(Te,{children:n.jsxs(ve,{children:[n.jsx(Se,{className:r.body,children:n.jsx(z,{required:!0,size:"large",value:a,maxLength:15,appearance:"underline",onChange:(p,w)=>i(w.value),contentBefore:n.jsx(Ke,{children:"Give A Name"})})}),n.jsxs(Ee,{children:[n.jsx(he,{disableButtonEnhancement:!0,children:n.jsx(I,{appearance:"secondary",children:"Cancel"})}),n.jsx(I,{disabled:d,appearance:"primary",onClick:()=>u(a),children:"Create"})]})]})})]})}const bs=new O("Avatar","Menu");function Ts(){const[o,{toggle:e}]=$(),[s,{toggle:t}]=$(),{instance:r}=je(),[a,{set:i}]=$(!0);x.useEffect(()=>{D.subscribe(d=>i(!d))},[]);const l=j.User.Get.useMe(bs),c=r.getActiveAccount(),u=c?.name||c?.username;return n.jsxs(n.Fragment,{children:[n.jsxs(Ze,{open:o,onOpenChange:e,children:[n.jsx(et,{children:n.jsx(tt,{size:36,active:o?"active":"unset",name:u})}),n.jsx(st,{children:n.jsxs(nt,{children:[n.jsx(W,{children:n.jsxs(rt,{children:["Hi ",u]})}),n.jsx(at,{children:n.jsx(B,{onClick:()=>r.loginRedirect(),children:"Login"})}),n.jsxs(W,{children:[n.jsx(U,{appearance:"subtle",href:"/History",children:n.jsx(B,{children:"History"})}),l?.Admin&&n.jsx(U,{appearance:"subtle",href:"/Admin",children:n.jsx(B,{children:"Admin"})}),n.jsx(B,{onClick:t,children:"Setting"}),n.jsx(B,{onClick:()=>r.logoutRedirect(),children:"Logout"})]})]})})]}),a&&n.jsx(W,{children:n.jsx($e,{Open:s,Toggle:t})})]})}function Be({Items:o,Columns:e,NoHeader:s}){return n.jsxs(ot,{items:o||[],columns:e,getRowId:t=>t.Id,children:[!s&&n.jsx(it,{children:n.jsx(we,{children:({renderHeaderCell:t})=>t()})}),n.jsx(ct,{children:({item:t,rowId:r})=>n.jsx(we,{children:({renderCell:a})=>a(t)},r)}),!o&&n.jsx(ut,{size:48})]})}function vs({Guid:o,Log:e,...s}){const t=k(()=>e.With("GuidImage")),{data:r,run:a}=h(j.Storage.GetBySlice.bind(j.Storage),{manual:!0,onError:t.error});return x.useEffect(()=>{o&&a(o,t)},[o]),n.jsx(Oe,{...s,src:r?URL.createObjectURL(new Blob(r)):"https://placehold.co/400?text=Loading..."})}const Pe=P({unset:{flexBasis:"unset",flexGrow:0},img:{...Dt,aspectRatio:"1",marginTop:m.spacingVerticalXS,marginBottom:m.spacingVerticalXS}});function Ss(o,e){const s={width:`${o}px`};return Q({columnId:"Cover",renderHeaderCell:()=>{const t=Pe();return n.jsx(lt,{className:t.unset,children:n.jsx("div",{style:s})})},renderCell(t){const r=Pe();return n.jsx(X,{className:r.unset,children:n.jsx(vs,{className:r.img,style:s,Guid:t.Cover,Log:e})})}})}function Es(o){const{List:e}=F(),{data:s}=h(()=>j.Product.Get.Limit(o)),t=s||3;let r=0;for(const a of e)if(a.ProdId===o&&(r+=a.Quantity),r>=t)return[!0,t];return[!1,t]}const le=P({prod:{...M,alignItems:"flex-start",justifyContent:"center"},qua:{flexBasis:"12%",flexGrow:0},act:{flexBasis:"7%",flexGrow:0}}),Ls=[Q({columnId:"Product",renderCell(o){return n.jsxs(X,{className:le().prod,children:[n.jsx(U,{href:`/Product/${o.ProdId}`,appearance:"subtle",children:n.jsx(dt,{children:o.Name})}),n.jsx(ht,{children:Object.values(o.Type).reduce((e,s)=>`${e} ${s},`,"")})]})}}),Q({columnId:"Quantity",renderCell(o){const{List:e,Update:s}=F(),[t,r]=Es(o.ProdId);return n.jsx(X,{className:le().qua,children:n.jsx(mt,{min:1,max:r,value:o.Quantity,onChange:(a,i)=>{t&&i.value>=o.Quantity||(o.Quantity=i.value,s(e))}})})}}),Q({columnId:"Action",renderCell(o){const{List:e,Update:s}=F();return n.jsx(X,{className:le().act,children:n.jsx(I,{appearance:"subtle",icon:n.jsx(pt,{}),onClick:()=>s(e.filter(t=>t.Id!==o.Id))})})}})];function He(o){return[Ss(44,o),...Ls]}const Is=P({person:G,inf:{...M,flexBasis:"50%",rowGap:m.spacingVerticalM}});function Ns({Log:o}){const e=Is(),s=k(()=>o.With("PersonaInfo")),t=j.User.Get.useMe(s);return n.jsxs(n.Fragment,{children:[n.jsxs("div",{className:e.person,children:[n.jsx("div",{className:e.inf,children:n.jsx(E,{label:"Name",size:"large",children:n.jsx(H,{children:t?.Name})})}),n.jsx("div",{className:e.inf,children:n.jsx(E,{label:"Phone",size:"large",children:n.jsx(H,{children:t?.Phone})})})]}),n.jsx(E,{label:"E-Mail",size:"large",children:n.jsx(H,{children:t?.EMail})}),n.jsx(E,{label:"Address",size:"large",children:n.jsx(H,{children:t?.Address})})]})}const Gs=P({body:{...M,rowGap:m.spacingVerticalXL},sub:{width:"fit-content",alignSelf:"flex-end"}}),de=new O("TopNavBar","ShopCart","Confirm");function ks(){const[o,e]=x.useState(),[s,{toggle:t}]=$(),{List:r,Update:a}=F(),{Nav:i}=V(),l=Gs(),{dispatch:c,dispatchToast:u}=ne(de),{run:d}=j.Order.Post.useNew({manual:!0,onError(p,w){c({Message:"Failed Create Order",Request:w,Error:p})},onSuccess(p){u(n.jsxs(Z,{children:[n.jsx(ee,{children:"Order Placed"}),n.jsxs(te,{children:["Order Id: ",p]})]}),{intent:"success"}),a([]),t(),i("History",p)}});return n.jsxs(n.Fragment,{children:[n.jsx(I,{appearance:"primary",onClick:t,disabled:!r.length,children:"Checkout"}),n.jsxs(gt,{open:s,onOpenChange:t,position:"end",size:"medium",modalType:"alert",children:[n.jsx(xt,{children:n.jsx(ft,{action:n.jsx(I,{appearance:"subtle",icon:n.jsx(wt,{}),onClick:t}),children:"Confirm Order"})}),n.jsx(yt,{children:n.jsxs("div",{className:l.body,children:[n.jsx(Ns,{Log:de}),n.jsx(Be,{Items:r,Columns:k(()=>He(de)),NoHeader:!0}),n.jsx(E,{label:"Comment",size:"large",children:n.jsx(Pt,{value:o,onChange:(p,w)=>e(w.value),maxLength:1e3})}),n.jsx(I,{appearance:"primary",className:l.sub,disabled:!r.length,onClick:()=>d(r,o),children:"Submit"})]})})]})]})}const Os=P({conf:{...G,width:"100%",alignItems:"center",justifyContent:"space-between",marginTop:m.spacingVerticalS,columnGap:m.spacingHorizontalL},tooltip:{backgroundColor:m.colorBrandBackground,color:m.colorNeutralForegroundInverted,...R.borderRadius(m.borderRadiusCircular)}}),As=new O("TopNavBar","ShopCart");function $s(){const[o,{toggle:e}]=$(),[s,{toggle:t}]=$(),r=Os(),{List:a}=F();return Ct(()=>{if(o)return;t();const i=setTimeout(t,2e3);return()=>clearTimeout(i)},[a]),n.jsxs(jt,{withArrow:!0,open:o,onOpenChange:e,children:[n.jsx(bt,{disableButtonEnhancement:!0,children:n.jsx(Tt,{visible:s,withArrow:!0,content:{children:"↑",className:r.tooltip},relationship:"inaccessible",children:n.jsx(vt,{icon:n.jsx(St,{}),appearance:"subtle",size:"large",checked:o})})}),n.jsxs(Et,{children:[n.jsx(Be,{Items:a,Columns:k(()=>He(As)),NoHeader:!0}),n.jsxs("div",{className:r.conf,children:[a.map(i=>i.Quantity).reduce((i,l)=>i+l,0)," items in shopping cart",n.jsx(ks,{})]})]})]})}const Us=P({navBox:{position:"fixed",top:0,width:"100%",height:`${pe}px`,...R.padding(0,m.spacingHorizontalXXXL),backgroundColor:"#fff",boxSizing:"border-box",boxShadow:m.shadow4},navBar:{...G,maxWidth:ge,height:"100%",...R.margin(0,"auto"),alignItems:"center",justifyContent:"space-between"},logoBox:{...G,columnGap:m.spacingHorizontalL,alignItems:"center"},logoText:{color:m.colorBrandForeground2}});function Ms(){const o=Us();return n.jsx(Lt,{children:n.jsx("header",{className:o.navBox,children:n.jsxs("nav",{className:o.navBar,children:[n.jsxs(U,{className:o.logoBox,href:"/",appearance:"subtle",children:[n.jsx(Oe,{src:"/Awai.png",height:pe}),n.jsx(J,{size:600,font:"monospace",className:o.logoText,children:xe.Name})]}),n.jsx(os,{}),n.jsxs("div",{className:o.logoBox,children:[n.jsx(js,{}),n.jsx(rs,{}),n.jsx($s,{}),n.jsx(Ts,{})]})]})})})}function Ds(){const{Rep:o}=V();return setTimeout(()=>o("/"),3e3),n.jsxs(n.Fragment,{children:[n.jsxs(It,{children:[n.jsxs("title",{children:["Redirect - Not Found - ",xe.Name]}),n.jsx("meta",{name:"robots",content:"noindex, nofollow"})]}),n.jsx(q,{size:"huge",label:"Redirecting..."})]})}const Rs=P({body:{...M,minWidth:"1024px",position:"absolute",marginTop:`${pe}px`,width:"100%",minHeight:"-webkit-fill-available",justifyContent:"space-between",backgroundColor:m.colorNeutralBackground2},content:{...M,maxWidth:ge,width:"-webkit-fill-available",marginLeft:"auto",marginRight:"auto",paddingLeft:m.spacingHorizontalM,paddingRight:m.spacingHorizontalM,paddingTop:m.spacingVerticalXXXL}});function Vs(){const o=Rs(),{Paths:e}=V(),s=e.at(0),t=x.useMemo(()=>{switch(s){case"Product":return n.jsx(Bs,{});case"Admin":return n.jsx(Hs,{});case"History":return n.jsx(zs,{});case"Login":return n.jsx(q,{size:"huge",label:"Login Redirecting..."});case"Reload":return n.jsx(q,{size:"huge",label:"Reloading..."});case"":case void 0:return n.jsx(Fs,{});default:return n.jsx(Ds,{})}},[s]);return n.jsxs(n.Fragment,{children:[n.jsx(Ms,{}),n.jsxs("div",{className:o.body,children:[n.jsx("main",{className:o.content,children:n.jsx(x.Suspense,{fallback:n.jsx(q,{}),children:t})}),n.jsx(ns,{})]}),n.jsx(Bt,{})]})}const Bs=x.lazy(()=>se(()=>import("./index-M75ftWWX.js"),__vite__mapDeps([0,1,2,3,4,5]))),Hs=x.lazy(()=>se(()=>import("./index-Or5Q2pDR.js"),__vite__mapDeps([6,1,7,8,3,4]))),zs=x.lazy(()=>se(()=>import("./index-iGJtzlF3.js"),__vite__mapDeps([9,1,7]))),Fs=x.lazy(()=>se(()=>import("./index-fE5hFxdC.js"),__vite__mapDeps([10,1,2,3,8])));Nt.createRoot(document.getElementById(xe.Name)).render(n.jsx(Gt,{theme:kt,children:n.jsx($t,{children:n.jsx(Ot,{instance:N,children:n.jsxs(ts,{children:[n.jsx(At,{pauseOnHover:!0}),n.jsx(Vs,{})]})})})}));export{ys as A,Ws as B,Dt as C,xe as D,G as F,vs as G,j as H,O as L,Ss as M,Qs as S,M as a,Es as b,V as c,Ut as d,ne as e,Be as f,F as u}; -function __vite__mapDeps(indexes) { - if (!__vite__mapDeps.viteFileDeps) { - __vite__mapDeps.viteFileDeps = ["assets/index-M75ftWWX.js","assets/vendor-DpqXKvKY.js","assets/isArrayLike--sVJAW2Y.js","assets/isObject-tyZXtoJz.js","assets/Lazy-vvLq-Rxx.js","assets/index-scunr7sf.css","assets/index-Or5Q2pDR.js","assets/Columns-iLzEQjYF.js","assets/toFinite-GMFxiq4g.js","assets/index-iGJtzlF3.js","assets/index-fE5hFxdC.js"] - } - return indexes.map((i) => __vite__mapDeps.viteFileDeps[i]) -} diff --git a/assets/index-5nAmJIOp.js b/assets/index-qK3m2KiI.js similarity index 99% rename from assets/index-5nAmJIOp.js rename to assets/index-qK3m2KiI.js index 0bd8b66..1cf9514 100644 --- a/assets/index-5nAmJIOp.js +++ b/assets/index-qK3m2KiI.js @@ -1,4 +1,4 @@ -import{r as $,j as p,aT as yg,aU as vg,az as ns,as as Ja,am as Va,aV as Sg,aW as $g,aX as Rg,B as Un,aY as Ag,aZ as Og,m as it,s as P,ap as Wr,t as an,a_ as Xa,a$ as wg,b0 as Dg,b1 as gt,I as Gn,J as Lg,b2 as Mg,b3 as Za,b4 as Le,b5 as qa,b6 as Qa,b7 as eu,b8 as tu,b9 as nu,ba as ru,bb as Ti,bc as iu,h as ou,i as lu,k as su,F as Or,l as au,n as yi,Q as pr,R as mr,bd as yt,be as bg,bf as rs,bg as is,bh as os,bi as ls,bj as ss,bk as as,bl as us,bm as cs,V as _r,W as Cr,_ as ue,aj as kg,ak as Ig,ao as Pg,bn as Fg,bo as Bg,bp as jg,bq as zg,br as sr,bs as Kg,bt as Hg,bu as Wg,bv as Ug,N as Gg,bw as Yg,D as ds,bx as Jg,g as gs,by as Vg,bz as Xg,bA as fs,bB as Zg,bC as qg,bD as Qg,bE as ef,bF as tf,bG as nf}from"./vendor-DpqXKvKY.js";import{F as uu,B as cu,d as rf,D as du,S as of}from"./index-YSLnLPU4.js";var gu={},Ui={},fu=$;let hu=fu.createContext(null);Ui.LexicalComposerContext=hu;Ui.createLexicalComposerContext=function(t,e){let n=null;return t!=null&&(n=t[1]),{getTheme:function(){return e??(n!=null?n.getTheme():null)}}};Ui.useLexicalComposerContext=function(){let t=fu.useContext(hu);if(t==null)throw Error("Minified Lexical error #8; visit https://lexical.dev/docs/error?code=8 for the full message or use the non-minified dev environment for full errors and additional helpful warnings.");return t};const lf=Ui;var X=lf,R={};let ul={},pu={},wr={},xr={},Do={},Fn={},cl={},Lo={},Dr={},Lr={},Pt={},dl={},gl={},mu={},_u={},Cu={},xu={},Nu={},Eu={},Tu={},vi={},yu={},vu={},Su={},$u={},Ru={},Au={},Ou={},wu={},Du={},fl={},hl={},Lu={},Mu={},bu={};function D(t){throw Error(`Minified Lexical error #${t}; visit https://lexical.dev/docs/error?code=${t} for the full message or use the non-minified dev environment for full errors and additional helpful warnings.`)}let At=typeof window<"u"&&typeof window.document<"u"&&typeof window.document.createElement<"u",sf=At&&"documentMode"in document?document.documentMode:null,Ie=At&&/Mac|iPod|iPhone|iPad/.test(navigator.platform),un=At&&/^(?!.*Seamonkey)(?=.*Firefox).*/i.test(navigator.userAgent),Si=At&&"InputEvent"in window&&!sf?"getTargetRanges"in new window.InputEvent("input"):!1,pl=At&&/Version\/[\d.]+.*Safari/.test(navigator.userAgent),ml=At&&/iPad|iPhone|iPod/.test(navigator.userAgent)&&!window.MSStream,af=At&&/^(?=.*Chrome).*/i.test(navigator.userAgent),_l=At&&/AppleWebKit\/[\d.]+/.test(navigator.userAgent)&&!af,Gi=pl||ml||_l?" ":"​",uf=un?" ":Gi,cf=/^[^A-Za-z\u00c0-\u00d6\u00d8-\u00f6\u00f8-\u02b8\u0300-\u0590\u0800-\u1fff\u200e\u2c00-\ufb1c\ufe00-\ufe6f\ufefd-\uffff]*[\u0591-\u07ff\ufb1d-\ufdfd\ufe70-\ufefc]/,df=/^[^\u0591-\u07ff\ufb1d-\ufdfd\ufe70-\ufefc]*[A-Za-z\u00c0-\u00d6\u00d8-\u00f6\u00f8-\u02b8\u0300-\u0590\u0800-\u1fff\u200e\u2c00-\ufb1c\ufe00-\ufe6f\ufefd-\uffff]/,nn={bold:1,code:16,highlight:128,italic:2,strikethrough:4,subscript:32,superscript:64,underline:8},gf={directionless:1,unmergeable:2},hs={center:2,end:6,justify:4,left:1,right:3,start:5},ff={2:"center",6:"end",4:"justify",1:"left",3:"right",5:"start"},hf={normal:0,segmented:2,token:1},pf={0:"normal",2:"segmented",1:"token"},Mo=!1,Cl=0;function mf(t){Cl=t.timeStamp}function uo(t,e,n){return e.__lexicalLineBreak===t||t[`__lexicalKey_${n._key}`]!==void 0}function _f(t){return t.getEditorState().read(()=>{let e=Q();return e!==null?e.clone():null})}function ku(t,e,n){Mo=!0;let r=100{let i=Q()||_f(t);var o=new Map,l=t.getRootElement(),s=t._editorState,a=t._blockCursorElement;let c=!1,g="";for(var d=0;d{ku(t,e,n)})}let Cf=1,xf=typeof queueMicrotask=="function"?queueMicrotask:t=>{Promise.resolve().then(t)};function xl(t){let e=document.activeElement;if(e===null)return!1;let n=e.nodeName;return q(Gr(t))&&(n==="INPUT"||n==="TEXTAREA"||e.contentEditable==="true"&&e.__lexicalEditor==null)}function Ur(t,e,n){let r=t.getRootElement();try{return r!==null&&r.contains(e)&&r.contains(n)&&e!==null&&!xl(e)&&Nl(e)===t}catch{return!1}}function Nl(t){for(;t!=null;){let e=t.__lexicalEditor;if(e!=null)return e;t=Yi(t)}return null}function bo(t){return t.isToken()||t.isSegmented()}function $i(t){for(;t!=null;){if(t.nodeType===3)return t;t=t.firstChild}return null}function Fu(t,e,n){return e=nn[e],t&e&&(n===null||!(n&e))?t^e:n===null||n&e?t|e:t}function Bu(t){return M(t)||Pr(t)||q(t)}function ju(t,e){if(e!=null)t.__key=e;else{je(),99pt().getTextContent())}function Nf(t,e){Ye(t,()=>{var n=_t();if(!n.isEmpty())if(e==="root")pt().markDirty();else{n=n._nodeMap;for(let[,r]of n)r.markDirty()}},t._pendingEditorState===null?{tag:"history-merge"}:void 0)}function pt(){return _t()._nodeMap.get("root")}function zt(t){je();let e=_t();t!==null&&(t.dirty=!0,t._cachedNodes=null),e._selection=t}function bn(t){var e=se(),n;e:{for(n=t;n!=null;){let r=n[`__lexicalKey_${e._key}`];if(r!==void 0){n=r;break e}n=Yi(n)}n=null}return n===null?(e=e.getRootElement(),t===e?Ce("root"):null):Ce(n)}function Hu(t){return/[\uD800-\uDBFF][\uDC00-\uDFFF]/g.test(t)}function El(t){let e=[];for(;t!==null;)e.push(t),t=t._parentEditor;return e}function Wu(){return Math.random().toString(36).replace(/[^a-z]+/g,"").substr(0,5)}function Tl(t,e,n){if(e=mt(e._window),e!==null){var r=e.anchorNode,{anchorOffset:i,focusOffset:o}=e;if(r!==null&&(e=r.nodeType===3?r.nodeValue:null,r=Gr(r),e!==null&&M(r))){if(r.canContainTabs()){var l=e.includes(" ");if(n&&0{c.update(()=>{o.isAttached()&&o.remove()})},20)}else{i=o.getParent(),e=Vr();var s=Ft(),a=o.getKey();o.isToken()||s!==null&&a===s&&!l||i!==null&&z(e)&&!i.canInsertTextBefore()&&e.anchor.offset===0?o.markDirty():(l=Q(),z(l)&&n!==null&&r!==null&&(l.setTextNodeRange(o,n,o,r),o.isSegmented()&&(n=o.getTextContent(),n=ve(n),o.replace(n),o=n)),o.setTextContent(t))}}}function Ef(t,e){if(e.isSegmented())return!0;if(!t.isCollapsed())return!1;t=t.anchor.offset;let n=e.getParentOrThrow(),r=e.isToken();return t===0?((t=!e.canInsertTextBefore()||!n.canInsertTextBefore()||r)||(e=e.getPreviousSibling(),t=(M(e)||O(e)&&e.isInline())&&!e.canInsertTextAfter()),t):t===e.getTextContentSize()?!e.canInsertTextAfter()||!n.canInsertTextAfter()||r:!1}function Nr(t,e){var n=t[e];return typeof n=="string"?(n=n.split(" "),t[e]=n):n}function vl(t,e,n,r,i){n.size!==0&&(n=r.__key,e=e.get(r.__type),e===void 0&&D(33),r=e.klass,e=t.get(r),e===void 0&&(e=new Map,t.set(r,e)),t=e.get(n),r=t==="destroyed"&&i==="created",(t===void 0||r)&&e.set(n,r?"updated":i))}function ms(t,e,n){let r=t.getParent(),i=n;return r!==null&&(e&&n===0?(i=t.getIndexWithinParent(),t=r):e||n!==t.getChildrenSize()||(i=t.getIndexWithinParent()+1,t=r)),t.getChildAtIndex(e?i-1:i)}function ko(t,e){var n=t.offset;return t.type==="element"?(t=t.getNode(),ms(t,e,n)):(t=t.getNode(),e&&n===0||!e&&n===t.getTextContentSize()?(n=e?t.getPreviousSibling():t.getNextSibling(),n===null?ms(t.getParentOrThrow(),e,t.getIndexWithinParent()+(e?0:1)):n):null)}function Uu(t){return t=(t=Ji(t).event)&&t.inputType,t==="insertFromPaste"||t==="insertFromPasteAsQuotation"}function Ai(t){return!We(t)&&!t.isLastChild()&&!t.isInline()}function Oi(t,e){return t=t._keyToDOMMap.get(e),t===void 0&&D(75),t}function Yi(t){return t=t.assignedSlot||t.parentElement,t!==null&&t.nodeType===11?t.host:t}function Tf(t,e=0){if(e!==0&&D(1),e=Q(),!z(e)||!O(t))return e;let{anchor:n,focus:r}=e,i=n.getNode(),o=r.getNode();return wi(i,t)&&n.set(t.__key,0,"element"),wi(o,t)&&r.set(t.__key,0,"element"),e}function wi(t,e){for(t=t.getParent();t!==null;){if(t.is(e))return!0;t=t.getParent()}return!1}function Ji(t){return t=t._window,t===null&&D(78),t}function Gu(t){for(t=t.getParentOrThrow();t!==null&&!nt(t);)t=t.getParentOrThrow();return t}function nt(t){return We(t)||O(t)&&t.isShadowRoot()}function Yu(t){return t=t.constructor.clone(t),ju(t,null),t}function Vi(t){var e=se();let n=t.constructor.getType();return e=e._nodes.get(n),e===void 0&&D(97),e=e.replace,e!==null?(e=e(t),e instanceof t.constructor||D(98),e):t}function co(t,e){t=t.getParent(),!We(t)||O(e)||q(e)||D(99)}function go(t){return(q(t)||O(t)&&!t.canBeEmpty())&&!t.isInline()}function Io(t,e,n){n.style.removeProperty("caret-color"),e._blockCursorElement=null,e=t.parentElement,e!==null&&e.removeChild(t)}function mt(t){return At?(t||window).getSelection():null}function Ju(t,e){let n=t.getChildAtIndex(e);n==null&&(n=t),nt(t)&&D(102);let r=l=>{const s=l.getParentOrThrow(),a=nt(s),c=l!==n||a?Yu(l):l;if(a)return l.insertAfter(c),[l,c,c];const[g,d,u]=r(s);return l=l.getNextSiblings(),u.append(c,...l),[g,d,c]},[i,o]=r(n);return[i,o]}function Di(t,e){for(;t!==pt()&&t!=null;){if(e(t))return t;t=t.getParent()}return null}function yf(t){let e=[],n=[t];for(;0e&&r&&t.classList.remove(n)}n=getComputedStyle(t).getPropertyValue("--lexical-indent-base-value")||"40px",t.style.setProperty("padding-inline-start",e===0?"":`calc(${e} * ${n})`)}function ec(t,e){t=t.style,e===0?Vt(t,""):e===1?Vt(t,"left"):e===2?Vt(t,"center"):e===3?Vt(t,"right"):e===4?Vt(t,"justify"):e===5?Vt(t,"start"):e===6&&Vt(t,"end")}function hi(t,e,n){let r=Ht.get(t);r===void 0&&D(60);let i=r.createDOM(Kt,Me);var o=Me._keyToDOMMap;if(i["__lexicalKey_"+Me._key]=t,o.set(t,i),M(r)?i.setAttribute("data-lexical-text","true"):q(r)&&i.setAttribute("data-lexical-decorator","true"),O(r)){if(t=r.__indent,o=r.__size,t!==0&&Qu(i,t),o!==0){--o,t=Li(r,Ht);var l=Be;Be="",zo(t,r,0,o,i,null),nc(r,i),Be=l}t=r.__format,t!==0&&ec(i,t),r.isInline()||tc(null,r,i),Ai(r)&&(me+=` +import{r as $,j as p,aT as yg,aU as vg,az as ns,as as Ja,am as Va,aV as Sg,aW as $g,aX as Rg,B as Un,aY as Ag,aZ as Og,m as it,s as P,ap as Wr,t as an,a_ as Xa,a$ as wg,b0 as Dg,b1 as gt,I as Gn,J as Lg,b2 as Mg,b3 as Za,b4 as Le,b5 as qa,b6 as Qa,b7 as eu,b8 as tu,b9 as nu,ba as ru,bb as Ti,bc as iu,h as ou,i as lu,k as su,F as Or,l as au,n as yi,Q as pr,R as mr,bd as yt,be as bg,bf as rs,bg as is,bh as os,bi as ls,bj as ss,bk as as,bl as us,bm as cs,V as _r,W as Cr,_ as ue,aj as kg,ak as Ig,ao as Pg,bn as Fg,bo as Bg,bp as jg,bq as zg,br as sr,bs as Kg,bt as Hg,bu as Wg,bv as Ug,N as Gg,bw as Yg,D as ds,bx as Jg,g as gs,by as Vg,bz as Xg,bA as fs,bB as Zg,bC as qg,bD as Qg,bE as ef,bF as tf,bG as nf}from"./vendor-DpqXKvKY.js";import{F as uu,B as cu,d as rf,D as du,S as of}from"./index-7dlI38O5.js";var gu={},Ui={},fu=$;let hu=fu.createContext(null);Ui.LexicalComposerContext=hu;Ui.createLexicalComposerContext=function(t,e){let n=null;return t!=null&&(n=t[1]),{getTheme:function(){return e??(n!=null?n.getTheme():null)}}};Ui.useLexicalComposerContext=function(){let t=fu.useContext(hu);if(t==null)throw Error("Minified Lexical error #8; visit https://lexical.dev/docs/error?code=8 for the full message or use the non-minified dev environment for full errors and additional helpful warnings.");return t};const lf=Ui;var X=lf,R={};let ul={},pu={},wr={},xr={},Do={},Fn={},cl={},Lo={},Dr={},Lr={},Pt={},dl={},gl={},mu={},_u={},Cu={},xu={},Nu={},Eu={},Tu={},vi={},yu={},vu={},Su={},$u={},Ru={},Au={},Ou={},wu={},Du={},fl={},hl={},Lu={},Mu={},bu={};function D(t){throw Error(`Minified Lexical error #${t}; visit https://lexical.dev/docs/error?code=${t} for the full message or use the non-minified dev environment for full errors and additional helpful warnings.`)}let At=typeof window<"u"&&typeof window.document<"u"&&typeof window.document.createElement<"u",sf=At&&"documentMode"in document?document.documentMode:null,Ie=At&&/Mac|iPod|iPhone|iPad/.test(navigator.platform),un=At&&/^(?!.*Seamonkey)(?=.*Firefox).*/i.test(navigator.userAgent),Si=At&&"InputEvent"in window&&!sf?"getTargetRanges"in new window.InputEvent("input"):!1,pl=At&&/Version\/[\d.]+.*Safari/.test(navigator.userAgent),ml=At&&/iPad|iPhone|iPod/.test(navigator.userAgent)&&!window.MSStream,af=At&&/^(?=.*Chrome).*/i.test(navigator.userAgent),_l=At&&/AppleWebKit\/[\d.]+/.test(navigator.userAgent)&&!af,Gi=pl||ml||_l?" ":"​",uf=un?" ":Gi,cf=/^[^A-Za-z\u00c0-\u00d6\u00d8-\u00f6\u00f8-\u02b8\u0300-\u0590\u0800-\u1fff\u200e\u2c00-\ufb1c\ufe00-\ufe6f\ufefd-\uffff]*[\u0591-\u07ff\ufb1d-\ufdfd\ufe70-\ufefc]/,df=/^[^\u0591-\u07ff\ufb1d-\ufdfd\ufe70-\ufefc]*[A-Za-z\u00c0-\u00d6\u00d8-\u00f6\u00f8-\u02b8\u0300-\u0590\u0800-\u1fff\u200e\u2c00-\ufb1c\ufe00-\ufe6f\ufefd-\uffff]/,nn={bold:1,code:16,highlight:128,italic:2,strikethrough:4,subscript:32,superscript:64,underline:8},gf={directionless:1,unmergeable:2},hs={center:2,end:6,justify:4,left:1,right:3,start:5},ff={2:"center",6:"end",4:"justify",1:"left",3:"right",5:"start"},hf={normal:0,segmented:2,token:1},pf={0:"normal",2:"segmented",1:"token"},Mo=!1,Cl=0;function mf(t){Cl=t.timeStamp}function uo(t,e,n){return e.__lexicalLineBreak===t||t[`__lexicalKey_${n._key}`]!==void 0}function _f(t){return t.getEditorState().read(()=>{let e=Q();return e!==null?e.clone():null})}function ku(t,e,n){Mo=!0;let r=100{let i=Q()||_f(t);var o=new Map,l=t.getRootElement(),s=t._editorState,a=t._blockCursorElement;let c=!1,g="";for(var d=0;d{ku(t,e,n)})}let Cf=1,xf=typeof queueMicrotask=="function"?queueMicrotask:t=>{Promise.resolve().then(t)};function xl(t){let e=document.activeElement;if(e===null)return!1;let n=e.nodeName;return q(Gr(t))&&(n==="INPUT"||n==="TEXTAREA"||e.contentEditable==="true"&&e.__lexicalEditor==null)}function Ur(t,e,n){let r=t.getRootElement();try{return r!==null&&r.contains(e)&&r.contains(n)&&e!==null&&!xl(e)&&Nl(e)===t}catch{return!1}}function Nl(t){for(;t!=null;){let e=t.__lexicalEditor;if(e!=null)return e;t=Yi(t)}return null}function bo(t){return t.isToken()||t.isSegmented()}function $i(t){for(;t!=null;){if(t.nodeType===3)return t;t=t.firstChild}return null}function Fu(t,e,n){return e=nn[e],t&e&&(n===null||!(n&e))?t^e:n===null||n&e?t|e:t}function Bu(t){return M(t)||Pr(t)||q(t)}function ju(t,e){if(e!=null)t.__key=e;else{je(),99pt().getTextContent())}function Nf(t,e){Ye(t,()=>{var n=_t();if(!n.isEmpty())if(e==="root")pt().markDirty();else{n=n._nodeMap;for(let[,r]of n)r.markDirty()}},t._pendingEditorState===null?{tag:"history-merge"}:void 0)}function pt(){return _t()._nodeMap.get("root")}function zt(t){je();let e=_t();t!==null&&(t.dirty=!0,t._cachedNodes=null),e._selection=t}function bn(t){var e=se(),n;e:{for(n=t;n!=null;){let r=n[`__lexicalKey_${e._key}`];if(r!==void 0){n=r;break e}n=Yi(n)}n=null}return n===null?(e=e.getRootElement(),t===e?Ce("root"):null):Ce(n)}function Hu(t){return/[\uD800-\uDBFF][\uDC00-\uDFFF]/g.test(t)}function El(t){let e=[];for(;t!==null;)e.push(t),t=t._parentEditor;return e}function Wu(){return Math.random().toString(36).replace(/[^a-z]+/g,"").substr(0,5)}function Tl(t,e,n){if(e=mt(e._window),e!==null){var r=e.anchorNode,{anchorOffset:i,focusOffset:o}=e;if(r!==null&&(e=r.nodeType===3?r.nodeValue:null,r=Gr(r),e!==null&&M(r))){if(r.canContainTabs()){var l=e.includes(" ");if(n&&0{c.update(()=>{o.isAttached()&&o.remove()})},20)}else{i=o.getParent(),e=Vr();var s=Ft(),a=o.getKey();o.isToken()||s!==null&&a===s&&!l||i!==null&&z(e)&&!i.canInsertTextBefore()&&e.anchor.offset===0?o.markDirty():(l=Q(),z(l)&&n!==null&&r!==null&&(l.setTextNodeRange(o,n,o,r),o.isSegmented()&&(n=o.getTextContent(),n=ve(n),o.replace(n),o=n)),o.setTextContent(t))}}}function Ef(t,e){if(e.isSegmented())return!0;if(!t.isCollapsed())return!1;t=t.anchor.offset;let n=e.getParentOrThrow(),r=e.isToken();return t===0?((t=!e.canInsertTextBefore()||!n.canInsertTextBefore()||r)||(e=e.getPreviousSibling(),t=(M(e)||O(e)&&e.isInline())&&!e.canInsertTextAfter()),t):t===e.getTextContentSize()?!e.canInsertTextAfter()||!n.canInsertTextAfter()||r:!1}function Nr(t,e){var n=t[e];return typeof n=="string"?(n=n.split(" "),t[e]=n):n}function vl(t,e,n,r,i){n.size!==0&&(n=r.__key,e=e.get(r.__type),e===void 0&&D(33),r=e.klass,e=t.get(r),e===void 0&&(e=new Map,t.set(r,e)),t=e.get(n),r=t==="destroyed"&&i==="created",(t===void 0||r)&&e.set(n,r?"updated":i))}function ms(t,e,n){let r=t.getParent(),i=n;return r!==null&&(e&&n===0?(i=t.getIndexWithinParent(),t=r):e||n!==t.getChildrenSize()||(i=t.getIndexWithinParent()+1,t=r)),t.getChildAtIndex(e?i-1:i)}function ko(t,e){var n=t.offset;return t.type==="element"?(t=t.getNode(),ms(t,e,n)):(t=t.getNode(),e&&n===0||!e&&n===t.getTextContentSize()?(n=e?t.getPreviousSibling():t.getNextSibling(),n===null?ms(t.getParentOrThrow(),e,t.getIndexWithinParent()+(e?0:1)):n):null)}function Uu(t){return t=(t=Ji(t).event)&&t.inputType,t==="insertFromPaste"||t==="insertFromPasteAsQuotation"}function Ai(t){return!We(t)&&!t.isLastChild()&&!t.isInline()}function Oi(t,e){return t=t._keyToDOMMap.get(e),t===void 0&&D(75),t}function Yi(t){return t=t.assignedSlot||t.parentElement,t!==null&&t.nodeType===11?t.host:t}function Tf(t,e=0){if(e!==0&&D(1),e=Q(),!z(e)||!O(t))return e;let{anchor:n,focus:r}=e,i=n.getNode(),o=r.getNode();return wi(i,t)&&n.set(t.__key,0,"element"),wi(o,t)&&r.set(t.__key,0,"element"),e}function wi(t,e){for(t=t.getParent();t!==null;){if(t.is(e))return!0;t=t.getParent()}return!1}function Ji(t){return t=t._window,t===null&&D(78),t}function Gu(t){for(t=t.getParentOrThrow();t!==null&&!nt(t);)t=t.getParentOrThrow();return t}function nt(t){return We(t)||O(t)&&t.isShadowRoot()}function Yu(t){return t=t.constructor.clone(t),ju(t,null),t}function Vi(t){var e=se();let n=t.constructor.getType();return e=e._nodes.get(n),e===void 0&&D(97),e=e.replace,e!==null?(e=e(t),e instanceof t.constructor||D(98),e):t}function co(t,e){t=t.getParent(),!We(t)||O(e)||q(e)||D(99)}function go(t){return(q(t)||O(t)&&!t.canBeEmpty())&&!t.isInline()}function Io(t,e,n){n.style.removeProperty("caret-color"),e._blockCursorElement=null,e=t.parentElement,e!==null&&e.removeChild(t)}function mt(t){return At?(t||window).getSelection():null}function Ju(t,e){let n=t.getChildAtIndex(e);n==null&&(n=t),nt(t)&&D(102);let r=l=>{const s=l.getParentOrThrow(),a=nt(s),c=l!==n||a?Yu(l):l;if(a)return l.insertAfter(c),[l,c,c];const[g,d,u]=r(s);return l=l.getNextSiblings(),u.append(c,...l),[g,d,c]},[i,o]=r(n);return[i,o]}function Di(t,e){for(;t!==pt()&&t!=null;){if(e(t))return t;t=t.getParent()}return null}function yf(t){let e=[],n=[t];for(;0e&&r&&t.classList.remove(n)}n=getComputedStyle(t).getPropertyValue("--lexical-indent-base-value")||"40px",t.style.setProperty("padding-inline-start",e===0?"":`calc(${e} * ${n})`)}function ec(t,e){t=t.style,e===0?Vt(t,""):e===1?Vt(t,"left"):e===2?Vt(t,"center"):e===3?Vt(t,"right"):e===4?Vt(t,"justify"):e===5?Vt(t,"start"):e===6&&Vt(t,"end")}function hi(t,e,n){let r=Ht.get(t);r===void 0&&D(60);let i=r.createDOM(Kt,Me);var o=Me._keyToDOMMap;if(i["__lexicalKey_"+Me._key]=t,o.set(t,i),M(r)?i.setAttribute("data-lexical-text","true"):q(r)&&i.setAttribute("data-lexical-decorator","true"),O(r)){if(t=r.__indent,o=r.__size,t!==0&&Qu(i,t),o!==0){--o,t=Li(r,Ht);var l=Be;Be="",zo(t,r,0,o,i,null),nc(r,i),Be=l}t=r.__format,t!==0&&ec(i,t),r.isInline()||tc(null,r,i),Ai(r)&&(me+=` `,vt+=` @@ -32,7 +32,7 @@ import{r as $,j as p,aT as yg,aU as vg,az as ns,as as Ja,am as Va,aV as Sg,aW as `&&r[i-2].getTextContent()===` `&&e.isCollapsed()&&e.anchor.key===this.__key&&e.anchor.offset===i)return r[i-1].remove(),r[i-2].remove(),e=b.$createParagraphNode(),this.insertAfter(e,n),e;if(n=e.anchor.getNode(),i=jr(n),i!=null){for(r=0,i=i.getTextContent();re.append(n)),this.replace(e),!0}setLanguage(e){this.getWritable().__language=sa(e)}getLanguage(){return this.getLatest().__language}};function tr(t){return b.$applyNodeReplacement(new Hn(t))}function to(t){return t instanceof Hn}function aa(){return{node:tr(),preformatted:!0}}function yp(t){let e=t.style.fontFamily.match("monospace")!==null;return e||$p(t)?{after:n=>{let r=t.parentNode;return r!=null&&t!==r.lastChild&&n.push(b.$createLineBreakNode()),n},node:e?tr():null,preformatted:e}:{node:null}}function vp(){return{node:tr(),preformatted:!0}}function ua(){return{node:null}}function Sp(t){return{after:e=>(t.parentNode&&t.parentNode.nextSibling&&e.push(b.$createLineBreakNode()),e),node:null}}function $p(t){for(t=t.parentElement;t!==null;){if(t.style.fontFamily.match("monospace")!==null)return!0;t=t.parentElement}return!1}function Eo(t){return t.classList.contains("js-file-line-container")}let ad={c:"C",clike:"C-like",cpp:"C++",css:"CSS",html:"HTML",java:"Java",js:"JavaScript",markdown:"Markdown",objc:"Objective-C",plain:"Plain Text",py:"Python",rust:"Rust",sql:"SQL",swift:"Swift",typescript:"TypeScript",xml:"XML"},ud={cpp:"cpp",java:"java",javascript:"js",md:"markdown",plaintext:"plain",python:"py",text:"plain",ts:"typescript"};function cd(t){return ud[t]||t}let Br=class dd extends b.TextNode{constructor(e,n,r){super(e,r),this.__highlightType=n}static getType(){return"code-highlight"}static clone(e){return new dd(e.__text,e.__highlightType||void 0,e.__key)}getHighlightType(){return this.getLatest().__highlightType}createDOM(e){let n=super.createDOM(e);return e=To(e.theme,this.__highlightType),Kn.addClassNamesToElement(n,e),n}updateDOM(e,n,r){let i=super.updateDOM(e,n,r);return e=To(r.theme,e.__highlightType),r=To(r.theme,this.__highlightType),e!==r&&(e&&Kn.removeClassNamesFromElement(n,e),r&&Kn.addClassNamesToElement(n,r)),i}static importJSON(e){let n=ln(e.text,e.highlightType);return n.setFormat(e.format),n.setDetail(e.detail),n.setMode(e.mode),n.setStyle(e.style),n}exportJSON(){return{...super.exportJSON(),highlightType:this.getHighlightType(),type:"code-highlight",version:1}}setFormat(){return this}isParentRequired(){return!0}createParentElementNode(){return tr()}};function To(t,e){return e&&t&&t.codeHighlight&&t.codeHighlight[e]}function ln(t,e){return b.$applyNodeReplacement(new Br(t,e))}function Re(t){return t instanceof Br}function jr(t){let e=null,n=t.getPreviousSiblings();for(n.push(t);0{Rp(r,()=>{var i=b.$getNodeByKey(r);if(!to(i)||!i.isAttached())return!1;var o=i.getTextContent();o=n.tokenize(o,i.getLanguage()||n.defaultLanguage),o=md(o);var l=i.getChildren();for(i=0;i{yo.delete(r)},skipTransforms:!0}))}function md(t){let e=[];return t.forEach(n=>{if(typeof n=="string"){n=n.split(` `);for(var r=0;rs+a.getTextContentSize(),0)}e()&&(i?n.getNode().select(r,r):t.getChildren().some(l=>{let s=b.$isTextNode(l);if(s||b.$isLineBreakNode(l)){let a=l.getTextContentSize();if(s&&a>=o)return l.select(o,o),!0;o-=a}return!1}))}else e()}}function da(t,e){return Re(t)&&Re(e)?t.__text===e.__text&&t.__highlightType===e.__highlightType:!!(b.$isLineBreakNode(t)&&b.$isLineBreakNode(e))}function ga(t){var e=b.$getSelection();if(!b.$isRangeSelection(e)||e.isCollapsed())return!1;e=e.getNodes();for(var n=0;nh.remove()),t===b.KEY_ARROW_UP_COMMAND?(u.forEach(h=>f.insertBefore(h)),f.insertBefore(e)):(f.insertAfter(e),f=e,u.forEach(h=>{f.insertAfter(h),f=h})),n.setTextNodeRange(s,o,a,l),!0}function pa(t,e){let n=b.$getSelection();if(!b.$isRangeSelection(n))return!1;let{anchor:r,focus:i}=n,o=r.getNode(),l=i.getNode();if(t=t===b.MOVE_TO_START,!Re(o)||!Re(l))return!1;let s,a;return t?{node:s,offset:a}=fd(l):{node:s,offset:a}=hd(l),s!==null&&a!==-1&&n.setTextNodeRange(s,a,s,a),e.preventDefault(),e.stopPropagation(),!0}pe.$createCodeHighlightNode=ln;pe.$createCodeNode=tr;pe.$isCodeHighlightNode=Re;pe.$isCodeNode=to;pe.CODE_LANGUAGE_FRIENDLY_NAME_MAP=ad;pe.CODE_LANGUAGE_MAP=ud;pe.CodeHighlightNode=Br;pe.CodeNode=Hn;pe.DEFAULT_CODE_LANGUAGE="javascript";pe.PrismTokenizer=gd;pe.getCodeLanguages=()=>Object.keys(zn.languages).filter(t=>typeof zn.languages[t]!="function").sort();pe.getDefaultCodeLanguage=()=>"javascript";pe.getEndOfCodeInLine=hd;pe.getFirstCodeHighlightNodeOfLine=jr;pe.getLanguageFriendlyName=function(t){return t=cd(t),ad[t]||t};pe.getLastCodeHighlightNodeOfLine=nl;pe.getStartOfCodeInLine=fd;pe.normalizeCodeLang=cd;pe.registerCodeHighlighting=function(t,e){if(!t.hasNodes([Hn,Br]))throw Error("CodeHighlightPlugin: CodeNode or CodeHighlightNode not registered on editor");return e==null&&(e=gd),Kn.mergeRegister(t.registerMutationListener(Hn,n=>{t.update(()=>{for(let[o,l]of n)if(l!=="destroyed"){var r=b.$getNodeByKey(o);if(r!==null)e:{var i=r;if(r=t.getElementByKey(i.getKey()),r===null)break e;i=i.getChildren();let s=i.length;if(s===r.__cachedChildrenLength)break e;r.__cachedChildrenLength=s;let a="1",c=1;for(let g=0;gpd(n,t,e)),t.registerNodeTransform(b.TextNode,n=>ca(n,t,e)),t.registerNodeTransform(Br,n=>ca(n,t,e)),t.registerCommand(b.INDENT_CONTENT_COMMAND,()=>ga(b.INDENT_CONTENT_COMMAND),b.COMMAND_PRIORITY_LOW),t.registerCommand(b.OUTDENT_CONTENT_COMMAND,()=>ga(b.OUTDENT_CONTENT_COMMAND),b.COMMAND_PRIORITY_LOW),t.registerCommand(b.KEY_ARROW_UP_COMMAND,n=>ha(b.KEY_ARROW_UP_COMMAND,n),b.COMMAND_PRIORITY_LOW),t.registerCommand(b.KEY_ARROW_DOWN_COMMAND,n=>ha(b.KEY_ARROW_DOWN_COMMAND,n),b.COMMAND_PRIORITY_LOW),t.registerCommand(b.MOVE_TO_END,n=>pa(b.MOVE_TO_END,n),b.COMMAND_PRIORITY_LOW),t.registerCommand(b.MOVE_TO_START,n=>pa(b.MOVE_TO_START,n),b.COMMAND_PRIORITY_LOW))};const Ap=pe;var he=Ap,wt={},_d=V,ft=C;let Op=new Set(["http:","https:","mailto:","sms:","tel:"]),no=class Cd extends ft.ElementNode{static getType(){return"link"}static clone(e){return new Cd(e.__url,{rel:e.__rel,target:e.__target,title:e.__title},e.__key)}constructor(e,n={},r){super(r);let{target:i=null,rel:o=null,title:l=null}=n;this.__url=e,this.__target=i,this.__rel=o,this.__title=l}createDOM(e){let n=document.createElement("a");return n.href=this.sanitizeUrl(this.__url),this.__target!==null&&(n.target=this.__target),this.__rel!==null&&(n.rel=this.__rel),this.__title!==null&&(n.title=this.__title),_d.addClassNamesToElement(n,e.theme.link),n}updateDOM(e,n){let r=this.__url,i=this.__target,o=this.__rel,l=this.__title;return r!==e.__url&&(n.href=r),i!==e.__target&&(i?n.target=i:n.removeAttribute("target")),o!==e.__rel&&(o?n.rel=o:n.removeAttribute("rel")),l!==e.__title&&(l?n.title=l:n.removeAttribute("title")),!1}static importDOM(){return{a:()=>({conversion:wp,priority:1})}}static importJSON(e){let n=zr(e.url,{rel:e.rel,target:e.target,title:e.title});return n.setFormat(e.format),n.setIndent(e.indent),n.setDirection(e.direction),n}sanitizeUrl(e){try{let n=new URL(e);if(!Op.has(n.protocol))return"about:blank"}catch{return"https://"}return e}exportJSON(){return{...super.exportJSON(),rel:this.getRel(),target:this.getTarget(),title:this.getTitle(),type:"link",url:this.getURL(),version:1}}getURL(){return this.getLatest().__url}setURL(e){this.getWritable().__url=e}getTarget(){return this.getLatest().__target}setTarget(e){this.getWritable().__target=e}getRel(){return this.getLatest().__rel}setRel(e){this.getWritable().__rel=e}getTitle(){return this.getLatest().__title}setTitle(e){this.getWritable().__title=e}insertNewAfter(e,n=!0){return e=this.getParentOrThrow().insertNewAfter(e,n),ft.$isElementNode(e)?(n=zr(this.__url,{rel:this.__rel,target:this.__target,title:this.__title}),e.append(n),n):null}canInsertTextBefore(){return!1}canInsertTextAfter(){return!1}canBeEmpty(){return!1}isInline(){return!0}extractWithChild(e,n){if(!ft.$isRangeSelection(n))return!1;e=n.anchor.getNode();let r=n.focus.getNode();return this.isParentOf(e)&&this.isParentOf(r)&&0{if(l=l.getParent(),Zt(l)){let s=l.getChildren();for(let a=0;a{var c=a.getParent();if(c!==s&&c!==null&&(!ft.$isElementNode(a)||a.isInline()))if(Zt(c))s=c,c.setURL(t),n!==void 0&&c.setTarget(n),i!==null&&s.setRel(i),r!==void 0&&s.setTitle(r);else if(c.is(l)||(l=c,s=zr(t,{rel:i,target:n}),Zt(c)?a.getPreviousSibling()===null?c.insertBefore(s):c.insertAfter(s):a.insertBefore(s)),Zt(a)){if(!a.is(s)){if(s!==null){c=a.getChildren();for(let g=0;g({conversion:bp,priority:0})}}exportJSON(){return{altText:this.getAltText(),caption:this.caption.toJSON(),height:this.height==="inherit"?0:this.height,maxWidth:this.maxWidth,showCaption:this.showCaption,src:this.getSrc(),type:"image",version:1,width:this.width==="inherit"?0:this.width}}setWidthAndHeight(e,n){const r=this.getWritable();r.width=e,r.height=n}setShowCaption(e){const n=this.getWritable();n.showCaption=e}createDOM(e){const n=document.createElement("span"),i=e.theme.image;return i&&(n.className=i),n}updateDOM(){return!1}getSrc(){return this.src}getAltText(){return this.altText}decorate(){return p.jsx($.Suspense,{fallback:null,children:p.jsx(kp,{src:this.src,altText:this.altText,width:this.width,height:this.height,maxWidth:this.maxWidth,nodeKey:this.getKey(),showCaption:this.showCaption,caption:this.caption,captionsEnabled:this.captionsEnabled,resizable:!0})})}}const kp=$.lazy(()=>Ja(()=>import("./Component-RuL62tq9.js"),__vite__mapDeps([0,1,2,3,4])));function ro({altText:t,height:e,maxWidth:n=500,captionsEnabled:r,src:i,width:o,showCaption:l,caption:s,key:a}){return C.$applyNodeReplacement(new Ut(i,t,n,o,e,l,s,r,a))}function Nd(t){return t instanceof Ut}const Ip=[rt.HeadingNode,fe.ListNode,fe.ListItemNode,rt.QuoteNode,he.CodeNode,he.CodeHighlightNode,ce.AutoLinkNode,ce.LinkNode,Ut];function Pp(){const[t]=X.useLexicalComposerContext(),e=t.isEditable();return p.jsx(Va,{appearance:"outline",icon:e?p.jsx(Sg,{}):p.jsx($g,{}),checked:!e,onClick:()=>t.setEditable(!e)})}var te={},U=C,Rr=he,Ae=fe,Bt=rt,Fp=V,vo=ce;function il(t,e){let n={};for(let r of t)t=e(r),n[t]?n[t].push(r):n[t]=[r];return n}function Bl(t){return t=il(t,e=>e.type),{element:t.element||[],textFormat:t["text-format"]||[],textMatch:t["text-match"]||[]}}let zi=/[!-/:-@[-`{-~\s]/;function Bp(t){let e=Bl(t),n=e.textFormat.filter(r=>r.format.length===1);return r=>{let i=[];r=(r||U.$getRoot()).getChildren();for(let o of r)r=jp(o,e.element,n,e.textMatch),r!=null&&i.push(r);return i.join(` +`+ ++c);r.setAttribute("data-gutter",a)}}})}),t.registerNodeTransform(Hn,n=>pd(n,t,e)),t.registerNodeTransform(b.TextNode,n=>ca(n,t,e)),t.registerNodeTransform(Br,n=>ca(n,t,e)),t.registerCommand(b.INDENT_CONTENT_COMMAND,()=>ga(b.INDENT_CONTENT_COMMAND),b.COMMAND_PRIORITY_LOW),t.registerCommand(b.OUTDENT_CONTENT_COMMAND,()=>ga(b.OUTDENT_CONTENT_COMMAND),b.COMMAND_PRIORITY_LOW),t.registerCommand(b.KEY_ARROW_UP_COMMAND,n=>ha(b.KEY_ARROW_UP_COMMAND,n),b.COMMAND_PRIORITY_LOW),t.registerCommand(b.KEY_ARROW_DOWN_COMMAND,n=>ha(b.KEY_ARROW_DOWN_COMMAND,n),b.COMMAND_PRIORITY_LOW),t.registerCommand(b.MOVE_TO_END,n=>pa(b.MOVE_TO_END,n),b.COMMAND_PRIORITY_LOW),t.registerCommand(b.MOVE_TO_START,n=>pa(b.MOVE_TO_START,n),b.COMMAND_PRIORITY_LOW))};const Ap=pe;var he=Ap,wt={},_d=V,ft=C;let Op=new Set(["http:","https:","mailto:","sms:","tel:"]),no=class Cd extends ft.ElementNode{static getType(){return"link"}static clone(e){return new Cd(e.__url,{rel:e.__rel,target:e.__target,title:e.__title},e.__key)}constructor(e,n={},r){super(r);let{target:i=null,rel:o=null,title:l=null}=n;this.__url=e,this.__target=i,this.__rel=o,this.__title=l}createDOM(e){let n=document.createElement("a");return n.href=this.sanitizeUrl(this.__url),this.__target!==null&&(n.target=this.__target),this.__rel!==null&&(n.rel=this.__rel),this.__title!==null&&(n.title=this.__title),_d.addClassNamesToElement(n,e.theme.link),n}updateDOM(e,n){let r=this.__url,i=this.__target,o=this.__rel,l=this.__title;return r!==e.__url&&(n.href=r),i!==e.__target&&(i?n.target=i:n.removeAttribute("target")),o!==e.__rel&&(o?n.rel=o:n.removeAttribute("rel")),l!==e.__title&&(l?n.title=l:n.removeAttribute("title")),!1}static importDOM(){return{a:()=>({conversion:wp,priority:1})}}static importJSON(e){let n=zr(e.url,{rel:e.rel,target:e.target,title:e.title});return n.setFormat(e.format),n.setIndent(e.indent),n.setDirection(e.direction),n}sanitizeUrl(e){try{let n=new URL(e);if(!Op.has(n.protocol))return"about:blank"}catch{return"https://"}return e}exportJSON(){return{...super.exportJSON(),rel:this.getRel(),target:this.getTarget(),title:this.getTitle(),type:"link",url:this.getURL(),version:1}}getURL(){return this.getLatest().__url}setURL(e){this.getWritable().__url=e}getTarget(){return this.getLatest().__target}setTarget(e){this.getWritable().__target=e}getRel(){return this.getLatest().__rel}setRel(e){this.getWritable().__rel=e}getTitle(){return this.getLatest().__title}setTitle(e){this.getWritable().__title=e}insertNewAfter(e,n=!0){return e=this.getParentOrThrow().insertNewAfter(e,n),ft.$isElementNode(e)?(n=zr(this.__url,{rel:this.__rel,target:this.__target,title:this.__title}),e.append(n),n):null}canInsertTextBefore(){return!1}canInsertTextAfter(){return!1}canBeEmpty(){return!1}isInline(){return!0}extractWithChild(e,n){if(!ft.$isRangeSelection(n))return!1;e=n.anchor.getNode();let r=n.focus.getNode();return this.isParentOf(e)&&this.isParentOf(r)&&0{if(l=l.getParent(),Zt(l)){let s=l.getChildren();for(let a=0;a{var c=a.getParent();if(c!==s&&c!==null&&(!ft.$isElementNode(a)||a.isInline()))if(Zt(c))s=c,c.setURL(t),n!==void 0&&c.setTarget(n),i!==null&&s.setRel(i),r!==void 0&&s.setTitle(r);else if(c.is(l)||(l=c,s=zr(t,{rel:i,target:n}),Zt(c)?a.getPreviousSibling()===null?c.insertBefore(s):c.insertAfter(s):a.insertBefore(s)),Zt(a)){if(!a.is(s)){if(s!==null){c=a.getChildren();for(let g=0;g({conversion:bp,priority:0})}}exportJSON(){return{altText:this.getAltText(),caption:this.caption.toJSON(),height:this.height==="inherit"?0:this.height,maxWidth:this.maxWidth,showCaption:this.showCaption,src:this.getSrc(),type:"image",version:1,width:this.width==="inherit"?0:this.width}}setWidthAndHeight(e,n){const r=this.getWritable();r.width=e,r.height=n}setShowCaption(e){const n=this.getWritable();n.showCaption=e}createDOM(e){const n=document.createElement("span"),i=e.theme.image;return i&&(n.className=i),n}updateDOM(){return!1}getSrc(){return this.src}getAltText(){return this.altText}decorate(){return p.jsx($.Suspense,{fallback:null,children:p.jsx(kp,{src:this.src,altText:this.altText,width:this.width,height:this.height,maxWidth:this.maxWidth,nodeKey:this.getKey(),showCaption:this.showCaption,caption:this.caption,captionsEnabled:this.captionsEnabled,resizable:!0})})}}const kp=$.lazy(()=>Ja(()=>import("./Component-uOG8IUJI.js"),__vite__mapDeps([0,1,2,3,4])));function ro({altText:t,height:e,maxWidth:n=500,captionsEnabled:r,src:i,width:o,showCaption:l,caption:s,key:a}){return C.$applyNodeReplacement(new Ut(i,t,n,o,e,l,s,r,a))}function Nd(t){return t instanceof Ut}const Ip=[rt.HeadingNode,fe.ListNode,fe.ListItemNode,rt.QuoteNode,he.CodeNode,he.CodeHighlightNode,ce.AutoLinkNode,ce.LinkNode,Ut];function Pp(){const[t]=X.useLexicalComposerContext(),e=t.isEditable();return p.jsx(Va,{appearance:"outline",icon:e?p.jsx(Sg,{}):p.jsx($g,{}),checked:!e,onClick:()=>t.setEditable(!e)})}var te={},U=C,Rr=he,Ae=fe,Bt=rt,Fp=V,vo=ce;function il(t,e){let n={};for(let r of t)t=e(r),n[t]?n[t].push(r):n[t]=[r];return n}function Bl(t){return t=il(t,e=>e.type),{element:t.element||[],textFormat:t["text-format"]||[],textMatch:t["text-match"]||[]}}let zi=/[!-/:-@[-`{-~\s]/;function Bp(t){let e=Bl(t),n=e.textFormat.filter(r=>r.format.length===1);return r=>{let i=[];r=(r||U.$getRoot()).getChildren();for(let o of r)r=jp(o,e.element,n,e.textMatch),r!=null&&i.push(r);return i.join(` `)}}function jp(t,e,n,r){for(let i of e)if(e=i.export(t,o=>Ki(o,n,r)),e!=null)return e;return U.$isElementNode(t)?Ki(t,n,r):U.$isDecoratorNode(t)?t.getTextContent():null}function Ki(t,e,n){let r=[];t=t.getChildren();e:for(let i of t){for(let o of n)if(t=o.export(i,l=>Ki(l,e,n),(l,s)=>ma(l,s,e)),t!=null){r.push(t);continue e}U.$isLineBreakNode(i)?r.push(` `):U.$isTextNode(i)?r.push(ma(i,i.getTextContent(),e)):U.$isElementNode(i)?r.push(Ki(i,e,n)):U.$isDecoratorNode(i)&&r.push(i.getTextContent())}return r.join("")}function ma(t,e,n){let r=e.trim(),i=r,o=new Set;for(let s of n){n=s.format[0];let a=s.tag;if(So(t,n)&&!o.has(n)){o.add(n);var l=_a(t,!0);So(l,n)||(i=a+i),l=_a(t,!1),So(l,n)||(i+=a)}}return e.replace(r,i)}function _a(t,e){let n=e?t.getPreviousSibling():t.getNextSibling();for(n||(t=t.getParentOrThrow(),t.isInline()&&(n=e?t.getPreviousSibling():t.getNextSibling()));n;){if(U.$isElementNode(n)){if(!n.isInline())break;if(t=e?n.getLastDescendant():n.getFirstDescendant(),U.$isTextNode(t))return t;n=e?n.getPreviousSibling():n.getNextSibling()}if(U.$isTextNode(n))return n;if(!U.$isElementNode(n))break}return null}function So(t,e){return U.$isTextNode(t)&&t.hasFormat(e)}let nr=typeof window<"u"&&typeof window.document<"u"&&typeof window.document.createElement<"u",zp=nr&&"documentMode"in document?document.documentMode:null;nr&&"InputEvent"in window&&!zp&&"getTargetRanges"in new window.InputEvent("input");let Ca=nr&&/Version\/[\d.]+.*Safari/.test(navigator.userAgent),xa=nr&&/iPad|iPhone|iPod/.test(navigator.userAgent)&&!window.MSStream,Kp=nr&&/^(?=.*Chrome).*/i.test(navigator.userAgent),Na=nr&&/AppleWebKit\/[\d.]+/.test(navigator.userAgent)&&!Kp,Hp=/^\s{0,3}$/,Ea=/^```(\w{1,10})?\s?$/;function Wp(t){let e=Bl(t),n=Gp(e.textFormat);return(r,i)=>{r=r.split(` @@ -44,10 +44,10 @@ import{r as $,j as p,aT as yg,aU as vg,az as ns,as as Ja,am as Va,aV as Sg,aW as `+e:"")+"\n```"},regExp:/^```(\w{1,10})?\s/,replace:yd(t=>Rr.$createCodeNode(t?t[1]:void 0)),type:"element"},Rd={dependencies:[Ae.ListNode,Ae.ListItemNode],export:(t,e)=>Ae.$isListNode(t)?io(t,e,0):null,regExp:/^(\s*)[-*+]\s/,replace:jl("bullet"),type:"element"},Yp={dependencies:[Ae.ListNode,Ae.ListItemNode],export:(t,e)=>Ae.$isListNode(t)?io(t,e,0):null,regExp:/^(\s*)(?:-\s)?\s?(\[(\s|x)?\])\s/i,replace:jl("check"),type:"element"},Ad={dependencies:[Ae.ListNode,Ae.ListItemNode],export:(t,e)=>Ae.$isListNode(t)?io(t,e,0):null,regExp:/^(\s*)(\d{1,})\.\s/,replace:jl("number"),type:"element"},Od={format:["code"],tag:"`",type:"text-format"},wd={format:["highlight"],tag:"==",type:"text-format"},Dd={format:["bold","italic"],tag:"***",type:"text-format"},Ld={format:["bold","italic"],intraword:!1,tag:"___",type:"text-format"},Md={format:["bold"],tag:"**",type:"text-format"},bd={format:["bold"],intraword:!1,tag:"__",type:"text-format"},kd={format:["strikethrough"],tag:"~~",type:"text-format"},Id={format:["italic"],tag:"*",type:"text-format"},Pd={format:["italic"],intraword:!1,tag:"_",type:"text-format"},Fd={dependencies:[vo.LinkNode],export:(t,e,n)=>{if(!vo.$isLinkNode(t))return null;e=(e=t.getTitle())?`[${t.getTextContent()}](${t.getURL()} "${e}")`:`[${t.getTextContent()}](${t.getURL()})`;const r=t.getFirstChild();return t.getChildrenSize()===1&&U.$isTextNode(r)?n(r,e):e},importRegExp:/(?:\[([^[]+)\])(?:\((?:([^()\s]+)(?:\s"((?:[^"]*\\")*[^"]*)"\s*)?)\))/,regExp:/(?:\[([^[]+)\])(?:\((?:([^()\s]+)(?:\s"((?:[^"]*\\")*[^"]*)"\s*)?)\))$/,replace:(t,e)=>{const[,n,r,i]=e;e=vo.$createLinkNode(r,{title:i});const o=U.$createTextNode(n);o.setFormat(t.getFormat()),e.append(o),t.replace(e)},trigger:")",type:"text-match"},Bd=[vd,Sd,$d,Rd,Ad],jd=[Od,Dd,Ld,Md,bd,wd,Id,Pd,kd],zd=[Fd],oo=[...Bd,...jd,...zd];te.$convertFromMarkdownString=function(t,e=oo,n){return Wp(e)(t,n)};te.$convertToMarkdownString=function(t=oo,e){return Bp(t)(e)};te.BOLD_ITALIC_STAR=Dd;te.BOLD_ITALIC_UNDERSCORE=Ld;te.BOLD_STAR=Md;te.BOLD_UNDERSCORE=bd;te.CHECK_LIST=Yp;te.CODE=$d;te.ELEMENT_TRANSFORMERS=Bd;te.HEADING=vd;te.HIGHLIGHT=wd;te.INLINE_CODE=Od;te.ITALIC_STAR=Id;te.ITALIC_UNDERSCORE=Pd;te.LINK=Fd;te.ORDERED_LIST=Ad;te.QUOTE=Sd;te.STRIKETHROUGH=kd;te.TEXT_FORMAT_TRANSFORMERS=jd;te.TEXT_MATCH_TRANSFORMERS=zd;te.TRANSFORMERS=oo;te.UNORDERED_LIST=Rd;te.registerMarkdownShortcuts=function(t,e=oo){let n=Bl(e),r=il(n.textFormat,({tag:o})=>o[o.length-1]),i=il(n.textMatch,({trigger:o})=>o);for(let o of e)if(e=o.type,(e==="element"||e==="text-match")&&!t.hasNodes(o.dependencies))throw Error("Minified Lexical error #79; visit https://lexical.dev/docs/error?code=79 for the full message or use the non-minified dev environment for full errors and additional helpful warnings.");return t.registerUpdateListener(({tags:o,dirtyLeaves:l,editorState:s,prevEditorState:a})=>{if(!o.has("historic")){var c=s.read(U.$getSelection);if(o=a.read(U.$getSelection),U.$isRangeSelection(o)&&U.$isRangeSelection(c)&&c.isCollapsed()){a=c.anchor.key;var g=c.anchor.offset,d=s._nodeMap.get(a);U.$isTextNode(d)&&l.has(a)&&(g===1||g===o.anchor.offset+1)&&t.update(()=>{if(!d.hasFormat("code")){var u=d.getParent();if(u!==null&&!Rr.$isCodeNode(u)){var f=c.anchor.offset;e:{var h=n.element,m=u.getParent();if(U.$isRootOrShadowRoot(m)&&u.getFirstChild()===d&&(m=d.getTextContent(),m[f-1]===" ")){for(let{regExp:S,replace:A}of h)if((h=m.match(S))&&h[0].length===f){m=d.getNextSiblings();let[w,B]=d.splitText(f);w.remove(),m=B?[B,...m]:m,A(u,m,h,!1),u=!0;break e}}u=!1}if(!u){e:{if(h=d.getTextContent(),u=i[h[f-1]],u!=null){fh&&(v=v.getPreviousSibling())&&!U.$isLineBreakNode(v);)U.$isTextNode(v)&&(h=v.getTextContent(),u=v,h=Ta(h,h.length,x));if(!(0>h||u===N&&h+y===A||(x=u.getTextContent(),0{let n=qt.$getNodeByKey(e);return n===null?!1:n.isSelected()})}Kd.useLexicalNodeSelection=function(t){let[e]=Vp.useLexicalComposerContext(),[n,r]=ai.useState(()=>ya(e,t));ai.useEffect(()=>{let l=!0,s=e.registerUpdateListener(()=>{l&&r(ya(e,t))});return()=>{l=!1,s()}},[e,t]);let i=ai.useCallback(l=>{e.update(()=>{let s=qt.$getSelection();qt.$isNodeSelection(s)||(s=qt.$createNodeSelection(),qt.$setSelection(s)),l?s.add(t):s.delete(t)})},[e,t]),o=ai.useCallback(()=>{e.update(()=>{const l=qt.$getSelection();qt.$isNodeSelection(l)&&l.clear()})},[e]);return[n,i,o]};const Xp=Kd;var Zp=Xp,qp=X,Qp=Zp,em=V,qe=C,_i=$;let tm=qe.createCommand("INSERT_HORIZONTAL_RULE_COMMAND");function nm({nodeKey:t}){let[e]=qp.useLexicalComposerContext(),[n,r,i]=Qp.useLexicalNodeSelection(t),o=_i.useCallback(l=>(n&&qe.$isNodeSelection(qe.$getSelection())&&(l.preventDefault(),l=qe.$getNodeByKey(t),Hd(l)&&l.remove(),r(!1)),!1),[n,t,r]);return _i.useEffect(()=>em.mergeRegister(e.registerCommand(qe.CLICK_COMMAND,l=>{let s=e.getElementByKey(t);return l.target===s?(l.shiftKey||i(),r(!n),!0):!1},qe.COMMAND_PRIORITY_LOW),e.registerCommand(qe.KEY_DELETE_COMMAND,o,qe.COMMAND_PRIORITY_LOW),e.registerCommand(qe.KEY_BACKSPACE_COMMAND,o,qe.COMMAND_PRIORITY_LOW)),[i,e,n,t,o,r]),_i.useEffect(()=>{let l=e.getElementByKey(t);l!==null&&(l.className=n?"selected":"")},[e,n,t]),null}class Zr extends qe.DecoratorNode{static getType(){return"horizontalrule"}static clone(e){return new Zr(e.__key)}static importJSON(){return zl()}static importDOM(){return{hr:()=>({conversion:rm,priority:0})}}exportJSON(){return{type:"horizontalrule",version:1}}exportDOM(){return{element:document.createElement("hr")}}createDOM(){return document.createElement("hr")}getTextContent(){return` `}isInline(){return!1}updateDOM(){return!1}decorate(){return _i.createElement(nm,{nodeKey:this.__key})}}function rm(){return{node:zl()}}function zl(){return qe.$applyNodeReplacement(new Zr)}function Hd(t){return t instanceof Zr}Xr.$createHorizontalRuleNode=zl;Xr.$isHorizontalRuleNode=Hd;Xr.HorizontalRuleNode=Zr;Xr.INSERT_HORIZONTAL_RULE_COMMAND=tm;const im=Xr;var jt=im,Y={},E=C,le=V;let ee={BOTH:3,COLUMN:2,NO_STATUS:0,ROW:1};class qr extends E.DEPRECATED_GridCellNode{static getType(){return"tablecell"}static clone(e){let n=new qr(e.__headerState,e.__colSpan,e.__width,e.__key);return n.__rowSpan=e.__rowSpan,n.__backgroundColor=e.__backgroundColor,n}static importDOM(){return{td:()=>({conversion:va,priority:0}),th:()=>({conversion:va,priority:0})}}static importJSON(e){let n=et(e.headerState,e.colSpan,e.width||void 0);return n.__rowSpan=e.rowSpan,n.__backgroundColor=e.backgroundColor||null,n}constructor(e=ee.NO_STATUS,n=1,r,i){super(n,i),this.__headerState=e,this.__width=r,this.__backgroundColor=null}createDOM(e){let n=document.createElement(this.getTag());return this.__width&&(n.style.width=`${this.__width}px`),1H(r)&&!E.$isElementNode(n)?(r=E.$createParagraphNode(),E.$isLineBreakNode(n)&&n.getTextContent()===` `?null:(r.append(n),r)):n,node:e}}function et(t,e=1,n){return E.$applyNodeReplacement(new qr(t,e,n))}function H(t){return t instanceof qr}let Kl=class Wd extends E.DEPRECATED_GridRowNode{static getType(){return"tablerow"}static clone(e){return new Wd(e.__height,e.__key)}static importDOM(){return{tr:()=>({conversion:om,priority:0})}}static importJSON(e){return hn(e.height)}constructor(e,n){super(n),this.__height=e}exportJSON(){return{...super.exportJSON(),type:"tablerow",version:1}}createDOM(e){let n=document.createElement("tr");return this.__height&&(n.style.height=`${this.__height}px`),le.addClassNamesToElement(n,e.theme.tableRow),n}isShadowRoot(){return!0}setHeight(e){return this.getWritable().__height=e,this.__height}getHeight(){return this.getLatest().__height}updateDOM(e){return e.__height!==this.__height}canBeEmpty(){return!1}canIndent(){return!1}};function om(){return{node:hn()}}function hn(t){return E.$applyNodeReplacement(new Kl(t))}function pn(t){return t instanceof Kl}function Oe(t){throw Error(`Minified Lexical error #${t}; visit https://lexical.dev/docs/error?code=${t} for the full message or use the non-minified dev environment for full errors and additional helpful warnings.`)}let lm=typeof window<"u"&&typeof window.document<"u"&&typeof window.document.createElement<"u",Ud=class{constructor(e,n){this.isHighlightingCells=!1,this.focusY=this.focusX=this.anchorY=this.anchorX=-1,this.listenersToRemove=new Set,this.tableNodeKey=n,this.editor=e,this.grid={cells:[],columns:0,rows:0},this.focusCell=this.anchorCell=this.focusCellNodeKey=this.anchorCellNodeKey=this.gridSelection=null,this.hasHijackedSelectionStyles=!1,this.trackTableGrid()}getGrid(){return this.grid}removeListeners(){Array.from(this.listenersToRemove).forEach(e=>e())}trackTableGrid(){let e=new MutationObserver(n=>{this.editor.update(()=>{var r=!1;for(let i=0;i{let n=this.editor.getElementByKey(this.tableNodeKey);if(!n)throw Error("Expected to find TableElement in DOM");this.grid=xi(n),e.observe(n,{childList:!0,subtree:!0})})}clearHighlight(){let e=this.editor;this.isHighlightingCells=!1,this.focusY=this.focusX=this.anchorY=this.anchorX=-1,this.focusCell=this.anchorCell=this.focusCellNodeKey=this.anchorCellNodeKey=this.gridSelection=null,this.hasHijackedSelectionStyles=!1,this.enableHighlightStyle(),e.update(()=>{var n=E.$getNodeByKey(this.tableNodeKey);if(!Wn(n))throw Error("Expected TableNode.");if(n=e.getElementByKey(this.tableNodeKey),!n)throw Error("Expected to find TableElement in DOM");n=xi(n),ui(e,n,null),E.$setSelection(null),e.dispatchCommand(E.SELECTION_CHANGE_COMMAND,void 0)})}enableHighlightStyle(){let e=this.editor;e.update(()=>{let n=e.getElementByKey(this.tableNodeKey);if(!n)throw Error("Expected to find TableElement in DOM");n.classList.remove("disable-selection"),this.hasHijackedSelectionStyles=!1})}disableHighlightStyle(){let e=this.editor;e.update(()=>{let n=e.getElementByKey(this.tableNodeKey);if(!n)throw Error("Expected to find TableElement in DOM");n.classList.add("disable-selection"),this.hasHijackedSelectionStyles=!0})}updateTableGridSelection(e){if(e!=null&&e.gridKey===this.tableNodeKey){let n=this.editor;this.gridSelection=e,this.isHighlightingCells=!0,this.disableHighlightStyle(),ui(n,this.grid,this.gridSelection)}else e==null&&this.clearHighlight()}setFocusCellForSelection(e,n=!1){let r=this.editor;r.update(()=>{var i=E.$getNodeByKey(this.tableNodeKey);if(!Wn(i))throw Error("Expected TableNode.");if(!r.getElementByKey(this.tableNodeKey))throw Error("Expected to find TableElement in DOM");i=e.x;let o=e.y;if(this.focusCell=e,this.anchorCell!==null){let l=lm?(r._window||window).getSelection():null;l&&l.setBaseAndExtent(this.anchorCell.elem,0,this.focusCell.elem,0)}if(!this.isHighlightingCells&&(this.anchorX!==i||this.anchorY!==o||n))this.isHighlightingCells=!0,this.disableHighlightStyle();else if(i===this.focusX&&o===this.focusY)return;this.focusX=i,this.focusY=o,this.isHighlightingCells&&(i=E.$getNearestNodeFromDOMNode(e.elem),this.gridSelection!=null&&this.anchorCellNodeKey!=null&&H(i)&&(i=i.getKey(),this.gridSelection=this.gridSelection.clone()||E.DEPRECATED_$createGridSelection(),this.focusCellNodeKey=i,this.gridSelection.set(this.tableNodeKey,this.anchorCellNodeKey,this.focusCellNodeKey),E.$setSelection(this.gridSelection),r.dispatchCommand(E.SELECTION_CHANGE_COMMAND,void 0),ui(r,this.grid,this.gridSelection)))})}setAnchorCellForSelection(e){this.isHighlightingCells=!1,this.anchorCell=e,this.anchorX=e.x,this.anchorY=e.y,this.editor.update(()=>{var n=E.$getNearestNodeFromDOMNode(e.elem);H(n)&&(n=n.getKey(),this.gridSelection=E.DEPRECATED_$createGridSelection(),this.anchorCellNodeKey=n)})}formatCells(e){this.editor.update(()=>{let n=E.$getSelection();E.DEPRECATED_$isGridSelection(n)||Oe(11);let r=E.$createRangeSelection(),i=r.anchor,o=r.focus;n.getNodes().forEach(l=>{H(l)&&l.getTextContentSize()!==0&&(i.set(l.getKey(),0,"element"),o.set(l.getKey(),l.getChildrenSize(),"element"),r.formatText(e))}),E.$setSelection(n),this.editor.dispatchCommand(E.SELECTION_CHANGE_COMMAND,void 0)})}clearText(){let e=this.editor;e.update(()=>{let n=E.$getNodeByKey(this.tableNodeKey);if(!Wn(n))throw Error("Expected TableNode.");var r=E.$getSelection();E.DEPRECATED_$isGridSelection(r)||Oe(11),r=r.getNodes().filter(H),r.length===this.grid.columns*this.grid.rows?(n.selectPrevious(),n.remove(),E.$getRoot().selectStart()):(r.forEach(i=>{if(E.$isElementNode(i)){let o=E.$createParagraphNode(),l=E.$createTextNode();o.append(l),i.append(o),i.getChildren().forEach(s=>{s!==o&&s.remove()})}}),ui(e,this.grid,null),E.$setSelection(null),e.dispatchCommand(E.SELECTION_CHANGE_COMMAND,void 0))})}};function Ci(t){for(;t!=null;){let e=t.nodeName;if(e==="TD"||e==="TH"){if(t=t._cell,t===void 0)break;return t}t=t.parentNode}return null}function xi(t){let e=[],n={cells:e,columns:0,rows:0};var r=t.firstChild;let i=t=0;for(e.length=0;r!=null;){var o=r.nodeName;if(o==="TD"||o==="TH")o=r,o={elem:o,hasBackgroundColor:o.style.backgroundColor!=="",highlighted:!1,x:t,y:i},r._cell=o,e[i]===void 0&&(e[i]=[]),e[i][t]=o;else if(o=r.firstChild,o!=null){r=o;continue}if(o=r.nextSibling,o!=null)t++,r=o;else if(o=r.parentNode,o!=null){if(r=o.nextSibling,r==null)break;i++,t=0}}return n.columns=t+1,n.rows=i+1,n}function ui(t,e,n){let r=[],i=new Set(n?n.getNodes():[]);return Hl(e,(o,l)=>{let s=o.elem;i.has(l)?(o.highlighted=!0,Gd(t,o),r.push(o)):(o.highlighted=!1,Yd(t,o),s.getAttribute("style")||s.removeAttribute("style"))}),r}function Hl(t,e){({cells:t}=t);for(let n=0;n{n.highlighted=!0,Gd(t,n)})}function sm(t,e){e.enableHighlightStyle(),Hl(e.grid,n=>{let r=n.elem;n.highlighted=!1,Yd(t,n),r.getAttribute("style")||r.removeAttribute("style")})}let ur=(t,e,n,r,i)=>{const o=i==="forward";switch(i){case"backward":case"forward":return n!==(o?t.grid.columns-1:0)?ci(e.getCellNodeFromCordsOrThrow(n+(o?1:-1),r,t.grid)):r!==(o?t.grid.rows-1:0)?ci(e.getCellNodeFromCordsOrThrow(o?0:t.grid.columns-1,r+(o?1:-1),t.grid)):o?e.selectNext():e.selectPrevious(),!0;case"up":return r!==0?ci(e.getCellNodeFromCordsOrThrow(n,r-1,t.grid)):e.selectPrevious(),!0;case"down":return r!==t.grid.rows-1?ci(e.getCellNodeFromCordsOrThrow(n,r+1,t.grid)):e.selectNext(),!0;default:return!1}},bt=(t,e,n,r,i)=>{const o=i==="forward";switch(i){case"backward":case"forward":return n!==(o?t.grid.columns-1:0)&&t.setFocusCellForSelection(e.getCellFromCordsOrThrow(n+(o?1:-1),r,t.grid)),!0;case"up":return r!==0?(t.setFocusCellForSelection(e.getCellFromCordsOrThrow(n,r-1,t.grid)),!0):!1;case"down":return r!==t.grid.rows-1?(t.setFocusCellForSelection(e.getCellFromCordsOrThrow(n,r+1,t.grid)),!0):!1;default:return!1}};function Et(t,e){if(E.$isRangeSelection(t)||E.DEPRECATED_$isGridSelection(t)){let n=e.isParentOf(t.anchor.getNode());return t=e.isParentOf(t.focus.getNode()),n&&t}return!1}function ci(t){let e=t.getChildren().find(n=>E.$isParagraphNode(n));E.$isParagraphNode(e)?e.selectEnd():t.selectEnd()}function Gd(t,e){if(t=e.elem,e=E.$getNearestNodeFromDOMNode(t),!H(e))throw Error("Expected to find LexicalNode from Table Cell DOMNode");e.getBackgroundColor()===null?t.style.setProperty("background-color","rgb(172,206,247)"):t.style.setProperty("background-image","linear-gradient(to right, rgba(172,206,247,0.85), rgba(172,206,247,0.85))"),t.style.setProperty("caret-color","transparent")}function Yd(t,e){if(t=e.elem,e=E.$getNearestNodeFromDOMNode(t),!H(e))throw Error("Expected to find LexicalNode from Table Cell DOMNode");e.getBackgroundColor()===null&&t.style.removeProperty("background-color"),t.style.removeProperty("background-image"),t.style.removeProperty("caret-color")}class Qr extends E.DEPRECATED_GridNode{static getType(){return"table"}static clone(e){return new Qr(e.__key)}static importDOM(){return{table:()=>({conversion:am,priority:1})}}static importJSON(){return lo()}constructor(e){super(e)}exportJSON(){return{...super.exportJSON(),type:"table",version:1}}createDOM(e){let n=document.createElement("table");return le.addClassNamesToElement(n,e.theme.table),n}updateDOM(){return!1}exportDOM(e){return{...super.exportDOM(e),after:n=>{if(n){let r=n.cloneNode(),i=document.createElement("colgroup"),o=document.createElement("tbody");if(o.append(...n.children),n=this.getFirstChildOrThrow(),!pn(n))throw Error("Expected to find row node.");n=n.getChildrenSize();for(let l=0;lE.$getNearestNodeFromDOMNode(l)===e),o!==-1)return{x:o,y:n}}throw Error("Cell not found in table.")}getCellFromCords(e,n,r){return{cells:r}=r,n=r[n],n==null?null:(e=n[e],e??null)}getCellFromCordsOrThrow(e,n,r){if(e=this.getCellFromCords(e,n,r),!e)throw Error("Cell not found at cords.");return e}getCellNodeFromCords(e,n,r){return e=this.getCellFromCords(e,n,r),e==null?null:(e=E.$getNearestNodeFromDOMNode(e.elem),H(e)?e:null)}getCellNodeFromCordsOrThrow(e,n,r){if(e=this.getCellNodeFromCords(e,n,r),!e)throw Error("Node at cords not TableCellNode.");return e}canSelectBefore(){return!0}canIndent(){return!1}}function am(){return{node:lo()}}function lo(){return E.$applyNodeReplacement(new Qr)}function Wn(t){return t instanceof Qr}function Wl(t){if(t=le.$findMatchingParent(t,e=>pn(e)),pn(t))return t;throw Error("Expected table cell to be inside of table row.")}function Ul(t){if(t=le.$findMatchingParent(t,e=>Wn(e)),Wn(t))return t;throw Error("Expected table cell to be inside of table.")}function Jd(t,e){let n=Ul(t),{x:r,y:i}=n.getCordsFromCellNode(t,e);return{above:n.getCellNodeFromCords(r,i-1,e),below:n.getCellNodeFromCords(r,i+1,e),left:n.getCellNodeFromCords(r-1,i,e),right:n.getCellNodeFromCords(r+1,i,e)}}function Hr(t){t=t.getFirstDescendant(),t===null&&Oe(124),t.getParentOrThrow().selectStart()}function Gl(t,e){let n=t.getFirstChild();n!==null?n.insertBefore(e):t.append(e)}let um=E.createCommand("INSERT_TABLE_COMMAND");Y.$createTableCellNode=et;Y.$createTableNode=lo;Y.$createTableNodeWithDimensions=function(t,e,n=!0){let r=lo();for(let o=0;o=r.length||0>e)throw Error("Table column target index out of range");r[e].remove()}}return t};Y.$deleteTableColumn__EXPERIMENTAL=function(){var t=E.$getSelection();E.$isRangeSelection(t)||E.DEPRECATED_$isGridSelection(t)||Oe(118);var e=t.anchor.getNode();t=t.focus.getNode();let[n,,r]=E.DEPRECATED_$getNodeTriplet(e);[e]=E.DEPRECATED_$getNodeTriplet(t);let[i,o,l]=E.DEPRECATED_$computeGridMap(r,n,e);var{startColumn:s}=o;let{startRow:a,startColumn:c}=l;t=Math.min(s,c),s=Math.max(s+n.__colSpan-1,c+e.__colSpan-1);let g=s-t+1;if(i[0].length===s-t+1)r.selectPrevious(),r.remove();else{var d=i.length;for(let u=0;us?f===s&&h.setColSpan(h.__colSpan-(s-m+1)):h.remove()}t=i[a],e=t[c+e.__colSpan],e!==void 0?({cell:e}=e,Hr(e)):({cell:e}=t[c-1],Hr(e))}};Y.$deleteTableRow__EXPERIMENTAL=function(){var t=E.$getSelection();E.$isRangeSelection(t)||E.DEPRECATED_$isGridSelection(t)||Oe(118);var e=t.anchor.getNode();t=t.focus.getNode();let[n,,r]=E.DEPRECATED_$getNodeTriplet(e);[t]=E.DEPRECATED_$getNodeTriplet(t);let[i,o,l]=E.DEPRECATED_$computeGridMap(r,n,t);({startRow:e}=o);var{startRow:s}=l;if(t=s+t.__rowSpan-1,i.length===t-e+1)r.remove();else{s=i[0].length;var a=i[t+1],c=r.getChildAtIndex(t+1);for(let d=t;d>=e;d--){for(var g=s-1;0<=g;g--){let{cell:u,startRow:f,startColumn:h}=i[d][g];if(h===g&&(d===e&&f=e&&f+u.__rowSpan-1>t))if(u.setRowSpan(u.__rowSpan-(t-f+1)),c===null&&Oe(122),g===0)Gl(c,u);else{let{cell:m}=a[g-1];m.insertAfter(u)}}g=r.getChildAtIndex(d),E.DEPRECATED_$isGridRowNode(g)||Oe(123),g.remove()}a!==void 0?({cell:e}=a[0],Hr(e)):({cell:e}=i[e-1][0],Hr(e))}};Y.$getElementGridForTableNode=function(t,e){if(t=t.getElementByKey(e.getKey()),t==null)throw Error("Table Element Not Found");return xi(t)};Y.$getTableCellNodeFromLexicalNode=function(t){return t=le.$findMatchingParent(t,e=>H(e)),H(t)?t:null};Y.$getTableColumnIndexFromTableCellNode=function(t){return Wl(t).getChildren().findIndex(e=>e.is(t))};Y.$getTableNodeFromLexicalNodeOrThrow=Ul;Y.$getTableRowIndexFromTableCellNode=function(t){let e=Wl(t);return Ul(e).getChildren().findIndex(n=>n.is(e))};Y.$getTableRowNodeFromTableCellNodeOrThrow=Wl;Y.$insertTableColumn=function(t,e,n=!0,r,i){let o=t.getChildren();for(let a=0;a=l.length||0>e)throw Error("Table column target index out of range");l=l[e],H(l)||Oe(12);let{left:d,right:u}=Jd(l,i);var s=ee.NO_STATUS;(d&&d.hasHeaderState(ee.ROW)||u&&u.hasHeaderState(ee.ROW))&&(s|=ee.ROW),s=et(s),s.append(E.$createParagraphNode()),n?l.insertAfter(s):l.insertBefore(s)}}return t};Y.$insertTableColumn__EXPERIMENTAL=function(t=!0){function e(){let g=et(ee.NO_STATUS).append(E.$createParagraphNode());return a===null&&(a=g),g}var n=E.$getSelection();E.$isRangeSelection(n)||E.DEPRECATED_$isGridSelection(n)||Oe(118),n=n.focus.getNode();let[r,,i]=E.DEPRECATED_$getNodeTriplet(n),[o,l]=E.DEPRECATED_$computeGridMap(i,r,r);n=o.length;var{startColumn:s}=l;t=t?s+r.__colSpan-1:s-1,s=i.getFirstChild(),E.DEPRECATED_$isGridRowNode(s)||Oe(120);let a=null;var c=s;e:for(s=0;st){Gl(c,e());continue}let{cell:d,startColumn:u,startRow:f}=g[t];if(u+d.__colSpan-1<=t){let h=d,m=f,N=t;for(;m!==s&&1=o.length||0>e)throw Error("Table row target index out of range");if(e=o[e],pn(e))for(o=0;o=n.length||0>e)throw Error("Expected table cell to be inside of table row.");return n[e].remove(),t};Y.$unmergeCell=function(){var t=E.$getSelection();E.$isRangeSelection(t)||E.DEPRECATED_$isGridSelection(t)||Oe(118),t=t.anchor.getNode();let[e,n,r]=E.DEPRECATED_$getNodeTriplet(t);t=e.__colSpan;let i=e.__rowSpan;if(1{let u=Ci(d.target);u!==null&&(d.preventDefault(),d.stopImmediatePropagation(),d.stopPropagation(),i.setAnchorCellForSelection(u),i.setFocusCellForSelection(u,!0),o=!1)}),e.addEventListener("mousedown",d=>{setTimeout(()=>{if(d.button===0){var u=Ci(d.target);u!==null&&(d.preventDefault(),d.stopPropagation(),d.stopImmediatePropagation(),i.setAnchorCellForSelection(u))}},0)}),e.addEventListener("mousemove",d=>{if(l&&(d.preventDefault(),d.stopPropagation(),d.stopImmediatePropagation()),o){let u=Ci(d.target);if(u!==null){let f=u.x,h=u.y;o&&(i.anchorX!==f||i.anchorY!==h||i.isHighlightingCells)&&(d.preventDefault(),i.setFocusCellForSelection(u))}}}),e.addEventListener("mouseleave",()=>{});let s=d=>{d.button===0&&n.update(()=>{var u=E.$getSelection();const f=d.target;if(f instanceof Node){if(E.DEPRECATED_$isGridSelection(u)&&u.gridKey===i.tableNodeKey&&r.contains(f))return i.clearHighlight();u=E.$getNearestNodeFromDOMNode(f),u!==null&&le.$findMatchingParent(u,E.DEPRECATED_$isGridNode)&&(o=!0)}})};window.addEventListener("mousedown",s),i.listenersToRemove.add(()=>window.removeEventListener("mousedown",s));let a=d=>{var u;(u=o)&&(u=d.target,u=u!==null&&u.nodeName==="SPAN",u=!u),u&&(d.preventDefault(),d.stopPropagation()),o=!1};window.addEventListener("mouseup",a),i.listenersToRemove.add(()=>window.removeEventListener("mouseup",a)),e.addEventListener("mouseup",a),i.listenersToRemove.add(()=>e.removeEventListener("mouseup",a)),i.listenersToRemove.add(n.registerCommand(E.KEY_ARROW_DOWN_COMMAND,d=>{var u=E.$getSelection();if(!Et(u,t))return!1;if(E.$isRangeSelection(u)){if(u.isCollapsed()){var f=le.$findMatchingParent(u.anchor.getNode(),m=>H(m));if(!H(f))return!1;var h=t.getCordsFromCellNode(f,i.grid);if(u=le.$findMatchingParent(u.anchor.getNode(),m=>E.$isElementNode(m)),u==null)throw Error("Expected BlockNode Parent");if((f=f.getLastChild())&&u.isParentOf(f)||u===f||d.shiftKey)return d.preventDefault(),d.stopImmediatePropagation(),d.stopPropagation(),d.shiftKey?(i.setAnchorCellForSelection(t.getCellFromCordsOrThrow(h.x,h.y,i.grid)),bt(i,t,h.x,h.y,"down")):ur(i,t,h.x,h.y,"down")}}else if(E.DEPRECATED_$isGridSelection(u)&&d.shiftKey)return h=u.focus.getNode(),H(h)?(h=t.getCordsFromCellNode(h,i.grid),d.preventDefault(),d.stopImmediatePropagation(),d.stopPropagation(),bt(i,t,h.x,h.y,"down")):!1;return!1},E.COMMAND_PRIORITY_HIGH)),i.listenersToRemove.add(n.registerCommand(E.KEY_ARROW_UP_COMMAND,d=>{var u=E.$getSelection();if(!Et(u,t))return!1;if(E.$isRangeSelection(u)){if(u.isCollapsed()){var f=le.$findMatchingParent(u.anchor.getNode(),m=>H(m));if(!H(f))return!1;var h=t.getCordsFromCellNode(f,i.grid);if(u=le.$findMatchingParent(u.anchor.getNode(),m=>E.$isElementNode(m)),u==null)throw Error("Expected BlockNode Parent");if((f=f.getLastChild())&&u.isParentOf(f)||u===f||d.shiftKey)return d.preventDefault(),d.stopImmediatePropagation(),d.stopPropagation(),d.shiftKey?(i.setAnchorCellForSelection(t.getCellFromCordsOrThrow(h.x,h.y,i.grid)),bt(i,t,h.x,h.y,"up")):ur(i,t,h.x,h.y,"up")}}else if(E.DEPRECATED_$isGridSelection(u)&&d.shiftKey)return h=u.focus.getNode(),H(h)?(h=t.getCordsFromCellNode(h,i.grid),d.preventDefault(),d.stopImmediatePropagation(),d.stopPropagation(),bt(i,t,h.x,h.y,"up")):!1;return!1},E.COMMAND_PRIORITY_HIGH)),i.listenersToRemove.add(n.registerCommand(E.KEY_ARROW_LEFT_COMMAND,d=>{var u=E.$getSelection();if(!Et(u,t))return!1;if(E.$isRangeSelection(u)){if(u.isCollapsed()){var f=le.$findMatchingParent(u.anchor.getNode(),h=>H(h));if(!H(f))return!1;if(f=t.getCordsFromCellNode(f,i.grid),le.$findMatchingParent(u.anchor.getNode(),h=>E.$isElementNode(h))==null)throw Error("Expected BlockNode Parent");if(u.anchor.offset===0||d.shiftKey)return d.preventDefault(),d.stopImmediatePropagation(),d.stopPropagation(),d.shiftKey?(i.setAnchorCellForSelection(t.getCellFromCordsOrThrow(f.x,f.y,i.grid)),bt(i,t,f.x,f.y,"backward")):ur(i,t,f.x,f.y,"backward")}}else if(E.DEPRECATED_$isGridSelection(u)&&d.shiftKey)return u=u.focus.getNode(),H(u)?(u=t.getCordsFromCellNode(u,i.grid),d.preventDefault(),d.stopImmediatePropagation(),d.stopPropagation(),bt(i,t,u.x,u.y,"backward")):!1;return!1},E.COMMAND_PRIORITY_HIGH)),i.listenersToRemove.add(n.registerCommand(E.KEY_ARROW_RIGHT_COMMAND,d=>{var u=E.$getSelection();if(!Et(u,t))return!1;if(E.$isRangeSelection(u)){if(u.isCollapsed()){var f=le.$findMatchingParent(u.anchor.getNode(),h=>H(h));if(!H(f))return!1;if(f=t.getCordsFromCellNode(f,i.grid),le.$findMatchingParent(u.anchor.getNode(),h=>E.$isElementNode(h))==null)throw Error("Expected BlockNode Parent");if(u.anchor.offset===u.anchor.getNode().getTextContentSize()||d.shiftKey)return d.preventDefault(),d.stopImmediatePropagation(),d.stopPropagation(),d.shiftKey?(i.setAnchorCellForSelection(t.getCellFromCordsOrThrow(f.x,f.y,i.grid)),bt(i,t,f.x,f.y,"forward")):ur(i,t,f.x,f.y,"forward")}}else if(E.DEPRECATED_$isGridSelection(u)&&d.shiftKey)return u=u.focus.getNode(),H(u)?(u=t.getCordsFromCellNode(u,i.grid),d.preventDefault(),d.stopImmediatePropagation(),d.stopPropagation(),bt(i,t,u.x,u.y,"forward")):!1;return!1},E.COMMAND_PRIORITY_HIGH));let c=d=>()=>{var u=E.$getSelection();if(!Et(u,t))return!1;if(E.DEPRECATED_$isGridSelection(u))return i.clearText(),!0;if(E.$isRangeSelection(u)){const m=le.$findMatchingParent(u.anchor.getNode(),N=>H(N));if(!H(m))return!1;var f=u.anchor.getNode(),h=u.focus.getNode();if(f=t.isParentOf(f),h=t.isParentOf(h),f&&!h||h&&!f)return i.clearText(),!0;if(f=(h=le.$findMatchingParent(u.anchor.getNode(),N=>E.$isElementNode(N)))&&le.$findMatchingParent(h,N=>E.$isElementNode(N)&&H(N.getParent())),!E.$isElementNode(f)||!E.$isElementNode(h))return!1;if(d===E.DELETE_LINE_COMMAND&&f.getPreviousSibling()===null)return!0;if((d===E.DELETE_CHARACTER_COMMAND||d===E.DELETE_WORD_COMMAND)&&u.isCollapsed()&&u.anchor.offset===0&&h!==f){u=h.getChildren();const N=E.$createParagraphNode();return u.forEach(y=>N.append(y)),h.replace(N),h.getWritable().__parent=m.getKey(),!0}}return!1};[E.DELETE_WORD_COMMAND,E.DELETE_LINE_COMMAND,E.DELETE_CHARACTER_COMMAND].forEach(d=>{i.listenersToRemove.add(n.registerCommand(d,c(d),E.COMMAND_PRIORITY_CRITICAL))});let g=d=>{const u=E.$getSelection();return Et(u,t)?E.DEPRECATED_$isGridSelection(u)?(d.preventDefault(),d.stopPropagation(),i.clearText(),!0):(E.$isRangeSelection(u)&&(d=le.$findMatchingParent(u.anchor.getNode(),f=>H(f)),H(d)),!1):!1};return i.listenersToRemove.add(n.registerCommand(E.KEY_BACKSPACE_COMMAND,g,E.COMMAND_PRIORITY_CRITICAL)),i.listenersToRemove.add(n.registerCommand(E.KEY_DELETE_COMMAND,g,E.COMMAND_PRIORITY_CRITICAL)),i.listenersToRemove.add(n.registerCommand(E.FORMAT_TEXT_COMMAND,d=>{let u=E.$getSelection();return Et(u,t)?E.DEPRECATED_$isGridSelection(u)?(i.formatCells(d),!0):(E.$isRangeSelection(u)&&(d=le.$findMatchingParent(u.anchor.getNode(),f=>H(f)),H(d)),!1):!1},E.COMMAND_PRIORITY_CRITICAL)),i.listenersToRemove.add(n.registerCommand(E.CONTROLLED_TEXT_INSERTION_COMMAND,()=>{var d=E.$getSelection();return Et(d,t)&&(E.DEPRECATED_$isGridSelection(d)?i.clearHighlight():E.$isRangeSelection(d)&&(d=le.$findMatchingParent(d.anchor.getNode(),u=>H(u)),H(d))),!1},E.COMMAND_PRIORITY_CRITICAL)),i.listenersToRemove.add(n.registerCommand(E.KEY_TAB_COMMAND,d=>{var u=E.$getSelection();if(!Et(u,t))return!1;if(E.$isRangeSelection(u)){let f=le.$findMatchingParent(u.anchor.getNode(),h=>H(h));if(!H(f))return!1;if(u.isCollapsed())return u=t.getCordsFromCellNode(f,i.grid),d.preventDefault(),ur(i,t,u.x,u.y,d.shiftKey?"backward":"forward"),!0}return!1},E.COMMAND_PRIORITY_HIGH)),i.listenersToRemove.add(n.registerCommand(E.FOCUS_COMMAND,()=>t.isSelected(),E.COMMAND_PRIORITY_HIGH)),i.listenersToRemove.add(n.registerCommand(E.SELECTION_CHANGE_COMMAND,()=>{let d=E.$getSelection();var u=E.$getPreviousSelection();if(d&&E.$isRangeSelection(d)&&!d.isCollapsed()){var f=d.anchor.getNode(),h=d.focus.getNode();f=t.isParentOf(f);var m=t.isParentOf(h);if(h=f&&!m||m&&!f,f=f&&m&&!t.isSelected(),h)return u=d.isBackward(),f=E.$createRangeSelection(),h=t.getKey(),f.anchor.set(d.anchor.key,d.anchor.offset,d.anchor.type),f.focus.set(h,u?0:t.getChildrenSize(),"element"),l=!0,E.$setSelection(f),Sa(n,i),!0;if(f&&({grid:f}=i,d.getNodes().filter(H).length===f.rows*f.columns)){f=E.DEPRECATED_$createGridSelection(),h=t.getKey(),m=t.getFirstChildOrThrow().getFirstChild();let N=t.getLastChildOrThrow().getLastChild();if(m!=null&&N!=null)return f.set(h,m.getKey(),N.getKey()),E.$setSelection(f),i.updateTableGridSelection(f),!0}}return d&&!d.is(u)&&(E.DEPRECATED_$isGridSelection(d)||E.DEPRECATED_$isGridSelection(u))&&i.gridSelection&&!i.gridSelection.is(u)?(E.DEPRECATED_$isGridSelection(d)&&d.gridKey===i.tableNodeKey?i.updateTableGridSelection(d):!E.DEPRECATED_$isGridSelection(d)&&E.DEPRECATED_$isGridSelection(u)&&u.gridKey===i.tableNodeKey&&i.updateTableGridSelection(null),!1):(i.hasHijackedSelectionStyles&&!t.isSelected()?(sm(n,i),l=!1):!i.hasHijackedSelectionStyles&&t.isSelected()&&Sa(n,i),!1)},E.COMMAND_PRIORITY_CRITICAL)),i};Y.getCellFromTarget=Ci;Y.getTableSelectionFromTableElement=function(t){return t.__lexicalTableSelection};const cm=Y;var He=cm;const dm={dependencies:[jt.HorizontalRuleNode],export:t=>jt.$isHorizontalRuleNode(t)?"***":null,regExp:/^(---|\*\*\*|___)\s?$/,replace:(t,e,n,r)=>{const i=jt.$createHorizontalRuleNode();r||t.getNextSibling()?t.replace(i):t.insertBefore(i),i.selectNext()},type:"element"},gm={dependencies:[Ut],export:(t,e,n)=>Nd(t)?`![${t.getAltText()}](${t.getSrc()})`:null,importRegExp:/!(?:\[([^[]*)\])(?:\(([^(]+)\))/,regExp:/!(?:\[([^[]*)\])(?:\(([^(]+)\))$/,replace:(t,e)=>{const[,n,r]=e,i=ro({altText:n,maxWidth:800,src:r});t.replace(i)},trigger:")",type:"text-match"},Vd=/^(?:\|)(.+)(?:\|)\s?$/,fm={dependencies:[He.TableNode,He.TableRowNode,He.TableCellNode],export:(t,e)=>{if(!He.$isTableNode(t))return null;const n=[];for(const r of t.getChildren()){const i=[];if(He.$isTableRowNode(r))for(const o of r.getChildren())C.$isElementNode(o)&&i.push(e(o));n.push(`| ${i.join(" | ")} |`)}return n.join(` -`)},regExp:Vd,replace:(t,e,n)=>{const r=$a(n[0]);if(!r)return;const i=[r];let o=t.getPreviousSibling(),l=r.length;for(;o&&!(!C.$isParagraphNode(o)||o.getChildrenSize()!==1);){const c=o.getFirstChild();if(!C.$isTextNode(c))break;const g=$a(c.getTextContent());if(!g)break;l=Math.max(l,g.length),i.unshift(g);const d=o.getPreviousSibling();o.remove(),o=d}const s=He.$createTableNode();for(const c of i){const g=He.$createTableRowNode();s.append(g);for(let d=0;d{const e=He.$createTableCellNode(He.TableCellHeaderStates.NO_STATUS),n=C.$createParagraphNode();return t!=null&&n.append(C.$createTextNode(t.trim())),e.append(n),e},$a=t=>{const e=t.match(Vd);return!e||!e[1]?null:e[1].split("|").map(n=>Xd(n))},ol=[fm,dm,gm,Kr.CHECK_LIST,...Kr.TRANSFORMERS];function pm(){const[t]=X.useLexicalComposerContext(),e=$.useCallback(()=>t.update(()=>{const n=C.$getRoot(),r=n.getFirstChild();if(he.$isCodeNode(r)&&r.getLanguage()==="markdown")Kr.$convertFromMarkdownString(r.getTextContent(),ol);else{const i=Kr.$convertToMarkdownString(ol);n.clear().append(he.$createCodeNode("markdown").append(C.$createTextNode(i)))}n.selectEnd()}),[t]);return p.jsx(Va,{appearance:"outline",icon:p.jsx(Rg,{}),onClick:e})}var Yl={},mm=C;function _m(t){let e=document.createElement("input");e.type="file",e.accept=".lexical",e.addEventListener("change",n=>{if(n=n.target,n.files){n=n.files[0];let r=new FileReader;r.readAsText(n,"UTF-8"),r.onload=i=>{i.target&&t(i.target.result)}}}),e.click()}Yl.exportFile=function(t,e=Object.freeze({})){var n=new Date;t={editorState:t.getEditorState(),lastSaved:n.getTime(),source:e.source||"Lexical",version:"0.10.0"};{e=`${e.fileName||n.toISOString()}.lexical`,n=document.createElement("a");let r=document.body;r!==null&&(r.appendChild(n),n.style.display="none",t=JSON.stringify(t),t=new Blob([t],{type:"octet/stream"}),t=window.URL.createObjectURL(t),n.href=t,n.download=e,n.click(),window.URL.revokeObjectURL(t),n.remove())}};Yl.importFile=function(t){_m(e=>{e=JSON.parse(e),e=t.parseEditorState(JSON.stringify(e.editorState)),t.setEditorState(e),t.dispatchCommand(mm.CLEAR_HISTORY_COMMAND,void 0)})};const Cm=Yl;var Ra=Cm;function xm(){const[t]=X.useLexicalComposerContext();return p.jsxs(p.Fragment,{children:[p.jsx(Un,{appearance:"outline",icon:p.jsx(Ag,{}),onClick:()=>Ra.importFile(t)}),p.jsx(Un,{appearance:"outline",icon:p.jsx(Og,{}),onClick:()=>Ra.exportFile(t,{fileName:`Bunlog ${new Date().toISOString()}`,source:"Bunlog"})})]})}const Nm=it({box:{...uu,columnGap:"3px",position:"absolute",...P.padding("10px"),bottom:0,left:0}});function Em({anchor:t}){const e=Nm(),[n]=X.useLexicalComposerContext(),[r,i]=$.useState(()=>n.isEditable()),[o,l]=$.useState(!0);return $.useEffect(()=>V.mergeRegister(n.registerEditableListener(s=>i(s))),[n]),$.useEffect(()=>n.registerUpdateListener(({dirtyElements:s,prevEditorState:a,tags:c})=>{!r&&s.size>0&&!c.has("historic")&&!c.has("collaboration")&&console.debug(n.getEditorState()),n.getEditorState().read(()=>{const g=C.$getRoot().getChildren();g.length>1?l(!1):C.$isParagraphNode(g[0])?l(g[0].getChildren().length===0):l(!1)})}),[n,r]),p.jsx(Wr,{mountNode:t,children:p.jsxs("div",{className:e.box,children:[p.jsx(xm,{}),p.jsx(Pp,{}),p.jsx(pm,{})]})})}var Jl={},Xt=ce,Tm=X,ym=V,Rt=C,vm=$;function Zd(t,e){for(let n=0;nr.getLatest())}function Sm(t,e,n){vm.useEffect(()=>{if(!t.hasNodes([Xt.AutoLinkNode]))throw Error("Minified Lexical error #77; visit https://lexical.dev/docs/error?code=77 for the full message or use the non-minified dev environment for full errors and additional helpful warnings.");let r=(i,o)=>{n&&n(i,o)};return ym.mergeRegister(t.registerNodeTransform(Rt.TextNode,i=>{var o=i.getParentOrThrow(),l=i.getPreviousSibling();if(Xt.$isAutoLinkNode(o))$o(o,e,r);else if(!Xt.$isLinkNode(o)){if(i.isSimpleText()&&(en.test(i.getTextContent()[0])||!Xt.$isAutoLinkNode(l))){l=o=i.getTextContent();let f=0,h=i;for(var s;(s=Zd(l,e))&&s!==null;){let m=s.index,N=s.length,y=m+N;var a=f+m,c=f+y,g=o,d=i;if((0n){return n=>{let r=t.exec(n);return r===null?null:{index:r.index,length:r[0].length,text:r[0],url:e(n)}}};const $m=Jl;var Rm=$m;const Am=/((https?:\/\/(www\.)?)|(www\.))[-a-zA-Z0-9@:%._+~#=]{1,256}\.[a-zA-Z0-9()]{1,6}\b([-a-zA-Z0-9()@:%_+.~#?&//=]*)/,Om=/(([^<>()[\]\\.,;:\s@"]+(\.[^<>()[\]\\.,;:\s@"]+)*)|(".+"))@((\[[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\])|(([a-zA-Z\-0-9]+\.)+[a-zA-Z]{2,}))/,wm=[t=>{const e=Am.exec(t);if(!e)return null;const n=e[0];return{index:e.index,length:n.length,text:n,url:n.startsWith("http")?n:`https://${n}`}},t=>{const e=Om.exec(t);return e&&{index:e.index,length:e[0].length,text:e[0],url:`mailto:${e[0]}`}}];function Dm(){return p.jsx(Rm.AutoLinkPlugin,{matchers:wm})}function Aa({filter:t,newTab:e=!0}){const[n]=X.useLexicalComposerContext();return $.useEffect(()=>{function r(i){const o=i,l=Lm(o,n);if(!l)return;const s=l.getAttribute("href");if(l.getAttribute("contenteditable")==="false"||!s)return;const a=n.getEditorState().read(C.$getSelection);if(C.$isRangeSelection(a)&&!a.isCollapsed())return;let c;if(n.update(()=>{const g=C.$getNearestNodeFromDOMNode(l);ce.$isLinkNode(g)&&(c=g)}),!(!c||t&&!t(o,c)))try{if(s){const g=o.type==="auxclick"&&o.button===1;window.open(s,e||o.metaKey||o.ctrlKey||g?"_blank":"_self"),o.preventDefault()}}catch{}}return n.registerRootListener((i,o)=>{o&&(o.removeEventListener("click",r),o.removeEventListener("auxclick",r)),i&&(i.addEventListener("click",r),i.addEventListener("auxclick",r))})},[n,t,e]),null}function Oa(t){return t.nodeName.toLowerCase()==="a"}function Lm(t,e){return e.getEditorState().read(()=>{const n=t.target;return Oa(n)?n:n.parentNode&&Oa(n.parentNode)?n.parentNode:null})}const Mm=it({green:{color:an.colorPaletteLightGreenForeground3}});function bm({editor:t,getCodeDOMNode:e}){const[n,r]=$.useState(!1),{run:i}=Xa(()=>{r(!1)},{wait:1e3});async function o(){const s=e();if(!s)return;let a="";t.update(()=>{const c=C.$getNearestNodeFromDOMNode(s);he.$isCodeNode(c)&&(a=c.getTextContent());const g=C.$getSelection();C.$setSelection(g)});try{await navigator.clipboard.writeText(a),r(!0),i()}catch(c){console.error("Failed to copy: ",c)}}const l=Mm();return p.jsx(Un,{size:"small",appearance:"subtle",onClick:o,icon:n?p.jsx(wg,{className:l.green}):p.jsx(Dg,{})})}const km=8,Im=it({container:{height:"35.8px",fontSize:"10px",color:"rgba(0, 0, 0, 0.5)",position:"absolute",display:"flex",alignItems:"center",flexDirection:"row",userSelect:"none"},lang:{marginRight:"4px"}});function Pm(t){const e=t.target;if(e&&e instanceof HTMLElement){const n=e.closest("code.LexEditor_code"),r=!(n||e.closest("div.LexEditor_CodeMenu"));return{codeDOMNode:n,isOutside:r}}else return{codeDOMNode:null,isOutside:!0}}function Fm({anchor:t=document.body}){const[e]=X.useLexicalComposerContext(),[n,r]=$.useState(!1),[i,o]=$.useState(!1),[l,s]=$.useState(""),[a,c]=$.useState({right:"0",top:"0"}),g=$.useRef(new Set),d=$.useRef(null),{run:u,cancel:f}=Xa(N=>{const{codeDOMNode:y,isOutside:_}=Pm(N);if(_){r(!1);return}if(!y)return;d.current=y;let x=null,v="";if(e.update(()=>{const S=C.$getNearestNodeFromDOMNode(y);he.$isCodeNode(S)&&(x=S,v=x.getLanguage()||"")}),x){const{y:S,right:A}=t.getBoundingClientRect(),{y:w,right:B}=y.getBoundingClientRect();s(v),r(!0),c({right:`${A-B+km}px`,top:`${w-S}px`})}},{wait:100,maxWait:1e3});$.useEffect(()=>{if(i)return document.addEventListener("mousemove",u),()=>{r(!1),f(),document.removeEventListener("mousemove",u)}},[i,u]),e.registerMutationListener(he.CodeNode,N=>{e.getEditorState().read(()=>{for(const[y,_]of N)switch(_){case"created":g.current.add(y),o(g.current.size>0);break;case"destroyed":g.current.delete(y),o(g.current.size>0);break}})});const h=he.getLanguageFriendlyName(l),m=Im();return p.jsx(Wr,{mountNode:t,children:n&&p.jsxs("div",{className:gt(m.container,"LexEditor_CodeMenu"),style:a,children:[p.jsx("div",{className:m.lang,children:h}),p.jsx(bm,{editor:e,getCodeDOMNode:()=>d.current})]})})}function Bm(){const[t]=X.useLexicalComposerContext();return $.useEffect(()=>he.registerCodeHighlighting(t),[t]),null}class mn extends C.ElementNode{constructor(e,n){super(n),this.open=e,this.open=e}static getType(){return"collapsible-container"}static clone(e){return new mn(e.open,e.__key)}createDOM(e){const n=document.createElement("details");return n.classList.add("LexEditor_Collapsible"),n.open=this.open,n}updateDOM(e,n){return e.open!==this.open&&(n.open=this.open),!1}static importDOM(){return{}}static importJSON(e){return eg()}exportJSON(){return{...super.exportJSON(),type:"collapsible-container",version:1}}setOpen(e){const n=this.getWritable();n.open=e}getOpen(){return this.open}toggleOpen(){this.setOpen(!this.getOpen())}}function eg(){return new mn(!0)}function Qt(t){return t instanceof mn}class _n extends C.ElementNode{static getType(){return"collapsible-content"}static clone(e){return new _n(e.__key)}createDOM(e){const n=document.createElement("div");return n.classList.add("LexEditor_CollapsibleContent"),n}updateDOM(e,n){return!1}static importDOM(){return{}}static importJSON(e){return tg()}isShadowRoot(){return!0}exportJSON(){return{...super.exportJSON(),type:"collapsible-content",version:1}}}function tg(){return new _n}function ng(t){return t instanceof _n}class Cn extends C.ElementNode{static getType(){return"collapsible-title"}static clone(e){return new Cn(e.__key)}createDOM(e,n){const r=document.createElement("summary");return r.classList.add("LexEditor_CollapsibleTitle"),r}updateDOM(e,n){return!1}static importDOM(){return{}}static importJSON(e){return rg()}exportJSON(){return{...super.exportJSON(),type:"collapsible-title",version:1}}collapseAtStart(e){return this.getParentOrThrow().insertBefore(this),!0}insertNewAfter(e,n=!0){const r=this.getParentOrThrow();if(!Qt(r))throw new Error("CollapsibleTitleNode expects to be child of CollapsibleContainerNode");if(r.getOpen()){const i=this.getNextSibling();if(!ng(i))throw new Error("CollapsibleTitleNode expects to have CollapsibleContentNode sibling");const o=i.getFirstChild();if(C.$isElementNode(o))return o;{const l=C.$createParagraphNode();return i.append(l),l}}else{const i=C.$createParagraphNode();return r.insertAfter(i,n),i}}}function rg(){return new Cn}function wa(t){return t instanceof Cn}const ig=C.createCommand(),jm=C.createCommand();function zm(){const[t]=X.useLexicalComposerContext();return $.useEffect(()=>{if(!t.hasNodes([mn,Cn,_n]))throw new Error("CollapsiblePlugin: CollapsibleContainerNode, CollapsibleTitleNode, or CollapsibleContentNode not registered on editor");return V.mergeRegister(t.registerNodeTransform(_n,e=>{const n=e.getParent();if(!Qt(n)){const r=e.getChildren();for(const i of r)e.insertBefore(i);e.remove()}}),t.registerNodeTransform(Cn,e=>{const n=e.getParent();Qt(n)||e.replace(C.$createParagraphNode().append(...e.getChildren()))}),t.registerNodeTransform(mn,e=>{const n=e.getChildren();if(n.length!==2||!wa(n[0])||!ng(n[1])){for(const r of n)e.insertBefore(r);e.remove()}}),t.registerCommand(C.DELETE_CHARACTER_COMMAND,()=>{const e=C.$getSelection();if(!C.$isRangeSelection(e)||!e.isCollapsed()||e.anchor.offset!==0)return!1;const r=e.anchor.getNode().getTopLevelElement();if(!r)return!1;const i=r.getPreviousSibling();return!Qt(i)||i.getOpen()?!1:(i.setOpen(!0),!0)},C.COMMAND_PRIORITY_LOW),t.registerCommand(C.KEY_ARROW_DOWN_COMMAND,()=>{const e=C.$getSelection();if(!C.$isRangeSelection(e)||!e.isCollapsed())return!1;const n=V.$findMatchingParent(e.anchor.getNode(),Qt);if(!n)return!1;const r=n.getParent();return r&&r.getLastChild()===n&&r.append(C.$createParagraphNode()),!1},C.COMMAND_PRIORITY_LOW),t.registerCommand(C.INSERT_PARAGRAPH_COMMAND,()=>{const e=t._window?.event;if(e&&(e.ctrlKey||e.metaKey)&&e.key==="Enter"){const n=C.$getPreviousSelection();if(C.$isRangeSelection(n)&&n.isCollapsed()){const r=V.$findMatchingParent(n.anchor.getNode(),i=>C.$isElementNode(i)&&!i.isInline());if(wa(r)){const i=r.getParent();if(Qt(i))return i.toggleOpen(),C.$setSelection(n.clone()),!0}}}return!1},C.COMMAND_PRIORITY_LOW),t.registerCommand(ig,()=>(t.update(()=>{const e=C.$getSelection();if(!C.$isRangeSelection(e))return;const n=rg(),r=tg().append(C.$createParagraphNode()),i=eg().append(n,r);e.insertNodes([i]),n.selectStart()}),!0),C.COMMAND_PRIORITY_EDITOR),t.registerCommand(jm,e=>(t.update(()=>{const n=C.$getNodeByKey(e);Qt(n)&&n.toggleOpen()}),!0),C.COMMAND_PRIORITY_EDITOR))},[t]),null}function Ro(t){return t instanceof HTMLElement}class og{constructor(e,n){this.x=e,this.y=n}equals({x:e,y:n}){return this.x===e&&this.y===n}calcDeltaXTo({x:e}){return this.x-e}calcDeltaYTo({y:e}){return this.y-e}calcHorizontalDistanceTo(e){return Math.abs(this.calcDeltaXTo(e))}calcVerticalDistance(e){return Math.abs(this.calcDeltaYTo(e))}calcDistanceTo(e){return Math.sqrt(Math.pow(this.calcDeltaXTo(e),2)+Math.pow(this.calcDeltaYTo(e),2))}}function Km(t){return t instanceof og}class tn{_left;_top;_right;_bottom;constructor(e,n,r,i){const[o,l]=n<=i?[n,i]:[i,n],[s,a]=e<=r?[e,r]:[r,e];this._top=o,this._right=a,this._left=s,this._bottom=l}get top(){return this._top}get right(){return this._right}get bottom(){return this._bottom}get left(){return this._left}get width(){return Math.abs(this._left-this._right)}get height(){return Math.abs(this._bottom-this._top)}equals({top:e,left:n,bottom:r,right:i}){return e===this._top&&r===this._bottom&&n===this._left&&i===this._right}contains(e){if(Km(e)){const{x:n,y:r}=e,i=rthis._bottom,l=nthis._right;return{reason:{isOnBottomSide:o,isOnLeftSide:l,isOnRightSide:s,isOnTopSide:i},result:!i&&!o&&!l&&!s}}else{const{top:n,left:r,bottom:i,right:o}=e;return n>=this._top&&n<=this._bottom&&i>=this._top&&i<=this._bottom&&r>=this._left&&r<=this._right&&o>=this._left&&o<=this._right}}intersectsWith(e){const{left:n,top:r,width:i,height:o}=e,{left:l,top:s,width:a,height:c}=this,g=n+i>=l+a?n+i:l+a,d=r+o>=s+c?r+o:s+c,u=n<=l?n:l,f=r<=s?r:s;return g-u<=i+a&&d-f<=o+c}generateNewRect({left:e=this.left,top:n=this.top,right:r=this.right,bottom:i=this.bottom}){return new tn(e,n,r,i)}static fromLTRB(e,n,r,i){return new tn(e,n,r,i)}static fromLWTH(e,n,r,i){return new tn(e,r,e+n,r+i)}static fromPoints(e,n){const{y:r,x:i}=e,{y:o,x:l}=n;return tn.fromLTRB(i,r,l,o)}static fromDOM(e){const{top:n,width:r,left:i,height:o}=e.getBoundingClientRect();return tn.fromLWTH(i,r,n,o)}}let Ei=1/0;function Hm(t){return t===0?1/0:Ei>=0&&EiC.$getRoot().getChildrenKeys())}const Da=0;function Ao(t,e,n){const r=t.getBoundingClientRect(),i=Wm(e);let o=null;return e.getEditorState().read(()=>{let l=Hm(i.length),s=Da;for(;l>=0&&le.style.transform=n)}const La=28;function Jm(t,e,n,r){const i=window.getComputedStyle(e),{top:o,height:l}=e.getBoundingClientRect(),{top:s,width:a}=r.getBoundingClientRect();let c=o;n-o>l/2?c+=l+parseFloat(i.marginBottom):c-=parseFloat(i.marginTop);const g=c-s-2,d=La-ll;t.style.transform=`translate(${d}px, ${g}px)`,t.style.width=`${a-(La-ll)*2}px`,t.style.opacity=".4"}function Vm(t){t&&(t.style.opacity="0",t.style.transform="translate(-10000px, -10000px)")}const Ma="application/x-lexical-drag-block";function Xm({editor:t,anchor:e}){const n=e.parentElement,r=$.useRef(null),i=$.useRef(null),[o,l]=$.useState(null);$.useEffect(()=>{function g(u){const f=u.target;if(!Ro(f)){l(null);return}if(Um(f))return;const h=Ao(e,t,u);l(h)}function d(){l(null)}return n?.addEventListener("mousemove",g),n?.addEventListener("mouseleave",d),()=>{n?.removeEventListener("mousemove",g),n?.removeEventListener("mouseleave",d)}},[n,e,t]),$.useEffect(()=>{r.current&&Gm(o,r.current,e)},[e,o]),$.useEffect(()=>{function g(u){const[f]=rt.eventFiles(u);if(f)return!1;const{pageY:h,target:m}=u;if(!Ro(m))return!1;const N=Ao(e,t,u),y=i.current;return!N||!y?!1:(Jm(y,N,h,e),u.preventDefault(),!0)}function d(u){const[f]=rt.eventFiles(u);if(f)return!1;const{target:h,dataTransfer:m,pageY:N}=u,y=m?.getData(Ma)||"",_=C.$getNodeByKey(y);if(!_||!Ro(h))return!1;const x=Ao(e,t,u);if(!x)return!1;const v=C.$getNearestNodeFromDOMNode(x);if(!v)return!1;if(v===_)return!0;const{top:S,height:A}=x.getBoundingClientRect();return N-S>A/2?v.insertAfter(_):v.insertBefore(_),l(null),!0}return V.mergeRegister(t.registerCommand(C.DRAGOVER_COMMAND,u=>g(u),C.COMMAND_PRIORITY_LOW),t.registerCommand(C.DROP_COMMAND,u=>d(u),C.COMMAND_PRIORITY_HIGH))},[e,t]);function s(g){const d=g.dataTransfer;if(!d||!o)return;Ym(d,o);let u="";t.update(()=>{const f=C.$getNearestNodeFromDOMNode(o);f&&(u=f.getKey())}),d.setData(Ma,u)}function a(){Vm(i.current)}const c=Zm();return p.jsxs(Wr,{mountNode:e,children:[p.jsx("div",{className:gt("LexEditor_Draggable",c.meun),ref:r,draggable:!0,onDragStart:s,onDragEnd:a,children:p.jsx("div",{className:t._editable?gt(c.icon,"LexEditor_DraggableIcon"):""})}),p.jsx("div",{className:c.line,ref:i})]})}const Zm=it({meun:{...P.borderRadius("4px"),...P.padding("2px","1px"),cursor:"grab",opacity:0,position:"absolute",left:0,top:0,willChange:"transform",":active":{cursor:"grabbing"},":hover":{backgroundColor:"#efefef"}},icon:{width:"16px",height:"16px",opacity:.3},line:{pointerEvents:"none",backgroundColor:"deepskyblue",height:"4px",position:"absolute",left:0,top:0,opacity:0,willChange:"transform"}});function qm({anchor:t=document.body}){const[e]=X.useLexicalComposerContext();return p.jsx(Xm,{anchor:t,editor:e})}function so(t){const e=t.anchor,n=t.focus,r=t.anchor.getNode(),i=t.focus.getNode();return r===i?r:t.isBackward()?Se.$isAtNodeEnd(n)?r:i:Se.$isAtNodeEnd(e)?r:i}const Qm=10,e_=5;function sl(t,e,n,r=Qm,i=e_){const o=n.parentElement;if(!t||!o){e.style.opacity="0",e.style.transform="translate(-10000px, -10000px)";return}const l=e.getBoundingClientRect(),s=n.getBoundingClientRect(),a=o.getBoundingClientRect();let c=t.top-l.height-r,g=t.left-i;ca.right&&(g=a.right-l.width-i),c-=s.top,g-=s.left,e.style.opacity="1",e.style.transform=`translate(${g}px, ${c}px)`}function lg(t){const e=/^(?:(?:https?|mailto|ftp|tel|file|sms):|[^&:/?#]*(?:[/?#]|$))/gi,n=/^data:(?:image\/(?:bmp|gif|jpeg|jpg|png|tiff|webp)|video\/(?:mpeg|mp4|ogg|webm)|audio\/(?:mp3|oga|ogg|opus));base64,[a-z0-9+/]+=*$/i;return t=String(t).trim(),t.match(e)||t.match(n)?t:"https://"}const t_=new RegExp(/((([A-Za-z]{3,9}:(?:\/\/)?)(?:[-;:&=+$,\w]+@)?[A-Za-z0-9.-]+|(?:www.|[-;:&=+$,\w]+@)[A-Za-z0-9.-]+)((?:\/[+~%/.\w-_]*)?\??(?:[-+=&;%@.\w_]*)#?(?:[\w]*))?)/);function n_(t){return t==="https://"||t_.test(t)}function r_({editor:t,isLink:e,setIsLink:n,anchor:r}){const i=$.useRef(null),o=$.useRef(null),[l,s]=$.useState(""),[a,c]=$.useState(!1),[g,d]=$.useState(),u=$.useCallback(()=>{const h=C.$getSelection();if(C.$isRangeSelection(h)){const x=so(h),v=x.getParent();ce.$isLinkNode(v)?s(v.getURL()):ce.$isLinkNode(x)?s(x.getURL()):s("")}const m=i.current,N=window.getSelection(),y=document.activeElement;if(!m)return;const _=t.getRootElement();if(h&&N&&_&&_.contains(N.anchorNode)&&t.isEditable()){const x=N.getRangeAt(0);let v;if(N.anchorNode===_){let S=_;for(;S.firstElementChild;)S=S.firstElementChild;v=S.getBoundingClientRect()}else v=x.getBoundingClientRect();sl(v,m,r),d(h)}else(!y||y.className!=="link-input")&&(_&&sl(null,m,r),d(void 0),c(!1),s(""));return!0},[r,t]);$.useEffect(()=>{const h=r.parentElement;function m(){t.getEditorState().read(()=>u())}return window.addEventListener("resize",m),h&&h.addEventListener("scroll",m),()=>{window.removeEventListener("resize",m),h&&h.removeEventListener("scroll",m)}},[r.parentElement,t,u]),$.useEffect(()=>V.mergeRegister(t.registerUpdateListener(({editorState:h})=>h.read(()=>u())),t.registerCommand(C.SELECTION_CHANGE_COMMAND,()=>(u(),!0),C.COMMAND_PRIORITY_LOW),t.registerCommand(C.KEY_ESCAPE_COMMAND,()=>e?(n(!1),!0):!1,C.COMMAND_PRIORITY_HIGH)),[t,u,n,e]),$.useEffect(()=>{t.getEditorState().read(()=>u())},[t,u]),$.useEffect(()=>{a&&o.current&&o.current.focus()},[a]);const f=i_();return p.jsx("div",{ref:i,style:{transition:"opacity 0.5s"},className:f.editor,children:a?p.jsx(Gn,{ref:o,className:f.input,value:l,onChange:(h,m)=>s(m.value),onKeyDown:h=>{h.key==="Enter"?(h.preventDefault(),g&&(l&&t.dispatchCommand(ce.TOGGLE_LINK_COMMAND,lg(l)),c(!1))):h.key==="Escape"&&(h.preventDefault(),c(!1))}}):p.jsxs("div",{className:f.link,children:[p.jsx(Lg,{href:l,target:"_blank",rel:"noopener noreferrer",className:f.a,children:l}),p.jsx(Un,{appearance:"subtle",icon:p.jsx(Mg,{}),onClick:()=>c(!0)})]})})}const ba={...P.margin("8px","10px"),...P.padding("4px","12px")},i_=it({editor:{...cu,...rf,position:"absolute",top:0,left:0,maxWidth:"400px",width:"100%",opacity:0,willChange:"transform"},a:{whiteSpace:"nowrap",...P.overflow("hidden"),textOverflow:"ellipsis"},link:{...uu,justifyContent:"space-between",alignItems:"center",width:"calc(100% - 20px)",boxSizing:"border-box",...P.borderRadius(an.borderRadiusMedium),backgroundColor:"#eee",position:"relative",...ba},input:ba});function o_({editor:t,anchor:e}){const[n,r]=$.useState(t),[i,o]=$.useState(!1);return $.useEffect(()=>t.registerCommand(C.SELECTION_CHANGE_COMMAND,(l,s)=>{const a=C.$getSelection();if(C.$isRangeSelection(a)){const c=so(a),g=V.$findMatchingParent(c,ce.$isLinkNode),d=V.$findMatchingParent(c,ce.$isAutoLinkNode);o(!!(g&&!d))}return r(s),!1},C.COMMAND_PRIORITY_CRITICAL),[t]),i&&p.jsx(Wr,{mountNode:e,children:p.jsx(r_,{editor:n,isLink:i,anchor:e,setIsLink:o})})}function l_({anchor:t=document.body}){const[e]=X.useLexicalComposerContext();return p.jsx(o_,{editor:e,anchor:t})}function s_(t,e){const n=t.getRangeAt(0);let r;if(t.anchorNode===e){let i=e;for(;i.firstElementChild;)i=i.firstElementChild;r=i.getBoundingClientRect()}else r=n.getBoundingClientRect();return r}function a_({editor:t,anchor:e,isLink:n,isBold:r,isItalic:i,isUnderline:o,isCode:l,isStrikethrough:s,isSubscript:a,isSuperscript:c}){const g=$.useRef(null),d=$.useCallback(()=>{n?t.dispatchCommand(ce.TOGGLE_LINK_COMMAND,null):t.dispatchCommand(ce.TOGGLE_LINK_COMMAND,"https://")},[t,n]),u=$.useCallback(()=>{const m=C.$getSelection(),N=g.current,y=window.getSelection();if(!N)return;const _=t.getRootElement();if(m&&y&&!y.isCollapsed&&_&&_.contains(y.anchorNode)){const x=s_(y,_);sl(x,N,e)}},[t,e]);$.useEffect(()=>{const m=e.parentElement;function N(){t.getEditorState().read(()=>u())}return window.addEventListener("resize",N),m&&m.addEventListener("scroll",N),()=>{window.removeEventListener("resize",N),m&&m.removeEventListener("scroll",N)}},[t,u,e]),$.useEffect(()=>(t.getEditorState().read(()=>u()),V.mergeRegister(t.registerUpdateListener(({editorState:m})=>m.read(()=>u())),t.registerCommand(C.SELECTION_CHANGE_COMMAND,()=>(u(),!1),C.COMMAND_PRIORITY_LOW))),[t,u]);const f=[r&&"bold",i&&"italic",o&&"underline",l&&"code",s&&"strikethrough",a&&"subscript",c&&"superscript",n&&"link"],h=u_();return p.jsxs(Za,{ref:g,className:h.toolbar,style:{transition:"opacity 0.5s"},checkedValues:{opts:f},children:[p.jsx(Le,{name:"opts",value:"bold",appearance:"subtle","aria-label":"Format text as bold",icon:p.jsx(qa,{}),onClick:()=>t.dispatchCommand(C.FORMAT_TEXT_COMMAND,"bold")}),p.jsx(Le,{name:"opts",value:"italic",appearance:"subtle","aria-label":"Format text as italics",icon:p.jsx(Qa,{}),onClick:()=>t.dispatchCommand(C.FORMAT_TEXT_COMMAND,"italic")}),p.jsx(Le,{name:"opts",value:"underline",appearance:"subtle","aria-label":"Format text to underlined",icon:p.jsx(eu,{}),onClick:()=>t.dispatchCommand(C.FORMAT_TEXT_COMMAND,"underline")}),p.jsx(Le,{name:"opts",value:"strikethrough",appearance:"subtle","aria-label":"Format text with a strikethrough",icon:p.jsx(tu,{}),onClick:()=>t.dispatchCommand(C.FORMAT_TEXT_COMMAND,"strikethrough")}),p.jsx(Le,{name:"opts",value:"subscript",appearance:"subtle","aria-label":"Format Subscript",icon:p.jsx(nu,{}),onClick:()=>t.dispatchCommand(C.FORMAT_TEXT_COMMAND,"subscript")}),p.jsx(Le,{name:"opts",value:"superscript",appearance:"subtle","aria-label":"Format Superscript",icon:p.jsx(ru,{}),onClick:()=>t.dispatchCommand(C.FORMAT_TEXT_COMMAND,"superscript")}),p.jsx(Le,{name:"opts",value:"code",appearance:"subtle","aria-label":"Insert code block",icon:p.jsx(Ti,{}),onClick:()=>t.dispatchCommand(C.FORMAT_TEXT_COMMAND,"code")}),p.jsx(Le,{name:"opts",value:"link",appearance:"subtle","aria-label":"Insert link",icon:p.jsx(iu,{}),onClick:d})]})}const u_=it({toolbar:{...cu,...P.padding("4px"),verticalAlign:"middle",position:"absolute",top:0,left:0,opacity:0,height:"35px",willChange:"transform"}});function c_({editor:t,anchor:e}){const[n,r]=$.useState(!1),[i,o]=$.useState(!1),[l,s]=$.useState(!1),[a,c]=$.useState(!1),[g,d]=$.useState(!1),[u,f]=$.useState(!1),[h,m]=$.useState(!1),[N,y]=$.useState(!1),[_,x]=$.useState(!1),v=$.useCallback(()=>{t.getEditorState().read(()=>{if(t.isComposing())return;const S=C.$getSelection(),A=window.getSelection(),w=t.getRootElement();if(A&&(!C.$isRangeSelection(S)||!w||!w.contains(A.anchorNode))){r(!1);return}if(!C.$isRangeSelection(S))return;const B=so(S);s(S.hasFormat("bold")),c(S.hasFormat("italic")),d(S.hasFormat("underline")),f(S.hasFormat("strikethrough")),m(S.hasFormat("subscript")),y(S.hasFormat("superscript")),x(S.hasFormat("code"));const k=B.getParent();ce.$isLinkNode(k)||ce.$isLinkNode(B)?o(!0):o(!1),!he.$isCodeHighlightNode(S.anchor.getNode())&&S.getTextContent()?r(C.$isTextNode(B)):r(!1)})},[t]);return $.useEffect(()=>(document.addEventListener("selectionchange",v),()=>document.removeEventListener("selectionchange",v)),[v]),$.useEffect(()=>V.mergeRegister(t.registerUpdateListener(()=>v()),t.registerRootListener(()=>{t.getRootElement()||r(!1)})),[t,v]),!n||i?null:p.jsx(Wr,{mountNode:e,children:p.jsx(a_,{editor:t,anchor:e,isLink:i,isBold:l,isItalic:a,isStrikethrough:u,isSubscript:h,isSuperscript:N,isUnderline:g,isCode:_})})}function ka({anchor:t=document.body}){const[e]=X.useLexicalComposerContext();return p.jsx(c_,{editor:e,anchor:t})}function d_(){const[t]=X.useLexicalComposerContext();return $.useEffect(()=>t.registerCommand(jt.INSERT_HORIZONTAL_RULE_COMMAND,e=>{const n=C.$getSelection();if(!C.$isRangeSelection(n))return!1;if(n.focus.getNode()){const i=jt.$createHorizontalRuleNode();V.$insertNodeToNearestRoot(i)}return!0},C.COMMAND_PRIORITY_EDITOR),[t]),null}const Vl=C.createCommand("INSERT_IMAGE_COMMAND");function g_({editor:t}){const[e,n]=$.useState("https://source.unsplash.com/random"),[r,i]=$.useState(du.Name);return p.jsxs(ou,{children:[p.jsx(lu,{children:"Insert Image"}),p.jsxs(su,{children:[p.jsx(Or,{label:"Source",required:!0,children:p.jsx(Gn,{placeholder:e,onChange:(o,l)=>n(l.value||"")})}),p.jsx(Or,{label:"Alt Text",required:!0,children:p.jsx(Gn,{placeholder:r,onChange:(o,l)=>i(l.value||"")})})]}),p.jsx(au,{children:p.jsx(yi,{disableButtonEnhancement:!0,children:p.jsx(Un,{onClick:()=>{t.dispatchCommand(Vl,{altText:r,src:e})},children:"Confirm"})})})]})}function Ia({captionsEnabled:t}){const[e]=X.useLexicalComposerContext();return $.useEffect(()=>{if(!e.hasNodes([Ut]))throw new Error("ImagesPlugin: ImageNode not registered on editor");return V.mergeRegister(e.registerCommand(Vl,n=>{const r=ro(n);return C.$insertNodes([r]),C.$isRootOrShadowRoot(r.getParentOrThrow())&&V.$wrapNodeInElement(r,C.$createParagraphNode).selectEnd(),!0},C.COMMAND_PRIORITY_EDITOR),e.registerCommand(C.DRAGSTART_COMMAND,n=>h_(n),C.COMMAND_PRIORITY_HIGH),e.registerCommand(C.DRAGOVER_COMMAND,n=>p_(n),C.COMMAND_PRIORITY_LOW),e.registerCommand(C.DROP_COMMAND,n=>m_(n,e),C.COMMAND_PRIORITY_HIGH))},[t,e]),null}const f_="data:image/gif;base64,R0lGODlhAQABAIAAAAAAAP///yH5BAEAAAAALAAAAAABAAEAAAIBRAA7",sg=document.createElement("img");sg.src=f_;function h_(t){const e=Xl();if(!e)return!1;const n=t.dataTransfer;return n?(n.setData("text/plain","_"),n.setDragImage(sg,0,0),n.setData("application/x-lexical-drag",JSON.stringify({data:{altText:e.altText,caption:e.caption,height:e.height,key:e.getKey(),maxWidth:e.maxWidth,showCaption:e.showCaption,src:e.src,width:e.width},type:"image"})),!0):!1}function p_(t){return Xl()?(ag(t)||t.preventDefault(),!0):!1}function m_(t,e){const n=Xl();if(!n)return!1;const r=__(t);if(!r)return!1;if(t.preventDefault(),ag(t)){const i=C_(t);n.remove();const o=C.$createRangeSelection();i&&o.applyDOMRange(i),C.$setSelection(o),e.dispatchCommand(Vl,r)}return!0}function Xl(){const t=C.$getSelection();if(!C.$isNodeSelection(t))return null;const n=t.getNodes()[0];return Nd(n)?n:null}function __(t){const e=t.dataTransfer?.getData("application/x-lexical-drag");if(!e)return null;const{type:n,data:r}=JSON.parse(e);return n!=="image"?null:r}function ag(t){const e=t.target;return!!(e&&e instanceof HTMLElement&&!e.closest("code, span.LexEditor_Image")&&e.parentElement&&e.parentElement.closest("div.LexEditor_Content"))}function C_(t){let e;const n=window.getSelection();if(document.caretRangeFromPoint)e=document.caretRangeFromPoint(t.clientX,t.clientY);else if(t.rangeParent&&n)n.collapse(t.rangeParent,t.rangeOffset||0),e=n.getRangeAt(0);else throw Error("Cannot get the selection when dragging");return e}var ug={},wn=ce,x_=X,N_=V,Dn=C,E_=$;ug.LinkPlugin=function({validateUrl:t}){let[e]=x_.useLexicalComposerContext();return E_.useEffect(()=>{if(!e.hasNodes([wn.LinkNode]))throw Error("LinkPlugin: LinkNode not registered on editor");return N_.mergeRegister(e.registerCommand(wn.TOGGLE_LINK_COMMAND,n=>{if(n===null)return wn.toggleLink(n),!0;if(typeof n=="string")return t===void 0||t(n)?(wn.toggleLink(n),!0):!1;let{url:r,target:i,rel:o,title:l}=n;return wn.toggleLink(r,{rel:o,target:i,title:l}),!0},Dn.COMMAND_PRIORITY_LOW),t!==void 0?e.registerCommand(Dn.PASTE_COMMAND,n=>{let r=Dn.$getSelection();if(!Dn.$isRangeSelection(r)||r.isCollapsed()||!(n instanceof ClipboardEvent)||n.clipboardData==null)return!1;let i=n.clipboardData.getData("text");return t(i)?r.getNodes().some(o=>Dn.$isElementNode(o))?!1:(e.dispatchCommand(wn.TOGGLE_LINK_COMMAND,i),n.preventDefault(),!0):!1},Dn.COMMAND_PRIORITY_LOW):()=>{})},[e,t]),null};const T_=ug;var y_=T_;function Pa(){return p.jsx(y_.LinkPlugin,{validateUrl:n_})}function v_(t){const e=t.getNodes();return e.length===0?new Set([t.anchor.getNode().getParentOrThrow(),t.focus.getNode().getParentOrThrow()]):new Set(e.map(n=>C.$isElementNode(n)?n:n.getParentOrThrow()))}function S_(t){const e=C.$getSelection();if(!C.$isRangeSelection(e))return!1;const n=v_(e);let r=0;for(const i of n)if(fe.$isListNode(i))r=Math.max(fe.$getListDepth(i)+1,r);else if(fe.$isListItemNode(i)){const o=i.getParent();if(!fe.$isListNode(o))throw new Error("ListMaxIndentLevelPlugin: A ListItemNode must have a ListNode for a parent.");r=Math.max(fe.$getListDepth(o)+1,r)}return r<=t}function $_({maxDepth:t}){const[e]=X.useLexicalComposerContext();return $.useEffect(()=>e.registerCommand(C.INDENT_CONTENT_COMMAND,()=>!S_(t??7),C.COMMAND_PRIORITY_CRITICAL),[e,t]),null}var Zl={},cg=Kr,R_=X,Oo=jt,A_=$;let dg=[{dependencies:[Oo.HorizontalRuleNode],export:t=>Oo.$isHorizontalRuleNode(t)?"***":null,regExp:/^(---|\*\*\*|___)\s?$/,replace:(t,e,n,r)=>{e=Oo.$createHorizontalRuleNode(),r||t.getNextSibling()!=null?t.replace(e):t.insertBefore(e),e.selectNext()},type:"element"},...cg.TRANSFORMERS];Zl.DEFAULT_TRANSFORMERS=dg;Zl.MarkdownShortcutPlugin=function({transformers:t=dg}){let[e]=R_.useLexicalComposerContext();return A_.useEffect(()=>cg.registerMarkdownShortcuts(e,t),[e,t]),null};const O_=Zl;var w_=O_;function D_(){return p.jsx(w_.MarkdownShortcutPlugin,{transformers:ol})}const L_=100;let gg=0,Fa=!1;function M_(){window.addEventListener("keydown",t=>{t.keyCode===9&&(gg=t.timeStamp)},!0)}function b_(){const[t]=X.useLexicalComposerContext();return $.useEffect(()=>(Fa||(M_(),Fa=!0),t.registerCommand(C.FOCUS_COMMAND,e=>{const n=C.$getSelection();return C.$isRangeSelection(n)&&gg+L_>e.timeStamp&&C.$setSelection(n.clone()),!1},C.COMMAND_PRIORITY_LOW)),[t]),null}function fg(){return Math.random().toString(36).replace(/[^a-z]+/g,"").substring(0,5)}const k_=new Map,yC=new Map,hg='{"root":{"children":[{"children":[],"direction":null,"format":"","indent":0,"type":"paragraph","version":1}],"direction":null,"format":"","indent":0,"type":"root","version":1}}';function I_(t){return t?`{"root":{"children":[{"children":[{"detail":0,"format":0,"mode":"normal","style":"","text":${t},"type":"text","version":1}],"direction":"ltr","format":"","indent":0,"type":"paragraph","version":1}],"direction":"ltr","format":"","indent":0,"type":"root","version":1}}`:hg}function Pn(t){return{colSpan:1,id:fg(),json:hg,type:t,width:null}}function Hi(){return{cells:[],height:null,id:fg()}}function P_(t){const e=t.querySelectorAll("tr");if(!e||e.length===0)return null;const n=[];for(let r=0;r({conversion:P_,priority:0})}}exportDOM(){return{element:F_(this.rows)}}createDOM(){const e=document.createElement("div");return e.style.display="contents",e}updateDOM(){return!1}mergeRows(e,n,r){const o=this.getWritable().rows,l=Math.min(o.length,n+r.length);for(let s=n;sJa(()=>import("./Component-aAfnRv22.js"),__vite__mapDeps([5,1,2,3,4])));function j_(t,e,...n){if(!t)throw new Error("Internal Lexical error: invariant() is meant to be replaced at compile time. There is no runtime version. Error: "+e)}const mg=C.createCommand("INSERT_NEW_TABLE_COMMAND"),_g=$.createContext({cellEditorConfig:null,cellEditorPlugins:null,set:()=>{}});function z_({children:t}){const[e,n]=$.useState({cellEditorConfig:null,cellEditorPlugins:null});return p.jsx(_g.Provider,{value:$.useMemo(()=>({cellEditorConfig:e.cellEditorConfig,cellEditorPlugins:e.cellEditorPlugins,set:(r,i)=>n({cellEditorConfig:r,cellEditorPlugins:i})}),[e.cellEditorConfig,e.cellEditorPlugins]),children:t})}function K_({editor:t}){const[e,n]=$.useState("5"),[r,i]=$.useState("5");return p.jsxs(ou,{children:[p.jsx(lu,{children:"Insert Table"}),p.jsxs(su,{children:[p.jsx(Or,{label:"Rows",required:!0,children:p.jsx(Gn,{placeholder:e,onChange:(o,l)=>l&&n(l.value)})}),p.jsx(Or,{label:"Cols",required:!0,children:p.jsx(Gn,{placeholder:r,onChange:(o,l)=>l&&i(l.value)})})]}),p.jsx(au,{children:p.jsx(yi,{disableButtonEnhancement:!0,children:p.jsx(Un,{onClick:()=>{t.dispatchCommand(mg,{columns:r,rows:e})},children:"Confirm"})})})]})}function H_(t,e,n=!0){const r=[];for(let i=0;i(n.hasNodes([rr])||j_(!1,"TablePlugin: TableNode is not registered on editor"),r.set(t,e),n.registerCommand(mg,({columns:i,rows:o,includeHeaders:l})=>{const s=C.$getSelection();if(!C.$isRangeSelection(s))return!0;const a=s.focus,c=a.getNode();if(c){const g=H_(Number(o),Number(i),l);if(C.$isRootOrShadowRoot(c)){const u=c.getChildAtIndex(a.offset);u?u.insertBefore(g):c.append(g),g.insertBefore(C.$createParagraphNode())}else c.getTopLevelElementOrThrow().insertAfter(g);g.insertAfter(C.$createParagraphNode());const d=C.$createNodeSelection();d.add(g.getKey()),C.$setSelection(d)}return!0},C.COMMAND_PRIORITY_EDITOR)),[r,t,e,n]),null}var ql={},U_=C;class Cg extends U_.DecoratorNode{constructor(e,n){super(n),this.__format=e||""}exportJSON(){return{format:this.__format||"",type:"decorator-block",version:1}}createDOM(){return document.createElement("div")}updateDOM(){return!1}setFormat(e){this.getWritable().__format=e}}ql.$isDecoratorBlockNode=function(t){return t instanceof Cg};ql.DecoratorBlockNode=Cg;const G_=ql;var Y_=G_;const J_="documentMode"in document?document.documentMode:null,kt=/Mac|iPod|iPhone|iPad/.test(navigator.platform);"InputEvent"in window&&!J_&&"getTargetRanges"in new window.InputEvent("input");const al={bullet:"Bulleted List",check:"Check List",code:"Code Block",h1:"Heading 1",h2:"Heading 2",h3:"Heading 3",h4:"Heading 4",h5:"Heading 5",h6:"Heading 6",number:"Numbered List",paragraph:"Normal",quote:"Quote"};function V_({editor:t,blockType:e,disabled:n=!1}){function r(){e!=="paragraph"&&t.update(()=>{const g=C.$getSelection();(C.$isRangeSelection(g)||C.DEPRECATED_$isGridSelection(g))&&Se.$setBlocksType(g,()=>C.$createParagraphNode())})}function i(g){e!==g&&t.update(()=>{const d=C.$getSelection();(C.$isRangeSelection(d)||C.DEPRECATED_$isGridSelection(d))&&Se.$setBlocksType(d,()=>rt.$createHeadingNode(g))})}function o(){e!=="bullet"?t.dispatchCommand(fe.INSERT_UNORDERED_LIST_COMMAND,void 0):t.dispatchCommand(fe.REMOVE_LIST_COMMAND,void 0)}function l(){e!=="check"?t.dispatchCommand(fe.INSERT_CHECK_LIST_COMMAND,void 0):t.dispatchCommand(fe.REMOVE_LIST_COMMAND,void 0)}function s(){e!=="number"?t.dispatchCommand(fe.INSERT_ORDERED_LIST_COMMAND,void 0):t.dispatchCommand(fe.REMOVE_LIST_COMMAND,void 0)}function a(){e!=="quote"&&t.update(()=>{const g=C.$getSelection();(C.$isRangeSelection(g)||C.DEPRECATED_$isGridSelection(g))&&Se.$setBlocksType(g,()=>rt.$createQuoteNode())})}function c(){e!=="code"&&t.update(()=>{const g=C.$getSelection();if(C.$isRangeSelection(g)||C.DEPRECATED_$isGridSelection(g))if(g.isCollapsed())Se.$setBlocksType(g,()=>he.$createCodeNode());else{const d=g.getTextContent(),u=he.$createCodeNode();g.insertNodes([u]),g.insertRawText(d)}})}return p.jsxs(pr,{children:[p.jsx(mr,{children:p.jsx(yt,{disabled:n,"aria-label":"Formatting options for text style",children:al[e],icon:(()=>{switch(e){case"paragraph":return p.jsx(cs,{});case"h1":return p.jsx(us,{});case"h2":return p.jsx(as,{});case"h3":return p.jsx(ss,{});case"bullet":return p.jsx(ls,{});case"check":return p.jsx(os,{});case"number":return p.jsx(is,{});case"quote":return p.jsx(rs,{});case"code":return p.jsx(Ti,{});default:return p.jsx(bg,{})}})()})}),p.jsx(_r,{children:p.jsxs(Cr,{children:[p.jsx(ue,{icon:p.jsx(cs,{}),onClick:r,children:"Normal"}),p.jsx(ue,{icon:p.jsx(us,{}),onClick:()=>i("h1"),children:"Heading 1"}),p.jsx(ue,{icon:p.jsx(as,{}),onClick:()=>i("h2"),children:"Heading 2"}),p.jsx(ue,{icon:p.jsx(ss,{}),onClick:()=>i("h3"),children:"Heading 3"}),p.jsx(ue,{icon:p.jsx(ls,{}),onClick:o,children:"Bullet List"}),p.jsx(ue,{icon:p.jsx(is,{}),onClick:s,children:"Numbered List"}),p.jsx(ue,{icon:p.jsx(os,{}),onClick:l,children:"Check List"}),p.jsx(ue,{icon:p.jsx(rs,{}),onClick:a,children:"Quote"}),p.jsx(ue,{icon:p.jsx(Ti,{}),onClick:c,children:"Code Block"})]})})]})}const X_=["#d0021b","#f5a623","#f8e71c","#8b572a","#7ed321","#417505","#bd10e0","#9013fe","#4a90e2","#50e3c2","#b8e986","#000000","#4a4a4a","#9b9b9b","#ffffff"],cr=214,Ba=150;function Z_({color:t,onChange:e}){const[n,r]=$.useState(Ln("hex",t)),[i,o]=$.useState(t),l=$.useRef(null),s=$.useMemo(()=>({x:n.hsv.s/100*cr,y:(100-n.hsv.v)/100*Ba}),[n.hsv.s,n.hsv.v]),a=$.useMemo(()=>({x:n.hsv.h/360*cr}),[n.hsv]);function c(u){if(o(u),/^#[0-9A-Fa-f]{6}$/i.test(u)){const f=Ln("hex",u);r(f)}}function g({x:u,y:f}){const h={...n.hsv,s:u/cr*100,v:100-f/Ba*100},m=Ln("hsv",h);r(m),o(m.hex)}function d({x:u}){const f={...n.hsv,h:u/cr*360},h=Ln("hsv",f);r(h),o(h.hex)}return $.useEffect(()=>{l.current!==null&&e&&(e(n.hex),o(n.hex))},[n,e]),$.useEffect(()=>{if(t===void 0)return;const u=Ln("hex",t);r(u),o(u.hex)},[t]),p.jsxs("div",{style:{width:cr},ref:l,children:[p.jsx(Or,{label:"Hex",style:{paddingBottom:an.spacingVerticalS},children:p.jsx(Gn,{onChange:(u,f)=>c(f.value),value:i})}),p.jsx("div",{className:"color-picker-basic-color",children:X_.map(u=>p.jsx("button",{className:u===n.hex?" active":"",style:{backgroundColor:u},onClick:()=>{o(u),r(Ln("hex",u))}},u))}),p.jsx(ja,{className:"color-picker-saturation",style:{backgroundColor:`hsl(${n.hsv.h}, 100%, 50%)`},onChange:g,children:p.jsx("div",{className:"color-picker-saturation_cursor",style:{backgroundColor:n.hex,left:s.x,top:s.y}})}),p.jsx(ja,{className:"color-picker-hue",onChange:d,children:p.jsx("div",{className:"color-picker-hue_cursor",style:{backgroundColor:`hsl(${n.hsv.h}, 100%, 50%)`,left:a.x}})}),p.jsx("div",{className:"color-picker-color",style:{backgroundColor:n.hex}})]})}function ja({className:t,style:e,onChange:n,children:r}){const i=$.useRef(null),o=s=>{if(i.current){const{current:a}=i,{width:c,height:g,left:d,top:u}=a.getBoundingClientRect(),f=za(s.clientX-d,c,0),h=za(s.clientY-u,g,0);n({x:f,y:h})}};function l(s){if(s.button!==0)return;o(s);function a(g){o(g)}function c(g){document.removeEventListener("mousemove",a,!1),document.removeEventListener("mouseup",c,!1),o(g)}document.addEventListener("mousemove",a,!1),document.addEventListener("mouseup",c,!1)}return p.jsx("div",{ref:i,className:t,style:e,onMouseDown:l,children:r})}function za(t,e,n){return t>e?e:tn?e+e:"#").join(""),t;if(t.length===7||t.length===9)return t}else{const e=document.createElement("canvas").getContext("2d");if(!e)throw new Error("2d context not supported or canvas already initialized");return e.fillStyle=t,e.fillStyle}return"#000000"}function Ha(t){const e=(t.replace(/^#?([a-f\d])([a-f\d])([a-f\d])$/i,(n,r,i,o)=>"#"+r+r+i+i+o+o).substring(1).match(/.{2}/g)||[]).map(n=>parseInt(n,16));return{b:e[2],g:e[1],r:e[0]}}function wo({r:t,g:e,b:n}){t/=255,e/=255,n/=255;const r=Math.max(t,e,n),i=r-Math.min(t,e,n),o=i?(r===t?(e-n)/i+(er.toString(16).padStart(2,"0")).join("")}function Ln(t,e){let n=Ka("#121212"),r=Ha(n),i=wo(r);return t==="hex"?(n=Ka(e),r=Ha(n),i=wo(r)):t==="rgb"?(r=e,n=Wa(r),i=wo(r)):t==="hsv"&&(i=e,r=q_(i),n=Wa(r)),{hex:n,hsv:i,rgb:r}}function Ua({disabled:t,ariaLabel:e,color:n,onChange:r,icon:i}){return p.jsxs(kg,{trapFocus:!0,withArrow:!0,children:[p.jsx(Ig,{children:p.jsx(yt,{disabled:t,icon:i,title:e,"aria-label":e})}),p.jsx(Pg,{children:p.jsx(Z_,{color:n,onChange:r})})]})}const Q_=[["Arial","Arial"],["Courier New","Courier New"],["Georgia","Georgia"],["Times New Roman","Times New Roman"],["Trebuchet MS","Trebuchet MS"],["Verdana","Verdana"]],eC=[["10px","10px"],["11px","11px"],["12px","12px"],["13px","13px"],["14px","14px"],["15px","15px"],["16px","16px"],["17px","17px"],["18px","18px"],["19px","19px"],["20px","20px"]];function Ga({editor:t,value:e,style:n,disabled:r=!1}){const i=$.useCallback(l=>{t.update(()=>{const s=C.$getSelection();C.$isRangeSelection(s)&&Se.$patchStyleText(s,{[n]:l})})},[t,n]),o=n==="font-family"?"Formatting options for font family":"Formatting options for font size";return p.jsxs(pr,{children:[p.jsx(mr,{children:p.jsx(yt,{disabled:r,"aria-label":o,icon:n==="font-family"?p.jsx(Fg,{}):p.jsx(Bg,{}),children:e})}),p.jsx(_r,{children:p.jsx(Cr,{children:(n==="font-family"?Q_:eC).map(([l,s],a)=>p.jsx(ue,{children:s,onClick:()=>i(l)},a))})})]})}const tC=it({box:{columnGap:"1px",backgroundColor:"#fff",borderTopLeftRadius:an.borderRadiusLarge,borderTopRightRadius:an.borderRadiusLarge}}),nC=(()=>{const t=[];for(const[e,n]of Object.entries(he.CODE_LANGUAGE_FRIENDLY_NAME_MAP))t.push([e,n]);return t})();function rC(){const[t]=X.useLexicalComposerContext(),[e,n]=$.useState(t),[r,i]=$.useState("paragraph"),[o,l]=$.useState(null),[s,a]=$.useState("15px"),[c,g]=$.useState("#000"),[d,u]=$.useState("#fff"),[f,h]=$.useState("Arial"),[m,N]=$.useState(!1),[y,_]=$.useState(!1),[x,v]=$.useState(!1),[S,A]=$.useState(""),[w,B]=$.useState(()=>t.isEditable()),[k,K]=$.useState([]),Z=$.useCallback(()=>{const I=C.$getSelection();if(C.$isRangeSelection(I)){const G=I.anchor.getNode();let de=G.getKey()==="root"?G:V.$findMatchingParent(G,De=>{const Te=De.getParent();return!!Te&&C.$isRootOrShadowRoot(Te)});de||(de=G.getTopLevelElementOrThrow());const ge=de.getKey(),Dt=e.getElementByKey(ge),oe=[];I.hasFormat("bold")&&oe.push("bold"),I.hasFormat("italic")&&oe.push("italic"),I.hasFormat("underline")&&oe.push("underline"),I.hasFormat("strikethrough")&&oe.push("strikethrough"),I.hasFormat("subscript")&&oe.push("subscript"),I.hasFormat("superscript")&&oe.push("superscript"),I.hasFormat("code")&&oe.push("code");const lt=so(I),st=lt.getParent();if(ce.$isLinkNode(st)||ce.$isLinkNode(lt)?(oe.push("link"),N(!0)):N(!1),K(oe),Dt)if(l(ge),fe.$isListNode(de)){const De=V.$getNearestNodeOfType(G,fe.ListNode),Te=De?De.getListType():de.getListType();i(Te)}else{const De=rt.$isHeadingNode(de)?de.getTag():de.getType();if(De in al&&i(De),he.$isCodeNode(de)){const Te=de.getLanguage();A(Te?he.CODE_LANGUAGE_MAP[Te]||Te:"");return}}a(Se.$getSelectionStyleValueForProperty(I,"font-size","15px")),g(Se.$getSelectionStyleValueForProperty(I,"color","#000")),u(Se.$getSelectionStyleValueForProperty(I,"background-color","#fff")),h(Se.$getSelectionStyleValueForProperty(I,"font-family","Arial"))}},[e]);$.useEffect(()=>t.registerCommand(C.SELECTION_CHANGE_COMMAND,(I,G)=>(Z(),n(G),!1),C.COMMAND_PRIORITY_CRITICAL),[t,Z]),$.useEffect(()=>V.mergeRegister(t.registerEditableListener(I=>B(I)),e.registerUpdateListener(({editorState:I})=>I.read(()=>Z())),e.registerCommand(C.CAN_UNDO_COMMAND,I=>(_(I),!1),C.COMMAND_PRIORITY_CRITICAL),e.registerCommand(C.CAN_REDO_COMMAND,I=>(v(I),!1),C.COMMAND_PRIORITY_CRITICAL)),[e,t,Z]);const ie=$.useCallback(I=>{e.update(()=>{const G=C.$getSelection();C.$isRangeSelection(G)&&Se.$patchStyleText(G,I)})},[e]),ot=$.useCallback(()=>{e.update(()=>{const I=C.$getSelection();C.$isRangeSelection(I)&&(Se.$selectAll(I),I.getNodes().forEach(G=>{C.$isTextNode(G)&&(G.setFormat(0),G.setStyle(""),V.$getNearestBlockElementAncestorOrThrow(G).setFormat("")),Y_.$isDecoratorBlockNode(G)&&G.setFormat("")}))})},[e]),Tn=$.useCallback(I=>ie({color:I}),[ie]),yn=$.useCallback(I=>ie({"background-color":I}),[ie]),vn=$.useCallback(()=>{m?t.dispatchCommand(ce.TOGGLE_LINK_COMMAND,null):t.dispatchCommand(ce.TOGGLE_LINK_COMMAND,lg("https://"))},[t,m]),xt=$.useCallback(I=>{e.update(()=>{if(o!==null){const G=C.$getNodeByKey(o);he.$isCodeNode(G)&&G.setLanguage(I)}})},[e,o]),ae=tC();return p.jsxs(Za,{checkedValues:{opts:k},className:gt("LexEditor_Toolbar",ae.box),children:[p.jsx(yt,{disabled:!y||!w,title:kt?"Undo (⌘Z)":"Undo (Ctrl+Z)","aria-label":"Undo",icon:p.jsx(jg,{}),onClick:()=>e.dispatchCommand(C.UNDO_COMMAND,void 0)}),p.jsx(yt,{disabled:!x||!w,title:kt?"Redo (⌘Y)":"Redo (Ctrl+Y)","aria-label":"Redo",icon:p.jsx(zg,{}),onClick:()=>e.dispatchCommand(C.REDO_COMMAND,void 0)}),p.jsx(sr,{}),r in al&&e===t&&p.jsxs(p.Fragment,{children:[p.jsx(V_,{disabled:!w,blockType:r,editor:t}),p.jsx(sr,{})]}),r==="code"?p.jsxs(pr,{children:[p.jsx(mr,{children:p.jsx(yt,{disabled:!w,title:"Select language","aria-label":"Select language",icon:p.jsx(Kg,{}),children:he.getLanguageFriendlyName(S)})}),p.jsx(_r,{children:p.jsx(Cr,{children:nC.map(([I,G],de)=>p.jsx(ue,{onClick:()=>xt(I),children:G},de))})})]}):p.jsxs(p.Fragment,{children:[p.jsx(Ga,{disabled:!w,style:"font-family",value:f,editor:t}),p.jsx(Ga,{disabled:!w,style:"font-size",value:s,editor:t}),p.jsx(sr,{}),p.jsx(Le,{name:"opts",value:"bold",appearance:"subtle",disabled:!w,title:kt?"Bold (⌘B)":"Bold (Ctrl+B)","aria-label":`Format text as bold. Shortcut: ${kt?"⌘B":"Ctrl+B"}`,icon:p.jsx(qa,{}),onClick:()=>e.dispatchCommand(C.FORMAT_TEXT_COMMAND,"bold")}),p.jsx(Le,{name:"opts",value:"italic",appearance:"subtle",disabled:!w,title:kt?"Italic (⌘I)":"Italic (Ctrl+I)","aria-label":`Format text as italics. Shortcut: ${kt?"⌘I":"Ctrl+I"}`,icon:p.jsx(Qa,{}),onClick:()=>e.dispatchCommand(C.FORMAT_TEXT_COMMAND,"italic")}),p.jsx(Le,{name:"opts",value:"underline",appearance:"subtle",disabled:!w,title:kt?"Underline (⌘U)":"Underline (Ctrl+U)","aria-label":`Format text to underlined. Shortcut: ${kt?"⌘U":"Ctrl+U"}`,icon:p.jsx(eu,{}),onClick:()=>e.dispatchCommand(C.FORMAT_TEXT_COMMAND,"underline")}),p.jsx(Le,{name:"opts",value:"strikethrough",appearance:"subtle",disabled:!w,title:"Strikethrough","aria-label":"Format text with a strikethrough",icon:p.jsx(tu,{}),onClick:()=>e.dispatchCommand(C.FORMAT_TEXT_COMMAND,"strikethrough")}),p.jsx(Le,{name:"opts",value:"subscript",appearance:"subtle",disabled:!w,title:"Subscript","aria-label":"Format text with a subscript",icon:p.jsx(nu,{}),onClick:()=>e.dispatchCommand(C.FORMAT_TEXT_COMMAND,"subscript")}),p.jsx(Le,{name:"opts",value:"superscript",appearance:"subtle",disabled:!w,title:"Superscript","aria-label":"Format text with a superscript",icon:p.jsx(ru,{}),onClick:()=>e.dispatchCommand(C.FORMAT_TEXT_COMMAND,"superscript")}),p.jsx(Le,{name:"opts",value:"code",appearance:"subtle",disabled:!w,title:"Insert code block","aria-label":"Insert code block",icon:p.jsx(Ti,{}),onClick:()=>e.dispatchCommand(C.FORMAT_TEXT_COMMAND,"code")}),p.jsx(Le,{name:"opts",value:"link",appearance:"subtle",disabled:!w,title:"Insert link","aria-label":"Insert link",icon:p.jsx(iu,{}),onClick:vn}),p.jsx(Ua,{disabled:!w,ariaLabel:"Formatting text color",color:c,icon:p.jsx(Hg,{}),onChange:Tn}),p.jsx(Ua,{disabled:!w,ariaLabel:"Formatting background color",color:d,icon:p.jsx(Wg,{}),onChange:yn}),p.jsx(yt,{disabled:!w,title:"Clear text formatting","aria-label":"Clear all text formatting",icon:p.jsx(Ug,{}),onClick:ot}),p.jsx(sr,{}),p.jsxs(pr,{children:[p.jsx(mr,{children:p.jsx(yt,{disabled:!w,title:"Insert","aria-label":"Insert specialized editor node",icon:p.jsx(Gg,{}),children:"Insert"})}),p.jsx(_r,{children:p.jsxs(Cr,{children:[p.jsx(ue,{icon:p.jsx(Yg,{}),onClick:()=>e.dispatchCommand(jt.INSERT_HORIZONTAL_RULE_COMMAND,void 0),children:"Horizontal Rule"}),p.jsxs(ds,{children:[p.jsx(yi,{disableButtonEnhancement:!0,children:p.jsx(ue,{icon:p.jsx(Jg,{}),children:"Image"})}),p.jsx(gs,{children:p.jsx(g_,{editor:e})})]}),p.jsxs(ds,{children:[p.jsx(yi,{disableButtonEnhancement:!0,children:p.jsx(ue,{icon:p.jsx(Vg,{}),children:"Table"})}),p.jsx(gs,{children:p.jsx(K_,{editor:e})})]}),p.jsx(ue,{icon:p.jsx(Xg,{}),onClick:()=>t.dispatchCommand(ig,void 0),children:"Collapsible"})]})})]})]}),p.jsx(sr,{}),p.jsxs(pr,{children:[p.jsx(mr,{children:p.jsx(yt,{disabled:!w,title:"Align","aria-label":"Formatting options for text alignment",icon:p.jsx(fs,{}),children:"Align"})}),p.jsx(_r,{children:p.jsxs(Cr,{children:[p.jsx(ue,{icon:p.jsx(fs,{}),onClick:()=>e.dispatchCommand(C.FORMAT_ELEMENT_COMMAND,"left"),children:"Left Align"}),p.jsx(ue,{icon:p.jsx(Zg,{}),onClick:()=>e.dispatchCommand(C.FORMAT_ELEMENT_COMMAND,"center"),children:"Center Align"}),p.jsx(ue,{icon:p.jsx(qg,{}),onClick:()=>e.dispatchCommand(C.FORMAT_ELEMENT_COMMAND,"right"),children:"Right Align"}),p.jsx(ue,{icon:p.jsx(Qg,{}),onClick:()=>e.dispatchCommand(C.FORMAT_ELEMENT_COMMAND,"justify"),children:"Justify Align"}),p.jsx(ef,{}),p.jsx(ue,{icon:p.jsx(tf,{}),onClick:()=>e.dispatchCommand(C.OUTDENT_CONTENT_COMMAND,void 0),children:"Outdent"}),p.jsx(ue,{icon:p.jsx(nf,{}),onClick:()=>e.dispatchCommand(C.INDENT_CONTENT_COMMAND,void 0),children:"Indent"})]})})]})]})}const iC=it({ltr:{textAlign:"left"},rtl:{textAlign:"right"},paragraph:{...P.margin(0),position:"relative"},quote:{...P.margin(0),marginLeft:"20px",marginBottom:"10px",fontSize:"15px",color:"rgb(101, 103, 107)",borderLeftColor:"rgb(206, 208, 212)",borderLeftWidth:"4px",borderLeftStyle:"solid",paddingLeft:"16px"},h1:{fontSize:"24px",color:"rgb(5, 5, 5)",fontWeight:400,...P.margin(0)},h2:{fontSize:"15px",color:"rgb(101, 103, 107)",fontWeight:700,...P.margin(0),textTransform:"uppercase"},h3:{fontSize:"12px",...P.margin(0),textTransform:"uppercase"},textBold:{fontWeight:"bold"},textItalic:{fontStyle:"italic"},textSubscript:{fontSize:"0.8em",verticalAlign:"sub !important"},textSuperscript:{fontSize:"0.8em",verticalAlign:"super"},textCode:{backgroundColor:"rgb(240, 242, 245)",...P.padding("1px","0.25rem"),fontFamily:"Menlo, Consolas, Monaco, monospace",fontSize:"94%"},code:{backgroundColor:"rgb(240, 242, 245)",fontFamily:"Menlo, Consolas, Monaco, monospace",display:"block",...P.padding("8px","8px","8px","52px"),lineHeight:1.53,fontSize:"13px",...P.margin(0),marginTop:"8px",marginBottom:"8px",tabSize:2,overflowX:"auto",position:"relative",":before":{content:"attr(data-gutter)",position:"absolute",backgroundColor:"#eee",left:0,top:0,...P.borderRight("1px","solid","#ccc"),...P.padding("8px"),color:"#777",whiteSpace:"pre-wrap",textAlign:"right",minWidth:"25px"}},table:{borderCollapse:"collapse",borderSpacing:0,maxWidth:"100%",overflowY:"scroll",tableLayout:"fixed",width:"calc(100% - 25px)",...P.margin("30px",0)},tableSelected:{...P.outline("2px","solid","rgb(60, 132, 244)")},tableCell:{...P.border("1px","solid","#bbb"),minWidth:"75px",verticalAlign:"top",textAlign:"start",...P.padding("6px","8px"),position:"relative",cursor:"default",...P.outline("none")},tableCellSortedIndicator:{display:"block",opacity:.5,position:"absolute",bottom:0,left:0,width:"100%",height:"4px",backgroundColor:"#999"},tableCellResizer:{position:"absolute",right:"-4px",height:"100%",width:"8px",cursor:"ew-resize",zIndex:10,top:0},tableCellHeader:{backgroundColor:"#f2f3f5",textAlign:"start"},tableCellSelected:{backgroundColor:"#c9dbf0"},tableCellPrimarySelected:{...P.border("2px","solid","rgb(60, 132, 244)"),display:"block",height:"calc(100% - 2px)",position:"absolute",width:"calc(100% - 2px)",left:"-1px",top:"-1px",zIndex:2},tableCellEditing:{boxShadow:"0 0 5px rgba(0, 0, 0, 0.4)",...P.borderRadius("3px")},tableAddColumns:{position:"absolute",top:0,width:"20px",backgroundColor:"#eee",height:"100%",right:0,...P.border(0),cursor:"pointer",":after":{backgroundSize:"contain",backgroundRepeat:"no-repeat",display:"block",content:'" "',position:"absolute",top:0,left:0,width:"100%",height:"100%",opacity:.4},":hover":{backgroundColor:"#c9dbf0"}},tableAddRows:{position:"absolute",bottom:"-25px",width:"calc(100% - 25px)",backgroundColor:"#eee",height:"20px",left:0,...P.border(0),cursor:"pointer",":after":{backgroundSize:"contain",backgroundRepeat:"no-repeat",display:"block",content:'" "',position:"absolute",top:0,left:0,width:"100%",height:"100%",opacity:.4},":hover":{backgroundColor:"#c9dbf0"}},tableCellResizeRuler:{display:"block",position:"absolute",width:"1px",backgroundColor:"rgb(60, 132, 244)",height:"100%",top:0},tableCellActionButtonContainer:{display:"block",right:"5px",top:"2px",position:"absolute",zIndex:4},tableCellActionButton:{backgroundColor:"#eee",display:"block",...P.border(0),...P.borderRadius("20px"),width:"20px",height:"20px",color:"#222",cursor:"pointer",":hover":{backgroundColor:"#ddd"}},ol1:{...P.padding(0),...P.margin(0),marginLeft:"16px",listStylePosition:"inside"},ol2:{...P.padding(0),...P.margin(0),marginLeft:"16px",listStyleType:"upper-alpha",listStylePosition:"inside"},ol3:{...P.padding(0),...P.margin(0),marginLeft:"16px",listStyleType:"lower-alpha",listStylePosition:"inside"},ol4:{...P.padding(0),...P.margin(0),marginLeft:"16px",listStyleType:"upper-roman",listStylePosition:"inside"},ol5:{...P.padding(0),...P.margin(0),marginLeft:"16px",listStyleType:"lower-roman",listStylePosition:"inside"},ul:{...P.padding(0),...P.margin(0),marginLeft:"16px",listStylePosition:"inside"},listItem:{...P.margin(0,"8px")},tokenComment:{color:"slategray"},tokenPunctuation:{color:"#999"},tokenProperty:{color:"#905"},tokenSelector:{color:"#690"},tokenOperator:{color:"#9a6e3a"},tokenAttr:{color:"#07a"},tokenVariable:{color:"#e90"},tokenFunction:{color:"#dd4a68"},embedBlock:{userSelect:"none"},embedBlockFocus:{...P.outline("2px solid rgb(60, 132, 244)")}});function xg(){const t=iC();return{blockCursor:"LexEditor_blockCursor",code:gt(t.code,"LexEditor_code"),codeHighlight:{atrule:t.tokenAttr,attr:t.tokenAttr,boolean:t.tokenProperty,builtin:t.tokenSelector,cdata:t.tokenComment,char:t.tokenSelector,class:t.tokenFunction,"class-name":t.tokenFunction,comment:t.tokenComment,constant:t.tokenProperty,deleted:t.tokenProperty,doctype:t.tokenComment,entity:t.tokenOperator,function:t.tokenFunction,important:t.tokenVariable,inserted:t.tokenSelector,namespace:t.tokenVariable,number:t.tokenProperty,operator:t.tokenOperator,prolog:t.tokenComment,property:t.tokenProperty,punctuation:t.tokenPunctuation,regex:t.tokenVariable,selector:t.tokenSelector,string:t.tokenSelector,symbol:t.tokenProperty,tag:t.tokenProperty,url:t.tokenOperator,variable:t.tokenVariable},embedBlock:{base:t.embedBlock,focus:t.embedBlockFocus},heading:{h1:t.h1,h2:t.h2,h3:t.h3},image:"LexEditor_Image",link:"LexEditor_link",list:{listitem:t.listItem,listitemChecked:"LexEditor_listItemChecked",listitemUnchecked:"LexEditor_listItemUnchecked",nested:{listitem:"LexEditor_nestedListItem"},olDepth:[t.ol1,t.ol2,t.ol3,t.ol4,t.ol5],ul:t.ul},ltr:t.ltr,mark:"LexEditor_mark",markOverlap:"LexEditor_markOverlap",paragraph:t.paragraph,quote:t.quote,rtl:t.rtl,table:t.table,tableAddColumns:gt(t.tableAddColumns,"LexEditor_tableAddColumns"),tableAddRows:gt(t.tableAddRows,"LexEditor_tableAddRows"),tableCell:t.tableCell,tableCellActionButton:t.tableCellActionButton,tableCellActionButtonContainer:t.tableCellActionButtonContainer,tableCellEditing:t.tableCellEditing,tableCellHeader:t.tableCellHeader,tableCellPrimarySelected:t.tableCellPrimarySelected,tableCellResizer:t.tableCellResizer,tableCellSelected:t.tableCellSelected,tableCellSortedIndicator:t.tableCellSortedIndicator,tableResizeRuler:t.tableCellResizeRuler,tableSelected:t.tableSelected,text:{bold:t.textBold,code:t.textCode,italic:t.textItalic,strikethrough:"LexEditor_textStrikethrough",subscript:t.textSubscript,superscript:t.textSuperscript,underline:"LexEditor_textUnderline",underlineStrikethrough:"LexEditor_textUnderlineStrikethrough"}}}var Ng={},oC=X,Ar=$,lC=typeof window<"u"&&typeof window.document<"u"&&typeof window.document.createElement<"u"?Ar.useLayoutEffect:Ar.useEffect;Ng.ContentEditable=function({ariaActiveDescendant:t,ariaAutoComplete:e,ariaControls:n,ariaDescribedBy:r,ariaExpanded:i,ariaLabel:o,ariaLabelledBy:l,ariaMultiline:s,ariaOwns:a,ariaRequired:c,autoCapitalize:g,className:d,id:u,role:f="textbox",spellCheck:h=!0,style:m,tabIndex:N,"data-testid":y}){let[_]=oC.useLexicalComposerContext(),[x,v]=Ar.useState(!1),S=Ar.useCallback(A=>{_.setRootElement(A)},[_]);return lC(()=>(v(_.isEditable()),_.registerEditableListener(A=>{v(A)})),[_]),Ar.createElement("div",{"aria-activedescendant":x?t:void 0,"aria-autocomplete":x?e:"none","aria-controls":x?n:void 0,"aria-describedby":r,"aria-expanded":x&&f==="combobox"?!!i:void 0,"aria-label":o,"aria-labelledby":l,"aria-multiline":s,"aria-owns":x?a:void 0,"aria-required":c,autoCapitalize:g,className:d,contentEditable:x,"data-testid":y,id:u,ref:S,role:x?f:void 0,spellCheck:h,style:m,tabIndex:N})};const sC=Ng;var aC=sC;const uC=it({root:{...P.border(0),fontSize:"15px",display:"block",position:"relative",tabSize:1,...P.outline(0),...P.padding("8px","28px"),minHeight:"calc(100% - 16px)"},table:{minHeight:"20px",...P.border(0),resize:"none",cursor:"text",display:"block",position:"relative",tabSize:1,...P.outline(0),...P.padding(0),userSelect:"text",fontSize:"15px",whiteSpace:"pre-wrap",wordBreak:"break-word",zIndex:3},display:{...P.padding(0)}});function Ya({className:t,table:e}){const n=uC(),{Display:r}=vc();return p.jsx(aC.ContentEditable,{className:gt("LexEditor_Content",t||e?n.table:n.root,!e&&r&&n.display)})}const cC=it({box:{fontSize:"15px",color:"#999",...P.overflow("hidden"),position:"absolute",textOverflow:"ellipsis",top:"8px",left:"28px",right:"28px",userSelect:"none",whiteSpace:"nowrap",display:"inline-block",pointerEvents:"none"}});function dC({children:t,className:e}){const n=cC();return p.jsx("div",{className:e||n.box,children:t})}const gC=it({shell:{lineHeight:"1.7"},container:{position:"relative"},noTreeView:{borderBottomLeftRadius:an.borderRadiusLarge,borderBottomRightRadius:an.borderRadiusLarge},scroller:{minHeight:"150px",...P.overflow("auto"),resize:"vertical"}});function fC(){of(X.useLexicalComposerContext()[0]);const{Namespace:t,OnError:e,Placeholder:n,Display:r,Plugin:{Actions:i,AutoFocus:o,AutoLink:l,CheckList:s,ClickableLink:a,CodeActionMenu:c,CodeHighlight:g,Collapsible:d,DraggableBlock:u,FloatingLinkEditor:f,FloatingTextFormatToolbar:h,HorizontalRule:m,Images:N,Link:y,ListMaxIndentLevel:_,List:x,MarkdownShortcut:v,TabFocus:S,TabIndentation:A,Table:w,Toolbar:B}}=vc(),k=p.jsx(dC,{children:n||"Let's say something awesome...."}),[K,Z]=$.useState(),ie=gC();return p.jsxs("div",{className:gt("LexEditor_Shell",ie.shell),children:[B&&p.jsx(rC,{}),p.jsxs("div",{className:gt(...r?[]:[ie.container,ie.noTreeView,ie.scroller]),ref:ot=>ot&&Z(ot),children:[o&&p.jsx(Fs.AutoFocusPlugin,{}),l&&p.jsx(Dm,{}),s&&p.jsx(vh.CheckListPlugin,{}),a&&p.jsx(Aa,{}),g&&p.jsx(Bm,{}),d&&p.jsx(zm,{}),m&&p.jsx(d_,{}),N&&p.jsx(Ia,{}),y&&p.jsx(Pa,{}),_&&p.jsx($_,{maxDepth:_}),x&&p.jsx(kh.ListPlugin,{}),v&&p.jsx(D_,{}),p.jsx(la.RichTextPlugin,{contentEditable:p.jsx(Ya,{}),placeholder:!r&&k,ErrorBoundary:qs}),S&&p.jsx(b_,{}),A&&p.jsx(Ep.TabIndentationPlugin,{}),w&&p.jsxs(W_,{cellEditorConfig:{namespace:t,nodes:[...Ip],onError:e,theme:xg()},children:[p.jsx(Fs.AutoFocusPlugin,{}),p.jsx(Aa,{}),p.jsx(ka,{}),p.jsx(Ia,{captionsEnabled:!1}),p.jsx(Pa,{}),p.jsx(la.RichTextPlugin,{contentEditable:p.jsx(Ya,{table:!0}),placeholder:null,ErrorBoundary:qs})]}),K&&p.jsxs(p.Fragment,{children:[i&&p.jsx(Em,{anchor:K}),c&&p.jsx(Fm,{anchor:K}),u&&p.jsx(qm,{anchor:K}),f&&p.jsx(l_,{anchor:K}),h&&p.jsx(ka,{anchor:K})]})]})]})}var En={},$t=C,di=V;class ei extends $t.ElementNode{static getType(){return"mark"}static clone(e){return new ei(Array.from(e.__ids),e.__key)}static importDOM(){return null}static importJSON(e){let n=Wi(e.ids);return n.setFormat(e.format),n.setIndent(e.indent),n.setDirection(e.direction),n}exportJSON(){return{...super.exportJSON(),ids:this.getIDs(),type:"mark",version:1}}constructor(e,n){super(n),this.__ids=e||[]}createDOM(e){let n=document.createElement("mark");return di.addClassNamesToElement(n,e.theme.mark),1{throw s},State:i,Placeholder:o,Display:l}){return n=l?!1:n,p.jsx(qf.LexicalComposer,{initialConfig:{editorState:i,namespace:t,nodes:[...CC],onError:r,theme:xg(),editable:n},children:p.jsx(th,{Namespace:t,Plugin:l?Qf:e,Editable:n,OnError:r,State:i,Placeholder:o,Display:l,children:p.jsx(z_,{children:p.jsx(fC,{})})})})}const vC=Object.freeze(Object.defineProperty({__proto__:null,default:xC},Symbol.toStringTag,{value:"Module"}));export{Nd as $,_g as C,kt as I,X as L,dC as P,rr as T,C as a,V as b,Fs as c,Pa as d,la as e,Ya as f,qs as g,k_ as h,Jh as i,yC as j,qh as k,F_ as l,Hi as m,fg as n,Pn as o,I_ as p,vC as q,Zp as u}; +`)},regExp:Vd,replace:(t,e,n)=>{const r=$a(n[0]);if(!r)return;const i=[r];let o=t.getPreviousSibling(),l=r.length;for(;o&&!(!C.$isParagraphNode(o)||o.getChildrenSize()!==1);){const c=o.getFirstChild();if(!C.$isTextNode(c))break;const g=$a(c.getTextContent());if(!g)break;l=Math.max(l,g.length),i.unshift(g);const d=o.getPreviousSibling();o.remove(),o=d}const s=He.$createTableNode();for(const c of i){const g=He.$createTableRowNode();s.append(g);for(let d=0;d{const e=He.$createTableCellNode(He.TableCellHeaderStates.NO_STATUS),n=C.$createParagraphNode();return t!=null&&n.append(C.$createTextNode(t.trim())),e.append(n),e},$a=t=>{const e=t.match(Vd);return!e||!e[1]?null:e[1].split("|").map(n=>Xd(n))},ol=[fm,dm,gm,Kr.CHECK_LIST,...Kr.TRANSFORMERS];function pm(){const[t]=X.useLexicalComposerContext(),e=$.useCallback(()=>t.update(()=>{const n=C.$getRoot(),r=n.getFirstChild();if(he.$isCodeNode(r)&&r.getLanguage()==="markdown")Kr.$convertFromMarkdownString(r.getTextContent(),ol);else{const i=Kr.$convertToMarkdownString(ol);n.clear().append(he.$createCodeNode("markdown").append(C.$createTextNode(i)))}n.selectEnd()}),[t]);return p.jsx(Va,{appearance:"outline",icon:p.jsx(Rg,{}),onClick:e})}var Yl={},mm=C;function _m(t){let e=document.createElement("input");e.type="file",e.accept=".lexical",e.addEventListener("change",n=>{if(n=n.target,n.files){n=n.files[0];let r=new FileReader;r.readAsText(n,"UTF-8"),r.onload=i=>{i.target&&t(i.target.result)}}}),e.click()}Yl.exportFile=function(t,e=Object.freeze({})){var n=new Date;t={editorState:t.getEditorState(),lastSaved:n.getTime(),source:e.source||"Lexical",version:"0.10.0"};{e=`${e.fileName||n.toISOString()}.lexical`,n=document.createElement("a");let r=document.body;r!==null&&(r.appendChild(n),n.style.display="none",t=JSON.stringify(t),t=new Blob([t],{type:"octet/stream"}),t=window.URL.createObjectURL(t),n.href=t,n.download=e,n.click(),window.URL.revokeObjectURL(t),n.remove())}};Yl.importFile=function(t){_m(e=>{e=JSON.parse(e),e=t.parseEditorState(JSON.stringify(e.editorState)),t.setEditorState(e),t.dispatchCommand(mm.CLEAR_HISTORY_COMMAND,void 0)})};const Cm=Yl;var Ra=Cm;function xm(){const[t]=X.useLexicalComposerContext();return p.jsxs(p.Fragment,{children:[p.jsx(Un,{appearance:"outline",icon:p.jsx(Ag,{}),onClick:()=>Ra.importFile(t)}),p.jsx(Un,{appearance:"outline",icon:p.jsx(Og,{}),onClick:()=>Ra.exportFile(t,{fileName:`Bunlog ${new Date().toISOString()}`,source:"Bunlog"})})]})}const Nm=it({box:{...uu,columnGap:"3px",position:"absolute",...P.padding("10px"),bottom:0,left:0}});function Em({anchor:t}){const e=Nm(),[n]=X.useLexicalComposerContext(),[r,i]=$.useState(()=>n.isEditable()),[o,l]=$.useState(!0);return $.useEffect(()=>V.mergeRegister(n.registerEditableListener(s=>i(s))),[n]),$.useEffect(()=>n.registerUpdateListener(({dirtyElements:s,prevEditorState:a,tags:c})=>{!r&&s.size>0&&!c.has("historic")&&!c.has("collaboration")&&console.debug(n.getEditorState()),n.getEditorState().read(()=>{const g=C.$getRoot().getChildren();g.length>1?l(!1):C.$isParagraphNode(g[0])?l(g[0].getChildren().length===0):l(!1)})}),[n,r]),p.jsx(Wr,{mountNode:t,children:p.jsxs("div",{className:e.box,children:[p.jsx(xm,{}),p.jsx(Pp,{}),p.jsx(pm,{})]})})}var Jl={},Xt=ce,Tm=X,ym=V,Rt=C,vm=$;function Zd(t,e){for(let n=0;nr.getLatest())}function Sm(t,e,n){vm.useEffect(()=>{if(!t.hasNodes([Xt.AutoLinkNode]))throw Error("Minified Lexical error #77; visit https://lexical.dev/docs/error?code=77 for the full message or use the non-minified dev environment for full errors and additional helpful warnings.");let r=(i,o)=>{n&&n(i,o)};return ym.mergeRegister(t.registerNodeTransform(Rt.TextNode,i=>{var o=i.getParentOrThrow(),l=i.getPreviousSibling();if(Xt.$isAutoLinkNode(o))$o(o,e,r);else if(!Xt.$isLinkNode(o)){if(i.isSimpleText()&&(en.test(i.getTextContent()[0])||!Xt.$isAutoLinkNode(l))){l=o=i.getTextContent();let f=0,h=i;for(var s;(s=Zd(l,e))&&s!==null;){let m=s.index,N=s.length,y=m+N;var a=f+m,c=f+y,g=o,d=i;if((0n){return n=>{let r=t.exec(n);return r===null?null:{index:r.index,length:r[0].length,text:r[0],url:e(n)}}};const $m=Jl;var Rm=$m;const Am=/((https?:\/\/(www\.)?)|(www\.))[-a-zA-Z0-9@:%._+~#=]{1,256}\.[a-zA-Z0-9()]{1,6}\b([-a-zA-Z0-9()@:%_+.~#?&//=]*)/,Om=/(([^<>()[\]\\.,;:\s@"]+(\.[^<>()[\]\\.,;:\s@"]+)*)|(".+"))@((\[[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\])|(([a-zA-Z\-0-9]+\.)+[a-zA-Z]{2,}))/,wm=[t=>{const e=Am.exec(t);if(!e)return null;const n=e[0];return{index:e.index,length:n.length,text:n,url:n.startsWith("http")?n:`https://${n}`}},t=>{const e=Om.exec(t);return e&&{index:e.index,length:e[0].length,text:e[0],url:`mailto:${e[0]}`}}];function Dm(){return p.jsx(Rm.AutoLinkPlugin,{matchers:wm})}function Aa({filter:t,newTab:e=!0}){const[n]=X.useLexicalComposerContext();return $.useEffect(()=>{function r(i){const o=i,l=Lm(o,n);if(!l)return;const s=l.getAttribute("href");if(l.getAttribute("contenteditable")==="false"||!s)return;const a=n.getEditorState().read(C.$getSelection);if(C.$isRangeSelection(a)&&!a.isCollapsed())return;let c;if(n.update(()=>{const g=C.$getNearestNodeFromDOMNode(l);ce.$isLinkNode(g)&&(c=g)}),!(!c||t&&!t(o,c)))try{if(s){const g=o.type==="auxclick"&&o.button===1;window.open(s,e||o.metaKey||o.ctrlKey||g?"_blank":"_self"),o.preventDefault()}}catch{}}return n.registerRootListener((i,o)=>{o&&(o.removeEventListener("click",r),o.removeEventListener("auxclick",r)),i&&(i.addEventListener("click",r),i.addEventListener("auxclick",r))})},[n,t,e]),null}function Oa(t){return t.nodeName.toLowerCase()==="a"}function Lm(t,e){return e.getEditorState().read(()=>{const n=t.target;return Oa(n)?n:n.parentNode&&Oa(n.parentNode)?n.parentNode:null})}const Mm=it({green:{color:an.colorPaletteLightGreenForeground3}});function bm({editor:t,getCodeDOMNode:e}){const[n,r]=$.useState(!1),{run:i}=Xa(()=>{r(!1)},{wait:1e3});async function o(){const s=e();if(!s)return;let a="";t.update(()=>{const c=C.$getNearestNodeFromDOMNode(s);he.$isCodeNode(c)&&(a=c.getTextContent());const g=C.$getSelection();C.$setSelection(g)});try{await navigator.clipboard.writeText(a),r(!0),i()}catch(c){console.error("Failed to copy: ",c)}}const l=Mm();return p.jsx(Un,{size:"small",appearance:"subtle",onClick:o,icon:n?p.jsx(wg,{className:l.green}):p.jsx(Dg,{})})}const km=8,Im=it({container:{height:"35.8px",fontSize:"10px",color:"rgba(0, 0, 0, 0.5)",position:"absolute",display:"flex",alignItems:"center",flexDirection:"row",userSelect:"none"},lang:{marginRight:"4px"}});function Pm(t){const e=t.target;if(e&&e instanceof HTMLElement){const n=e.closest("code.LexEditor_code"),r=!(n||e.closest("div.LexEditor_CodeMenu"));return{codeDOMNode:n,isOutside:r}}else return{codeDOMNode:null,isOutside:!0}}function Fm({anchor:t=document.body}){const[e]=X.useLexicalComposerContext(),[n,r]=$.useState(!1),[i,o]=$.useState(!1),[l,s]=$.useState(""),[a,c]=$.useState({right:"0",top:"0"}),g=$.useRef(new Set),d=$.useRef(null),{run:u,cancel:f}=Xa(N=>{const{codeDOMNode:y,isOutside:_}=Pm(N);if(_){r(!1);return}if(!y)return;d.current=y;let x=null,v="";if(e.update(()=>{const S=C.$getNearestNodeFromDOMNode(y);he.$isCodeNode(S)&&(x=S,v=x.getLanguage()||"")}),x){const{y:S,right:A}=t.getBoundingClientRect(),{y:w,right:B}=y.getBoundingClientRect();s(v),r(!0),c({right:`${A-B+km}px`,top:`${w-S}px`})}},{wait:100,maxWait:1e3});$.useEffect(()=>{if(i)return document.addEventListener("mousemove",u),()=>{r(!1),f(),document.removeEventListener("mousemove",u)}},[i,u]),e.registerMutationListener(he.CodeNode,N=>{e.getEditorState().read(()=>{for(const[y,_]of N)switch(_){case"created":g.current.add(y),o(g.current.size>0);break;case"destroyed":g.current.delete(y),o(g.current.size>0);break}})});const h=he.getLanguageFriendlyName(l),m=Im();return p.jsx(Wr,{mountNode:t,children:n&&p.jsxs("div",{className:gt(m.container,"LexEditor_CodeMenu"),style:a,children:[p.jsx("div",{className:m.lang,children:h}),p.jsx(bm,{editor:e,getCodeDOMNode:()=>d.current})]})})}function Bm(){const[t]=X.useLexicalComposerContext();return $.useEffect(()=>he.registerCodeHighlighting(t),[t]),null}class mn extends C.ElementNode{constructor(e,n){super(n),this.open=e,this.open=e}static getType(){return"collapsible-container"}static clone(e){return new mn(e.open,e.__key)}createDOM(e){const n=document.createElement("details");return n.classList.add("LexEditor_Collapsible"),n.open=this.open,n}updateDOM(e,n){return e.open!==this.open&&(n.open=this.open),!1}static importDOM(){return{}}static importJSON(e){return eg()}exportJSON(){return{...super.exportJSON(),type:"collapsible-container",version:1}}setOpen(e){const n=this.getWritable();n.open=e}getOpen(){return this.open}toggleOpen(){this.setOpen(!this.getOpen())}}function eg(){return new mn(!0)}function Qt(t){return t instanceof mn}class _n extends C.ElementNode{static getType(){return"collapsible-content"}static clone(e){return new _n(e.__key)}createDOM(e){const n=document.createElement("div");return n.classList.add("LexEditor_CollapsibleContent"),n}updateDOM(e,n){return!1}static importDOM(){return{}}static importJSON(e){return tg()}isShadowRoot(){return!0}exportJSON(){return{...super.exportJSON(),type:"collapsible-content",version:1}}}function tg(){return new _n}function ng(t){return t instanceof _n}class Cn extends C.ElementNode{static getType(){return"collapsible-title"}static clone(e){return new Cn(e.__key)}createDOM(e,n){const r=document.createElement("summary");return r.classList.add("LexEditor_CollapsibleTitle"),r}updateDOM(e,n){return!1}static importDOM(){return{}}static importJSON(e){return rg()}exportJSON(){return{...super.exportJSON(),type:"collapsible-title",version:1}}collapseAtStart(e){return this.getParentOrThrow().insertBefore(this),!0}insertNewAfter(e,n=!0){const r=this.getParentOrThrow();if(!Qt(r))throw new Error("CollapsibleTitleNode expects to be child of CollapsibleContainerNode");if(r.getOpen()){const i=this.getNextSibling();if(!ng(i))throw new Error("CollapsibleTitleNode expects to have CollapsibleContentNode sibling");const o=i.getFirstChild();if(C.$isElementNode(o))return o;{const l=C.$createParagraphNode();return i.append(l),l}}else{const i=C.$createParagraphNode();return r.insertAfter(i,n),i}}}function rg(){return new Cn}function wa(t){return t instanceof Cn}const ig=C.createCommand(),jm=C.createCommand();function zm(){const[t]=X.useLexicalComposerContext();return $.useEffect(()=>{if(!t.hasNodes([mn,Cn,_n]))throw new Error("CollapsiblePlugin: CollapsibleContainerNode, CollapsibleTitleNode, or CollapsibleContentNode not registered on editor");return V.mergeRegister(t.registerNodeTransform(_n,e=>{const n=e.getParent();if(!Qt(n)){const r=e.getChildren();for(const i of r)e.insertBefore(i);e.remove()}}),t.registerNodeTransform(Cn,e=>{const n=e.getParent();Qt(n)||e.replace(C.$createParagraphNode().append(...e.getChildren()))}),t.registerNodeTransform(mn,e=>{const n=e.getChildren();if(n.length!==2||!wa(n[0])||!ng(n[1])){for(const r of n)e.insertBefore(r);e.remove()}}),t.registerCommand(C.DELETE_CHARACTER_COMMAND,()=>{const e=C.$getSelection();if(!C.$isRangeSelection(e)||!e.isCollapsed()||e.anchor.offset!==0)return!1;const r=e.anchor.getNode().getTopLevelElement();if(!r)return!1;const i=r.getPreviousSibling();return!Qt(i)||i.getOpen()?!1:(i.setOpen(!0),!0)},C.COMMAND_PRIORITY_LOW),t.registerCommand(C.KEY_ARROW_DOWN_COMMAND,()=>{const e=C.$getSelection();if(!C.$isRangeSelection(e)||!e.isCollapsed())return!1;const n=V.$findMatchingParent(e.anchor.getNode(),Qt);if(!n)return!1;const r=n.getParent();return r&&r.getLastChild()===n&&r.append(C.$createParagraphNode()),!1},C.COMMAND_PRIORITY_LOW),t.registerCommand(C.INSERT_PARAGRAPH_COMMAND,()=>{const e=t._window?.event;if(e&&(e.ctrlKey||e.metaKey)&&e.key==="Enter"){const n=C.$getPreviousSelection();if(C.$isRangeSelection(n)&&n.isCollapsed()){const r=V.$findMatchingParent(n.anchor.getNode(),i=>C.$isElementNode(i)&&!i.isInline());if(wa(r)){const i=r.getParent();if(Qt(i))return i.toggleOpen(),C.$setSelection(n.clone()),!0}}}return!1},C.COMMAND_PRIORITY_LOW),t.registerCommand(ig,()=>(t.update(()=>{const e=C.$getSelection();if(!C.$isRangeSelection(e))return;const n=rg(),r=tg().append(C.$createParagraphNode()),i=eg().append(n,r);e.insertNodes([i]),n.selectStart()}),!0),C.COMMAND_PRIORITY_EDITOR),t.registerCommand(jm,e=>(t.update(()=>{const n=C.$getNodeByKey(e);Qt(n)&&n.toggleOpen()}),!0),C.COMMAND_PRIORITY_EDITOR))},[t]),null}function Ro(t){return t instanceof HTMLElement}class og{constructor(e,n){this.x=e,this.y=n}equals({x:e,y:n}){return this.x===e&&this.y===n}calcDeltaXTo({x:e}){return this.x-e}calcDeltaYTo({y:e}){return this.y-e}calcHorizontalDistanceTo(e){return Math.abs(this.calcDeltaXTo(e))}calcVerticalDistance(e){return Math.abs(this.calcDeltaYTo(e))}calcDistanceTo(e){return Math.sqrt(Math.pow(this.calcDeltaXTo(e),2)+Math.pow(this.calcDeltaYTo(e),2))}}function Km(t){return t instanceof og}class tn{_left;_top;_right;_bottom;constructor(e,n,r,i){const[o,l]=n<=i?[n,i]:[i,n],[s,a]=e<=r?[e,r]:[r,e];this._top=o,this._right=a,this._left=s,this._bottom=l}get top(){return this._top}get right(){return this._right}get bottom(){return this._bottom}get left(){return this._left}get width(){return Math.abs(this._left-this._right)}get height(){return Math.abs(this._bottom-this._top)}equals({top:e,left:n,bottom:r,right:i}){return e===this._top&&r===this._bottom&&n===this._left&&i===this._right}contains(e){if(Km(e)){const{x:n,y:r}=e,i=rthis._bottom,l=nthis._right;return{reason:{isOnBottomSide:o,isOnLeftSide:l,isOnRightSide:s,isOnTopSide:i},result:!i&&!o&&!l&&!s}}else{const{top:n,left:r,bottom:i,right:o}=e;return n>=this._top&&n<=this._bottom&&i>=this._top&&i<=this._bottom&&r>=this._left&&r<=this._right&&o>=this._left&&o<=this._right}}intersectsWith(e){const{left:n,top:r,width:i,height:o}=e,{left:l,top:s,width:a,height:c}=this,g=n+i>=l+a?n+i:l+a,d=r+o>=s+c?r+o:s+c,u=n<=l?n:l,f=r<=s?r:s;return g-u<=i+a&&d-f<=o+c}generateNewRect({left:e=this.left,top:n=this.top,right:r=this.right,bottom:i=this.bottom}){return new tn(e,n,r,i)}static fromLTRB(e,n,r,i){return new tn(e,n,r,i)}static fromLWTH(e,n,r,i){return new tn(e,r,e+n,r+i)}static fromPoints(e,n){const{y:r,x:i}=e,{y:o,x:l}=n;return tn.fromLTRB(i,r,l,o)}static fromDOM(e){const{top:n,width:r,left:i,height:o}=e.getBoundingClientRect();return tn.fromLWTH(i,r,n,o)}}let Ei=1/0;function Hm(t){return t===0?1/0:Ei>=0&&EiC.$getRoot().getChildrenKeys())}const Da=0;function Ao(t,e,n){const r=t.getBoundingClientRect(),i=Wm(e);let o=null;return e.getEditorState().read(()=>{let l=Hm(i.length),s=Da;for(;l>=0&&le.style.transform=n)}const La=28;function Jm(t,e,n,r){const i=window.getComputedStyle(e),{top:o,height:l}=e.getBoundingClientRect(),{top:s,width:a}=r.getBoundingClientRect();let c=o;n-o>l/2?c+=l+parseFloat(i.marginBottom):c-=parseFloat(i.marginTop);const g=c-s-2,d=La-ll;t.style.transform=`translate(${d}px, ${g}px)`,t.style.width=`${a-(La-ll)*2}px`,t.style.opacity=".4"}function Vm(t){t&&(t.style.opacity="0",t.style.transform="translate(-10000px, -10000px)")}const Ma="application/x-lexical-drag-block";function Xm({editor:t,anchor:e}){const n=e.parentElement,r=$.useRef(null),i=$.useRef(null),[o,l]=$.useState(null);$.useEffect(()=>{function g(u){const f=u.target;if(!Ro(f)){l(null);return}if(Um(f))return;const h=Ao(e,t,u);l(h)}function d(){l(null)}return n?.addEventListener("mousemove",g),n?.addEventListener("mouseleave",d),()=>{n?.removeEventListener("mousemove",g),n?.removeEventListener("mouseleave",d)}},[n,e,t]),$.useEffect(()=>{r.current&&Gm(o,r.current,e)},[e,o]),$.useEffect(()=>{function g(u){const[f]=rt.eventFiles(u);if(f)return!1;const{pageY:h,target:m}=u;if(!Ro(m))return!1;const N=Ao(e,t,u),y=i.current;return!N||!y?!1:(Jm(y,N,h,e),u.preventDefault(),!0)}function d(u){const[f]=rt.eventFiles(u);if(f)return!1;const{target:h,dataTransfer:m,pageY:N}=u,y=m?.getData(Ma)||"",_=C.$getNodeByKey(y);if(!_||!Ro(h))return!1;const x=Ao(e,t,u);if(!x)return!1;const v=C.$getNearestNodeFromDOMNode(x);if(!v)return!1;if(v===_)return!0;const{top:S,height:A}=x.getBoundingClientRect();return N-S>A/2?v.insertAfter(_):v.insertBefore(_),l(null),!0}return V.mergeRegister(t.registerCommand(C.DRAGOVER_COMMAND,u=>g(u),C.COMMAND_PRIORITY_LOW),t.registerCommand(C.DROP_COMMAND,u=>d(u),C.COMMAND_PRIORITY_HIGH))},[e,t]);function s(g){const d=g.dataTransfer;if(!d||!o)return;Ym(d,o);let u="";t.update(()=>{const f=C.$getNearestNodeFromDOMNode(o);f&&(u=f.getKey())}),d.setData(Ma,u)}function a(){Vm(i.current)}const c=Zm();return p.jsxs(Wr,{mountNode:e,children:[p.jsx("div",{className:gt("LexEditor_Draggable",c.meun),ref:r,draggable:!0,onDragStart:s,onDragEnd:a,children:p.jsx("div",{className:t._editable?gt(c.icon,"LexEditor_DraggableIcon"):""})}),p.jsx("div",{className:c.line,ref:i})]})}const Zm=it({meun:{...P.borderRadius("4px"),...P.padding("2px","1px"),cursor:"grab",opacity:0,position:"absolute",left:0,top:0,willChange:"transform",":active":{cursor:"grabbing"},":hover":{backgroundColor:"#efefef"}},icon:{width:"16px",height:"16px",opacity:.3},line:{pointerEvents:"none",backgroundColor:"deepskyblue",height:"4px",position:"absolute",left:0,top:0,opacity:0,willChange:"transform"}});function qm({anchor:t=document.body}){const[e]=X.useLexicalComposerContext();return p.jsx(Xm,{anchor:t,editor:e})}function so(t){const e=t.anchor,n=t.focus,r=t.anchor.getNode(),i=t.focus.getNode();return r===i?r:t.isBackward()?Se.$isAtNodeEnd(n)?r:i:Se.$isAtNodeEnd(e)?r:i}const Qm=10,e_=5;function sl(t,e,n,r=Qm,i=e_){const o=n.parentElement;if(!t||!o){e.style.opacity="0",e.style.transform="translate(-10000px, -10000px)";return}const l=e.getBoundingClientRect(),s=n.getBoundingClientRect(),a=o.getBoundingClientRect();let c=t.top-l.height-r,g=t.left-i;ca.right&&(g=a.right-l.width-i),c-=s.top,g-=s.left,e.style.opacity="1",e.style.transform=`translate(${g}px, ${c}px)`}function lg(t){const e=/^(?:(?:https?|mailto|ftp|tel|file|sms):|[^&:/?#]*(?:[/?#]|$))/gi,n=/^data:(?:image\/(?:bmp|gif|jpeg|jpg|png|tiff|webp)|video\/(?:mpeg|mp4|ogg|webm)|audio\/(?:mp3|oga|ogg|opus));base64,[a-z0-9+/]+=*$/i;return t=String(t).trim(),t.match(e)||t.match(n)?t:"https://"}const t_=new RegExp(/((([A-Za-z]{3,9}:(?:\/\/)?)(?:[-;:&=+$,\w]+@)?[A-Za-z0-9.-]+|(?:www.|[-;:&=+$,\w]+@)[A-Za-z0-9.-]+)((?:\/[+~%/.\w-_]*)?\??(?:[-+=&;%@.\w_]*)#?(?:[\w]*))?)/);function n_(t){return t==="https://"||t_.test(t)}function r_({editor:t,isLink:e,setIsLink:n,anchor:r}){const i=$.useRef(null),o=$.useRef(null),[l,s]=$.useState(""),[a,c]=$.useState(!1),[g,d]=$.useState(),u=$.useCallback(()=>{const h=C.$getSelection();if(C.$isRangeSelection(h)){const x=so(h),v=x.getParent();ce.$isLinkNode(v)?s(v.getURL()):ce.$isLinkNode(x)?s(x.getURL()):s("")}const m=i.current,N=window.getSelection(),y=document.activeElement;if(!m)return;const _=t.getRootElement();if(h&&N&&_&&_.contains(N.anchorNode)&&t.isEditable()){const x=N.getRangeAt(0);let v;if(N.anchorNode===_){let S=_;for(;S.firstElementChild;)S=S.firstElementChild;v=S.getBoundingClientRect()}else v=x.getBoundingClientRect();sl(v,m,r),d(h)}else(!y||y.className!=="link-input")&&(_&&sl(null,m,r),d(void 0),c(!1),s(""));return!0},[r,t]);$.useEffect(()=>{const h=r.parentElement;function m(){t.getEditorState().read(()=>u())}return window.addEventListener("resize",m),h&&h.addEventListener("scroll",m),()=>{window.removeEventListener("resize",m),h&&h.removeEventListener("scroll",m)}},[r.parentElement,t,u]),$.useEffect(()=>V.mergeRegister(t.registerUpdateListener(({editorState:h})=>h.read(()=>u())),t.registerCommand(C.SELECTION_CHANGE_COMMAND,()=>(u(),!0),C.COMMAND_PRIORITY_LOW),t.registerCommand(C.KEY_ESCAPE_COMMAND,()=>e?(n(!1),!0):!1,C.COMMAND_PRIORITY_HIGH)),[t,u,n,e]),$.useEffect(()=>{t.getEditorState().read(()=>u())},[t,u]),$.useEffect(()=>{a&&o.current&&o.current.focus()},[a]);const f=i_();return p.jsx("div",{ref:i,style:{transition:"opacity 0.5s"},className:f.editor,children:a?p.jsx(Gn,{ref:o,className:f.input,value:l,onChange:(h,m)=>s(m.value),onKeyDown:h=>{h.key==="Enter"?(h.preventDefault(),g&&(l&&t.dispatchCommand(ce.TOGGLE_LINK_COMMAND,lg(l)),c(!1))):h.key==="Escape"&&(h.preventDefault(),c(!1))}}):p.jsxs("div",{className:f.link,children:[p.jsx(Lg,{href:l,target:"_blank",rel:"noopener noreferrer",className:f.a,children:l}),p.jsx(Un,{appearance:"subtle",icon:p.jsx(Mg,{}),onClick:()=>c(!0)})]})})}const ba={...P.margin("8px","10px"),...P.padding("4px","12px")},i_=it({editor:{...cu,...rf,position:"absolute",top:0,left:0,maxWidth:"400px",width:"100%",opacity:0,willChange:"transform"},a:{whiteSpace:"nowrap",...P.overflow("hidden"),textOverflow:"ellipsis"},link:{...uu,justifyContent:"space-between",alignItems:"center",width:"calc(100% - 20px)",boxSizing:"border-box",...P.borderRadius(an.borderRadiusMedium),backgroundColor:"#eee",position:"relative",...ba},input:ba});function o_({editor:t,anchor:e}){const[n,r]=$.useState(t),[i,o]=$.useState(!1);return $.useEffect(()=>t.registerCommand(C.SELECTION_CHANGE_COMMAND,(l,s)=>{const a=C.$getSelection();if(C.$isRangeSelection(a)){const c=so(a),g=V.$findMatchingParent(c,ce.$isLinkNode),d=V.$findMatchingParent(c,ce.$isAutoLinkNode);o(!!(g&&!d))}return r(s),!1},C.COMMAND_PRIORITY_CRITICAL),[t]),i&&p.jsx(Wr,{mountNode:e,children:p.jsx(r_,{editor:n,isLink:i,anchor:e,setIsLink:o})})}function l_({anchor:t=document.body}){const[e]=X.useLexicalComposerContext();return p.jsx(o_,{editor:e,anchor:t})}function s_(t,e){const n=t.getRangeAt(0);let r;if(t.anchorNode===e){let i=e;for(;i.firstElementChild;)i=i.firstElementChild;r=i.getBoundingClientRect()}else r=n.getBoundingClientRect();return r}function a_({editor:t,anchor:e,isLink:n,isBold:r,isItalic:i,isUnderline:o,isCode:l,isStrikethrough:s,isSubscript:a,isSuperscript:c}){const g=$.useRef(null),d=$.useCallback(()=>{n?t.dispatchCommand(ce.TOGGLE_LINK_COMMAND,null):t.dispatchCommand(ce.TOGGLE_LINK_COMMAND,"https://")},[t,n]),u=$.useCallback(()=>{const m=C.$getSelection(),N=g.current,y=window.getSelection();if(!N)return;const _=t.getRootElement();if(m&&y&&!y.isCollapsed&&_&&_.contains(y.anchorNode)){const x=s_(y,_);sl(x,N,e)}},[t,e]);$.useEffect(()=>{const m=e.parentElement;function N(){t.getEditorState().read(()=>u())}return window.addEventListener("resize",N),m&&m.addEventListener("scroll",N),()=>{window.removeEventListener("resize",N),m&&m.removeEventListener("scroll",N)}},[t,u,e]),$.useEffect(()=>(t.getEditorState().read(()=>u()),V.mergeRegister(t.registerUpdateListener(({editorState:m})=>m.read(()=>u())),t.registerCommand(C.SELECTION_CHANGE_COMMAND,()=>(u(),!1),C.COMMAND_PRIORITY_LOW))),[t,u]);const f=[r&&"bold",i&&"italic",o&&"underline",l&&"code",s&&"strikethrough",a&&"subscript",c&&"superscript",n&&"link"],h=u_();return p.jsxs(Za,{ref:g,className:h.toolbar,style:{transition:"opacity 0.5s"},checkedValues:{opts:f},children:[p.jsx(Le,{name:"opts",value:"bold",appearance:"subtle","aria-label":"Format text as bold",icon:p.jsx(qa,{}),onClick:()=>t.dispatchCommand(C.FORMAT_TEXT_COMMAND,"bold")}),p.jsx(Le,{name:"opts",value:"italic",appearance:"subtle","aria-label":"Format text as italics",icon:p.jsx(Qa,{}),onClick:()=>t.dispatchCommand(C.FORMAT_TEXT_COMMAND,"italic")}),p.jsx(Le,{name:"opts",value:"underline",appearance:"subtle","aria-label":"Format text to underlined",icon:p.jsx(eu,{}),onClick:()=>t.dispatchCommand(C.FORMAT_TEXT_COMMAND,"underline")}),p.jsx(Le,{name:"opts",value:"strikethrough",appearance:"subtle","aria-label":"Format text with a strikethrough",icon:p.jsx(tu,{}),onClick:()=>t.dispatchCommand(C.FORMAT_TEXT_COMMAND,"strikethrough")}),p.jsx(Le,{name:"opts",value:"subscript",appearance:"subtle","aria-label":"Format Subscript",icon:p.jsx(nu,{}),onClick:()=>t.dispatchCommand(C.FORMAT_TEXT_COMMAND,"subscript")}),p.jsx(Le,{name:"opts",value:"superscript",appearance:"subtle","aria-label":"Format Superscript",icon:p.jsx(ru,{}),onClick:()=>t.dispatchCommand(C.FORMAT_TEXT_COMMAND,"superscript")}),p.jsx(Le,{name:"opts",value:"code",appearance:"subtle","aria-label":"Insert code block",icon:p.jsx(Ti,{}),onClick:()=>t.dispatchCommand(C.FORMAT_TEXT_COMMAND,"code")}),p.jsx(Le,{name:"opts",value:"link",appearance:"subtle","aria-label":"Insert link",icon:p.jsx(iu,{}),onClick:d})]})}const u_=it({toolbar:{...cu,...P.padding("4px"),verticalAlign:"middle",position:"absolute",top:0,left:0,opacity:0,height:"35px",willChange:"transform"}});function c_({editor:t,anchor:e}){const[n,r]=$.useState(!1),[i,o]=$.useState(!1),[l,s]=$.useState(!1),[a,c]=$.useState(!1),[g,d]=$.useState(!1),[u,f]=$.useState(!1),[h,m]=$.useState(!1),[N,y]=$.useState(!1),[_,x]=$.useState(!1),v=$.useCallback(()=>{t.getEditorState().read(()=>{if(t.isComposing())return;const S=C.$getSelection(),A=window.getSelection(),w=t.getRootElement();if(A&&(!C.$isRangeSelection(S)||!w||!w.contains(A.anchorNode))){r(!1);return}if(!C.$isRangeSelection(S))return;const B=so(S);s(S.hasFormat("bold")),c(S.hasFormat("italic")),d(S.hasFormat("underline")),f(S.hasFormat("strikethrough")),m(S.hasFormat("subscript")),y(S.hasFormat("superscript")),x(S.hasFormat("code"));const k=B.getParent();ce.$isLinkNode(k)||ce.$isLinkNode(B)?o(!0):o(!1),!he.$isCodeHighlightNode(S.anchor.getNode())&&S.getTextContent()?r(C.$isTextNode(B)):r(!1)})},[t]);return $.useEffect(()=>(document.addEventListener("selectionchange",v),()=>document.removeEventListener("selectionchange",v)),[v]),$.useEffect(()=>V.mergeRegister(t.registerUpdateListener(()=>v()),t.registerRootListener(()=>{t.getRootElement()||r(!1)})),[t,v]),!n||i?null:p.jsx(Wr,{mountNode:e,children:p.jsx(a_,{editor:t,anchor:e,isLink:i,isBold:l,isItalic:a,isStrikethrough:u,isSubscript:h,isSuperscript:N,isUnderline:g,isCode:_})})}function ka({anchor:t=document.body}){const[e]=X.useLexicalComposerContext();return p.jsx(c_,{editor:e,anchor:t})}function d_(){const[t]=X.useLexicalComposerContext();return $.useEffect(()=>t.registerCommand(jt.INSERT_HORIZONTAL_RULE_COMMAND,e=>{const n=C.$getSelection();if(!C.$isRangeSelection(n))return!1;if(n.focus.getNode()){const i=jt.$createHorizontalRuleNode();V.$insertNodeToNearestRoot(i)}return!0},C.COMMAND_PRIORITY_EDITOR),[t]),null}const Vl=C.createCommand("INSERT_IMAGE_COMMAND");function g_({editor:t}){const[e,n]=$.useState("https://source.unsplash.com/random"),[r,i]=$.useState(du.Name);return p.jsxs(ou,{children:[p.jsx(lu,{children:"Insert Image"}),p.jsxs(su,{children:[p.jsx(Or,{label:"Source",required:!0,children:p.jsx(Gn,{placeholder:e,onChange:(o,l)=>n(l.value||"")})}),p.jsx(Or,{label:"Alt Text",required:!0,children:p.jsx(Gn,{placeholder:r,onChange:(o,l)=>i(l.value||"")})})]}),p.jsx(au,{children:p.jsx(yi,{disableButtonEnhancement:!0,children:p.jsx(Un,{onClick:()=>{t.dispatchCommand(Vl,{altText:r,src:e})},children:"Confirm"})})})]})}function Ia({captionsEnabled:t}){const[e]=X.useLexicalComposerContext();return $.useEffect(()=>{if(!e.hasNodes([Ut]))throw new Error("ImagesPlugin: ImageNode not registered on editor");return V.mergeRegister(e.registerCommand(Vl,n=>{const r=ro(n);return C.$insertNodes([r]),C.$isRootOrShadowRoot(r.getParentOrThrow())&&V.$wrapNodeInElement(r,C.$createParagraphNode).selectEnd(),!0},C.COMMAND_PRIORITY_EDITOR),e.registerCommand(C.DRAGSTART_COMMAND,n=>h_(n),C.COMMAND_PRIORITY_HIGH),e.registerCommand(C.DRAGOVER_COMMAND,n=>p_(n),C.COMMAND_PRIORITY_LOW),e.registerCommand(C.DROP_COMMAND,n=>m_(n,e),C.COMMAND_PRIORITY_HIGH))},[t,e]),null}const f_="data:image/gif;base64,R0lGODlhAQABAIAAAAAAAP///yH5BAEAAAAALAAAAAABAAEAAAIBRAA7",sg=document.createElement("img");sg.src=f_;function h_(t){const e=Xl();if(!e)return!1;const n=t.dataTransfer;return n?(n.setData("text/plain","_"),n.setDragImage(sg,0,0),n.setData("application/x-lexical-drag",JSON.stringify({data:{altText:e.altText,caption:e.caption,height:e.height,key:e.getKey(),maxWidth:e.maxWidth,showCaption:e.showCaption,src:e.src,width:e.width},type:"image"})),!0):!1}function p_(t){return Xl()?(ag(t)||t.preventDefault(),!0):!1}function m_(t,e){const n=Xl();if(!n)return!1;const r=__(t);if(!r)return!1;if(t.preventDefault(),ag(t)){const i=C_(t);n.remove();const o=C.$createRangeSelection();i&&o.applyDOMRange(i),C.$setSelection(o),e.dispatchCommand(Vl,r)}return!0}function Xl(){const t=C.$getSelection();if(!C.$isNodeSelection(t))return null;const n=t.getNodes()[0];return Nd(n)?n:null}function __(t){const e=t.dataTransfer?.getData("application/x-lexical-drag");if(!e)return null;const{type:n,data:r}=JSON.parse(e);return n!=="image"?null:r}function ag(t){const e=t.target;return!!(e&&e instanceof HTMLElement&&!e.closest("code, span.LexEditor_Image")&&e.parentElement&&e.parentElement.closest("div.LexEditor_Content"))}function C_(t){let e;const n=window.getSelection();if(document.caretRangeFromPoint)e=document.caretRangeFromPoint(t.clientX,t.clientY);else if(t.rangeParent&&n)n.collapse(t.rangeParent,t.rangeOffset||0),e=n.getRangeAt(0);else throw Error("Cannot get the selection when dragging");return e}var ug={},wn=ce,x_=X,N_=V,Dn=C,E_=$;ug.LinkPlugin=function({validateUrl:t}){let[e]=x_.useLexicalComposerContext();return E_.useEffect(()=>{if(!e.hasNodes([wn.LinkNode]))throw Error("LinkPlugin: LinkNode not registered on editor");return N_.mergeRegister(e.registerCommand(wn.TOGGLE_LINK_COMMAND,n=>{if(n===null)return wn.toggleLink(n),!0;if(typeof n=="string")return t===void 0||t(n)?(wn.toggleLink(n),!0):!1;let{url:r,target:i,rel:o,title:l}=n;return wn.toggleLink(r,{rel:o,target:i,title:l}),!0},Dn.COMMAND_PRIORITY_LOW),t!==void 0?e.registerCommand(Dn.PASTE_COMMAND,n=>{let r=Dn.$getSelection();if(!Dn.$isRangeSelection(r)||r.isCollapsed()||!(n instanceof ClipboardEvent)||n.clipboardData==null)return!1;let i=n.clipboardData.getData("text");return t(i)?r.getNodes().some(o=>Dn.$isElementNode(o))?!1:(e.dispatchCommand(wn.TOGGLE_LINK_COMMAND,i),n.preventDefault(),!0):!1},Dn.COMMAND_PRIORITY_LOW):()=>{})},[e,t]),null};const T_=ug;var y_=T_;function Pa(){return p.jsx(y_.LinkPlugin,{validateUrl:n_})}function v_(t){const e=t.getNodes();return e.length===0?new Set([t.anchor.getNode().getParentOrThrow(),t.focus.getNode().getParentOrThrow()]):new Set(e.map(n=>C.$isElementNode(n)?n:n.getParentOrThrow()))}function S_(t){const e=C.$getSelection();if(!C.$isRangeSelection(e))return!1;const n=v_(e);let r=0;for(const i of n)if(fe.$isListNode(i))r=Math.max(fe.$getListDepth(i)+1,r);else if(fe.$isListItemNode(i)){const o=i.getParent();if(!fe.$isListNode(o))throw new Error("ListMaxIndentLevelPlugin: A ListItemNode must have a ListNode for a parent.");r=Math.max(fe.$getListDepth(o)+1,r)}return r<=t}function $_({maxDepth:t}){const[e]=X.useLexicalComposerContext();return $.useEffect(()=>e.registerCommand(C.INDENT_CONTENT_COMMAND,()=>!S_(t??7),C.COMMAND_PRIORITY_CRITICAL),[e,t]),null}var Zl={},cg=Kr,R_=X,Oo=jt,A_=$;let dg=[{dependencies:[Oo.HorizontalRuleNode],export:t=>Oo.$isHorizontalRuleNode(t)?"***":null,regExp:/^(---|\*\*\*|___)\s?$/,replace:(t,e,n,r)=>{e=Oo.$createHorizontalRuleNode(),r||t.getNextSibling()!=null?t.replace(e):t.insertBefore(e),e.selectNext()},type:"element"},...cg.TRANSFORMERS];Zl.DEFAULT_TRANSFORMERS=dg;Zl.MarkdownShortcutPlugin=function({transformers:t=dg}){let[e]=R_.useLexicalComposerContext();return A_.useEffect(()=>cg.registerMarkdownShortcuts(e,t),[e,t]),null};const O_=Zl;var w_=O_;function D_(){return p.jsx(w_.MarkdownShortcutPlugin,{transformers:ol})}const L_=100;let gg=0,Fa=!1;function M_(){window.addEventListener("keydown",t=>{t.keyCode===9&&(gg=t.timeStamp)},!0)}function b_(){const[t]=X.useLexicalComposerContext();return $.useEffect(()=>(Fa||(M_(),Fa=!0),t.registerCommand(C.FOCUS_COMMAND,e=>{const n=C.$getSelection();return C.$isRangeSelection(n)&&gg+L_>e.timeStamp&&C.$setSelection(n.clone()),!1},C.COMMAND_PRIORITY_LOW)),[t]),null}function fg(){return Math.random().toString(36).replace(/[^a-z]+/g,"").substring(0,5)}const k_=new Map,yC=new Map,hg='{"root":{"children":[{"children":[],"direction":null,"format":"","indent":0,"type":"paragraph","version":1}],"direction":null,"format":"","indent":0,"type":"root","version":1}}';function I_(t){return t?`{"root":{"children":[{"children":[{"detail":0,"format":0,"mode":"normal","style":"","text":${t},"type":"text","version":1}],"direction":"ltr","format":"","indent":0,"type":"paragraph","version":1}],"direction":"ltr","format":"","indent":0,"type":"root","version":1}}`:hg}function Pn(t){return{colSpan:1,id:fg(),json:hg,type:t,width:null}}function Hi(){return{cells:[],height:null,id:fg()}}function P_(t){const e=t.querySelectorAll("tr");if(!e||e.length===0)return null;const n=[];for(let r=0;r({conversion:P_,priority:0})}}exportDOM(){return{element:F_(this.rows)}}createDOM(){const e=document.createElement("div");return e.style.display="contents",e}updateDOM(){return!1}mergeRows(e,n,r){const o=this.getWritable().rows,l=Math.min(o.length,n+r.length);for(let s=n;sJa(()=>import("./Component-4YKDN3nt.js"),__vite__mapDeps([5,1,2,3,4])));function j_(t,e,...n){if(!t)throw new Error("Internal Lexical error: invariant() is meant to be replaced at compile time. There is no runtime version. Error: "+e)}const mg=C.createCommand("INSERT_NEW_TABLE_COMMAND"),_g=$.createContext({cellEditorConfig:null,cellEditorPlugins:null,set:()=>{}});function z_({children:t}){const[e,n]=$.useState({cellEditorConfig:null,cellEditorPlugins:null});return p.jsx(_g.Provider,{value:$.useMemo(()=>({cellEditorConfig:e.cellEditorConfig,cellEditorPlugins:e.cellEditorPlugins,set:(r,i)=>n({cellEditorConfig:r,cellEditorPlugins:i})}),[e.cellEditorConfig,e.cellEditorPlugins]),children:t})}function K_({editor:t}){const[e,n]=$.useState("5"),[r,i]=$.useState("5");return p.jsxs(ou,{children:[p.jsx(lu,{children:"Insert Table"}),p.jsxs(su,{children:[p.jsx(Or,{label:"Rows",required:!0,children:p.jsx(Gn,{placeholder:e,onChange:(o,l)=>l&&n(l.value)})}),p.jsx(Or,{label:"Cols",required:!0,children:p.jsx(Gn,{placeholder:r,onChange:(o,l)=>l&&i(l.value)})})]}),p.jsx(au,{children:p.jsx(yi,{disableButtonEnhancement:!0,children:p.jsx(Un,{onClick:()=>{t.dispatchCommand(mg,{columns:r,rows:e})},children:"Confirm"})})})]})}function H_(t,e,n=!0){const r=[];for(let i=0;i(n.hasNodes([rr])||j_(!1,"TablePlugin: TableNode is not registered on editor"),r.set(t,e),n.registerCommand(mg,({columns:i,rows:o,includeHeaders:l})=>{const s=C.$getSelection();if(!C.$isRangeSelection(s))return!0;const a=s.focus,c=a.getNode();if(c){const g=H_(Number(o),Number(i),l);if(C.$isRootOrShadowRoot(c)){const u=c.getChildAtIndex(a.offset);u?u.insertBefore(g):c.append(g),g.insertBefore(C.$createParagraphNode())}else c.getTopLevelElementOrThrow().insertAfter(g);g.insertAfter(C.$createParagraphNode());const d=C.$createNodeSelection();d.add(g.getKey()),C.$setSelection(d)}return!0},C.COMMAND_PRIORITY_EDITOR)),[r,t,e,n]),null}var ql={},U_=C;class Cg extends U_.DecoratorNode{constructor(e,n){super(n),this.__format=e||""}exportJSON(){return{format:this.__format||"",type:"decorator-block",version:1}}createDOM(){return document.createElement("div")}updateDOM(){return!1}setFormat(e){this.getWritable().__format=e}}ql.$isDecoratorBlockNode=function(t){return t instanceof Cg};ql.DecoratorBlockNode=Cg;const G_=ql;var Y_=G_;const J_="documentMode"in document?document.documentMode:null,kt=/Mac|iPod|iPhone|iPad/.test(navigator.platform);"InputEvent"in window&&!J_&&"getTargetRanges"in new window.InputEvent("input");const al={bullet:"Bulleted List",check:"Check List",code:"Code Block",h1:"Heading 1",h2:"Heading 2",h3:"Heading 3",h4:"Heading 4",h5:"Heading 5",h6:"Heading 6",number:"Numbered List",paragraph:"Normal",quote:"Quote"};function V_({editor:t,blockType:e,disabled:n=!1}){function r(){e!=="paragraph"&&t.update(()=>{const g=C.$getSelection();(C.$isRangeSelection(g)||C.DEPRECATED_$isGridSelection(g))&&Se.$setBlocksType(g,()=>C.$createParagraphNode())})}function i(g){e!==g&&t.update(()=>{const d=C.$getSelection();(C.$isRangeSelection(d)||C.DEPRECATED_$isGridSelection(d))&&Se.$setBlocksType(d,()=>rt.$createHeadingNode(g))})}function o(){e!=="bullet"?t.dispatchCommand(fe.INSERT_UNORDERED_LIST_COMMAND,void 0):t.dispatchCommand(fe.REMOVE_LIST_COMMAND,void 0)}function l(){e!=="check"?t.dispatchCommand(fe.INSERT_CHECK_LIST_COMMAND,void 0):t.dispatchCommand(fe.REMOVE_LIST_COMMAND,void 0)}function s(){e!=="number"?t.dispatchCommand(fe.INSERT_ORDERED_LIST_COMMAND,void 0):t.dispatchCommand(fe.REMOVE_LIST_COMMAND,void 0)}function a(){e!=="quote"&&t.update(()=>{const g=C.$getSelection();(C.$isRangeSelection(g)||C.DEPRECATED_$isGridSelection(g))&&Se.$setBlocksType(g,()=>rt.$createQuoteNode())})}function c(){e!=="code"&&t.update(()=>{const g=C.$getSelection();if(C.$isRangeSelection(g)||C.DEPRECATED_$isGridSelection(g))if(g.isCollapsed())Se.$setBlocksType(g,()=>he.$createCodeNode());else{const d=g.getTextContent(),u=he.$createCodeNode();g.insertNodes([u]),g.insertRawText(d)}})}return p.jsxs(pr,{children:[p.jsx(mr,{children:p.jsx(yt,{disabled:n,"aria-label":"Formatting options for text style",children:al[e],icon:(()=>{switch(e){case"paragraph":return p.jsx(cs,{});case"h1":return p.jsx(us,{});case"h2":return p.jsx(as,{});case"h3":return p.jsx(ss,{});case"bullet":return p.jsx(ls,{});case"check":return p.jsx(os,{});case"number":return p.jsx(is,{});case"quote":return p.jsx(rs,{});case"code":return p.jsx(Ti,{});default:return p.jsx(bg,{})}})()})}),p.jsx(_r,{children:p.jsxs(Cr,{children:[p.jsx(ue,{icon:p.jsx(cs,{}),onClick:r,children:"Normal"}),p.jsx(ue,{icon:p.jsx(us,{}),onClick:()=>i("h1"),children:"Heading 1"}),p.jsx(ue,{icon:p.jsx(as,{}),onClick:()=>i("h2"),children:"Heading 2"}),p.jsx(ue,{icon:p.jsx(ss,{}),onClick:()=>i("h3"),children:"Heading 3"}),p.jsx(ue,{icon:p.jsx(ls,{}),onClick:o,children:"Bullet List"}),p.jsx(ue,{icon:p.jsx(is,{}),onClick:s,children:"Numbered List"}),p.jsx(ue,{icon:p.jsx(os,{}),onClick:l,children:"Check List"}),p.jsx(ue,{icon:p.jsx(rs,{}),onClick:a,children:"Quote"}),p.jsx(ue,{icon:p.jsx(Ti,{}),onClick:c,children:"Code Block"})]})})]})}const X_=["#d0021b","#f5a623","#f8e71c","#8b572a","#7ed321","#417505","#bd10e0","#9013fe","#4a90e2","#50e3c2","#b8e986","#000000","#4a4a4a","#9b9b9b","#ffffff"],cr=214,Ba=150;function Z_({color:t,onChange:e}){const[n,r]=$.useState(Ln("hex",t)),[i,o]=$.useState(t),l=$.useRef(null),s=$.useMemo(()=>({x:n.hsv.s/100*cr,y:(100-n.hsv.v)/100*Ba}),[n.hsv.s,n.hsv.v]),a=$.useMemo(()=>({x:n.hsv.h/360*cr}),[n.hsv]);function c(u){if(o(u),/^#[0-9A-Fa-f]{6}$/i.test(u)){const f=Ln("hex",u);r(f)}}function g({x:u,y:f}){const h={...n.hsv,s:u/cr*100,v:100-f/Ba*100},m=Ln("hsv",h);r(m),o(m.hex)}function d({x:u}){const f={...n.hsv,h:u/cr*360},h=Ln("hsv",f);r(h),o(h.hex)}return $.useEffect(()=>{l.current!==null&&e&&(e(n.hex),o(n.hex))},[n,e]),$.useEffect(()=>{if(t===void 0)return;const u=Ln("hex",t);r(u),o(u.hex)},[t]),p.jsxs("div",{style:{width:cr},ref:l,children:[p.jsx(Or,{label:"Hex",style:{paddingBottom:an.spacingVerticalS},children:p.jsx(Gn,{onChange:(u,f)=>c(f.value),value:i})}),p.jsx("div",{className:"color-picker-basic-color",children:X_.map(u=>p.jsx("button",{className:u===n.hex?" active":"",style:{backgroundColor:u},onClick:()=>{o(u),r(Ln("hex",u))}},u))}),p.jsx(ja,{className:"color-picker-saturation",style:{backgroundColor:`hsl(${n.hsv.h}, 100%, 50%)`},onChange:g,children:p.jsx("div",{className:"color-picker-saturation_cursor",style:{backgroundColor:n.hex,left:s.x,top:s.y}})}),p.jsx(ja,{className:"color-picker-hue",onChange:d,children:p.jsx("div",{className:"color-picker-hue_cursor",style:{backgroundColor:`hsl(${n.hsv.h}, 100%, 50%)`,left:a.x}})}),p.jsx("div",{className:"color-picker-color",style:{backgroundColor:n.hex}})]})}function ja({className:t,style:e,onChange:n,children:r}){const i=$.useRef(null),o=s=>{if(i.current){const{current:a}=i,{width:c,height:g,left:d,top:u}=a.getBoundingClientRect(),f=za(s.clientX-d,c,0),h=za(s.clientY-u,g,0);n({x:f,y:h})}};function l(s){if(s.button!==0)return;o(s);function a(g){o(g)}function c(g){document.removeEventListener("mousemove",a,!1),document.removeEventListener("mouseup",c,!1),o(g)}document.addEventListener("mousemove",a,!1),document.addEventListener("mouseup",c,!1)}return p.jsx("div",{ref:i,className:t,style:e,onMouseDown:l,children:r})}function za(t,e,n){return t>e?e:tn?e+e:"#").join(""),t;if(t.length===7||t.length===9)return t}else{const e=document.createElement("canvas").getContext("2d");if(!e)throw new Error("2d context not supported or canvas already initialized");return e.fillStyle=t,e.fillStyle}return"#000000"}function Ha(t){const e=(t.replace(/^#?([a-f\d])([a-f\d])([a-f\d])$/i,(n,r,i,o)=>"#"+r+r+i+i+o+o).substring(1).match(/.{2}/g)||[]).map(n=>parseInt(n,16));return{b:e[2],g:e[1],r:e[0]}}function wo({r:t,g:e,b:n}){t/=255,e/=255,n/=255;const r=Math.max(t,e,n),i=r-Math.min(t,e,n),o=i?(r===t?(e-n)/i+(er.toString(16).padStart(2,"0")).join("")}function Ln(t,e){let n=Ka("#121212"),r=Ha(n),i=wo(r);return t==="hex"?(n=Ka(e),r=Ha(n),i=wo(r)):t==="rgb"?(r=e,n=Wa(r),i=wo(r)):t==="hsv"&&(i=e,r=q_(i),n=Wa(r)),{hex:n,hsv:i,rgb:r}}function Ua({disabled:t,ariaLabel:e,color:n,onChange:r,icon:i}){return p.jsxs(kg,{trapFocus:!0,withArrow:!0,children:[p.jsx(Ig,{children:p.jsx(yt,{disabled:t,icon:i,title:e,"aria-label":e})}),p.jsx(Pg,{children:p.jsx(Z_,{color:n,onChange:r})})]})}const Q_=[["Arial","Arial"],["Courier New","Courier New"],["Georgia","Georgia"],["Times New Roman","Times New Roman"],["Trebuchet MS","Trebuchet MS"],["Verdana","Verdana"]],eC=[["10px","10px"],["11px","11px"],["12px","12px"],["13px","13px"],["14px","14px"],["15px","15px"],["16px","16px"],["17px","17px"],["18px","18px"],["19px","19px"],["20px","20px"]];function Ga({editor:t,value:e,style:n,disabled:r=!1}){const i=$.useCallback(l=>{t.update(()=>{const s=C.$getSelection();C.$isRangeSelection(s)&&Se.$patchStyleText(s,{[n]:l})})},[t,n]),o=n==="font-family"?"Formatting options for font family":"Formatting options for font size";return p.jsxs(pr,{children:[p.jsx(mr,{children:p.jsx(yt,{disabled:r,"aria-label":o,icon:n==="font-family"?p.jsx(Fg,{}):p.jsx(Bg,{}),children:e})}),p.jsx(_r,{children:p.jsx(Cr,{children:(n==="font-family"?Q_:eC).map(([l,s],a)=>p.jsx(ue,{children:s,onClick:()=>i(l)},a))})})]})}const tC=it({box:{columnGap:"1px",backgroundColor:"#fff",borderTopLeftRadius:an.borderRadiusLarge,borderTopRightRadius:an.borderRadiusLarge}}),nC=(()=>{const t=[];for(const[e,n]of Object.entries(he.CODE_LANGUAGE_FRIENDLY_NAME_MAP))t.push([e,n]);return t})();function rC(){const[t]=X.useLexicalComposerContext(),[e,n]=$.useState(t),[r,i]=$.useState("paragraph"),[o,l]=$.useState(null),[s,a]=$.useState("15px"),[c,g]=$.useState("#000"),[d,u]=$.useState("#fff"),[f,h]=$.useState("Arial"),[m,N]=$.useState(!1),[y,_]=$.useState(!1),[x,v]=$.useState(!1),[S,A]=$.useState(""),[w,B]=$.useState(()=>t.isEditable()),[k,K]=$.useState([]),Z=$.useCallback(()=>{const I=C.$getSelection();if(C.$isRangeSelection(I)){const G=I.anchor.getNode();let de=G.getKey()==="root"?G:V.$findMatchingParent(G,De=>{const Te=De.getParent();return!!Te&&C.$isRootOrShadowRoot(Te)});de||(de=G.getTopLevelElementOrThrow());const ge=de.getKey(),Dt=e.getElementByKey(ge),oe=[];I.hasFormat("bold")&&oe.push("bold"),I.hasFormat("italic")&&oe.push("italic"),I.hasFormat("underline")&&oe.push("underline"),I.hasFormat("strikethrough")&&oe.push("strikethrough"),I.hasFormat("subscript")&&oe.push("subscript"),I.hasFormat("superscript")&&oe.push("superscript"),I.hasFormat("code")&&oe.push("code");const lt=so(I),st=lt.getParent();if(ce.$isLinkNode(st)||ce.$isLinkNode(lt)?(oe.push("link"),N(!0)):N(!1),K(oe),Dt)if(l(ge),fe.$isListNode(de)){const De=V.$getNearestNodeOfType(G,fe.ListNode),Te=De?De.getListType():de.getListType();i(Te)}else{const De=rt.$isHeadingNode(de)?de.getTag():de.getType();if(De in al&&i(De),he.$isCodeNode(de)){const Te=de.getLanguage();A(Te?he.CODE_LANGUAGE_MAP[Te]||Te:"");return}}a(Se.$getSelectionStyleValueForProperty(I,"font-size","15px")),g(Se.$getSelectionStyleValueForProperty(I,"color","#000")),u(Se.$getSelectionStyleValueForProperty(I,"background-color","#fff")),h(Se.$getSelectionStyleValueForProperty(I,"font-family","Arial"))}},[e]);$.useEffect(()=>t.registerCommand(C.SELECTION_CHANGE_COMMAND,(I,G)=>(Z(),n(G),!1),C.COMMAND_PRIORITY_CRITICAL),[t,Z]),$.useEffect(()=>V.mergeRegister(t.registerEditableListener(I=>B(I)),e.registerUpdateListener(({editorState:I})=>I.read(()=>Z())),e.registerCommand(C.CAN_UNDO_COMMAND,I=>(_(I),!1),C.COMMAND_PRIORITY_CRITICAL),e.registerCommand(C.CAN_REDO_COMMAND,I=>(v(I),!1),C.COMMAND_PRIORITY_CRITICAL)),[e,t,Z]);const ie=$.useCallback(I=>{e.update(()=>{const G=C.$getSelection();C.$isRangeSelection(G)&&Se.$patchStyleText(G,I)})},[e]),ot=$.useCallback(()=>{e.update(()=>{const I=C.$getSelection();C.$isRangeSelection(I)&&(Se.$selectAll(I),I.getNodes().forEach(G=>{C.$isTextNode(G)&&(G.setFormat(0),G.setStyle(""),V.$getNearestBlockElementAncestorOrThrow(G).setFormat("")),Y_.$isDecoratorBlockNode(G)&&G.setFormat("")}))})},[e]),Tn=$.useCallback(I=>ie({color:I}),[ie]),yn=$.useCallback(I=>ie({"background-color":I}),[ie]),vn=$.useCallback(()=>{m?t.dispatchCommand(ce.TOGGLE_LINK_COMMAND,null):t.dispatchCommand(ce.TOGGLE_LINK_COMMAND,lg("https://"))},[t,m]),xt=$.useCallback(I=>{e.update(()=>{if(o!==null){const G=C.$getNodeByKey(o);he.$isCodeNode(G)&&G.setLanguage(I)}})},[e,o]),ae=tC();return p.jsxs(Za,{checkedValues:{opts:k},className:gt("LexEditor_Toolbar",ae.box),children:[p.jsx(yt,{disabled:!y||!w,title:kt?"Undo (⌘Z)":"Undo (Ctrl+Z)","aria-label":"Undo",icon:p.jsx(jg,{}),onClick:()=>e.dispatchCommand(C.UNDO_COMMAND,void 0)}),p.jsx(yt,{disabled:!x||!w,title:kt?"Redo (⌘Y)":"Redo (Ctrl+Y)","aria-label":"Redo",icon:p.jsx(zg,{}),onClick:()=>e.dispatchCommand(C.REDO_COMMAND,void 0)}),p.jsx(sr,{}),r in al&&e===t&&p.jsxs(p.Fragment,{children:[p.jsx(V_,{disabled:!w,blockType:r,editor:t}),p.jsx(sr,{})]}),r==="code"?p.jsxs(pr,{children:[p.jsx(mr,{children:p.jsx(yt,{disabled:!w,title:"Select language","aria-label":"Select language",icon:p.jsx(Kg,{}),children:he.getLanguageFriendlyName(S)})}),p.jsx(_r,{children:p.jsx(Cr,{children:nC.map(([I,G],de)=>p.jsx(ue,{onClick:()=>xt(I),children:G},de))})})]}):p.jsxs(p.Fragment,{children:[p.jsx(Ga,{disabled:!w,style:"font-family",value:f,editor:t}),p.jsx(Ga,{disabled:!w,style:"font-size",value:s,editor:t}),p.jsx(sr,{}),p.jsx(Le,{name:"opts",value:"bold",appearance:"subtle",disabled:!w,title:kt?"Bold (⌘B)":"Bold (Ctrl+B)","aria-label":`Format text as bold. Shortcut: ${kt?"⌘B":"Ctrl+B"}`,icon:p.jsx(qa,{}),onClick:()=>e.dispatchCommand(C.FORMAT_TEXT_COMMAND,"bold")}),p.jsx(Le,{name:"opts",value:"italic",appearance:"subtle",disabled:!w,title:kt?"Italic (⌘I)":"Italic (Ctrl+I)","aria-label":`Format text as italics. Shortcut: ${kt?"⌘I":"Ctrl+I"}`,icon:p.jsx(Qa,{}),onClick:()=>e.dispatchCommand(C.FORMAT_TEXT_COMMAND,"italic")}),p.jsx(Le,{name:"opts",value:"underline",appearance:"subtle",disabled:!w,title:kt?"Underline (⌘U)":"Underline (Ctrl+U)","aria-label":`Format text to underlined. Shortcut: ${kt?"⌘U":"Ctrl+U"}`,icon:p.jsx(eu,{}),onClick:()=>e.dispatchCommand(C.FORMAT_TEXT_COMMAND,"underline")}),p.jsx(Le,{name:"opts",value:"strikethrough",appearance:"subtle",disabled:!w,title:"Strikethrough","aria-label":"Format text with a strikethrough",icon:p.jsx(tu,{}),onClick:()=>e.dispatchCommand(C.FORMAT_TEXT_COMMAND,"strikethrough")}),p.jsx(Le,{name:"opts",value:"subscript",appearance:"subtle",disabled:!w,title:"Subscript","aria-label":"Format text with a subscript",icon:p.jsx(nu,{}),onClick:()=>e.dispatchCommand(C.FORMAT_TEXT_COMMAND,"subscript")}),p.jsx(Le,{name:"opts",value:"superscript",appearance:"subtle",disabled:!w,title:"Superscript","aria-label":"Format text with a superscript",icon:p.jsx(ru,{}),onClick:()=>e.dispatchCommand(C.FORMAT_TEXT_COMMAND,"superscript")}),p.jsx(Le,{name:"opts",value:"code",appearance:"subtle",disabled:!w,title:"Insert code block","aria-label":"Insert code block",icon:p.jsx(Ti,{}),onClick:()=>e.dispatchCommand(C.FORMAT_TEXT_COMMAND,"code")}),p.jsx(Le,{name:"opts",value:"link",appearance:"subtle",disabled:!w,title:"Insert link","aria-label":"Insert link",icon:p.jsx(iu,{}),onClick:vn}),p.jsx(Ua,{disabled:!w,ariaLabel:"Formatting text color",color:c,icon:p.jsx(Hg,{}),onChange:Tn}),p.jsx(Ua,{disabled:!w,ariaLabel:"Formatting background color",color:d,icon:p.jsx(Wg,{}),onChange:yn}),p.jsx(yt,{disabled:!w,title:"Clear text formatting","aria-label":"Clear all text formatting",icon:p.jsx(Ug,{}),onClick:ot}),p.jsx(sr,{}),p.jsxs(pr,{children:[p.jsx(mr,{children:p.jsx(yt,{disabled:!w,title:"Insert","aria-label":"Insert specialized editor node",icon:p.jsx(Gg,{}),children:"Insert"})}),p.jsx(_r,{children:p.jsxs(Cr,{children:[p.jsx(ue,{icon:p.jsx(Yg,{}),onClick:()=>e.dispatchCommand(jt.INSERT_HORIZONTAL_RULE_COMMAND,void 0),children:"Horizontal Rule"}),p.jsxs(ds,{children:[p.jsx(yi,{disableButtonEnhancement:!0,children:p.jsx(ue,{icon:p.jsx(Jg,{}),children:"Image"})}),p.jsx(gs,{children:p.jsx(g_,{editor:e})})]}),p.jsxs(ds,{children:[p.jsx(yi,{disableButtonEnhancement:!0,children:p.jsx(ue,{icon:p.jsx(Vg,{}),children:"Table"})}),p.jsx(gs,{children:p.jsx(K_,{editor:e})})]}),p.jsx(ue,{icon:p.jsx(Xg,{}),onClick:()=>t.dispatchCommand(ig,void 0),children:"Collapsible"})]})})]})]}),p.jsx(sr,{}),p.jsxs(pr,{children:[p.jsx(mr,{children:p.jsx(yt,{disabled:!w,title:"Align","aria-label":"Formatting options for text alignment",icon:p.jsx(fs,{}),children:"Align"})}),p.jsx(_r,{children:p.jsxs(Cr,{children:[p.jsx(ue,{icon:p.jsx(fs,{}),onClick:()=>e.dispatchCommand(C.FORMAT_ELEMENT_COMMAND,"left"),children:"Left Align"}),p.jsx(ue,{icon:p.jsx(Zg,{}),onClick:()=>e.dispatchCommand(C.FORMAT_ELEMENT_COMMAND,"center"),children:"Center Align"}),p.jsx(ue,{icon:p.jsx(qg,{}),onClick:()=>e.dispatchCommand(C.FORMAT_ELEMENT_COMMAND,"right"),children:"Right Align"}),p.jsx(ue,{icon:p.jsx(Qg,{}),onClick:()=>e.dispatchCommand(C.FORMAT_ELEMENT_COMMAND,"justify"),children:"Justify Align"}),p.jsx(ef,{}),p.jsx(ue,{icon:p.jsx(tf,{}),onClick:()=>e.dispatchCommand(C.OUTDENT_CONTENT_COMMAND,void 0),children:"Outdent"}),p.jsx(ue,{icon:p.jsx(nf,{}),onClick:()=>e.dispatchCommand(C.INDENT_CONTENT_COMMAND,void 0),children:"Indent"})]})})]})]})}const iC=it({ltr:{textAlign:"left"},rtl:{textAlign:"right"},paragraph:{...P.margin(0),position:"relative"},quote:{...P.margin(0),marginLeft:"20px",marginBottom:"10px",fontSize:"15px",color:"rgb(101, 103, 107)",borderLeftColor:"rgb(206, 208, 212)",borderLeftWidth:"4px",borderLeftStyle:"solid",paddingLeft:"16px"},h1:{fontSize:"24px",color:"rgb(5, 5, 5)",fontWeight:400,...P.margin(0)},h2:{fontSize:"15px",color:"rgb(101, 103, 107)",fontWeight:700,...P.margin(0),textTransform:"uppercase"},h3:{fontSize:"12px",...P.margin(0),textTransform:"uppercase"},textBold:{fontWeight:"bold"},textItalic:{fontStyle:"italic"},textSubscript:{fontSize:"0.8em",verticalAlign:"sub !important"},textSuperscript:{fontSize:"0.8em",verticalAlign:"super"},textCode:{backgroundColor:"rgb(240, 242, 245)",...P.padding("1px","0.25rem"),fontFamily:"Menlo, Consolas, Monaco, monospace",fontSize:"94%"},code:{backgroundColor:"rgb(240, 242, 245)",fontFamily:"Menlo, Consolas, Monaco, monospace",display:"block",...P.padding("8px","8px","8px","52px"),lineHeight:1.53,fontSize:"13px",...P.margin(0),marginTop:"8px",marginBottom:"8px",tabSize:2,overflowX:"auto",position:"relative",":before":{content:"attr(data-gutter)",position:"absolute",backgroundColor:"#eee",left:0,top:0,...P.borderRight("1px","solid","#ccc"),...P.padding("8px"),color:"#777",whiteSpace:"pre-wrap",textAlign:"right",minWidth:"25px"}},table:{borderCollapse:"collapse",borderSpacing:0,maxWidth:"100%",overflowY:"scroll",tableLayout:"fixed",width:"calc(100% - 25px)",...P.margin("30px",0)},tableSelected:{...P.outline("2px","solid","rgb(60, 132, 244)")},tableCell:{...P.border("1px","solid","#bbb"),minWidth:"75px",verticalAlign:"top",textAlign:"start",...P.padding("6px","8px"),position:"relative",cursor:"default",...P.outline("none")},tableCellSortedIndicator:{display:"block",opacity:.5,position:"absolute",bottom:0,left:0,width:"100%",height:"4px",backgroundColor:"#999"},tableCellResizer:{position:"absolute",right:"-4px",height:"100%",width:"8px",cursor:"ew-resize",zIndex:10,top:0},tableCellHeader:{backgroundColor:"#f2f3f5",textAlign:"start"},tableCellSelected:{backgroundColor:"#c9dbf0"},tableCellPrimarySelected:{...P.border("2px","solid","rgb(60, 132, 244)"),display:"block",height:"calc(100% - 2px)",position:"absolute",width:"calc(100% - 2px)",left:"-1px",top:"-1px",zIndex:2},tableCellEditing:{boxShadow:"0 0 5px rgba(0, 0, 0, 0.4)",...P.borderRadius("3px")},tableAddColumns:{position:"absolute",top:0,width:"20px",backgroundColor:"#eee",height:"100%",right:0,...P.border(0),cursor:"pointer",":after":{backgroundSize:"contain",backgroundRepeat:"no-repeat",display:"block",content:'" "',position:"absolute",top:0,left:0,width:"100%",height:"100%",opacity:.4},":hover":{backgroundColor:"#c9dbf0"}},tableAddRows:{position:"absolute",bottom:"-25px",width:"calc(100% - 25px)",backgroundColor:"#eee",height:"20px",left:0,...P.border(0),cursor:"pointer",":after":{backgroundSize:"contain",backgroundRepeat:"no-repeat",display:"block",content:'" "',position:"absolute",top:0,left:0,width:"100%",height:"100%",opacity:.4},":hover":{backgroundColor:"#c9dbf0"}},tableCellResizeRuler:{display:"block",position:"absolute",width:"1px",backgroundColor:"rgb(60, 132, 244)",height:"100%",top:0},tableCellActionButtonContainer:{display:"block",right:"5px",top:"2px",position:"absolute",zIndex:4},tableCellActionButton:{backgroundColor:"#eee",display:"block",...P.border(0),...P.borderRadius("20px"),width:"20px",height:"20px",color:"#222",cursor:"pointer",":hover":{backgroundColor:"#ddd"}},ol1:{...P.padding(0),...P.margin(0),marginLeft:"16px",listStylePosition:"inside"},ol2:{...P.padding(0),...P.margin(0),marginLeft:"16px",listStyleType:"upper-alpha",listStylePosition:"inside"},ol3:{...P.padding(0),...P.margin(0),marginLeft:"16px",listStyleType:"lower-alpha",listStylePosition:"inside"},ol4:{...P.padding(0),...P.margin(0),marginLeft:"16px",listStyleType:"upper-roman",listStylePosition:"inside"},ol5:{...P.padding(0),...P.margin(0),marginLeft:"16px",listStyleType:"lower-roman",listStylePosition:"inside"},ul:{...P.padding(0),...P.margin(0),marginLeft:"16px",listStylePosition:"inside"},listItem:{...P.margin(0,"8px")},tokenComment:{color:"slategray"},tokenPunctuation:{color:"#999"},tokenProperty:{color:"#905"},tokenSelector:{color:"#690"},tokenOperator:{color:"#9a6e3a"},tokenAttr:{color:"#07a"},tokenVariable:{color:"#e90"},tokenFunction:{color:"#dd4a68"},embedBlock:{userSelect:"none"},embedBlockFocus:{...P.outline("2px solid rgb(60, 132, 244)")}});function xg(){const t=iC();return{blockCursor:"LexEditor_blockCursor",code:gt(t.code,"LexEditor_code"),codeHighlight:{atrule:t.tokenAttr,attr:t.tokenAttr,boolean:t.tokenProperty,builtin:t.tokenSelector,cdata:t.tokenComment,char:t.tokenSelector,class:t.tokenFunction,"class-name":t.tokenFunction,comment:t.tokenComment,constant:t.tokenProperty,deleted:t.tokenProperty,doctype:t.tokenComment,entity:t.tokenOperator,function:t.tokenFunction,important:t.tokenVariable,inserted:t.tokenSelector,namespace:t.tokenVariable,number:t.tokenProperty,operator:t.tokenOperator,prolog:t.tokenComment,property:t.tokenProperty,punctuation:t.tokenPunctuation,regex:t.tokenVariable,selector:t.tokenSelector,string:t.tokenSelector,symbol:t.tokenProperty,tag:t.tokenProperty,url:t.tokenOperator,variable:t.tokenVariable},embedBlock:{base:t.embedBlock,focus:t.embedBlockFocus},heading:{h1:t.h1,h2:t.h2,h3:t.h3},image:"LexEditor_Image",link:"LexEditor_link",list:{listitem:t.listItem,listitemChecked:"LexEditor_listItemChecked",listitemUnchecked:"LexEditor_listItemUnchecked",nested:{listitem:"LexEditor_nestedListItem"},olDepth:[t.ol1,t.ol2,t.ol3,t.ol4,t.ol5],ul:t.ul},ltr:t.ltr,mark:"LexEditor_mark",markOverlap:"LexEditor_markOverlap",paragraph:t.paragraph,quote:t.quote,rtl:t.rtl,table:t.table,tableAddColumns:gt(t.tableAddColumns,"LexEditor_tableAddColumns"),tableAddRows:gt(t.tableAddRows,"LexEditor_tableAddRows"),tableCell:t.tableCell,tableCellActionButton:t.tableCellActionButton,tableCellActionButtonContainer:t.tableCellActionButtonContainer,tableCellEditing:t.tableCellEditing,tableCellHeader:t.tableCellHeader,tableCellPrimarySelected:t.tableCellPrimarySelected,tableCellResizer:t.tableCellResizer,tableCellSelected:t.tableCellSelected,tableCellSortedIndicator:t.tableCellSortedIndicator,tableResizeRuler:t.tableCellResizeRuler,tableSelected:t.tableSelected,text:{bold:t.textBold,code:t.textCode,italic:t.textItalic,strikethrough:"LexEditor_textStrikethrough",subscript:t.textSubscript,superscript:t.textSuperscript,underline:"LexEditor_textUnderline",underlineStrikethrough:"LexEditor_textUnderlineStrikethrough"}}}var Ng={},oC=X,Ar=$,lC=typeof window<"u"&&typeof window.document<"u"&&typeof window.document.createElement<"u"?Ar.useLayoutEffect:Ar.useEffect;Ng.ContentEditable=function({ariaActiveDescendant:t,ariaAutoComplete:e,ariaControls:n,ariaDescribedBy:r,ariaExpanded:i,ariaLabel:o,ariaLabelledBy:l,ariaMultiline:s,ariaOwns:a,ariaRequired:c,autoCapitalize:g,className:d,id:u,role:f="textbox",spellCheck:h=!0,style:m,tabIndex:N,"data-testid":y}){let[_]=oC.useLexicalComposerContext(),[x,v]=Ar.useState(!1),S=Ar.useCallback(A=>{_.setRootElement(A)},[_]);return lC(()=>(v(_.isEditable()),_.registerEditableListener(A=>{v(A)})),[_]),Ar.createElement("div",{"aria-activedescendant":x?t:void 0,"aria-autocomplete":x?e:"none","aria-controls":x?n:void 0,"aria-describedby":r,"aria-expanded":x&&f==="combobox"?!!i:void 0,"aria-label":o,"aria-labelledby":l,"aria-multiline":s,"aria-owns":x?a:void 0,"aria-required":c,autoCapitalize:g,className:d,contentEditable:x,"data-testid":y,id:u,ref:S,role:x?f:void 0,spellCheck:h,style:m,tabIndex:N})};const sC=Ng;var aC=sC;const uC=it({root:{...P.border(0),fontSize:"15px",display:"block",position:"relative",tabSize:1,...P.outline(0),...P.padding("8px","28px"),minHeight:"calc(100% - 16px)"},table:{minHeight:"20px",...P.border(0),resize:"none",cursor:"text",display:"block",position:"relative",tabSize:1,...P.outline(0),...P.padding(0),userSelect:"text",fontSize:"15px",whiteSpace:"pre-wrap",wordBreak:"break-word",zIndex:3},display:{...P.padding(0)}});function Ya({className:t,table:e}){const n=uC(),{Display:r}=vc();return p.jsx(aC.ContentEditable,{className:gt("LexEditor_Content",t||e?n.table:n.root,!e&&r&&n.display)})}const cC=it({box:{fontSize:"15px",color:"#999",...P.overflow("hidden"),position:"absolute",textOverflow:"ellipsis",top:"8px",left:"28px",right:"28px",userSelect:"none",whiteSpace:"nowrap",display:"inline-block",pointerEvents:"none"}});function dC({children:t,className:e}){const n=cC();return p.jsx("div",{className:e||n.box,children:t})}const gC=it({shell:{lineHeight:"1.7"},container:{position:"relative"},noTreeView:{borderBottomLeftRadius:an.borderRadiusLarge,borderBottomRightRadius:an.borderRadiusLarge},scroller:{minHeight:"150px",...P.overflow("auto"),resize:"vertical"}});function fC(){of(X.useLexicalComposerContext()[0]);const{Namespace:t,OnError:e,Placeholder:n,Display:r,Plugin:{Actions:i,AutoFocus:o,AutoLink:l,CheckList:s,ClickableLink:a,CodeActionMenu:c,CodeHighlight:g,Collapsible:d,DraggableBlock:u,FloatingLinkEditor:f,FloatingTextFormatToolbar:h,HorizontalRule:m,Images:N,Link:y,ListMaxIndentLevel:_,List:x,MarkdownShortcut:v,TabFocus:S,TabIndentation:A,Table:w,Toolbar:B}}=vc(),k=p.jsx(dC,{children:n||"Let's say something awesome...."}),[K,Z]=$.useState(),ie=gC();return p.jsxs("div",{className:gt("LexEditor_Shell",ie.shell),children:[B&&p.jsx(rC,{}),p.jsxs("div",{className:gt(...r?[]:[ie.container,ie.noTreeView,ie.scroller]),ref:ot=>ot&&Z(ot),children:[o&&p.jsx(Fs.AutoFocusPlugin,{}),l&&p.jsx(Dm,{}),s&&p.jsx(vh.CheckListPlugin,{}),a&&p.jsx(Aa,{}),g&&p.jsx(Bm,{}),d&&p.jsx(zm,{}),m&&p.jsx(d_,{}),N&&p.jsx(Ia,{}),y&&p.jsx(Pa,{}),_&&p.jsx($_,{maxDepth:_}),x&&p.jsx(kh.ListPlugin,{}),v&&p.jsx(D_,{}),p.jsx(la.RichTextPlugin,{contentEditable:p.jsx(Ya,{}),placeholder:!r&&k,ErrorBoundary:qs}),S&&p.jsx(b_,{}),A&&p.jsx(Ep.TabIndentationPlugin,{}),w&&p.jsxs(W_,{cellEditorConfig:{namespace:t,nodes:[...Ip],onError:e,theme:xg()},children:[p.jsx(Fs.AutoFocusPlugin,{}),p.jsx(Aa,{}),p.jsx(ka,{}),p.jsx(Ia,{captionsEnabled:!1}),p.jsx(Pa,{}),p.jsx(la.RichTextPlugin,{contentEditable:p.jsx(Ya,{table:!0}),placeholder:null,ErrorBoundary:qs})]}),K&&p.jsxs(p.Fragment,{children:[i&&p.jsx(Em,{anchor:K}),c&&p.jsx(Fm,{anchor:K}),u&&p.jsx(qm,{anchor:K}),f&&p.jsx(l_,{anchor:K}),h&&p.jsx(ka,{anchor:K})]})]})]})}var En={},$t=C,di=V;class ei extends $t.ElementNode{static getType(){return"mark"}static clone(e){return new ei(Array.from(e.__ids),e.__key)}static importDOM(){return null}static importJSON(e){let n=Wi(e.ids);return n.setFormat(e.format),n.setIndent(e.indent),n.setDirection(e.direction),n}exportJSON(){return{...super.exportJSON(),ids:this.getIDs(),type:"mark",version:1}}constructor(e,n){super(n),this.__ids=e||[]}createDOM(e){let n=document.createElement("mark");return di.addClassNamesToElement(n,e.theme.mark),1{throw s},State:i,Placeholder:o,Display:l}){return n=l?!1:n,p.jsx(qf.LexicalComposer,{initialConfig:{editorState:i,namespace:t,nodes:[...CC],onError:r,theme:xg(),editable:n},children:p.jsx(th,{Namespace:t,Plugin:l?Qf:e,Editable:n,OnError:r,State:i,Placeholder:o,Display:l,children:p.jsx(z_,{children:p.jsx(fC,{})})})})}const vC=Object.freeze(Object.defineProperty({__proto__:null,default:xC},Symbol.toStringTag,{value:"Module"}));export{Nd as $,_g as C,kt as I,X as L,dC as P,rr as T,C as a,V as b,Fs as c,Pa as d,la as e,Ya as f,qs as g,k_ as h,Jh as i,yC as j,qh as k,F_ as l,Hi as m,fg as n,Pn as o,I_ as p,vC as q,Zp as u}; function __vite__mapDeps(indexes) { if (!__vite__mapDeps.viteFileDeps) { - __vite__mapDeps.viteFileDeps = ["assets/Component-RuL62tq9.js","assets/vendor-DpqXKvKY.js","assets/LexicalNestedComposer-yIpoQP8r.js","assets/index-YSLnLPU4.js","assets/index-mRiAC1cH.css","assets/Component-aAfnRv22.js"] + __vite__mapDeps.viteFileDeps = ["assets/Component-uOG8IUJI.js","assets/vendor-DpqXKvKY.js","assets/LexicalNestedComposer-zwgIQe1H.js","assets/index-7dlI38O5.js","assets/index-mRiAC1cH.css","assets/Component-4YKDN3nt.js"] } return indexes.map((i) => __vite__mapDeps.viteFileDeps[i]) } diff --git a/assets/index-Or5Q2pDR.js b/assets/index-wo2xrWSk.js similarity index 99% rename from assets/index-Or5Q2pDR.js rename to assets/index-wo2xrWSk.js index 63a768c..406568d 100644 --- a/assets/index-Or5Q2pDR.js +++ b/assets/index-wo2xrWSk.js @@ -1 +1 @@ -import{m as S,j as e,T as A,b as P,F as O,B as i,r as w,ah as Ue,a5 as p,a6 as g,a7 as f,o as I,I as B,aE as Y,aF as V,t as E,x as T,aG as ve,ac as xe,ad as pe,ae as je,af as L,ag as Ce,L as ge,aH as fe,aI as Q,ab as J,D as K,n as R,g as W,h as Z,i as ee,k as ne,aa as Ie,N as se,aB as be,aj as ye,ak as Ae,ao as Pe,O as ke,aJ as Oe,aK as Me,c as Be,l as Le,aL as qe,a1 as $e,$ as ze,a0 as _e,a2 as Xe,a3 as Qe,a8 as Ne,aM as Ye,ar as Je}from"./vendor-DpqXKvKY.js";import{L as b,a as F,e as N,A as x,F as $,f as G,c as _,H as q,C as Ke,G as We,M as Ge}from"./index-YSLnLPU4.js";import{O as Ze,a as en,H as nn}from"./Columns-iLzEQjYF.js";import{t as sn}from"./toFinite-GMFxiq4g.js";import{L as rn}from"./Lazy-vvLq-Rxx.js";import"./isObject-tyZXtoJz.js";function tn(n){var s=sn(n),r=s%1;return s===s?r?s-r:s:0}function Re(n){return typeof n=="number"&&n==tn(n)}const an=S({body:{...F,alignItems:"flex-start"}}),on=new b("Admin","Order","Detail","Action");function cn({OrderId:n,Status:s,Refresh:r}){const t=an(),{dispatch:o,dispatchToast:l}=N(on),{run:c}=x.Order.Post.useAccept({manual:!0,onError(a,d){o({Message:"Failed Accept Order",Request:d,Error:a})},onSuccess(){l(e.jsx(A,{children:e.jsx(P,{children:"Order Accepted"})}),{intent:"success"}),r()}});switch(s){case"Processing":case"Shipping":case"Finished":case"Cancelled":case"Returning":return null}return e.jsx(O,{label:"Action",size:"large",children:e.jsx("div",{className:t.body,children:s==="Pending"&&e.jsx(i,{appearance:"subtle",onClick:()=>c(n),children:"Accept Order"})})})}const ln=S({body:{...$,justifyContent:"space-between"}}),dn=new b("Admin","Order","Detail","Append");function un({OrderId:n,Refresh:s}){const r=ln(),[t,o]=w.useState(),{dispatch:l,dispatchToast:c}=N(dn),{run:a}=x.Order.Post.useAppend({manual:!0,onError(h,u){l({Message:"Failed Append Comment",Request:u,Error:h})},onSuccess(){c(e.jsx(A,{children:e.jsx(P,{children:"Comment Appended"})}),{intent:"success"}),s()}}),{run:d}=x.Order.Post.useClose({manual:!0,onError(h,u){l({Message:"Failed Close Order",Request:u,Error:h})},onSuccess(){c(e.jsx(A,{children:e.jsx(P,{children:"Order Closed"})}),{intent:"success"}),s()}});return e.jsxs(e.Fragment,{children:[e.jsx(O,{label:"Append",size:"large",children:e.jsx(Ue,{value:t,onChange:(h,u)=>o(u.value),maxLength:1e3})}),e.jsxs("div",{className:r.body,children:[e.jsx(i,{onClick:()=>d(n,t),children:"Force Close with Reason"}),e.jsx(i,{appearance:"primary",onClick:()=>a(n,t),children:"Add Comment"})]})]})}const we=S({ten:{flexBasis:"10%",flexGrow:0}}),mn=[p({columnId:"Product",renderHeaderCell(){return e.jsx(g,{children:"Name"})},renderCell(n){return e.jsx(f,{children:n.Name})}}),p({columnId:"Type",renderHeaderCell(){return e.jsx(g,{children:"Type"})},renderCell(n){return e.jsx(f,{children:Object.entries(n.Type).reduce((s,r)=>`${s} ${r[0]} : ${r[1]} ;`,"")})}}),p({columnId:"Quantity",renderHeaderCell(){return e.jsx(g,{className:we().ten,children:"Quantity"})},renderCell(n){return e.jsx(f,{className:we().ten,children:n.Quantity})}})];function hn({Items:n}){return e.jsx(G,{Items:n,Columns:mn})}const xn=new b("Admin","Order","Detail","Shipment");function pn({OrderId:n,TrackingNumber:s,Refresh:r}){const[t,{setTrue:o,setFalse:l}]=I(),[c,a]=w.useState(s),{dispatch:d,dispatchToast:h}=N(xn),{run:u}=x.Order.Post.useShip({manual:!0,onError(j,m){d({Message:"Failed Update Tracking Number",Request:m,Error:j})},onSuccess(){h(e.jsx(A,{children:e.jsx(P,{children:"Tracking Number Updated"})}),{intent:"success"}),l(),r()}});return e.jsx(O,{label:"Shipment",size:"large",children:e.jsx(B,{value:c,disabled:!t,appearance:"underline",onChange:(j,m)=>a(m.value),placeholder:"Fill in this field to ship the order.",contentAfter:t?e.jsx(i,{appearance:"subtle",icon:e.jsx(Y,{}),onClick:()=>u(n,c)}):e.jsx(i,{appearance:"subtle",icon:e.jsx(V,{}),onClick:o})})})}const jn=S({body:{...F,rowGap:E.spacingVerticalXL}}),re=new b("Admin","Order","Detail");function Cn({OrderId:n}){const s=jn(),[r,{setTrue:t,setFalse:o}]=I(),{Nav:l,Paths:c}=_(),a=parseInt(c.at(2)),{data:d,run:h}=T(()=>x.Order.Get.Detail(n,re),{manual:!0,onError:re.error}),{data:u,run:j}=T(()=>x.Order.Get.Order(n),{onError(C){l("Admin","Order"),re.error(C)},manual:!0});function m(){j(),h()}return w.useEffect(()=>{a===n?(m(),t()):o()},[a]),e.jsxs(e.Fragment,{children:[e.jsx(i,{appearance:"subtle",icon:e.jsx(ve,{}),onClick:()=>l("Admin","Order",n)}),e.jsxs(xe,{open:r,position:"end",size:"medium",modalType:"alert",children:[e.jsx(pe,{children:e.jsx(je,{action:e.jsx(i,{appearance:"subtle",icon:e.jsx(L,{}),onClick:()=>l("Admin","Order")}),children:"Order Detail"})}),e.jsxs(Ce,{className:s.body,children:[e.jsx(Ze,{OrderId:n,Order:u,Admin:!0}),e.jsx(O,{label:"Required Products",size:"large",children:e.jsx(hn,{Items:d?.ShopCart})}),e.jsx(pn,{OrderId:n,TrackingNumber:u?.TrackingNumber,Refresh:m}),e.jsx(en,{Comments:d?.Comments}),e.jsx(un,{OrderId:n,Refresh:m}),e.jsx(cn,{OrderId:n,Status:u?.Status,Refresh:m})]})]})]})}const X=S({two:{flexBasis:"2.5%",flexGrow:0},twoc:{flexBasis:"2.5%",flexGrow:0,justifyContent:"center"},ten:{flexBasis:"10%",flexGrow:0}}),le=new b("Admin","Order"),gn=[...nn(le).slice(0,-1),p({columnId:"User",renderHeaderCell:()=>e.jsx(g,{className:X().ten,children:"User"}),renderCell(n){return e.jsx(f,{className:X().ten,children:n.User})}}),p({columnId:"Action",renderHeaderCell:()=>e.jsx(g,{className:X().two,children:"Action"}),renderCell(n){return e.jsx(f,{className:X().twoc,children:e.jsx(Cn,{OrderId:n.Id})})}})];function fn(){const{data:n}=T(()=>x.Order.Get.List(le),{onError:le.error});return e.jsx(G,{Items:n,Columns:gn})}const bn=S({body:{...$,alignItems:"center"},input:{flexGrow:1}}),te=new b("Admin","Product","Detail","Category");function yn({ProdId:n}){const[s,r]=w.useState(""),[t,{setTrue:o,setFalse:l}]=I();T(()=>x.Product.Get.Category(n),{onSuccess(y){y&&r(y)},onError:te.error});const{dispatch:c,dispatchToast:a}=N(te),{run:d}=x.Product.Patch.useCategory({manual:!0,onError(y,D){c({Message:"Failed Update Category",Request:D,Error:y})},onSuccess(){a(e.jsx(A,{children:e.jsx(P,{children:"Category Updated"})}),{intent:"success"}),l()}}),{data:h}=T(()=>q.Gallery.Get.Categories(),{onSuccess(y){j(y)},onError:te.error}),[u,j]=w.useState(h),[m,C]=w.useState(""),v=bn();return e.jsxs("div",{className:v.body,children:[e.jsx(ge,{size:"large",disabled:!t,children:"Category"}),e.jsxs(fe,{className:v.input,size:"large",disabled:!t,freeform:!0,placeholder:s||"Pending",appearance:"underline",onChange:y=>{const D=y.target.value.trim(),k=h?.filter(He=>He.toLowerCase().indexOf(D.toLowerCase())===0);j(k),D&&k&&k.length<1?C(D):C("")},onOptionSelect:(y,D)=>{const k=D.optionText;r(k),k&&h?.includes(k)?C(""):C(k)},children:[m&&e.jsxs(Q,{text:m,children:['Create New "',m,'"']},m),u?.map(y=>e.jsx(Q,{children:y},y))]}),t?e.jsx(i,{appearance:"subtle",icon:e.jsx(Y,{}),onClick:()=>s&&d(n,s)}):e.jsx(i,{appearance:"subtle",icon:e.jsx(V,{}),onClick:o})]})}const An=new b("Admin","Product","Detail","Combo","Delete");function Pn({ComboId:n,Refresh:s}){const{dispatch:r,dispatchToast:t}=N(An),{run:o}=x.Product.Delete.useCombo({manual:!0,onError(l,c){r({Message:"Failed Delete Combo",Request:c,Error:l})},onSuccess(){t(e.jsx(A,{children:e.jsx(P,{children:"Combo Deleted"})}),{intent:"success"}),s()}});return e.jsx(i,{appearance:"subtle",icon:e.jsx(J,{}),onClick:()=>o(n)})}const Nn=[p({columnId:"Variant",renderHeaderCell:()=>e.jsx(g,{children:"Variant"}),renderCell(n){return e.jsx(f,{children:n.Name})}}),p({columnId:"Type",renderHeaderCell:()=>e.jsx(g,{children:"Type"}),renderCell(n){return e.jsx(f,{children:e.jsx(fe,{defaultValue:n.Current,defaultSelectedOptions:[n.Current],onOptionSelect:(s,r)=>n.Update(r.optionValue),children:n.Types.map((s,r)=>e.jsx(Q,{children:s},r))})})}})],wn=S({body:{...$,justifyContent:"flex-end",alignItems:"center",columnGap:E.spacingVerticalM,marginTop:E.spacingHorizontalM}}),ae=new b("Admin","Product","Detail","Combo","Detail");function Sn({Id:n,ProdId:s,Combo:r,Stock:t,Refresh:o}){const[l,{toggle:c}]=I(),[a,d]=w.useState(r),[h,u]=w.useState(t),{data:j}=T(()=>x.Product.Get.Variants(s,ae),{onError:ae.error}),{dispatch:m,dispatchToast:C}=N(ae),{run:v}=x.Product.Patch.useCombo({manual:!0,onError(y,D){m({Message:"Failed Update Combo",Request:D,Error:y})},onSuccess(){C(e.jsx(A,{children:e.jsx(P,{children:"Combo Updated"})}),{intent:"success"}),o(),c()}});return e.jsxs(K,{open:l,onOpenChange:c,children:[e.jsx(R,{disableButtonEnhancement:!0,children:e.jsx(i,{appearance:"subtle",icon:e.jsx(V,{})})}),e.jsx(W,{children:e.jsxs(Z,{children:[e.jsx(ee,{action:e.jsx(R,{disableButtonEnhancement:!0,children:e.jsx(i,{appearance:"subtle",icon:e.jsx(L,{})})}),children:"Combo Detail"}),e.jsxs(ne,{children:[e.jsx(G,{Items:j?.map(y=>({Current:a[y.Name],Update(D){a[y.Name]=D,d({...a})},...y})),Columns:Nn}),e.jsxs("div",{className:wn().body,children:[e.jsx(ge,{children:"Stock"}),e.jsx(Ie,{value:h,min:0,onChange:(y,D)=>{if(D.value)u(D.value);else if(D.displayValue){const k=parseInt(D.displayValue);Re(k)&&u(k)}}}),e.jsx(i,{appearance:"primary",onClick:()=>v(n,a,h),children:"Submit"})]})]})]})})]})}const Dn=[p({columnId:"Variant",renderHeaderCell:()=>e.jsx(g,{children:"Variant"}),renderCell(n){return e.jsx(f,{children:n.Name})}}),p({columnId:"Type",renderHeaderCell:()=>e.jsx(g,{children:"Type"}),renderCell(n){return e.jsx(f,{children:e.jsx(fe,{onOptionSelect:(s,r)=>n.Update(r.optionValue),children:n.Types.map((s,r)=>e.jsx(Q,{children:s},r))})})}})],En=S({body:{...$,justifyContent:"flex-end",alignItems:"center",columnGap:E.spacingVerticalM,marginTop:E.spacingHorizontalM}}),oe=new b("Admin","Product","Detail","Combo","NewCombo");function Tn({ProdId:n,Refresh:s}){const[r,{toggle:t}]=I(),[o,l]=w.useState({}),[c,a]=w.useState(1),{data:d}=T(()=>x.Product.Get.Variants(n,oe),{onSuccess(m){for(const C of m)o[C.Name]="";l({...o})},onError:oe.error}),{dispatch:h,dispatchToast:u}=N(oe),{run:j}=x.Product.Post.useCombo({manual:!0,onError(m,C){h({Message:"Failed Create Combo",Request:C,Error:m})},onSuccess(){u(e.jsx(A,{children:e.jsx(P,{children:"Combo Created"})}),{intent:"success"}),s(),t()}});return e.jsxs(K,{open:r,onOpenChange:t,children:[e.jsx(R,{disableButtonEnhancement:!0,children:e.jsx(i,{appearance:"primary",icon:e.jsx(se,{}),children:"New Combo"})}),e.jsx(W,{children:e.jsxs(Z,{children:[e.jsx(ee,{action:e.jsx(R,{disableButtonEnhancement:!0,children:e.jsx(i,{appearance:"subtle",icon:e.jsx(L,{})})}),children:"New Combo"}),e.jsxs(ne,{children:[e.jsx(G,{Items:d?.map(m=>({Update(C){o[m.Name]=C,l({...o})},...m})),Columns:Dn}),e.jsxs("div",{className:En().body,children:[e.jsx(ge,{children:"Stock"}),e.jsx(Ie,{value:c,min:0,onChange:(m,C)=>{if(C.value)a(C.value);else if(C.displayValue){const v=parseInt(C.displayValue);Re(v)&&a(v)}}}),e.jsx(i,{appearance:"primary",onClick:()=>j(n,o,c),children:"Create"})]})]})]})})]})}const H=S({body:{...$,justifyContent:"space-between"},four:{flexBasis:"4%",flexGrow:0},seven:{flexBasis:"7%",flexGrow:0},five:{flexBasis:"5%",flexGrow:0}}),Se=new b("Admin","Product","Detail","Combo"),vn=[p({columnId:"Id",renderHeaderCell:()=>e.jsx(g,{className:H().four,children:"Id"}),renderCell(n){return e.jsx(f,{className:H().four,children:n.Id})}}),p({columnId:"Combo",renderHeaderCell:()=>e.jsx(g,{children:"Combo"}),renderCell(n){return e.jsx(f,{children:Object.entries(n.Combo).reduce((s,r)=>`${s} ${r[0]} : ${r[1]} ;`,"")})}}),p({columnId:"Stock",renderHeaderCell:()=>e.jsx(g,{className:H().five,children:"Stock"}),renderCell(n){return e.jsx(f,{className:H().five,children:n.Stock})}}),p({columnId:"Action",renderHeaderCell:()=>e.jsx(g,{className:H().seven,children:"Action"}),renderCell(n){return e.jsxs(f,{className:H().seven,children:[e.jsx(Sn,{...n}),e.jsx(Pn,{ComboId:n.Id,Refresh:n.Refresh})]})}})];function In({ProdId:n}){const{data:s,run:r}=T(()=>q.Product.Get.Combo(n,Se),{onError:Se.error});return e.jsxs(e.Fragment,{children:[e.jsxs("div",{className:H().body,children:[e.jsx(be,{children:"Combo"}),e.jsx(Tn,{ProdId:n,Refresh:r})]}),e.jsx(G,{Items:s?.map(t=>({ProdId:n,Refresh:r,...t})),Columns:vn})]})}const kn=new b("Admin","Product","Detail","Delete"),$n=S({root:{...F,rowGap:E.spacingHorizontalS}});function Gn({ProdId:n}){const{Nav:s}=_(),{dispatch:r,dispatchToast:t}=N(kn),{run:o,loading:l}=x.Product.Delete.useProduct({manual:!0,onError(a,d){r({Message:"Failed Delete Product",Request:d,Error:a})},onSuccess(){t(e.jsx(A,{children:e.jsx(P,{children:"Product Deleted"})}),{intent:"success"}),s("/Admin")}}),c=$n();return e.jsx("div",{children:e.jsxs(ye,{withArrow:!0,children:[e.jsx(Ae,{disableButtonEnhancement:!0,children:e.jsx(i,{children:"Delete Product"})}),e.jsxs(Pe,{className:c.root,children:["Are You Sure?",e.jsx(i,{disabled:l,appearance:"primary",onClick:()=>o(n),children:"Yes"})]})]})})}const Rn=S({btn:{...$,columnGap:E.spacingVerticalS},drawer:{width:"1100px"}}),Vn=new b("Admin","Product","Lexical");function Fn({ProdId:n}){const s=Rn(),[r,{toggle:t,setTrue:o}]=I(),{data:l,run:c}=T(()=>q.Product.Get.Lexical(n)),{dispatch:a,dispatchToast:d}=N(Vn),{run:h}=x.Product.Post.useLexical({manual:!0,onError(u,j){a({Message:"Failed Update Description",Request:j,Error:u})},onSuccess(){d(e.jsx(A,{children:e.jsx(P,{children:"Description Updated"})}),{intent:"success"}),c(),t()}});return e.jsxs(e.Fragment,{children:[e.jsx("div",{children:e.jsx(i,{onClick:()=>o(),children:"Open Description Editor"})}),e.jsxs(xe,{open:r,onOpenChange:t,position:"start",size:"large",modalType:"alert",className:s.drawer,children:[e.jsx(pe,{children:e.jsx(je,{action:e.jsxs("div",{className:s.btn,children:[e.jsx(i,{appearance:"primary",onClick:()=>h(n),children:"Save"}),e.jsx(i,{onClick:()=>t(),children:"Cancel"})]}),children:"Edit Product Description"})}),e.jsx(Ce,{children:e.jsx(rn,{State:l?.Description})})]})]})}const De=new b("Admin","Product","Detail","Name");function Hn({ProdId:n}){const[s,r]=w.useState(""),[t,{setTrue:o,setFalse:l}]=I(),{Nav:c}=_();T(()=>x.Product.Get.Name(n),{onSuccess(u){r(u)},onError(u){c("Admin"),De.error(u)}});const{dispatch:a,dispatchToast:d}=N(De),{run:h}=x.Product.Patch.useName({manual:!0,onError(u,j){a({Message:"Failed Update Name",Request:j,Error:u})},onSuccess(){d(e.jsx(A,{children:e.jsx(P,{children:"Name Updated"})}),{intent:"success"}),l()}});return e.jsx(B,{size:"large",value:s,disabled:!t,appearance:"underline",onChange:(u,j)=>r(j.value),contentBefore:e.jsx(ke,{children:"Name"}),contentAfter:t?e.jsx(i,{appearance:"subtle",icon:e.jsx(Y,{}),onClick:()=>h(n,s)}):e.jsx(i,{appearance:"subtle",icon:e.jsx(V,{}),onClick:o})})}const Un=S({box:{...$,columnGap:E.spacingHorizontalL},img:{...Ke,aspectRatio:"1",width:"50%"},cap:{...F,flexGrow:1,rowGap:E.spacingVerticalL}}),ce=new b("Admin","Product","Detail","Photo","Edit");function On({Photo:{Id:n,Cover:s,Caption:r},Refresh:t}){const o=Un(),[l,c]=w.useState(r||""),{dispatch:a,dispatchToast:d}=N(ce),{run:h}=x.Product.Patch.useCaption({manual:!0,onError(m,C){a({Message:"Failed Update Caption",Request:C,Error:m})},onSuccess(){d(e.jsx(A,{children:e.jsx(P,{children:"Caption Updated"})}),{intent:"success"}),t()}}),{run:u}=x.Product.Patch.usePhoto(ce,{manual:!0,onError(m,C){a({Message:"Failed Update Photo",Request:C,Error:m})},onSuccess(){d(e.jsx(A,{children:e.jsx(P,{children:"Photo Updated"})}),{intent:"success"}),t()}}),{run:j}=x.Product.Delete.usePhoto({manual:!0,onError(m,C){a({Message:"Failed Delete Photo",Request:C,Error:m})},onSuccess(){d(e.jsx(A,{children:e.jsx(P,{children:"Photo Deleted"})}),{intent:"success"}),t()}});return e.jsxs(K,{children:[e.jsx(R,{disableButtonEnhancement:!0,children:e.jsx(i,{appearance:"subtle",icon:e.jsx(V,{})})}),e.jsx(W,{children:e.jsxs(Z,{children:[e.jsx(ee,{action:e.jsx(R,{disableButtonEnhancement:!0,children:e.jsx(i,{appearance:"subtle",icon:e.jsx(L,{})})}),children:"Image Detail"}),e.jsxs(ne,{className:o.box,children:[e.jsx(We,{shape:"rounded",className:o.img,Guid:s,Log:ce}),e.jsxs("div",{className:o.cap,children:[e.jsx(O,{label:"Caption",children:e.jsx(B,{value:l,onChange:(m,C)=>c(C.value)})}),e.jsx(i,{onClick:()=>h(n,l),children:"Save Caption"}),e.jsx(i,{onClick:()=>{const m=document.createElement("input");m.type="file",m.accept="image/*",m.onchange=()=>{m.files&&u(n,m.files[0])},m.click()},children:"Replace"}),e.jsx(i,{appearance:"primary",onClick:()=>j(n),children:"Delete"})]})]})]})})]})}const ie=S({f11:{flexBasis:"11%",flexGrow:0},box:{...$,justifyContent:"space-between"}}),M=new b("Admin","Product","Detail","Photo"),Mn=[Ge(70,M),p({columnId:"Caption",renderHeaderCell:()=>e.jsx(g,{children:"Caption"}),renderCell(n){return e.jsx(f,{children:n.Caption})}}),p({columnId:"Action",renderHeaderCell:()=>e.jsx(g,{className:ie().f11,children:"Action"}),renderCell(n){const{dispatch:s}=N(M),{run:r}=x.Product.Post.useMovePhoto({manual:!0,onError(t,o){s({Message:"Failed Update Order",Request:o,Error:t})},onSuccess:de});return e.jsxs(f,{className:ie().f11,children:[e.jsx(i,{appearance:"subtle",icon:e.jsx(Oe,{}),onClick:()=>r(n.Id,!0)}),e.jsx(i,{appearance:"subtle",icon:e.jsx(Me,{}),onClick:()=>r(n.Id,!1)}),e.jsx(On,{Photo:n,Refresh:de})]})}})];let de;function Bn({ProdId:n}){const[s,r]=w.useState([]),{run:t}=T(()=>q.Product.Get.PhotoList(n,M),{onError:M.error,onSuccess([a]){const d=a.map(h=>({Id:h.Order,Cover:h.ObjectId,Caption:h.Caption||"No Caption"}));r(d)}});de=t;const{dispatch:o,dispatchToast:l}=N(M),{run:c}=x.Product.Post.usePhoto(M,{manual:!0,onError(a,d){o({Message:"Failed Upload Photo",Request:d,Error:a})},onSuccess(){l(e.jsx(A,{children:e.jsx(P,{children:"Photo Uploaded"})}),{intent:"success"}),t()}});return e.jsxs(e.Fragment,{children:[e.jsxs("div",{className:ie().box,children:[e.jsx(be,{children:"Photos"}),e.jsx(i,{appearance:"primary",icon:e.jsx(se,{}),onClick:()=>{const a=document.createElement("input");a.type="file",a.accept="image/*",a.onchange=()=>{a.files&&c(n,a.files[0])},a.click()},children:"New Image"})]}),e.jsx(G,{Items:s,Columns:Mn})]})}const Ln=new b("Admin","Product","Detail","Variant","Delete");function qn({VariantId:n,Refresh:s}){const{dispatch:r,dispatchToast:t}=N(Ln),{run:o}=x.Product.Delete.useVariant({manual:!0,onError(l,c){r({Message:"Failed Delete Variant",Request:c,Error:l})},onSuccess(){t(e.jsx(A,{children:e.jsx(P,{children:"Variant Deleted"})}),{intent:"success"}),s()}});return e.jsx(i,{appearance:"subtle",icon:e.jsx(J,{}),onClick:()=>o(n)})}const zn=new b("Admin","Product","Detail","Variant","Edit","TypeDelete");function _n({VariantId:n,Type:s,Refresh:r}){const{dispatch:t,dispatchToast:o}=N(zn),{run:l}=x.Product.Delete.useType({manual:!0,onError(c,a){t({Message:"Failed Delete Type",Request:a,Error:c})},onSuccess(){o(e.jsx(A,{children:e.jsx(P,{children:"Type Deleted"})}),{intent:"success"}),r()}});return e.jsx(i,{appearance:"subtle",icon:e.jsx(J,{}),onClick:()=>l(n,s)})}const Xn=new b("Admin","Product","Detail","Variant","Edit","Name");function Qn({Id:n,Name:s}){const[r,t]=w.useState(s),[o,{setTrue:l,setFalse:c}]=I(),{dispatch:a,dispatchToast:d}=N(Xn),{run:h}=x.Product.Patch.useVariantName({manual:!0,onError(u,j){a({Message:"Failed Update Variant Name",Request:j[0],Error:u})},onSuccess(){d(e.jsx(A,{children:e.jsx(P,{children:"Variant Name Updated"})}),{intent:"success"}),c()}});return e.jsx(B,{size:"large",value:r,disabled:!o,appearance:"underline",onChange:(u,j)=>t(j.value),contentBefore:e.jsx(ke,{children:"Name"}),contentAfter:o?e.jsx(i,{appearance:"subtle",icon:e.jsx(Y,{}),onClick:()=>h(n,r)}):e.jsx(i,{appearance:"subtle",icon:e.jsx(V,{}),onClick:l})})}const Yn=S({body:{...F,rowGap:E.spacingVerticalM}}),Jn=new b("Admin","Product","Detail","Variant","Edit","Type");function Ve({VariantId:n,Type:s,Refresh:r,New:t}){const o=Yn(),[l,{toggle:c}]=I(),[a,d]=w.useState(s||""),{dispatch:h,dispatchToast:u}=N(Jn),j={manual:!0,onError(v,y){h({Message:`Failed ${t?"Create":"Update"} Type ${a}`,Request:y,Error:v})},onSuccess(v){u(e.jsxs(A,{children:[e.jsxs(P,{children:["Type ",t?"Created":"Updated"]}),e.jsxs(Be,{children:[v," ",a]})]}),{intent:"success"}),r(),d(""),c()}},{run:m}=x.Product.Post.useType(j),{run:C}=x.Product.Patch.useType(j);return e.jsxs(ye,{withArrow:!0,open:l,onOpenChange:c,children:[e.jsx(Ae,{disableButtonEnhancement:!0,children:t?e.jsx(i,{icon:e.jsx(se,{}),appearance:"primary",children:"New Type"}):e.jsx(i,{appearance:"subtle",icon:e.jsx(V,{})})}),e.jsxs(Pe,{className:o.body,children:[e.jsx(O,{label:"Type Name",children:e.jsx(B,{value:a,onChange:(v,y)=>d(y.value)})}),e.jsx(i,{onClick:()=>t?m(n,a):C(n,s,a),children:"Submit"})]})]})}const ue=S({body:{...F,rowGap:E.spacingVerticalM},twelve:{flexBasis:"12%",flexGrow:0}}),Kn=[p({columnId:"Name",renderHeaderCell:()=>e.jsx(g,{children:"Name"}),renderCell(n){return e.jsx(f,{children:n.Name})}}),p({columnId:"Action",renderHeaderCell:()=>e.jsx(g,{className:ue().twelve,children:"Action"}),renderCell(n){return e.jsxs(f,{className:ue().twelve,children:[e.jsx(Ve,{VariantId:n.VariantId,Type:n.Name,Refresh:n.Refresh}),e.jsx(_n,{VariantId:n.VariantId,Type:n.Name,Refresh:n.Refresh})]})}})];function Wn({Variant:n,Refresh:s}){return e.jsxs(K,{children:[e.jsx(R,{disableButtonEnhancement:!0,children:e.jsx(i,{appearance:"subtle",icon:e.jsx(V,{})})}),e.jsx(W,{children:e.jsxs(Z,{children:[e.jsx(ee,{action:e.jsx(R,{disableButtonEnhancement:!0,children:e.jsx(i,{appearance:"subtle",icon:e.jsx(L,{})})}),children:"Variant Detail"}),e.jsxs(ne,{className:ue().body,children:[e.jsx(Qn,{Id:n.Id,Name:n.Name}),e.jsx(G,{Items:n.Types.map((r,t)=>({Id:t,Name:r,VariantId:n.Id,Refresh:s})),Columns:Kn})]}),e.jsx(Le,{children:e.jsx(Ve,{VariantId:n.Id,Refresh:s,New:!0})})]})})]})}const Zn=S({body:{...F,rowGap:E.spacingVerticalM}}),es=new b("Admin","Product","Detail","Variant","New");function ns({ProdId:n,Refresh:s}){const r=Zn(),[t,{toggle:o}]=I(),[l,c]=w.useState(""),{dispatch:a,dispatchToast:d}=N(es),{run:h}=x.Product.Post.useVariant({manual:!0,onError(u,j){a({Message:"Failed Create Variant",Request:j,Error:u})},onSuccess(){d(e.jsx(A,{children:e.jsx(P,{children:"Variant Created"})}),{intent:"success"}),s(),c(""),o()}});return e.jsxs(ye,{withArrow:!0,open:t,onOpenChange:o,children:[e.jsx(Ae,{disableButtonEnhancement:!0,children:e.jsx(i,{appearance:"primary",icon:e.jsx(se,{}),children:"New Variant"})}),e.jsxs(Pe,{className:r.body,children:[e.jsx(O,{required:!0,label:"Variant Name",children:e.jsx(B,{value:l,onChange:(u,j)=>c(j.value)})}),e.jsx(i,{onClick:()=>h(n,l),children:"Add"})]})]})}const U=S({body:{...$,justifyContent:"space-between"},four:{flexBasis:"4%",flexGrow:0},seven:{flexBasis:"7%",flexGrow:0},twelve:{flexBasis:"12%",flexGrow:0}}),Ee=new b("Admin","Product","Detail","Variant"),ss=[p({columnId:"Id",renderHeaderCell:()=>e.jsx(g,{className:U().four,children:"Id"}),renderCell(n){return e.jsx(f,{className:U().four,children:n.Id})}}),p({columnId:"Name",renderHeaderCell:()=>e.jsx(g,{className:U().twelve,children:"Name"}),renderCell(n){return e.jsx(f,{className:U().twelve,children:n.Name})}}),p({columnId:"Type",renderHeaderCell:()=>e.jsx(g,{children:"Type"}),renderCell(n){return e.jsx(f,{children:n.Types.reduce((s,r)=>`${s} ${r} ;`,"")})}}),p({columnId:"Action",renderHeaderCell:()=>e.jsx(g,{className:U().seven,children:"Action"}),renderCell(n){return e.jsxs(f,{className:U().seven,children:[e.jsx(Wn,{Variant:n,Refresh:me}),e.jsx(qn,{VariantId:n.Id,Refresh:me})]})}})];let me;function rs({ProdId:n}){const s=U(),{data:r,run:t}=T(()=>x.Product.Get.Variants(n,Ee),{onError:Ee.error});return me=t,e.jsxs(e.Fragment,{children:[e.jsxs("div",{className:s.body,children:[e.jsx(be,{children:"Variant"}),e.jsx(ns,{ProdId:n,Refresh:t})]}),e.jsx(G,{Items:r,Columns:ss})]})}const ts=S({body:{...F,rowGap:E.spacingVerticalXL,paddingBottom:E.spacingVerticalXXXL}});function as({ProdId:n}){const s=ts(),[r,{setFalse:t,setTrue:o}]=I(),{Nav:l,Paths:c}=_(),a=parseInt(c.at(1));return w.useEffect(()=>{a===n?o():t()},[c]),e.jsxs(e.Fragment,{children:[e.jsx(i,{appearance:"subtle",icon:e.jsx(ve,{}),onClick:()=>{l("Admin",n),o()}}),e.jsxs(xe,{open:r,position:"end",size:"large",modalType:"alert",children:[e.jsx(pe,{children:e.jsx(je,{action:e.jsx(i,{appearance:"subtle",icon:e.jsx(L,{}),onClick:()=>{l("Admin"),t()}}),children:"Product Detail"})}),e.jsxs(Ce,{className:s.body,children:[e.jsx(Hn,{ProdId:n}),e.jsx(yn,{ProdId:n}),e.jsx(Bn,{ProdId:n}),e.jsx(rs,{ProdId:n}),e.jsx(In,{ProdId:n}),e.jsx(Fn,{ProdId:n}),e.jsx(Gn,{ProdId:n})]})]})]})}const z=new b("Admin","Product","Row");function os({item:n}){const[s,r]=w.useState(()=>({Id:n,Cover:"",Name:"Loading..."})),[t,{setTrue:o}]=I(),l=q.Product.Get;return qe(async()=>{const c=await l.Product(n).catch(z.error);if(!c)return z.warn(`Product ${n} Not Found`),o();let a={...s,Name:c.Name,Category:c.Category||"Pending"};r(a);const[d,h]=await l.PhotoList(n,z);h||z.warn(`Product ${n} has no photo`),r(a={...a,Cover:h});const u=await x.Product.Get.Count(n).catch(z.error);u&&r({...a,...u})},[]),t?null:e.jsx($e,{children:({renderCell:c})=>c(s)},n)}const Te=S({two:{flexBasis:"2.5%",flexGrow:0},twoc:{flexBasis:"2.5%",flexGrow:0,justifyContent:"center"}}),Fe=new b("Admin","Product"),cs=[Ge(50,Fe),p({columnId:"Product",renderHeaderCell:()=>e.jsx(g,{children:"Product"}),renderCell(n){return e.jsx(f,{children:e.jsx(Ne,{children:n.Name})})}}),p({columnId:"Category",renderHeaderCell:()=>e.jsx(g,{children:"Category"}),renderCell(n){return e.jsx(f,{children:e.jsx(Ne,{children:n.Category})})}}),p({columnId:"Variant",renderHeaderCell:()=>e.jsx(g,{children:"Variant"}),renderCell(n){return e.jsx(f,{children:n.Variant})}}),p({columnId:"Combo",renderHeaderCell:()=>e.jsx(g,{children:"Combo"}),renderCell(n){return e.jsx(f,{children:n.Combo})}}),p({columnId:"Stock",renderHeaderCell:()=>e.jsx(g,{children:"Stock"}),renderCell(n){return e.jsx(f,{children:n.Stock})}}),p({columnId:"Action",renderHeaderCell:()=>e.jsx(g,{className:Te().two,children:"Detail"}),renderCell(n){return e.jsx(f,{className:Te().twoc,children:e.jsx(as,{ProdId:n.Id})})}})];function ls(){const n=x.Product.Get.useList(Fe);return e.jsxs(ze,{items:n?n.reverse():[],columns:cs,children:[e.jsx(_e,{children:e.jsx($e,{children:({renderHeaderCell:s})=>s()})}),e.jsx(Xe,{children:s=>e.jsx(os,{...s})}),!n&&e.jsx(Qe,{size:48})]})}const is=new b("Admin","User","Delete");function ds({UserId:n,Refresh:s}){const{dispatch:r,dispatchToast:t}=N(is),{run:o}=x.User.Delete.useUser({manual:!0,onError(l,c){r({Message:"Failed Delete User",Request:c,Error:l})},onSuccess(){t(e.jsx(A,{children:e.jsx(P,{children:"User Deleted"})}),{intent:"success"}),s()}});return e.jsx(i,{appearance:"subtle",icon:e.jsx(J,{}),onClick:()=>o(n)})}const us=new b("Admin","User","Grant");function ms({UserId:n,Admin:s,Refresh:r}){const{dispatch:t,dispatchToast:o}=N(us),{run:l}=x.User.Post.useAdmin({manual:!0,onError(a,d){t({Message:"Failed Grant Admin",Request:d,Error:a})},onSuccess(){o(e.jsx(A,{children:e.jsx(P,{children:"Admin Granted"})}),{intent:"success"}),r()}}),{run:c}=x.User.Delete.useAdmin({manual:!0,onError(a,d){t({Message:"Failed Revoke Admin",Request:d,Error:a})},onSuccess(){o(e.jsx(A,{children:e.jsx(P,{children:"Admin Revoked"})}),{intent:"success"}),r()}});return e.jsx(Ye,{checked:s,onChange:(a,d)=>{d.checked?l(n):c(n)}})}const hs=new b("Admin","User"),xs=[p({columnId:"Id",renderHeaderCell:()=>"Id",renderCell(n){return n.Id}}),p({columnId:"Name",renderHeaderCell:()=>"Real Name",renderCell(n){return n.Name}}),p({columnId:"Email",renderHeaderCell:()=>"E-Mail",renderCell(n){return n.EMail}}),p({columnId:"Admin",renderHeaderCell:()=>"Admin",renderCell(n){return e.jsx(ms,{UserId:n.Id,Admin:n.Admin,Refresh:he})}}),p({columnId:"Delete",renderHeaderCell:()=>"Delete",renderCell(n){return e.jsx(ds,{UserId:n.Id,Refresh:he})}})].map(({renderHeaderCell:n,renderCell:s,...r})=>({...r,renderHeaderCell:()=>e.jsx(g,{children:n()}),renderCell:t=>e.jsx(f,{children:s(t)})}));let he;function ps(){const{data:n,run:s}=T(()=>x.User.Get.List(),{onError:hs.error});return he=s,e.jsx(G,{Items:n,Columns:xs})}const js=new b("Admin");function Ps(){const{Paths:n,Nav:s}=_(),r=n.at(1),t=w.useMemo(()=>{switch(r){case"Order":return e.jsx(fn,{});case"User":return e.jsx(ps,{});default:return e.jsx(ls,{})}},[r]),o=q.User.Get.useMe(js);return o?o.Admin?t:s("/"):e.jsx(Je,{size:"huge",label:"Authenticating..."})}export{Ps as default}; +import{m as S,j as e,T as A,b as P,F as O,B as i,r as w,ah as Ue,a5 as p,a6 as g,a7 as f,o as I,I as B,aE as Y,aF as V,t as E,x as T,aG as ve,ac as xe,ad as pe,ae as je,af as L,ag as Ce,L as ge,aH as fe,aI as Q,ab as J,D as K,n as R,g as W,h as Z,i as ee,k as ne,aa as Ie,N as se,aB as be,aj as ye,ak as Ae,ao as Pe,O as ke,aJ as Oe,aK as Me,c as Be,l as Le,aL as qe,a1 as $e,$ as ze,a0 as _e,a2 as Xe,a3 as Qe,a8 as Ne,aM as Ye,ar as Je}from"./vendor-DpqXKvKY.js";import{L as b,a as F,e as N,A as x,F as $,f as G,c as _,H as q,C as Ke,G as We,M as Ge}from"./index-7dlI38O5.js";import{O as Ze,a as en,H as nn}from"./Columns-Qu8-yOAT.js";import{t as sn}from"./toFinite-GMFxiq4g.js";import{L as rn}from"./Lazy-XJRXDq2K.js";import"./isObject-tyZXtoJz.js";function tn(n){var s=sn(n),r=s%1;return s===s?r?s-r:s:0}function Re(n){return typeof n=="number"&&n==tn(n)}const an=S({body:{...F,alignItems:"flex-start"}}),on=new b("Admin","Order","Detail","Action");function cn({OrderId:n,Status:s,Refresh:r}){const t=an(),{dispatch:o,dispatchToast:l}=N(on),{run:c}=x.Order.Post.useAccept({manual:!0,onError(a,d){o({Message:"Failed Accept Order",Request:d,Error:a})},onSuccess(){l(e.jsx(A,{children:e.jsx(P,{children:"Order Accepted"})}),{intent:"success"}),r()}});switch(s){case"Processing":case"Shipping":case"Finished":case"Cancelled":case"Returning":return null}return e.jsx(O,{label:"Action",size:"large",children:e.jsx("div",{className:t.body,children:s==="Pending"&&e.jsx(i,{appearance:"subtle",onClick:()=>c(n),children:"Accept Order"})})})}const ln=S({body:{...$,justifyContent:"space-between"}}),dn=new b("Admin","Order","Detail","Append");function un({OrderId:n,Refresh:s}){const r=ln(),[t,o]=w.useState(),{dispatch:l,dispatchToast:c}=N(dn),{run:a}=x.Order.Post.useAppend({manual:!0,onError(h,u){l({Message:"Failed Append Comment",Request:u,Error:h})},onSuccess(){c(e.jsx(A,{children:e.jsx(P,{children:"Comment Appended"})}),{intent:"success"}),s()}}),{run:d}=x.Order.Post.useClose({manual:!0,onError(h,u){l({Message:"Failed Close Order",Request:u,Error:h})},onSuccess(){c(e.jsx(A,{children:e.jsx(P,{children:"Order Closed"})}),{intent:"success"}),s()}});return e.jsxs(e.Fragment,{children:[e.jsx(O,{label:"Append",size:"large",children:e.jsx(Ue,{value:t,onChange:(h,u)=>o(u.value),maxLength:1e3})}),e.jsxs("div",{className:r.body,children:[e.jsx(i,{onClick:()=>d(n,t),children:"Force Close with Reason"}),e.jsx(i,{appearance:"primary",onClick:()=>a(n,t),children:"Add Comment"})]})]})}const we=S({ten:{flexBasis:"10%",flexGrow:0}}),mn=[p({columnId:"Product",renderHeaderCell(){return e.jsx(g,{children:"Name"})},renderCell(n){return e.jsx(f,{children:n.Name})}}),p({columnId:"Type",renderHeaderCell(){return e.jsx(g,{children:"Type"})},renderCell(n){return e.jsx(f,{children:Object.entries(n.Type).reduce((s,r)=>`${s} ${r[0]} : ${r[1]} ;`,"")})}}),p({columnId:"Quantity",renderHeaderCell(){return e.jsx(g,{className:we().ten,children:"Quantity"})},renderCell(n){return e.jsx(f,{className:we().ten,children:n.Quantity})}})];function hn({Items:n}){return e.jsx(G,{Items:n,Columns:mn})}const xn=new b("Admin","Order","Detail","Shipment");function pn({OrderId:n,TrackingNumber:s,Refresh:r}){const[t,{setTrue:o,setFalse:l}]=I(),[c,a]=w.useState(s),{dispatch:d,dispatchToast:h}=N(xn),{run:u}=x.Order.Post.useShip({manual:!0,onError(j,m){d({Message:"Failed Update Tracking Number",Request:m,Error:j})},onSuccess(){h(e.jsx(A,{children:e.jsx(P,{children:"Tracking Number Updated"})}),{intent:"success"}),l(),r()}});return e.jsx(O,{label:"Shipment",size:"large",children:e.jsx(B,{value:c,disabled:!t,appearance:"underline",onChange:(j,m)=>a(m.value),placeholder:"Fill in this field to ship the order.",contentAfter:t?e.jsx(i,{appearance:"subtle",icon:e.jsx(Y,{}),onClick:()=>u(n,c)}):e.jsx(i,{appearance:"subtle",icon:e.jsx(V,{}),onClick:o})})})}const jn=S({body:{...F,rowGap:E.spacingVerticalXL}}),re=new b("Admin","Order","Detail");function Cn({OrderId:n}){const s=jn(),[r,{setTrue:t,setFalse:o}]=I(),{Nav:l,Paths:c}=_(),a=parseInt(c.at(2)),{data:d,run:h}=T(()=>x.Order.Get.Detail(n,re),{manual:!0,onError:re.error}),{data:u,run:j}=T(()=>x.Order.Get.Order(n),{onError(C){l("Admin","Order"),re.error(C)},manual:!0});function m(){j(),h()}return w.useEffect(()=>{a===n?(m(),t()):o()},[a]),e.jsxs(e.Fragment,{children:[e.jsx(i,{appearance:"subtle",icon:e.jsx(ve,{}),onClick:()=>l("Admin","Order",n)}),e.jsxs(xe,{open:r,position:"end",size:"medium",modalType:"alert",children:[e.jsx(pe,{children:e.jsx(je,{action:e.jsx(i,{appearance:"subtle",icon:e.jsx(L,{}),onClick:()=>l("Admin","Order")}),children:"Order Detail"})}),e.jsxs(Ce,{className:s.body,children:[e.jsx(Ze,{OrderId:n,Order:u,Admin:!0}),e.jsx(O,{label:"Required Products",size:"large",children:e.jsx(hn,{Items:d?.ShopCart})}),e.jsx(pn,{OrderId:n,TrackingNumber:u?.TrackingNumber,Refresh:m}),e.jsx(en,{Comments:d?.Comments}),e.jsx(un,{OrderId:n,Refresh:m}),e.jsx(cn,{OrderId:n,Status:u?.Status,Refresh:m})]})]})]})}const X=S({two:{flexBasis:"2.5%",flexGrow:0},twoc:{flexBasis:"2.5%",flexGrow:0,justifyContent:"center"},ten:{flexBasis:"10%",flexGrow:0}}),le=new b("Admin","Order"),gn=[...nn(le).slice(0,-1),p({columnId:"User",renderHeaderCell:()=>e.jsx(g,{className:X().ten,children:"User"}),renderCell(n){return e.jsx(f,{className:X().ten,children:n.User})}}),p({columnId:"Action",renderHeaderCell:()=>e.jsx(g,{className:X().two,children:"Action"}),renderCell(n){return e.jsx(f,{className:X().twoc,children:e.jsx(Cn,{OrderId:n.Id})})}})];function fn(){const{data:n}=T(()=>x.Order.Get.List(le),{onError:le.error});return e.jsx(G,{Items:n,Columns:gn})}const bn=S({body:{...$,alignItems:"center"},input:{flexGrow:1}}),te=new b("Admin","Product","Detail","Category");function yn({ProdId:n}){const[s,r]=w.useState(""),[t,{setTrue:o,setFalse:l}]=I();T(()=>x.Product.Get.Category(n),{onSuccess(y){y&&r(y)},onError:te.error});const{dispatch:c,dispatchToast:a}=N(te),{run:d}=x.Product.Patch.useCategory({manual:!0,onError(y,D){c({Message:"Failed Update Category",Request:D,Error:y})},onSuccess(){a(e.jsx(A,{children:e.jsx(P,{children:"Category Updated"})}),{intent:"success"}),l()}}),{data:h}=T(()=>q.Gallery.Get.Categories(),{onSuccess(y){j(y)},onError:te.error}),[u,j]=w.useState(h),[m,C]=w.useState(""),v=bn();return e.jsxs("div",{className:v.body,children:[e.jsx(ge,{size:"large",disabled:!t,children:"Category"}),e.jsxs(fe,{className:v.input,size:"large",disabled:!t,freeform:!0,placeholder:s||"Pending",appearance:"underline",onChange:y=>{const D=y.target.value.trim(),k=h?.filter(He=>He.toLowerCase().indexOf(D.toLowerCase())===0);j(k),D&&k&&k.length<1?C(D):C("")},onOptionSelect:(y,D)=>{const k=D.optionText;r(k),k&&h?.includes(k)?C(""):C(k)},children:[m&&e.jsxs(Q,{text:m,children:['Create New "',m,'"']},m),u?.map(y=>e.jsx(Q,{children:y},y))]}),t?e.jsx(i,{appearance:"subtle",icon:e.jsx(Y,{}),onClick:()=>s&&d(n,s)}):e.jsx(i,{appearance:"subtle",icon:e.jsx(V,{}),onClick:o})]})}const An=new b("Admin","Product","Detail","Combo","Delete");function Pn({ComboId:n,Refresh:s}){const{dispatch:r,dispatchToast:t}=N(An),{run:o}=x.Product.Delete.useCombo({manual:!0,onError(l,c){r({Message:"Failed Delete Combo",Request:c,Error:l})},onSuccess(){t(e.jsx(A,{children:e.jsx(P,{children:"Combo Deleted"})}),{intent:"success"}),s()}});return e.jsx(i,{appearance:"subtle",icon:e.jsx(J,{}),onClick:()=>o(n)})}const Nn=[p({columnId:"Variant",renderHeaderCell:()=>e.jsx(g,{children:"Variant"}),renderCell(n){return e.jsx(f,{children:n.Name})}}),p({columnId:"Type",renderHeaderCell:()=>e.jsx(g,{children:"Type"}),renderCell(n){return e.jsx(f,{children:e.jsx(fe,{defaultValue:n.Current,defaultSelectedOptions:[n.Current],onOptionSelect:(s,r)=>n.Update(r.optionValue),children:n.Types.map((s,r)=>e.jsx(Q,{children:s},r))})})}})],wn=S({body:{...$,justifyContent:"flex-end",alignItems:"center",columnGap:E.spacingVerticalM,marginTop:E.spacingHorizontalM}}),ae=new b("Admin","Product","Detail","Combo","Detail");function Sn({Id:n,ProdId:s,Combo:r,Stock:t,Refresh:o}){const[l,{toggle:c}]=I(),[a,d]=w.useState(r),[h,u]=w.useState(t),{data:j}=T(()=>x.Product.Get.Variants(s,ae),{onError:ae.error}),{dispatch:m,dispatchToast:C}=N(ae),{run:v}=x.Product.Patch.useCombo({manual:!0,onError(y,D){m({Message:"Failed Update Combo",Request:D,Error:y})},onSuccess(){C(e.jsx(A,{children:e.jsx(P,{children:"Combo Updated"})}),{intent:"success"}),o(),c()}});return e.jsxs(K,{open:l,onOpenChange:c,children:[e.jsx(R,{disableButtonEnhancement:!0,children:e.jsx(i,{appearance:"subtle",icon:e.jsx(V,{})})}),e.jsx(W,{children:e.jsxs(Z,{children:[e.jsx(ee,{action:e.jsx(R,{disableButtonEnhancement:!0,children:e.jsx(i,{appearance:"subtle",icon:e.jsx(L,{})})}),children:"Combo Detail"}),e.jsxs(ne,{children:[e.jsx(G,{Items:j?.map(y=>({Current:a[y.Name],Update(D){a[y.Name]=D,d({...a})},...y})),Columns:Nn}),e.jsxs("div",{className:wn().body,children:[e.jsx(ge,{children:"Stock"}),e.jsx(Ie,{value:h,min:0,onChange:(y,D)=>{if(D.value)u(D.value);else if(D.displayValue){const k=parseInt(D.displayValue);Re(k)&&u(k)}}}),e.jsx(i,{appearance:"primary",onClick:()=>v(n,a,h),children:"Submit"})]})]})]})})]})}const Dn=[p({columnId:"Variant",renderHeaderCell:()=>e.jsx(g,{children:"Variant"}),renderCell(n){return e.jsx(f,{children:n.Name})}}),p({columnId:"Type",renderHeaderCell:()=>e.jsx(g,{children:"Type"}),renderCell(n){return e.jsx(f,{children:e.jsx(fe,{onOptionSelect:(s,r)=>n.Update(r.optionValue),children:n.Types.map((s,r)=>e.jsx(Q,{children:s},r))})})}})],En=S({body:{...$,justifyContent:"flex-end",alignItems:"center",columnGap:E.spacingVerticalM,marginTop:E.spacingHorizontalM}}),oe=new b("Admin","Product","Detail","Combo","NewCombo");function Tn({ProdId:n,Refresh:s}){const[r,{toggle:t}]=I(),[o,l]=w.useState({}),[c,a]=w.useState(1),{data:d}=T(()=>x.Product.Get.Variants(n,oe),{onSuccess(m){for(const C of m)o[C.Name]="";l({...o})},onError:oe.error}),{dispatch:h,dispatchToast:u}=N(oe),{run:j}=x.Product.Post.useCombo({manual:!0,onError(m,C){h({Message:"Failed Create Combo",Request:C,Error:m})},onSuccess(){u(e.jsx(A,{children:e.jsx(P,{children:"Combo Created"})}),{intent:"success"}),s(),t()}});return e.jsxs(K,{open:r,onOpenChange:t,children:[e.jsx(R,{disableButtonEnhancement:!0,children:e.jsx(i,{appearance:"primary",icon:e.jsx(se,{}),children:"New Combo"})}),e.jsx(W,{children:e.jsxs(Z,{children:[e.jsx(ee,{action:e.jsx(R,{disableButtonEnhancement:!0,children:e.jsx(i,{appearance:"subtle",icon:e.jsx(L,{})})}),children:"New Combo"}),e.jsxs(ne,{children:[e.jsx(G,{Items:d?.map(m=>({Update(C){o[m.Name]=C,l({...o})},...m})),Columns:Dn}),e.jsxs("div",{className:En().body,children:[e.jsx(ge,{children:"Stock"}),e.jsx(Ie,{value:c,min:0,onChange:(m,C)=>{if(C.value)a(C.value);else if(C.displayValue){const v=parseInt(C.displayValue);Re(v)&&a(v)}}}),e.jsx(i,{appearance:"primary",onClick:()=>j(n,o,c),children:"Create"})]})]})]})})]})}const H=S({body:{...$,justifyContent:"space-between"},four:{flexBasis:"4%",flexGrow:0},seven:{flexBasis:"7%",flexGrow:0},five:{flexBasis:"5%",flexGrow:0}}),Se=new b("Admin","Product","Detail","Combo"),vn=[p({columnId:"Id",renderHeaderCell:()=>e.jsx(g,{className:H().four,children:"Id"}),renderCell(n){return e.jsx(f,{className:H().four,children:n.Id})}}),p({columnId:"Combo",renderHeaderCell:()=>e.jsx(g,{children:"Combo"}),renderCell(n){return e.jsx(f,{children:Object.entries(n.Combo).reduce((s,r)=>`${s} ${r[0]} : ${r[1]} ;`,"")})}}),p({columnId:"Stock",renderHeaderCell:()=>e.jsx(g,{className:H().five,children:"Stock"}),renderCell(n){return e.jsx(f,{className:H().five,children:n.Stock})}}),p({columnId:"Action",renderHeaderCell:()=>e.jsx(g,{className:H().seven,children:"Action"}),renderCell(n){return e.jsxs(f,{className:H().seven,children:[e.jsx(Sn,{...n}),e.jsx(Pn,{ComboId:n.Id,Refresh:n.Refresh})]})}})];function In({ProdId:n}){const{data:s,run:r}=T(()=>q.Product.Get.Combo(n,Se),{onError:Se.error});return e.jsxs(e.Fragment,{children:[e.jsxs("div",{className:H().body,children:[e.jsx(be,{children:"Combo"}),e.jsx(Tn,{ProdId:n,Refresh:r})]}),e.jsx(G,{Items:s?.map(t=>({ProdId:n,Refresh:r,...t})),Columns:vn})]})}const kn=new b("Admin","Product","Detail","Delete"),$n=S({root:{...F,rowGap:E.spacingHorizontalS}});function Gn({ProdId:n}){const{Nav:s}=_(),{dispatch:r,dispatchToast:t}=N(kn),{run:o,loading:l}=x.Product.Delete.useProduct({manual:!0,onError(a,d){r({Message:"Failed Delete Product",Request:d,Error:a})},onSuccess(){t(e.jsx(A,{children:e.jsx(P,{children:"Product Deleted"})}),{intent:"success"}),s("/Admin")}}),c=$n();return e.jsx("div",{children:e.jsxs(ye,{withArrow:!0,children:[e.jsx(Ae,{disableButtonEnhancement:!0,children:e.jsx(i,{children:"Delete Product"})}),e.jsxs(Pe,{className:c.root,children:["Are You Sure?",e.jsx(i,{disabled:l,appearance:"primary",onClick:()=>o(n),children:"Yes"})]})]})})}const Rn=S({btn:{...$,columnGap:E.spacingVerticalS},drawer:{width:"1100px"}}),Vn=new b("Admin","Product","Lexical");function Fn({ProdId:n}){const s=Rn(),[r,{toggle:t,setTrue:o}]=I(),{data:l,run:c}=T(()=>q.Product.Get.Lexical(n)),{dispatch:a,dispatchToast:d}=N(Vn),{run:h}=x.Product.Post.useLexical({manual:!0,onError(u,j){a({Message:"Failed Update Description",Request:j,Error:u})},onSuccess(){d(e.jsx(A,{children:e.jsx(P,{children:"Description Updated"})}),{intent:"success"}),c(),t()}});return e.jsxs(e.Fragment,{children:[e.jsx("div",{children:e.jsx(i,{onClick:()=>o(),children:"Open Description Editor"})}),e.jsxs(xe,{open:r,onOpenChange:t,position:"start",size:"large",modalType:"alert",className:s.drawer,children:[e.jsx(pe,{children:e.jsx(je,{action:e.jsxs("div",{className:s.btn,children:[e.jsx(i,{appearance:"primary",onClick:()=>h(n),children:"Save"}),e.jsx(i,{onClick:()=>t(),children:"Cancel"})]}),children:"Edit Product Description"})}),e.jsx(Ce,{children:e.jsx(rn,{State:l?.Description})})]})]})}const De=new b("Admin","Product","Detail","Name");function Hn({ProdId:n}){const[s,r]=w.useState(""),[t,{setTrue:o,setFalse:l}]=I(),{Nav:c}=_();T(()=>x.Product.Get.Name(n),{onSuccess(u){r(u)},onError(u){c("Admin"),De.error(u)}});const{dispatch:a,dispatchToast:d}=N(De),{run:h}=x.Product.Patch.useName({manual:!0,onError(u,j){a({Message:"Failed Update Name",Request:j,Error:u})},onSuccess(){d(e.jsx(A,{children:e.jsx(P,{children:"Name Updated"})}),{intent:"success"}),l()}});return e.jsx(B,{size:"large",value:s,disabled:!t,appearance:"underline",onChange:(u,j)=>r(j.value),contentBefore:e.jsx(ke,{children:"Name"}),contentAfter:t?e.jsx(i,{appearance:"subtle",icon:e.jsx(Y,{}),onClick:()=>h(n,s)}):e.jsx(i,{appearance:"subtle",icon:e.jsx(V,{}),onClick:o})})}const Un=S({box:{...$,columnGap:E.spacingHorizontalL},img:{...Ke,aspectRatio:"1",width:"50%"},cap:{...F,flexGrow:1,rowGap:E.spacingVerticalL}}),ce=new b("Admin","Product","Detail","Photo","Edit");function On({Photo:{Id:n,Cover:s,Caption:r},Refresh:t}){const o=Un(),[l,c]=w.useState(r||""),{dispatch:a,dispatchToast:d}=N(ce),{run:h}=x.Product.Patch.useCaption({manual:!0,onError(m,C){a({Message:"Failed Update Caption",Request:C,Error:m})},onSuccess(){d(e.jsx(A,{children:e.jsx(P,{children:"Caption Updated"})}),{intent:"success"}),t()}}),{run:u}=x.Product.Patch.usePhoto(ce,{manual:!0,onError(m,C){a({Message:"Failed Update Photo",Request:C,Error:m})},onSuccess(){d(e.jsx(A,{children:e.jsx(P,{children:"Photo Updated"})}),{intent:"success"}),t()}}),{run:j}=x.Product.Delete.usePhoto({manual:!0,onError(m,C){a({Message:"Failed Delete Photo",Request:C,Error:m})},onSuccess(){d(e.jsx(A,{children:e.jsx(P,{children:"Photo Deleted"})}),{intent:"success"}),t()}});return e.jsxs(K,{children:[e.jsx(R,{disableButtonEnhancement:!0,children:e.jsx(i,{appearance:"subtle",icon:e.jsx(V,{})})}),e.jsx(W,{children:e.jsxs(Z,{children:[e.jsx(ee,{action:e.jsx(R,{disableButtonEnhancement:!0,children:e.jsx(i,{appearance:"subtle",icon:e.jsx(L,{})})}),children:"Image Detail"}),e.jsxs(ne,{className:o.box,children:[e.jsx(We,{shape:"rounded",className:o.img,Guid:s,Log:ce}),e.jsxs("div",{className:o.cap,children:[e.jsx(O,{label:"Caption",children:e.jsx(B,{value:l,onChange:(m,C)=>c(C.value)})}),e.jsx(i,{onClick:()=>h(n,l),children:"Save Caption"}),e.jsx(i,{onClick:()=>{const m=document.createElement("input");m.type="file",m.accept="image/*",m.onchange=()=>{m.files&&u(n,m.files[0])},m.click()},children:"Replace"}),e.jsx(i,{appearance:"primary",onClick:()=>j(n),children:"Delete"})]})]})]})})]})}const ie=S({f11:{flexBasis:"11%",flexGrow:0},box:{...$,justifyContent:"space-between"}}),M=new b("Admin","Product","Detail","Photo"),Mn=[Ge(70,M),p({columnId:"Caption",renderHeaderCell:()=>e.jsx(g,{children:"Caption"}),renderCell(n){return e.jsx(f,{children:n.Caption})}}),p({columnId:"Action",renderHeaderCell:()=>e.jsx(g,{className:ie().f11,children:"Action"}),renderCell(n){const{dispatch:s}=N(M),{run:r}=x.Product.Post.useMovePhoto({manual:!0,onError(t,o){s({Message:"Failed Update Order",Request:o,Error:t})},onSuccess:de});return e.jsxs(f,{className:ie().f11,children:[e.jsx(i,{appearance:"subtle",icon:e.jsx(Oe,{}),onClick:()=>r(n.Id,!0)}),e.jsx(i,{appearance:"subtle",icon:e.jsx(Me,{}),onClick:()=>r(n.Id,!1)}),e.jsx(On,{Photo:n,Refresh:de})]})}})];let de;function Bn({ProdId:n}){const[s,r]=w.useState([]),{run:t}=T(()=>q.Product.Get.PhotoList(n,M),{onError:M.error,onSuccess([a]){const d=a.map(h=>({Id:h.Order,Cover:h.ObjectId,Caption:h.Caption||"No Caption"}));r(d)}});de=t;const{dispatch:o,dispatchToast:l}=N(M),{run:c}=x.Product.Post.usePhoto(M,{manual:!0,onError(a,d){o({Message:"Failed Upload Photo",Request:d,Error:a})},onSuccess(){l(e.jsx(A,{children:e.jsx(P,{children:"Photo Uploaded"})}),{intent:"success"}),t()}});return e.jsxs(e.Fragment,{children:[e.jsxs("div",{className:ie().box,children:[e.jsx(be,{children:"Photos"}),e.jsx(i,{appearance:"primary",icon:e.jsx(se,{}),onClick:()=>{const a=document.createElement("input");a.type="file",a.accept="image/*",a.onchange=()=>{a.files&&c(n,a.files[0])},a.click()},children:"New Image"})]}),e.jsx(G,{Items:s,Columns:Mn})]})}const Ln=new b("Admin","Product","Detail","Variant","Delete");function qn({VariantId:n,Refresh:s}){const{dispatch:r,dispatchToast:t}=N(Ln),{run:o}=x.Product.Delete.useVariant({manual:!0,onError(l,c){r({Message:"Failed Delete Variant",Request:c,Error:l})},onSuccess(){t(e.jsx(A,{children:e.jsx(P,{children:"Variant Deleted"})}),{intent:"success"}),s()}});return e.jsx(i,{appearance:"subtle",icon:e.jsx(J,{}),onClick:()=>o(n)})}const zn=new b("Admin","Product","Detail","Variant","Edit","TypeDelete");function _n({VariantId:n,Type:s,Refresh:r}){const{dispatch:t,dispatchToast:o}=N(zn),{run:l}=x.Product.Delete.useType({manual:!0,onError(c,a){t({Message:"Failed Delete Type",Request:a,Error:c})},onSuccess(){o(e.jsx(A,{children:e.jsx(P,{children:"Type Deleted"})}),{intent:"success"}),r()}});return e.jsx(i,{appearance:"subtle",icon:e.jsx(J,{}),onClick:()=>l(n,s)})}const Xn=new b("Admin","Product","Detail","Variant","Edit","Name");function Qn({Id:n,Name:s}){const[r,t]=w.useState(s),[o,{setTrue:l,setFalse:c}]=I(),{dispatch:a,dispatchToast:d}=N(Xn),{run:h}=x.Product.Patch.useVariantName({manual:!0,onError(u,j){a({Message:"Failed Update Variant Name",Request:j[0],Error:u})},onSuccess(){d(e.jsx(A,{children:e.jsx(P,{children:"Variant Name Updated"})}),{intent:"success"}),c()}});return e.jsx(B,{size:"large",value:r,disabled:!o,appearance:"underline",onChange:(u,j)=>t(j.value),contentBefore:e.jsx(ke,{children:"Name"}),contentAfter:o?e.jsx(i,{appearance:"subtle",icon:e.jsx(Y,{}),onClick:()=>h(n,r)}):e.jsx(i,{appearance:"subtle",icon:e.jsx(V,{}),onClick:l})})}const Yn=S({body:{...F,rowGap:E.spacingVerticalM}}),Jn=new b("Admin","Product","Detail","Variant","Edit","Type");function Ve({VariantId:n,Type:s,Refresh:r,New:t}){const o=Yn(),[l,{toggle:c}]=I(),[a,d]=w.useState(s||""),{dispatch:h,dispatchToast:u}=N(Jn),j={manual:!0,onError(v,y){h({Message:`Failed ${t?"Create":"Update"} Type ${a}`,Request:y,Error:v})},onSuccess(v){u(e.jsxs(A,{children:[e.jsxs(P,{children:["Type ",t?"Created":"Updated"]}),e.jsxs(Be,{children:[v," ",a]})]}),{intent:"success"}),r(),d(""),c()}},{run:m}=x.Product.Post.useType(j),{run:C}=x.Product.Patch.useType(j);return e.jsxs(ye,{withArrow:!0,open:l,onOpenChange:c,children:[e.jsx(Ae,{disableButtonEnhancement:!0,children:t?e.jsx(i,{icon:e.jsx(se,{}),appearance:"primary",children:"New Type"}):e.jsx(i,{appearance:"subtle",icon:e.jsx(V,{})})}),e.jsxs(Pe,{className:o.body,children:[e.jsx(O,{label:"Type Name",children:e.jsx(B,{value:a,onChange:(v,y)=>d(y.value)})}),e.jsx(i,{onClick:()=>t?m(n,a):C(n,s,a),children:"Submit"})]})]})}const ue=S({body:{...F,rowGap:E.spacingVerticalM},twelve:{flexBasis:"12%",flexGrow:0}}),Kn=[p({columnId:"Name",renderHeaderCell:()=>e.jsx(g,{children:"Name"}),renderCell(n){return e.jsx(f,{children:n.Name})}}),p({columnId:"Action",renderHeaderCell:()=>e.jsx(g,{className:ue().twelve,children:"Action"}),renderCell(n){return e.jsxs(f,{className:ue().twelve,children:[e.jsx(Ve,{VariantId:n.VariantId,Type:n.Name,Refresh:n.Refresh}),e.jsx(_n,{VariantId:n.VariantId,Type:n.Name,Refresh:n.Refresh})]})}})];function Wn({Variant:n,Refresh:s}){return e.jsxs(K,{children:[e.jsx(R,{disableButtonEnhancement:!0,children:e.jsx(i,{appearance:"subtle",icon:e.jsx(V,{})})}),e.jsx(W,{children:e.jsxs(Z,{children:[e.jsx(ee,{action:e.jsx(R,{disableButtonEnhancement:!0,children:e.jsx(i,{appearance:"subtle",icon:e.jsx(L,{})})}),children:"Variant Detail"}),e.jsxs(ne,{className:ue().body,children:[e.jsx(Qn,{Id:n.Id,Name:n.Name}),e.jsx(G,{Items:n.Types.map((r,t)=>({Id:t,Name:r,VariantId:n.Id,Refresh:s})),Columns:Kn})]}),e.jsx(Le,{children:e.jsx(Ve,{VariantId:n.Id,Refresh:s,New:!0})})]})})]})}const Zn=S({body:{...F,rowGap:E.spacingVerticalM}}),es=new b("Admin","Product","Detail","Variant","New");function ns({ProdId:n,Refresh:s}){const r=Zn(),[t,{toggle:o}]=I(),[l,c]=w.useState(""),{dispatch:a,dispatchToast:d}=N(es),{run:h}=x.Product.Post.useVariant({manual:!0,onError(u,j){a({Message:"Failed Create Variant",Request:j,Error:u})},onSuccess(){d(e.jsx(A,{children:e.jsx(P,{children:"Variant Created"})}),{intent:"success"}),s(),c(""),o()}});return e.jsxs(ye,{withArrow:!0,open:t,onOpenChange:o,children:[e.jsx(Ae,{disableButtonEnhancement:!0,children:e.jsx(i,{appearance:"primary",icon:e.jsx(se,{}),children:"New Variant"})}),e.jsxs(Pe,{className:r.body,children:[e.jsx(O,{required:!0,label:"Variant Name",children:e.jsx(B,{value:l,onChange:(u,j)=>c(j.value)})}),e.jsx(i,{onClick:()=>h(n,l),children:"Add"})]})]})}const U=S({body:{...$,justifyContent:"space-between"},four:{flexBasis:"4%",flexGrow:0},seven:{flexBasis:"7%",flexGrow:0},twelve:{flexBasis:"12%",flexGrow:0}}),Ee=new b("Admin","Product","Detail","Variant"),ss=[p({columnId:"Id",renderHeaderCell:()=>e.jsx(g,{className:U().four,children:"Id"}),renderCell(n){return e.jsx(f,{className:U().four,children:n.Id})}}),p({columnId:"Name",renderHeaderCell:()=>e.jsx(g,{className:U().twelve,children:"Name"}),renderCell(n){return e.jsx(f,{className:U().twelve,children:n.Name})}}),p({columnId:"Type",renderHeaderCell:()=>e.jsx(g,{children:"Type"}),renderCell(n){return e.jsx(f,{children:n.Types.reduce((s,r)=>`${s} ${r} ;`,"")})}}),p({columnId:"Action",renderHeaderCell:()=>e.jsx(g,{className:U().seven,children:"Action"}),renderCell(n){return e.jsxs(f,{className:U().seven,children:[e.jsx(Wn,{Variant:n,Refresh:me}),e.jsx(qn,{VariantId:n.Id,Refresh:me})]})}})];let me;function rs({ProdId:n}){const s=U(),{data:r,run:t}=T(()=>x.Product.Get.Variants(n,Ee),{onError:Ee.error});return me=t,e.jsxs(e.Fragment,{children:[e.jsxs("div",{className:s.body,children:[e.jsx(be,{children:"Variant"}),e.jsx(ns,{ProdId:n,Refresh:t})]}),e.jsx(G,{Items:r,Columns:ss})]})}const ts=S({body:{...F,rowGap:E.spacingVerticalXL,paddingBottom:E.spacingVerticalXXXL}});function as({ProdId:n}){const s=ts(),[r,{setFalse:t,setTrue:o}]=I(),{Nav:l,Paths:c}=_(),a=parseInt(c.at(1));return w.useEffect(()=>{a===n?o():t()},[c]),e.jsxs(e.Fragment,{children:[e.jsx(i,{appearance:"subtle",icon:e.jsx(ve,{}),onClick:()=>{l("Admin",n),o()}}),e.jsxs(xe,{open:r,position:"end",size:"large",modalType:"alert",children:[e.jsx(pe,{children:e.jsx(je,{action:e.jsx(i,{appearance:"subtle",icon:e.jsx(L,{}),onClick:()=>{l("Admin"),t()}}),children:"Product Detail"})}),e.jsxs(Ce,{className:s.body,children:[e.jsx(Hn,{ProdId:n}),e.jsx(yn,{ProdId:n}),e.jsx(Bn,{ProdId:n}),e.jsx(rs,{ProdId:n}),e.jsx(In,{ProdId:n}),e.jsx(Fn,{ProdId:n}),e.jsx(Gn,{ProdId:n})]})]})]})}const z=new b("Admin","Product","Row");function os({item:n}){const[s,r]=w.useState(()=>({Id:n,Cover:"",Name:"Loading..."})),[t,{setTrue:o}]=I(),l=q.Product.Get;return qe(async()=>{const c=await l.Product(n).catch(z.error);if(!c)return z.warn(`Product ${n} Not Found`),o();let a={...s,Name:c.Name,Category:c.Category||"Pending"};r(a);const[d,h]=await l.PhotoList(n,z);h||z.warn(`Product ${n} has no photo`),r(a={...a,Cover:h});const u=await x.Product.Get.Count(n).catch(z.error);u&&r({...a,...u})},[]),t?null:e.jsx($e,{children:({renderCell:c})=>c(s)},n)}const Te=S({two:{flexBasis:"2.5%",flexGrow:0},twoc:{flexBasis:"2.5%",flexGrow:0,justifyContent:"center"}}),Fe=new b("Admin","Product"),cs=[Ge(50,Fe),p({columnId:"Product",renderHeaderCell:()=>e.jsx(g,{children:"Product"}),renderCell(n){return e.jsx(f,{children:e.jsx(Ne,{children:n.Name})})}}),p({columnId:"Category",renderHeaderCell:()=>e.jsx(g,{children:"Category"}),renderCell(n){return e.jsx(f,{children:e.jsx(Ne,{children:n.Category})})}}),p({columnId:"Variant",renderHeaderCell:()=>e.jsx(g,{children:"Variant"}),renderCell(n){return e.jsx(f,{children:n.Variant})}}),p({columnId:"Combo",renderHeaderCell:()=>e.jsx(g,{children:"Combo"}),renderCell(n){return e.jsx(f,{children:n.Combo})}}),p({columnId:"Stock",renderHeaderCell:()=>e.jsx(g,{children:"Stock"}),renderCell(n){return e.jsx(f,{children:n.Stock})}}),p({columnId:"Action",renderHeaderCell:()=>e.jsx(g,{className:Te().two,children:"Detail"}),renderCell(n){return e.jsx(f,{className:Te().twoc,children:e.jsx(as,{ProdId:n.Id})})}})];function ls(){const n=x.Product.Get.useList(Fe);return e.jsxs(ze,{items:n?n.reverse():[],columns:cs,children:[e.jsx(_e,{children:e.jsx($e,{children:({renderHeaderCell:s})=>s()})}),e.jsx(Xe,{children:s=>e.jsx(os,{...s})}),!n&&e.jsx(Qe,{size:48})]})}const is=new b("Admin","User","Delete");function ds({UserId:n,Refresh:s}){const{dispatch:r,dispatchToast:t}=N(is),{run:o}=x.User.Delete.useUser({manual:!0,onError(l,c){r({Message:"Failed Delete User",Request:c,Error:l})},onSuccess(){t(e.jsx(A,{children:e.jsx(P,{children:"User Deleted"})}),{intent:"success"}),s()}});return e.jsx(i,{appearance:"subtle",icon:e.jsx(J,{}),onClick:()=>o(n)})}const us=new b("Admin","User","Grant");function ms({UserId:n,Admin:s,Refresh:r}){const{dispatch:t,dispatchToast:o}=N(us),{run:l}=x.User.Post.useAdmin({manual:!0,onError(a,d){t({Message:"Failed Grant Admin",Request:d,Error:a})},onSuccess(){o(e.jsx(A,{children:e.jsx(P,{children:"Admin Granted"})}),{intent:"success"}),r()}}),{run:c}=x.User.Delete.useAdmin({manual:!0,onError(a,d){t({Message:"Failed Revoke Admin",Request:d,Error:a})},onSuccess(){o(e.jsx(A,{children:e.jsx(P,{children:"Admin Revoked"})}),{intent:"success"}),r()}});return e.jsx(Ye,{checked:s,onChange:(a,d)=>{d.checked?l(n):c(n)}})}const hs=new b("Admin","User"),xs=[p({columnId:"Id",renderHeaderCell:()=>"Id",renderCell(n){return n.Id}}),p({columnId:"Name",renderHeaderCell:()=>"Real Name",renderCell(n){return n.Name}}),p({columnId:"Email",renderHeaderCell:()=>"E-Mail",renderCell(n){return n.EMail}}),p({columnId:"Admin",renderHeaderCell:()=>"Admin",renderCell(n){return e.jsx(ms,{UserId:n.Id,Admin:n.Admin,Refresh:he})}}),p({columnId:"Delete",renderHeaderCell:()=>"Delete",renderCell(n){return e.jsx(ds,{UserId:n.Id,Refresh:he})}})].map(({renderHeaderCell:n,renderCell:s,...r})=>({...r,renderHeaderCell:()=>e.jsx(g,{children:n()}),renderCell:t=>e.jsx(f,{children:s(t)})}));let he;function ps(){const{data:n,run:s}=T(()=>x.User.Get.List(),{onError:hs.error});return he=s,e.jsx(G,{Items:n,Columns:xs})}const js=new b("Admin");function Ps(){const{Paths:n,Nav:s}=_(),r=n.at(1),t=w.useMemo(()=>{switch(r){case"Order":return e.jsx(fn,{});case"User":return e.jsx(ps,{});default:return e.jsx(ls,{})}},[r]),o=q.User.Get.useMe(js);return o?o.Admin?t:s("/"):e.jsx(Je,{size:"huge",label:"Authenticating..."})}export{Ps as default}; diff --git a/index.html b/index.html index f7529f0..0f2d284 100644 --- a/index.html +++ b/index.html @@ -5,7 +5,7 @@ AwaiShop - +