PageSourceSearch

https://task.com.tw/assets/NotionWorkspace-CmxOXIe3.js

js task.com.tw collected 2026-10-08 16:07:45 UTC 43,444 bytes, 2 lines download raw bytes

1import{_ as de}from"./vendor-export-Do0PDzts.js";import{r as l,j as e,d as pe,X as Ne,bF as xe,a6 as fe,L as H,F as J,z as ye,aq as we,t as b,eX as Ce,an as Se,P as me,U as ke,eY as ue,aZ as ne,cK as Ae,H as $e,a9 as De,I as Me,au as Pe,m as Ee,T as Te,c8 as ze,dm as ge}from"./vendor-react-Cek5_fI5.js";import{t as P,b as _e,D as he,I as be,B as z,y as ce,z as ie,A as le,E as re,F as je}from"./index-DnYEcI1T.js";import{R as Fe}from"./RichTextEditor-sb6-GAdf.js";import{s as oe}from"./sanitizeHtml-CtrNZ7Nk.js";import{p as Le}from"./notionImport-Cd8Ar0Uc.js";import"./vendor-charts-CdtAEet6.js";import"./vendor-md-v2-C5Ivf5J6.js";import"./jszip.min-CCIxMT8B.js";function Re(r){const i=W=>W.replace(/&/g,"&amp;").replace(/</g,"&lt;").replace(/>/g,"&gt;"),N=W=>i(W).replace(/\*\*([^*]+)\*\*/g,"<b>$1</b>").replace(/(^|[^*])\*([^*\n]+)\*/g,"$1<i>$2</i>").replace(/`([^`]+)`/g,'<code class="px-1 rounded bg-black/10 text-[0.9em]">$1</code>'),n=r.replace(/\r/g,"").split(`
2`),x=[];let m=null,o=[];const p=()=>{m&&(x.push(`</${m}>`),m=null)},v=()=>{if(!o.length)return;const[W,...u]=o;x.push('<div class="overflow-x-auto my-2"><table class="text-xs border-collapse w-full">'),x.push("<thead><tr>"+W.map(g=>`<th class="border border-border px-2 py-1 bg-muted/50 text-left font-semibold">${N(g)}</th>`).join("")+"</tr></thead>"),x.push("<tbody>"+u.map(g=>"<tr>"+g.map(A=>`<td class="border border-border px-2 py-1 align-top">${N(A)}</td>`).join("")+"</tr>").join("")+"</tbody>"),x.push("</table></div>"),o=[]};for(const W of n){const u=W.trimEnd();if(/^\s*\|.*\|\s*$/.test(u)){p();const k=u.replace(/^\s*\|/,"").replace(/\|\s*$/,"").split("|").map(j=>j.trim());if(k.every(j=>/^:?-{2,}:?$/.test(j)))continue;o.push(k);continue}v();const g=u.match(/^(#{1,4})\s+(.*)$/),A=u.match(/^\s*[-*]\s+(.*)$/),y=u.match(/^\s*\d+[.)]\s+(.*)$/);if(g){p();const k=g[1].length,j=k<=1?"text-base font-bold mt-3 mb-1":k===2?"text-[15px] font-bold mt-3 mb-1":"text-sm font-semibold mt-2 mb-0.5";x.push(`<div class="${j}">${N(g[2])}</div>`)}else A?(m!=="ul"&&(p(),x.push('<ul class="list-disc pl-5 my-1 space-y-0.5">'),m="ul"),x.push(`<li>${N(A[1])}</li>`)):y?(m!=="ol"&&(p(),x.push('<ol class="list-decimal pl-5 my-1 space-y-0.5">'),m="ol"),x.push(`<li>${N(y[1])}</li>`)):u.trim()?(p(),x.push(`<p>${N(u)}</p>`)):(p(),x.push('<div class="h-2"></div>'))}return p(),v(),x.join("")}function Oe({orgId:r}){const[i,N]=l.useState(!1),[n,x]=l.useState([]),[m,o]=l.useState(""),[p,v]=l.useState({}),[W,u]=l.useState(null),g=l.useRef(null),A=P.useUtils(),y=P.notion.aiChat.useMutation({onSuccess:c=>{x(s=>[...s,{role:"assistant",content:String(c.reply)}]),setTimeout(()=>g.current?.scrollTo({top:999999,behavior:"smooth"}),60)}}),k=P.notion.aiSaveDoc.useMutation({onSuccess:(c,s)=>{v(M=>({...M,[s.__idx]:{url:c.url,title:c.title}})),A.notion.list.invalidate()}}),j=()=>{const c=m.trim();if(!c||y.isPending)return;const s=[...n,{role:"user",content:c}];x(s),o(""),y.mutate({orgId:r,messages:s}),setTimeout(()=>g.current?.scrollTo({top:999999,behavior:"smooth"}),60)},F=async(c,s)=>{try{await navigator.clipboard.writeText(c),u(s),setTimeout(()=>u(null),1500)}catch{}};return e.jsxs(e.Fragment,{children:[!i&&e.jsxs("button",{"data-loc":"client/src/components/NotionAiChat.tsx:92",onClick:()=>N(!0),className:"fixed bottom-24 right-6 z-[60] inline-flex items-center gap-2 px-4 py-3 rounded-full shadow-lg bg-gradient-to-r from-emerald-600 to-teal-600 text-white text-sm font-semibold hover:opacity-90 transition-opacity",style:{pointerEvents:"auto"},children:[e.jsx(pe,{"data-loc":"client/src/components/NotionAiChat.tsx:97",className:"w-4 h-4"})," AI 文件助手"]}),i&&e.jsxs("div",{"data-loc":"client/src/components/NotionAiChat.tsx:103",className:"fixed bottom-0 right-0 sm:bottom-6 sm:right-6 z-[60] w-full sm:w-[440px] h-[85vh] sm:h-[640px] flex flex-col rounded-t-2xl sm:rounded-2xl border bg-background shadow-2xl",style:{pointerEvents:"auto"},children:[e.jsxs("div",{"data-loc":"client/src/components/NotionAiChat.tsx:104",className:"flex items-center gap-2 px-4 py-3 border-b shrink-0",children:[e.jsx(pe,{"data-loc":"client/src/components/NotionAiChat.tsx:105",className:"w-4 h-4 text-emerald-600"}),e.jsxs("div",{"data-loc":"client/src/components/NotionAiChat.tsx:106",className:"flex-1 min-w-0",children:[e.jsx("div",{"data-loc":"client/src/components/NotionAiChat.tsx:107",className:"text-sm font-semibold",children:"AI 文件助手"}),e.jsx("div",{"data-loc":"client/src/components/NotionAiChat.tsx:108",className:"text-[11px] text-muted-foreground",children:"OpenAI GPT-5.5(最高階)・生成文件可直接取得分享網址"})]}),e.jsx("button",{"data-loc":"client/src/components/NotionAiChat.tsx:110",onClick:()=>N(!1),className:"p-1.5 rounded-md hover:bg-muted",children:e.jsx(Ne,{"data-loc":"client/src/components/NotionAiChat.tsx:110",className:"w-4 h-4"})})]}),e.jsxs("div",{"data-loc":"client/src/components/NotionAiChat.tsx:113",ref:g,className:"flex-1 overflow-y-auto px-4 py-3 space-y-3",children:[n.length===0&&e.jsxs("div",{"data-loc":"client/src/components/NotionAiChat.tsx:115",className:"text-sm text-muted-foreground space-y-2 pt-4",children:[e.jsx("p",{"data-loc":"client/src/components/NotionAiChat.tsx:116",children:"告訴我您要生成什麼,例如:"}),["幫我寫一份中秋節給客戶的祝賀信","生成一份業務部電話開發 SOP 文件","寫一篇新品上市的 FB 貼文文案,活潑一點","草擬一份簡單的保密協議(NDA)"].map(c=>e.jsx("button",{"data-loc":"client/src/components/NotionAiChat.tsx:118",onClick:()=>o(c),className:"block w-full text-left text-xs px-3 py-2 rounded-lg border hover:bg-muted/50",children:c},c))]}),n.map((c,s)=>e.jsx("div",{"data-loc":"client/src/components/NotionAiChat.tsx:123",className:c.role==="user"?"flex justify-end":"flex justify-start",children:e.jsxs("div",{"data-loc":"client/src/components/NotionAiChat.tsx:124",className:`max-w-[92%] rounded-xl px-3.5 py-2.5 text-sm leading-relaxed ${c.role==="user"?"bg-emerald-600 text-white whitespace-pre-wrap":"bg-muted/60"}`,children:[c.role==="assistant"?e.jsx("div",{"data-loc":"client/src/components/NotionAiChat.tsx:126",dangerouslySetInnerHTML:{__html:Re(c.content)}}):c.content,c.role==="assistant"&&e.jsxs("div",{"data-loc":"client/src/components/NotionAiChat.tsx:131",className:"mt-2.5 pt-2 border-t border-border/60 flex flex-wrap gap-1.5",children:[e.jsxs("button",{"data-loc":"client/src/components/NotionAiChat.tsx:132",onClick:()=>F(c.content,s),className:"inline-flex items-center gap-1 text-[11px] px-2 py-1 rounded-md border bg-background hover:bg-muted",children:[W===s?e.jsx(xe,{"data-loc":"client/src/components/NotionAiChat.tsx:133",className:"w-3 h-3 text-emerald-600"}):e.jsx(fe,{"data-loc":"client/src/components/NotionAiChat.tsx:133",className:"w-3 h-3"})," 複製內容"]}),p[s]?e.jsxs("span",{"data-loc":"client/src/components/NotionAiChat.tsx:144",className:"inline-flex items-center gap-1 text-[11px] px-2 py-1 rounded-md bg-emerald-50 dark:bg-emerald-950/30 border border-emerald-300 text-emerald-700 dark:text-emerald-300",children:[e.jsx(xe,{"data-loc":"client/src/components/NotionAiChat.tsx:145",className:"w-3 h-3"})," 已存為「",p[s].title.slice(0,16),"…」"]}):e.jsxs("button",{"data-loc":"client/src/components/NotionAiChat.tsx:136",onClick:()=>k.mutate({orgId:r,markdown:c.content,__idx:s}),disabled:k.isPending,className:"inline-flex items-center gap-1 text-[11px] px-2 py-1 rounded-md bg-emerald-600 text-white hover:opacity-90 disabled:opacity-50",children:[k.isPending?e.jsx(H,{"data-loc":"client/src/components/NotionAiChat.tsx:141",className:"w-3 h-3 animate-spin"}):e.jsx(J,{"data-loc":"client/src/components/NotionAiChat.tsx:141",className:"w-3 h-3"})," 存成文件+分享連結"]})]}),c.role==="assistant"&&p[s]&&e.jsxs("div",{"data-loc":"client/src/components/NotionAiChat.tsx:151",className:"mt-2 flex items-center gap-1.5 rounded-lg bg-emerald-50 dark:bg-emerald-950/30 border border-emerald-200 dark:border-emerald-900 px-2.5 py-2",children:[e.jsx(ye,{"data-loc":"client/src/components/NotionAiChat.tsx:152",className:"w-3.5 h-3.5 text-emerald-600 shrink-0"}),e.jsx("a",{"data-loc":"client/src/components/NotionAiChat.tsx:153",href:p[s].url,target:"_blank",rel:"noreferrer",className:"text-[11px] text-emerald-700 dark:text-emerald-300 underline truncate flex-1",children:p[s].url}),e.jsx("button",{"data-loc":"client/src/components/NotionAiChat.tsx:154",onClick:()=>F(p[s].url,1e4+s),className:"text-[11px] px-2 py-0.5 rounded border bg-background hover:bg-muted shrink-0",children:W===1e4+s?"已複製!":"複製連結"})]})]})},s)),y.isPending&&e.jsxs("div",{"data-loc":"client/src/components/NotionAiChat.tsx:163",className:"flex items-center gap-2 text-sm text-muted-foreground",children:[e.jsx(H,{"data-loc":"client/src/components/NotionAiChat.tsx:163",className:"w-4 h-4 animate-spin"})," AI 撰寫中…"]}),y.error&&e.jsx("div",{"data-loc":"client/src/components/NotionAiChat.tsx:166",className:"text-xs text-red-600",children:String(y.error?.message||"發生錯誤,請重試")})]}),e.jsxs("div",{"data-loc":"client/src/components/NotionAiChat.tsx:170",className:"p-3 border-t shrink-0",children:[e.jsxs("div",{"data-loc":"client/src/components/NotionAiChat.tsx:171",className:"flex gap-2 items-end",children:[e.jsx("textarea",{"data-loc":"client/src/components/NotionAiChat.tsx:172","data-no-i18n":!0,value:m,onChange:c=>o(c.target.value),onKeyDown:c=>{c.key==="Enter"&&!c.shiftKey&&!c.nativeEvent.isComposing&&(c.preventDefault(),j())},placeholder:"描述您要的文案或文件…(Enter 送出,Shift+Enter 換行)",rows:2,className:"flex-1 resize-none rounded-lg border bg-background px-3 py-2 text-sm focus:outline-none focus:ring-2 focus:ring-emerald-500/40"}),e.jsx("button",{"data-loc":"client/src/components/NotionAiChat.tsx:181",onClick:j,disabled:y.isPending||!m.trim(),className:"h-10 w-10 shrink-0 rounded-lg bg-emerald-600 text-white inline-flex items-center justify-center hover:opacity-90 disabled:opacity-40",children:e.jsx(we,{"data-loc":"client/src/components/NotionAiChat.tsx:182",className:"w-4 h-4"})})]}),n.length>0&&e.jsx("button",{"data-loc":"client/src/components/NotionAiChat.tsx:186",onClick:()=>{x([]),v({})},className:"mt-1.5 text-[11px] text-muted-foreground hover:text-foreground",children:"清空對話,開新主題"})]})]})]})}function Ie(r){const i=new Map;r.forEach(n=>i.set(n.id,{...n,children:[]}));const N=[];for(const n of r){const x=i.get(n.id);n.parentId!=null&&i.has(n.parentId)?i.get(n.parentId).children.push(x):N.push(x)}return N}function V(r){return String(r).replace(/&/g,"&amp;").replace(/"/g,"&quot;").replace(/</g,"&lt;").replace(/>/g,"&gt;")}function et(){const{currentOrg:r}=_e(),i=r?.orgId??0,N=P.useUtils(),{data:n=[],isLoading:x}=P.notion.list.useQuery({orgId:i},{enabled:i>0}),[m,o]=l.useState(null),[p,v]=l.useState("list"),W=t=>{o(t),v("page")},[u,g]=l.useState(new Set),[A,y]=l.useState(""),[k,j]=l.useState(!1),[F,c]=l.useState(!1),[s,M]=l.useState(!1),[w,E]=l.useState(null),[T,L]=l.useState(null),R=l.useMemo(()=>Ie(n),[n]);l.useEffect(()=>{m==null&&n.length>0&&o(n[0].id)},[n,m]);const O=P.notion.create.useMutation({onSuccess:t=>
2{N.notion.list.invalidate({orgId:i}),o(t.id),v("page"),M(!0)},onError:t=>b.error(t.message)}),U=P.notion.remove.useMutation({onSuccess:()=>{N.notion.list.invalidate({orgId:i}),o(null),v("list"),b.success("已刪除")},onError:t=>b.error(t.message)}),G=P.notion.reorder.useMutation({onSuccess:()=>N.notion.list.invalidate({orgId:i}),onError:t=>b.error(t.message)}),Q=t=>{const C=new Map;for(const S of n){const d=S.parentId??0;C.has(d)||C.set(d,[]),C.get(d).push(S.id)}const a=new Set,h=[t];for(;h.length;){const S=h.pop();a.add(S);for(const d of C.get(S)||[])h.push(d)}return a},I=(t,C)=>{const a=w;if(E(null),L(null),a==null)return;const h=n;if(t==null){const f=h.filter(_=>_.parentId==null&&_.id!==a).map(_=>_.id);f.push(a),G.mutate({orgId:i,parentId:null,orderedIds:f});return}if(a===t)return;if(Q(a).has(t)){b.error("不能把頁面移到它自己的子頁底下");return}const d=h.find(f=>f.id===t);let $,D;if(C==="inside")$=t,D=h.filter(f=>f.parentId===$&&f.id!==a).map(f=>f.id),D.push(a),g(f=>new Set(f).add(t));else{$=d.parentId??null,D=h.filter(_=>_.parentId===$&&_.id!==a).map(_=>_.id);const f=D.indexOf(t);D.splice(C==="before"?f:f+1,0,a)}G.mutate({orgId:i,parentId:$,orderedIds:D})},B=l.useMemo(()=>{if(!A.trim())return null;const t=A.toLowerCase();return n.filter(C=>C.title.toLowerCase().includes(t))},[A,n]),K=l.useMemo(()=>Array.from(new Set(n.map(t=>t.category).filter(Boolean))).sort(),[n]),X=l.useMemo(()=>{const t=new Map;for(const C of n){const a=C.category||"未分類";t.has(a)||t.set(a,[]),t.get(a).push(C)}return Array.from(t.entries()).sort((C,a)=>C[0]==="未分類"?1:a[0]==="未分類"?-1:C[0].localeCompare(a[0]))},[n]),q=({node:t,depth:C})=>{const a=t.children.length>0,h=u.has(t.id),S=T&&T.id===t.id?T.pos:null;return e.jsxs("div",{"data-loc":"client/src/pages/NotionWorkspace.tsx:143",children:[e.jsxs("div",{"data-loc":"client/src/pages/NotionWorkspace.tsx:144",draggable:!0,onDragStart:d=>{E(t.id),d.dataTransfer.effectAllowed="move"},onDragEnd:()=>{E(null),L(null)},onDragOver:d=>{if(w==null||w===t.id)return;d.preventDefault();const $=d.currentTarget.getBoundingClientRect(),D=d.clientY-$.top,f=D<$.height*.28?"before":D>$.height*.72?"after":"inside";(!T||T.id!==t.id||T.pos!==f)&&L({id:t.id,pos:f})},onDragLeave:()=>{T?.id===t.id&&L(null)},onDrop:d=>{d.preventDefault(),I(t.id,S||"inside")},className:`group relative flex items-center gap-1 rounded px-1.5 py-1 text-sm cursor-pointer hover:bg-slate-100 dark:hover:bg-slate-800 ${m===t.id?"bg-indigo-50 dark:bg-indigo-950 text-indigo-700 dark:text-indigo-300 font-medium":"text-slate-700 dark:text-slate-300"} ${S==="inside"?"ring-2 ring-indigo-400 ring-inset":""}`,style:{paddingLeft:C*14+4},onClick:()=>W(t.id),children:[S==="before"&&e.jsx("div",{"data-loc":"client/src/pages/NotionWorkspace.tsx:162",className:"absolute left-1 right-1 -top-px h-0.5 bg-indigo-500 rounded"}),S==="after"&&e.jsx("div",{"data-loc":"client/src/pages/NotionWorkspace.tsx:163",className:"absolute left-1 right-1 -bottom-px h-0.5 bg-indigo-500 rounded"}),e.jsx("button",{"data-loc":"client/src/pages/NotionWorkspace.tsx:164",className:"shrink-0 w-4 h-4 flex items-center justify-center text-slate-400 hover:text-slate-600",onClick:d=>{if(d.stopPropagation(),a){const $=new Set(u);h?$.delete(t.id):$.add(t.id),g($)}},children:a?h?e.jsx(De,{"data-loc":"client/src/pages/NotionWorkspace.tsx:168",className:"w-3.5 h-3.5"}):e.jsx(Me,{"data-loc":"client/src/pages/NotionWorkspace.tsx:168",className:"w-3.5 h-3.5"}):e.jsx("span",{"data-loc":"client/src/pages/NotionWorkspace.tsx:168",className:"w-3.5"})}),e.jsx("span",{"data-loc":"client/src/pages/NotionWorkspace.tsx:170",className:"shrink-0 w-4 text-center",children:t.icon||e.jsx(J,{"data-loc":"client/src/pages/NotionWorkspace.tsx:170",className:"w-3.5 h-3.5 inline text-slate-400"})}),e.jsx("span",{"data-loc":"client/src/pages/NotionWorkspace.tsx:171",className:"truncate flex-1",children:t.title||"未命名"}),["private","dept","custom"].includes(t.visibility)&&e.jsx("span",{"data-loc":"client/src/pages/NotionWorkspace.tsx:173",className:"shrink-0 text-[10px]",title:t.visibility==="private"?"私人頁面(僅自己可見)":t.visibility==="dept"?"部門內共享":"指定成員共享",children:(t.visibility==="private"||t.visibility==="dept","")}),e.jsx("button",{"data-loc":"client/src/pages/NotionWorkspace.tsx:177",className:"shrink-0 opacity-0 group-hover:opacity-100 text-slate-400 hover:text-indigo-600 p-0.5",title:"新增子頁",onClick:d=>{d.stopPropagation(),O.mutate({orgId:i,parentId:t.id,title:"未命名"}),g(new Set(u).add(t.id))},children:e.jsx(me,{"data-loc":"client/src/pages/NotionWorkspace.tsx:182",className:"w-3.5 h-3.5"})})]}),a&&h&&t.children.map(d=>e.jsx(q,{"data-loc":"client/src/pages/NotionWorkspace.tsx:185",node:d,depth:C+1},d.id))]})};return i<=0?e.jsx(he,{"data-loc":"client/src/pages/NotionWorkspace.tsx:190",children:e.jsx("div",{"data-loc":"client/src/pages/NotionWorkspace.tsx:190",className:"p-8 text-center text-slate-400",children:"請先選擇組織"})}):e.jsxs(he,{"data-loc":"client/src/pages/NotionWorkspace.tsx:193",children:[e.jsx(Oe,{"data-loc":"client/src/pages/NotionWorkspace.tsx:194",orgId:i}),e.jsxs("div",{"data-loc":"client/src/pages/NotionWorkspace.tsx:195",className:"flex h-[calc(100vh-9rem)] min-h-[520px] overflow-hidden rounded-lg border bg-background -mx-1 sm:-mx-2",children:[e.jsxs("aside",{"data-loc":"client/src/pages/NotionWorkspace.tsx:196","data-no-i18n":!0,className:`${p==="list"?"flex":"hidden"} md:flex w-full md:w-64 shrink-0 border-r bg-slate-50/60 dark:bg-slate-900/40 flex-col`,children:[e.jsxs("div",{"data-loc":"client/src/pages/NotionWorkspace.tsx:197",className:"p-3 border-b",children:[e.jsxs("div",{"data-loc":"client/src/pages/NotionWorkspace.tsx:198",className:"flex items-center gap-2 font-semibold text-slate-800 dark:text-slate-100",children:[e.jsx(Ce,{"data-loc":"client/src/pages/NotionWorkspace.tsx:199",className:"w-5 h-5 text-indigo-600"})," Notion 知識庫"]}),e.jsxs("div",{"data-loc":"client/src/pages/NotionWorkspace.tsx:201",className:"relative mt-2",children:[e.jsx(Se,{"data-loc":"client/src/pages/NotionWorkspace.tsx:202",className:"absolute left-2 top-1/2 -translate-y-1/2 w-3.5 h-3.5 text-slate-400"}),e.jsx(be,{"data-loc":"client/src/pages/NotionWorkspace.tsx:204",defaultValue:A,onChange:t=>y(t.target.value),placeholder:"搜尋頁面...",className:"pl-7 h-8 text-sm","data-no-i18n":!0})]}),e.jsxs("div",{"data-loc":"client/src/pages/NotionWorkspace.tsx:206",className:"flex gap-1.5 mt-2",children:[e.jsxs(z,{"data-loc":"client/src/pages/NotionWorkspace.tsx:207",size:"sm",className:"flex-1 h-8",onClick:()=>O.mutate({orgId:i,title:"未命名"}),disabled:O.isPending,children:[e.jsx(me,{"data-loc":"client/src/pages/NotionWorkspace.tsx:208",className:"w-4 h-4 mr-1"})," 新頁面"]}),e.jsx(z,{"data-loc":"client/src/pages/NotionWorkspace.tsx:210",size:"sm",variant:"outline",className:"h-8",onClick:()=>c(!0),title:"匯入 Notion 匯出資料",children:e.jsx(ke,{"data-loc":"client/src/pages/NotionWorkspace.tsx:211",className:"w-4 h-4"})})]}),K.length>0&&e.jsxs("div",{"data-loc":"client/src/pages/NotionWorkspace.tsx:215",className:"mt-2 flex rounded-md border overflow-hidden text-xs",children:[e.jsxs("button",{"data-loc":"client/src/pages/NotionWorkspace.tsx:216",onClick:()=>j(!1),className:`flex-1 py-1.5 flex items-center justify-center gap-1 ${k?"bg-white dark:bg-slate-800 text-slate-600 hover:bg-slate-50":"bg-indigo-600 text-white"}`,children:[e.jsx(ue,{"data-loc":"client/src/pages/NotionWorkspace.tsx:216",className:"w-3.5 h-3.5"}),"樹狀"]}),e.jsxs("button",{"data-loc":"client/src/pages/NotionWorkspace.tsx:217",onClick:()=>j(!0),className:`flex-1 py-1.5 flex items-center justify-center gap-1 ${k?"bg-indigo-600 text-white":"bg-white dark:bg-slate-800 text-slate-600 hover:bg-slate-50"}`,children:[e.jsx(ne,{"data-loc":"client/src/pages/NotionWorkspace.tsx:217",className:"w-3.5 h-3.5"}),"依分類"]})]})]}),e.jsxs("div",{"data-loc":"client/src/pages/NotionWorkspace.tsx:221",className:"flex-1 overflow-y-auto p-2",onDragOver:t=>{w!=null&&t.preventDefault()},onDrop:t=>{w!=null&&!T&&(t.preventDefault(),I(null,"after"))},children:[x&&e.jsxs("div",{"data-loc":"client/src/pages/NotionWorkspace.tsx:226",className:"text-center text-slate-400 text-sm py-6",children:[e.jsx(H,{"data-loc":"client/src/pages/NotionWorkspace.tsx:226",className:"w-4 h-4 animate-spin inline mr-1"}),"載入中"]}),!x&&n.length===0&&e.jsxs("div",{"data-loc":"client/src/pages/NotionWorkspace.tsx:228",className:"text-center text-slate-400 text-xs py-8 px-2",children:["還沒有頁面。",e.jsx("br",{"data-loc":"client/src/pages/NotionWorkspace.tsx:229"}),"點「新頁面」開始,或「匯入」你的 Notion 資料。"]}),B?B.map(t=>e.jsxs("div",{"data-loc":"client/src/pages/NotionWorkspace.tsx:234",className:`flex items-center gap-1.5 rounded px-2 py-1 text-sm cursor-pointer hover:bg-slate-100 ${m===t.id?"bg-indigo-50 text-indigo-700":"text-slate-700"}`,onClick:()=>W(t.id),children:[e.jsx("span",{"data-loc":"client/src/pages/NotionWorkspace.tsx:235",className:"w-4 text-center",children:t.icon||e.jsx(J,{"data-loc":"client/src/pages/NotionWorkspace.tsx:235",className:"w-3.5 h-3.5 inline text-slate-400"})}),e.jsx("span",{"data-loc":"client/src/pages/NotionWorkspace.tsx:236",className:"truncate",children:t.title||"未命名"})]},t.id)):k?X.map(([t,C])=>e.jsxs("div",{"data-loc":"client/src/pages/NotionWorkspace.tsx:241",className:"mb-1.5",children:[e.jsxs("div",{"data-loc":"client/src/pages/NotionWorkspace.tsx:242",className:"px-1.5 py-1 text-[11px] font-semibold text-slate-400 flex items-center gap-1",children:[e.jsx(ne,{"data-loc":"client/src/pages/NotionWorkspace.tsx:242",className:"w-3 h-3"}),t,e.jsxs("span",{"data-loc":"client/src/pages/NotionWorkspace.tsx:242",className:"text-slate-300 font-normal",children:["(",C.length,")"]})]}),C.map(a=>e.jsxs("div",{"data-loc":"client/src/pages/NotionWorkspace.tsx:244",className:`flex items-center gap-1.5 rounded px-2 py-1 ml-1 text-sm cursor-pointer hover:bg-slate-100 ${m===a.id?"bg-indigo-50 text-indigo-700":"text-slate-700"}`,onClick:()=>W(a.id),children:[e.jsx("span",{"data-loc":"client/src/pages/NotionWorkspace.tsx:245",className:"w-4 text-center",children:a.icon||e.jsx(J,{"data-loc":"client/src/pages/NotionWorkspace.tsx:245",className:"w-3.5 h-3.5 inline text-slate-400"})}),e.jsx("span",{"data-loc":"client/src/pages/NotionWorkspace.tsx:246",className:"truncate",children:a.title||"未命名"})]},a.id))]},t)):R.map(t=>e.jsx(q,{"data-loc":"client/src/pages/NotionWorkspace.tsx:251",node:t,depth:0},t.id)),w!=null&&!B&&e.jsxs("div",{"data-loc":"client/src/pages/NotionWorkspace.tsx:253",className:"mt-2 flex items-center justify-center gap-1 text-xs text-slate-400 border-2 border-dashed rounded py-2",onDragOver:t=>{t.preventDefault(),L(null)},onDrop:t=>{t.preventDefault(),I(null,"after")},children:[e.jsx(Ae,{"data-loc":"client/src/pages/NotionWorkspace.tsx:258",className:"w-3.5 h-3.5"})," 拖來這裡移到最上層"]})]})]}),e.jsxs("main",{"data-loc":"client/src/pages/NotionWorkspace.tsx:264",className:`${p==="page"?"block":"hidden"} md:block flex-1 overflow-y-auto`,children:[e.jsxs("button",{"data-loc":"client/src/pages/NotionWorkspace.tsx:266",className:"md:hidden sticky top-0 z-10 flex items-center gap-1 w-full border-b bg-background/95 backdrop-blur px-3 py-2 text-sm text-slate-600 dar
2k:text-slate-300",onClick:()=>v("list"),children:[e.jsx($e,{"data-loc":"client/src/pages/NotionWorkspace.tsx:270",className:"w-4 h-4"})," 返回列表"]}),m==null?e.jsxs("div",{"data-loc":"client/src/pages/NotionWorkspace.tsx:273",className:"h-full flex flex-col items-center justify-center text-slate-400 gap-2",children:[e.jsx(ue,{"data-loc":"client/src/pages/NotionWorkspace.tsx:274",className:"w-10 h-10"}),e.jsx("p",{"data-loc":"client/src/pages/NotionWorkspace.tsx:275",children:"從左側選一個頁面,或新增頁面"})]}):e.jsx(He,{"data-loc":"client/src/pages/NotionWorkspace.tsx:278",orgId:i,pageId:m,editing:s,setEditing:M,onDelete:()=>{confirm("確定要刪除此頁面(含所有子頁)?")&&U.mutate({orgId:i,id:m})}},m)]}),F&&e.jsx(Ue,{"data-loc":"client/src/pages/NotionWorkspace.tsx:282",orgId:i,onClose:()=>c(!1),onDone:()=>{N.notion.list.invalidate({orgId:i}),c(!1)}})]})]})}function He({orgId:r,pageId:i,editing:N,setEditing:n,onDelete:x}){const m=P.useUtils(),{data:o,isLoading:p}=P.notion.get.useQuery({orgId:r,id:i}),[v,W]=l.useState(""),[u,g]=l.useState(""),[A,y]=l.useState(""),k=l.useRef({title:"",content:""}),j=P.notion.update.useMutation({onSuccess:()=>{m.notion.list.invalidate({orgId:r}),m.notion.get.invalidate({orgId:r,id:i})},onError:a=>b.error(a.message)}),{data:F=[]}=P.notion.categories.useQuery({orgId:r},{enabled:r>0}),[c,s]=l.useState(null),[M,w]=l.useState(!1),[E,T]=l.useState(""),L=l.useRef(null),R=l.useRef(null),[O,U]=l.useState(!1),G=P.notion.uploadFile.useMutation(),Q=a=>{const h=a.target.files?.[0];if(!h)return;if(h.size>25*1024*1024){b.warning("檔案請小於 25MB"),R.current&&(R.current.value="");return}const S=new FileReader;U(!0),S.onload=async()=>{try{const d=String(S.result||"").split(",")[1]||"",$=await G.mutateAsync({orgId:r,dataBase64:d,mimeType:h.type||"application/octet-stream",fileName:h.name}),f=/^image\//.test(h.type||"")?`<p><img src="${$.url}" alt="${h.name}" /></p>`:`<p><a href="${$.url}" target="_blank" rel="noreferrer">${h.name}</a></p>`;y(_=>(_||"")+f),b.success("檔案已插入內文最下方,記得按「儲存」")}catch(d){b.error(d?.message||"上傳失敗")}finally{U(!1),R.current&&(R.current.value="")}},S.onerror=()=>{U(!1),b.error("讀取檔案失敗")},S.readAsDataURL(h)},I=P.notion.setShare.useMutation({onSuccess:a=>{m.notion.get.invalidate({orgId:r,id:i}),m.notion.list.invalidate({orgId:r}),a.shared&&a.url?s(a.url):(s(null),b.success("已關閉公開分享"))},onError:a=>b.error(a.message)}),B=()=>{if(!o)return;const a=F.filter(d=>d!==o.category),h=a.length?`(現有分類:${a.join("、")})`:"",S=prompt(`設定文章分類${h},留空=清除分類`,o.category||"");S!==null&&j.mutate({orgId:r,id:i,category:S.trim()})},K=async()=>{if(L.current){T("pdf");try{const a=await de(()=>import("./vendor-export-Do0PDzts.js").then(ae=>ae.j),[]),h=a.jsPDF||a.default,S=(await de(async()=>{const{default:ae}=await import("./vendor-export-Do0PDzts.js").then(We=>We.h);return{default:ae}},[])).default,d=await S(L.current,{scale:2,useCORS:!0,backgroundColor:"#ffffff"}),$=d.toDataURL("image/jpeg",.92),D=new h({unit:"pt",format:"a4"}),f=28,_=D.internal.pageSize.getWidth(),ve=D.internal.pageSize.getHeight(),Y=_-f*2,Z=d.height*Y/d.width,ee=ve-f*2;let te=Z,se=0;for(D.addImage($,"JPEG",f,f+se,Y,Z),te-=ee;te>0;)se-=ee,D.addPage(),D.addImage($,"JPEG",f,f+se,Y,Z),te-=ee;D.save(`${(v||"文章").slice(0,50)}.pdf`)}catch(a){b.error("PDF 匯出失敗:"+String(a?.message||a).slice(0,60))}finally{T("")}}},X=()=>{if(o)try{const a=oe(o.content||""),S=`<html xmlns:o='urn:schemas-microsoft-com:office:office' xmlns:w='urn:schemas-microsoft-com:office:word' xmlns='http://www.w3.org/TR/REC-html40'><head><meta charset='utf-8'><style>body{font-family:'Microsoft JhengHei','PingFang TC',sans-serif;line-height:1.6;color:#111}h1{font-size:22pt}table{border-collapse:collapse}td,th{border:1px solid #999;padding:4px}img{max-width:100%}</style></head><body>${`<h1>${V(u||"")} ${V(v||"未命名")}</h1>`}${a}</body></html>`,d=new Blob(["\uFEFF",S],{type:"application/msword"}),$=URL.createObjectURL(d),D=document.createElement("a");D.href=$,D.download=`${(v||"文章").slice(0,50)}.doc`,D.click(),setTimeout(()=>URL.revokeObjectURL($),1e3)}catch{b.error("Word 匯出失敗")}};l.useEffect(()=>{o&&(W(o.title),g(o.icon),y(o.content),k.current={title:o.title,content:o.content})},[o]);const q=()=>{o&&v!==k.current.title&&(j.mutate({orgId:r,id:i,title:v}),k.current.title=v)},t=()=>{j.mutate({orgId:r,id:i,content:A}
2),k.current.content=A,n(!1),b.success("已儲存")};if(p||!o)return e.jsxs("div",{"data-loc":"client/src/pages/NotionWorkspace.tsx:397",className:"p-8 text-slate-400",children:[e.jsx(H,{"data-loc":"client/src/pages/NotionWorkspace.tsx:397",className:"w-4 h-4 animate-spin inline mr-1"}),"載入中"]});const C=/<table|<img/i.test(o.content);return e.jsxs("div",{"data-loc":"client/src/pages/NotionWorkspace.tsx:402",className:"max-w-3xl mx-auto px-8 py-6",children:[e.jsxs("div",{"data-loc":"client/src/pages/NotionWorkspace.tsx:403",className:"flex items-center gap-2 mb-3",children:[e.jsx("button",{"data-loc":"client/src/pages/NotionWorkspace.tsx:404",className:"text-2xl shrink-0 hover:bg-slate-100 rounded px-1",title:"設定 emoji 圖示",onClick:()=>{const h=(prompt("輸入一個 emoji 作為圖示(留空清除)",u)??u).trim().slice(0,4);g(h),j.mutate({orgId:r,id:i,icon:h})},children:u||""}),e.jsx("input",{"data-loc":"client/src/pages/NotionWorkspace.tsx:411",className:"flex-1 text-3xl font-bold bg-transparent outline-none border-0 focus:ring-0 text-slate-900 dark:text-slate-100",value:v,onChange:a=>W(a.target.value),onBlur:q,placeholder:"未命名"}),e.jsxs("div",{"data-loc":"client/src/pages/NotionWorkspace.tsx:418",className:"flex items-center gap-1 shrink-0",children:[N?e.jsxs(e.Fragment,{children:[e.jsxs(z,{"data-loc":"client/src/pages/NotionWorkspace.tsx:427",size:"sm",onClick:t,disabled:j.isPending,children:[e.jsx(Ee,{"data-loc":"client/src/pages/NotionWorkspace.tsx:427",className:"w-4 h-4 mr-1"}),"儲存"]}),e.jsx(z,{"data-loc":"client/src/pages/NotionWorkspace.tsx:428",size:"sm",variant:"ghost",onClick:()=>{y(k.current.content),n(!1)},children:e.jsx(Ne,{"data-loc":"client/src/pages/NotionWorkspace.tsx:428",className:"w-4 h-4"})})]}):o.canEdit!==!1?e.jsxs(z,{"data-loc":"client/src/pages/NotionWorkspace.tsx:421",size:"sm",variant:"outline",onClick:()=>n(!0),children:[e.jsx(Pe,{"data-loc":"client/src/pages/NotionWorkspace.tsx:421",className:"w-4 h-4 mr-1"}),"編輯"]}):e.jsx("span",{"data-loc":"client/src/pages/NotionWorkspace.tsx:423",className:"text-xs text-slate-400 border rounded px-2 py-1",title:"此頁面為唯讀共享",children:"唯讀"}),o.canManage!==!1&&e.jsxs(z,{"data-loc":"client/src/pages/NotionWorkspace.tsx:431",size:"sm",variant:"outline",className:"text-red-600 border-red-200 hover:bg-red-50",onClick:x,title:"刪除此頁面(含所有子頁)",children:[e.jsx(Te,{"data-loc":"client/src/pages/NotionWorkspace.tsx:431",className:"w-4 h-4 mr-1"}),"刪除"]})]})]}),e.jsxs("div",{"data-loc":"client/src/pages/NotionWorkspace.tsx:435",className:"flex items-center flex-wrap gap-1.5 mb-4 -mt-1",children:[e.jsxs("button",{"data-loc":"client/src/pages/NotionWorkspace.tsx:436",onClick:B,className:"text-xs rounded-md border px-2 py-1 hover:bg-slate-50 flex items-center gap-1 text-slate-600",title:"設定文章分類",children:[e.jsx(ne,{"data-loc":"client/src/pages/NotionWorkspace.tsx:436",className:"w-3.5 h-3.5"}),o.category||"未分類"]}),o.canManage!==!1&&e.jsx(z,{"data-loc":"client/src/pages/NotionWorkspace.tsx:438",size:"sm",variant:"outline",onClick:()=>w(!0),className:o.visibility&&o.visibility!=="org"?"text-amber-700 border-amber-300":"",title:"頁面權限設定",children:o.visibility==="private"?"私人(僅自己)":o.visibility==="dept"?`部門共享(${o.deptName||"部門"})`:o.visibility==="custom"?"指定成員":"全公司共享"}),e.jsxs(z,{"data-loc":"client/src/pages/NotionWorkspace.tsx:447",size:"sm",variant:"outline",onClick:()=>I.mutate({orgId:r,id:i,enabled:!o.isShared}),disabled:I.isPending,className:o.isShared?"text-emerald-600 border-emerald-300":"",children:[e.jsx(ze,{"data-loc":"client/src/pages/NotionWorkspace.tsx:447",className:"w-3.5 h-3.5 mr-1"}),o.isShared?"已分享(點此管理)":"分享"]}),e.jsxs(z,{"data-loc":"client/src/pages/NotionWorkspace.tsx:448",size:"sm",variant:"outline",onClick:K,disabled:!!E,title:"匯出 PDF",children:[E==="pdf"?e.jsx(H,{"data-loc":"client/src/pages/NotionWorkspace.tsx:448",className:"w-3.5 h-3.5 mr-1 animate-spin"}):e.jsx(ge,{"data-loc":"client/src/pages/NotionWorkspace.tsx:448",className:"w-3.5 h-3.5 mr-1"}),"PDF"]}),e.jsxs(z,{"data-loc":"client/src/pages/NotionWorkspace.tsx:449",size:"sm",variant:"outline",onClick:X,title:"匯出 Word(.doc)",children:[e.jsx(ge,{"data-loc":"client/src/pages/NotionWorkspace.tsx:449",className:"w-3.5 h-3.5 mr-1"}),"Word"]})]}),e.jsxs("div",{"data-loc":"client/src/pages/NotionWorkspace.tsx:452",ref:L,"aria-hidden":!0,style:{position:"fixed",left:"-99999px",to
2p:0,width:"794px",background:"#fff",padding:"32px",color:"#111",zIndex:-1},className:"prose prose-slate max-w-none rte-content notion-content",children:[e.jsxs("h1",{"data-loc":"client/src/pages/NotionWorkspace.tsx:453",style:{marginTop:0},children:[u," ",v||"未命名"]}),e.jsx("div",{"data-loc":"client/src/pages/NotionWorkspace.tsx:454",dangerouslySetInnerHTML:{__html:oe(o.content||"")}})]}),c&&e.jsx(ce,{"data-loc":"client/src/pages/NotionWorkspace.tsx:458",open:!0,onOpenChange:a=>!a&&s(null),children:e.jsxs(ie,{"data-loc":"client/src/pages/NotionWorkspace.tsx:459",className:"max-w-md",children:[e.jsx(le,{"data-loc":"client/src/pages/NotionWorkspace.tsx:460",children:e.jsx(re,{"data-loc":"client/src/pages/NotionWorkspace.tsx:460",children:"公開分享連結"})}),e.jsxs("div",{"data-loc":"client/src/pages/NotionWorkspace.tsx:461",className:"space-y-2 text-sm",children:[e.jsx("p",{"data-loc":"client/src/pages/NotionWorkspace.tsx:462",className:"text-xs text-slate-500",children:"任何人有此連結即可閱讀本文章(唯讀、免登入)。再按一次「已分享」即可關閉公開。"}),e.jsxs("div",{"data-loc":"client/src/pages/NotionWorkspace.tsx:463",className:"flex items-center gap-2",children:[e.jsx(be,{"data-loc":"client/src/pages/NotionWorkspace.tsx:464",value:c,readOnly:!0,className:"text-xs",onFocus:a=>a.currentTarget.select()}),e.jsx(z,{"data-loc":"client/src/pages/NotionWorkspace.tsx:465",size:"sm",onClick:()=>{try{navigator.clipboard?.writeText(c),b.success("已複製連結")}catch{}},children:e.jsx(fe,{"data-loc":"client/src/pages/NotionWorkspace.tsx:465",className:"w-3.5 h-3.5"})})]}),e.jsx("a",{"data-loc":"client/src/pages/NotionWorkspace.tsx:467",href:c,target:"_blank",rel:"noreferrer",className:"text-xs text-blue-600 inline-block",children:"開啟預覽 →"})]})]})}),M&&o&&e.jsx(Be,{"data-loc":"client/src/pages/NotionWorkspace.tsx:473",orgId:r,pageId:i,page:o,onClose:()=>w(!1)}),N?e.jsxs(e.Fragment,{children:[C&&e.jsx("div",{"data-loc":"client/src/pages/NotionWorkspace.tsx:478",className:"mb-2 text-xs text-amber-700 bg-amber-50 border border-amber-200 rounded px-2 py-1.5",children:"此頁含表格或圖片等進階區塊;在編輯器中可能被簡化。若只是要閱讀,建議用「檢視」模式即可。"}),e.jsxs("div",{"data-loc":"client/src/pages/NotionWorkspace.tsx:482",className:"mb-2 flex items-center gap-2 flex-wrap",children:[e.jsx("input",{"data-loc":"client/src/pages/NotionWorkspace.tsx:483",ref:R,type:"file",className:"hidden",onChange:Q}),e.jsx(z,{"data-loc":"client/src/pages/NotionWorkspace.tsx:484",size:"sm",variant:"outline",disabled:O,onClick:()=>R.current?.click(),children:O?"上傳中…":"上傳檔案(插入內文)"}),e.jsx("span",{"data-loc":"client/src/pages/NotionWorkspace.tsx:485",className:"text-[11px] text-slate-400",children:"支援 PDF/Word/Excel/圖片/壓縮檔等(單檔 ≤25MB);圖片直接顯示,其他檔案以下載連結插入。"})]}),e.jsx(Fe,{"data-loc":"client/src/pages/NotionWorkspace.tsx:487",value:A,onChange:y,placeholder:"開始輸入內容..."})]}):e.jsx("div",{"data-loc":"client/src/pages/NotionWorkspace.tsx:490",className:"prose prose-slate max-w-none rte-content notion-content",dangerouslySetInnerHTML:{__html:oe(o.content||"<p style='color:#9ca3af'>(空白頁面,點「編輯」開始撰寫)</p>")}})]})}function Ue({orgId:r,onClose:i,onDone:N}){const[n,x]=l.useState(!1),[m,o]=l.useState(""),p=P.notion.importPages.useMutation(),v=P.notion.uploadImage.useMutation(),W=async u=>{if(!u.name.toLowerCase().endsWith(".zip")){b.error("請選擇 Notion 匯出的 .zip 檔");return}x(!0);try{o("解析 zip 中...");const{pages:g,images:A,warnings:y}=await Le(u);if(g.length===0){b.error(y[0]||"找不到可匯入的頁面"),x(!1);return}const k=new Map;if(A.length>0){let s=0;const M=[...A],w=async()=>{for(;M.length;){const E=M.shift();try{const T=await v.mutateAsync({orgId:r,dataBase64:E.base64,mimeType:E.mime,fileName:E.name});k.set(E.token,T.url)}catch{}s++,o(`上傳圖片 ${s}/${A.length}...`)}};await Promise.all([w(),w(),w(),w()])}const j=g.map(s=>{let M=s.contentHtml;
2for(const w of A){if(!M.includes(w.token))continue;const E=k.get(w.token),T=E?`<p><img src="${V(E)}" alt="${V(w.alt)}" style="max-width:100%;"/></p>`:`<p style="color:#9ca3af;">${V(w.alt||w.name)}(圖片上傳失敗)</p>`;M=M.split(w.token).join(T)}return{...s,contentHtml:M}});o(`上傳頁面(共 ${j.length} 頁)...`);const F=u.name.replace(/\.zip$/i,"").replace(/\s*Export.*/i,"").trim()||"Notion 匯入",c=await p.mutateAsync({orgId:r,rootTitle:F,pages:j});b.success(`已匯入 ${c.imported} 個頁面、${k.size} 張圖片`),y.length&&b.message(y.join(";")),N()}catch(g){b.error(`匯入失敗:${g?.message||g}`)}finally{x(!1),o("")}};return e.jsx(ce,{"data-loc":"client/src/pages/NotionWorkspace.tsx:561",open:!0,onOpenChange:u=>!u&&!n&&i(),children:e.jsxs(ie,{"data-loc":"client/src/pages/NotionWorkspace.tsx:562",className:"max-w-md",children:[e.jsx(le,{"data-loc":"client/src/pages/NotionWorkspace.tsx:563",children:e.jsx(re,{"data-loc":"client/src/pages/NotionWorkspace.tsx:563",children:"匯入 Notion 資料"})}),e.jsxs("div",{"data-loc":"client/src/pages/NotionWorkspace.tsx:564",className:"space-y-3 text-sm",children:[e.jsxs("p",{"data-loc":"client/src/pages/NotionWorkspace.tsx:565",className:"text-slate-600 dark:text-slate-300",children:["在 Notion 中選 ",e.jsx("b",{"data-loc":"client/src/pages/NotionWorkspace.tsx:566",children:"Settings → Export"}),"(或頁面右上「•••」→ Export),格式選 ",e.jsx("b",{"data-loc":"client/src/pages/NotionWorkspace.tsx:566",children:"Markdown & CSV"}),",把下載的 ",e.jsx("b",{"data-loc":"client/src/pages/NotionWorkspace.tsx:566",children:".zip"})," 直接上傳即可。系統會保留頁面階層、文字、表格(資料庫),",e.jsx("b",{"data-loc":"client/src/pages/NotionWorkspace.tsx:566",children:"圖片會上傳並託管於主機"}),"。"]}),e.jsxs("label",{"data-loc":"client/src/pages/NotionWorkspace.tsx:568",className:`flex flex-col items-center justify-center gap-2 border-2 border-dashed rounded-lg py-8 cursor-pointer ${n?"opacity-60 pointer-events-none":"hover:border-indigo-400 hover:bg-indigo-50/40"}`,children:[n?e.jsx(H,{"data-loc":"client/src/pages/NotionWorkspace.tsx:569",className:"w-6 h-6 animate-spin text-indigo-500"}):e.jsx(ke,{"data-loc":"client/src/pages/NotionWorkspace.tsx:569",className:"w-6 h-6 text-indigo-500"}),e.jsx("span",{"data-loc":"client/src/pages/NotionWorkspace.tsx:570",className:"text-slate-600",children:n?m||"處理中...":"點此選擇 Notion 匯出 .zip"}),e.jsx("input",{"data-loc":"client/src/pages/NotionWorkspace.tsx:571",type:"file",accept:".zip",className:"hidden",disabled:n,onChange:u=>{const g=u.target.files?.[0];g&&W(g)}})]}),e.jsx("p",{"data-loc":"client/src/pages/NotionWorkspace.tsx:573",className:"text-xs text-slate-400",children:"單張圖片上限 10MB;超大型匯出建議在 Notion 分區塊匯出後分批上傳。"})]}),e.jsx(je,{"data-loc":"client/src/pages/NotionWorkspace.tsx:575",children:e.jsx(z,{"data-loc":"client/src/pages/NotionWorkspace.tsx:576",variant:"outline",onClick:i,disabled:n,children:"關閉"})})]})})}function Be({orgId:r,pageId:i,page:N,onClose:n}){const x=P.useUtils(),{data:m=[]}=P.members.listActive.useQuery({orgId:r},{enabled:r>0}),o=l.useMemo(()=>Array.from(new Set(m.map(s=>String(s.department||"")).filter(Boolean))).sort(),[m]),[p,v]=l.useState(N.visibility||"org"),[W,u]=l.useState(N.deptName||""),[g,A]=l.useState(new Set((N.allowedUserIds||[]).map(Number))),[y,k]=l.useState(!!N.canEditGrant),j=P.notion.setPermission.useMutation({onSuccess:()=>{x.notion.get.invalidate({orgId:r,id:i}),x.notion.list.invalidate({orgId:r}),b.success("權限已更新"),n()},onError:s=>b.error(s.message)}),F=[{v:"org",label:"全公司共享",desc:"公司所有成員都可以閱讀與編輯(預設)"},{v:"dept",label:"部門內共享",desc:"只有指定部門的成員可以存取"},{v:"custom",label:"指定成員",desc:"只有勾選的成員可以存取"},{v:"private",label:"私人",desc:"只有您本人可以閱讀與修改(會關閉公開分享)"}],c=()=>{if(p==="dept"&&!W){b.warning("請選擇要共享的部門");return}if(p==="custom"&&g.size===0){b.warning("請至少勾選一位成員");return}j.mutate({orgId:r,id:i,visibility:p,deptName:p==="dept"?W:void 0,allowedUserIds:p==="custom"?Array.from(g):void 0,canEdit:y})};return e.jsx(ce,{"data-loc":"client/src/pages/NotionWorkspace.tsx:608",open:!0,onOpenChange:s=>!s&&n(),children:e.jsxs(ie,{"data-loc":"client/src/pages/NotionWorkspace.tsx:609",className:"max-w-md",children:[e.jsx(le,{"data-loc":"client/src/pages/NotionWorkspace.tsx:610",children:e.jsx(re,{"data-loc":"client/src/pages/NotionWorkspace.tsx:610",children:"頁面權限設定"})}),e.jsxs("div",{"data-loc":"client/src/pages/NotionWorkspace.tsx:611",className:"space-y-2",children:[F.map(s=>e.jsxs("label",{"data-loc":"client/src/pages/NotionWorkspace.tsx:613",className:`flex items-start gap-2 border rounded-lg p-2.5 cursor-pointer ${p===s.v?"border-indigo-400 bg-indigo-50 dark:bg-indigo-950":"hover:bg-slate-50 dark:hover:bg-slate-800"}`,children:[e.jsx("input",{"data-loc":"client/src/pages/NotionWorkspace.tsx:614",type:"radio",name:"notion-vis",className:"mt-1",checked:p===s.v,onChange:()=>v(s.v)}),e.jsxs("span",{"data-loc":"client/src/pages/NotionWorkspace.tsx:615",className:"text-sm",children:[e.jsx("b",{"data-loc":"client/src/pages/NotionWorkspace.tsx:615",children:s.label}),e.jsx("br",{"data-loc":"client/src/pages/NotionWorkspace.tsx:615"}),e.jsx("span",{"data-loc":"client/src/pages/NotionWorkspace.tsx:615",className:"text-xs text-slate-500",children:s.desc})]})]},s.v)),p==="dept"&&e.jsxs("select",{"data-loc":"client/src/pages/NotionWorkspace.tsx:619",value:W,onChange:s=>u(s.target.value),className:"w-full h-9 rounded-md border px-2 text-sm bg-background",children:[e.jsx("option",{"data-loc":"client/src/pages/NotionWorkspace.tsx:620",value:"",children:"選擇部門…"}),o.map(s=>e.jsx("option",{"data-loc":"client/src/pages/NotionWorkspace.tsx:621",value:s,children:s},s))]}),p==="custom"&&e.jsx("div",{"data-loc":"client/src/pages/NotionWorkspace.tsx:625",className:"max-h-44 overflow-y-auto border rounded-md p-2 space-y-1",children:m.map(s=>{const M=Number(s.userId??s.id);return e.jsxs("label",{"data-loc":"client/src/pages/NotionWorkspace.tsx:629",className:"flex items-center gap-2 text-sm cursor-pointer hover:bg-slate-50 dark:hover:bg-slate-800 rounded px-1 py-0.5",children:[e.jsx("input",{"data-loc":"client/src/pages/NotionWorkspace.tsx:630",type:"checkbox",checked:g.has(M),onChange:w=>{const E=new Set(g);w.target.checked?E.add(M):E.delete(M),A(E)}}),e.jsxs("span",{"data-loc":"client/src/pages/NotionWorkspace.tsx:631",children:[s.name,s.department?e.jsxs("span",{"data-loc":"client/src/pages/NotionWorkspace.tsx:631",className:"text-xs text-slate-400",children:[" · ",s.department]}):null]})]},M)})}),(p==="dept"||p==="custom")&&e.jsxs("label",{"data-loc":"client/src/pages/NotionWorkspace.tsx:638",className:"flex items-center gap-2 text-sm cursor-pointer border rounded-md p-2 bg-slate-50 dark:bg-slate-900",children:[e.jsx("input",{"data-loc":"client/src/pages/NotionWorkspace.tsx:639",type:"checkbox",checked:y,onChange:s=>k(s.target.checked)}),"允許他們編輯內容(不勾選=僅可閱讀)"]})]}),e.jsxs(je,{"data-loc":"client/src/pages/NotionWorkspace.tsx:644",children:[e.jsx(z,{"data-loc":"client/src/pages/NotionWorkspace.tsx:645",variant:"outline",onClick:n,children:"取消"}),e.jsx(z,{"data-loc":"client/src/pages/NotionWorkspace.tsx:646",onClick:c,disabled:j.isPending,children:j.isPending?"儲存中…":"å
2„²å­˜æ¬Šé™"})]})]})})}export{et as default};

Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.