diff --git a/RELEASE-v0.1.50.md b/RELEASE-v0.1.50.md new file mode 100644 index 0000000..e206e7d --- /dev/null +++ b/RELEASE-v0.1.50.md @@ -0,0 +1,26 @@ +# V0.1.50 — 手机离线轨迹与定时补传 + +## 手机使用 + +- “我的位置设置”分别设置定位采集频率(10 秒、1 分钟、5 分钟)和上传周期。上传保留实时、1/5 分钟,增加 1—5 小时、1—3 天,以及 1—720 小时 / 1—30 天的整数自定义周期。 +- 开启本人位置共享和历史保存后,采集点先写入手机私有 SQLite 队列,使用 Android Keystore 的 AES-256-GCM 加密。采集写入与网络同步使用独立线程,关闭流量、断网或上传超时不会阻塞本地写入。 +- 到达周期集中发送;断网恢复、解除网络限制、点击“立即同步”或重新打开有未完成队列的 App 时补传。只有采集授权窗口内的轨迹可以补传。授权到期停止新采集,但仍绑定的手机可以完成到期前记录的同步;解除手机绑定后不能上传。 +- 手机对每批内容计算 SHA-256,服务端核对整批内容、点数、时间和采集授权。收到“已接收”仍保留手机副本;百度网盘完成上传并回读校验后,手机核对批次、SHA-256 和点数,再事务性清理这一批。网络重试、回执丢失、进程重启均复用同一批次,避免重复入库。 +- 单批最多 128 点,最多 4 批等待校验。手机缓存以 50,000 点 / 12 MiB 密文先到为限,数据库最多 32 MiB,删除后的空页复用。达到上限暂停新增历史并提示,不能为了腾空间覆盖未确认记录。SQLite 事务日志可能临时增加少量占用。 +- 设置显示待同步点数、占用、累计校验清理数量和释放的记录字节数。支持立即重试、明确确认后放弃本机副本,以及删除全部历史;最后一项暂停共享并清理本机未完成记录,服务器隐藏历史并持续重试网盘删除。 +- 未完成队列存在时阻止直接更换配对,避免把同一个人的旧轨迹误归到另一个人。关闭共享立即停止新采集、清除实时位置;关闭前已经采集的授权轨迹继续完成同步。 + +## 平台与授权 + +- 网盘继续沿用 `家庭轨迹/家庭编号/成员编号/年/月/日`,只保存加密压缩文件。 +- 每次采集会话保存当时的查看人范围。后来新增的查看人不能读取旧的离线轨迹;查看时仍需现行授权,超级管理员没有绕过权限的入口。 +- 历史批次不覆盖“当前实时位置”。超过 15 分钟的坐标不作为实时点显示;长周期尚未到期显示“等待下次定时上传”,到期加宽限仍未收到才提示中断。排期时间持久化,服务端重启不应造成长周期误报。 +- 旧版手机继续使用原位置接口。新的离线批次接口有独立大小上限和原子校验,容量不足返回失败并让手机保留数据。用户主动删除的旧历史不能被迟到重传重新创建。 + +## 验证与使用边界 + +- 后端专项覆盖整批校验、跨手机隔离、3 天补传、授权到期、关闭共享、删除防重放、云端失败、重复请求和长周期状态。 +- 全量 Python 回归 326 项、JavaScript 回归 191 项通过。Edge 桌面与 390 像素手机宽度验证了排期提示、无错误中断警报和无横向溢出;Vue 生产构建与两个签名安装包构建通过。 +- 独立 JVM 周期测试通过 92 条断言。Android 11 真机隔离测试通过 163 条断言:Keystore 加密、SQLite 持久化重开、错误 / 部分回执、确认后只删对应批次、容量上限、归属隔离及密文篡改。测试包不申请 GPS,不访问家庭数据,测试后已卸载。 +- 真机存储测试不等于已在用户手机上验证移动 GPS、断流量和各厂商省电策略。需从下载页覆盖安装手机版本;测试不替任何家人开启定位或历史共享。 +- 本地队列在 App 进程结束后保留。系统强制停止、卸载、清除应用数据或撤销定位权限时不能保证继续采集;重新打开 App 可补传已保存队列,新采集仍由本人开启。卸载 / 清数据会删除尚未上传的本机副本,请使用覆盖安装。 diff --git a/VERSION b/VERSION index 352e98e..0665a48 100644 --- a/VERSION +++ b/VERSION @@ -1 +1 @@ -0.1.49 +0.1.50 diff --git a/android-display/AndroidManifest-terminal.xml b/android-display/AndroidManifest-terminal.xml index fbd415f..92792da 100644 --- a/android-display/AndroidManifest-terminal.xml +++ b/android-display/AndroidManifest-terminal.xml @@ -1,4 +1,4 @@ - + @@ -17,6 +17,6 @@ - + diff --git a/android-display/AndroidManifest.xml b/android-display/AndroidManifest.xml index ef4539c..09061f3 100644 --- a/android-display/AndroidManifest.xml +++ b/android-display/AndroidManifest.xml @@ -1,4 +1,4 @@ - + @@ -15,7 +15,7 @@ - + diff --git a/android-display/src/cn/ucvl/zhaodisplay/LocationActivity.java b/android-display/src/cn/ucvl/zhaodisplay/LocationActivity.java index 06116ed..3a6ff22 100644 --- a/android-display/src/cn/ucvl/zhaodisplay/LocationActivity.java +++ b/android-display/src/cn/ucvl/zhaodisplay/LocationActivity.java @@ -15,7 +15,9 @@ import java.util.*; public class LocationActivity extends Activity { static volatile boolean pairing=false; TextView identity,status,viewStatus,permissionStatus;EditText code;Button pair,reload; - CheckBox consent,historyConsent;Switch sharing;Spinner cadence;LinearLayout settings,recipients,familyList,homeContent,shareControls; + CheckBox consent,historyConsent;Switch sharing;Spinner cadence,sampleCadence,customUnit;EditText customAmount;LinearLayout customPeriod,settings,recipients,familyList,homeContent,shareControls; + TextView queueStatus;LocationQueue outbox;String queueOwner=""; + final int[] uploadIntervals={10,60,300,3600,7200,10800,14400,18000,86400,172800,259200,0}; TextView historyStatus,historyNotice;Dialog historyDialog;LocationMapView historyMap;Button historyMore;JSONArray historyPoints=new JSONArray();int historyRequest=0;boolean historyAcknowledged=false; VoicePanel voice;Button settingsButton; LocationMapView map;boolean rendering=false,visible=false,loading=false,settingsReady=false,pendingStart=false; @@ -28,6 +30,7 @@ public class LocationActivity extends Activity { Button button(String label,LinearLayout parent){Button b=new Button(this);b.setText(label);parent.addView(b);return b;} public void onCreate(Bundle state){ super.onCreate(state);prefs=getSharedPreferences("location",0); + outbox=new LocationQueue(this);refreshQueueStats(); getSharedPreferences("display",0).edit().putBoolean("phoneMode",true).apply(); stopService(new Intent(this,MonitorService.class)); // Process death/reboot cannot leave a stale switch claiming collection is active. @@ -49,13 +52,20 @@ public class LocationActivity extends Activity { shareControls=new LinearLayout(this);shareControls.setOrientation(1);settings.addView(shareControls); text("我的位置共享",22,shareControls);text("选择谁能看我的位置",16,shareControls); recipients=new LinearLayout(this);recipients.setOrientation(1);shareControls.addView(recipients); - text("上传频率",16,shareControls);cadence=new Spinner(this);cadence.setAdapter(new ArrayAdapter(this,android.R.layout.simple_spinner_dropdown_item,new String[]{"实时(约 10 秒)","每 1 分钟","每 5 分钟(默认)"}));cadence.setSelection(2);shareControls.addView(cadence); - text("实时档更耗电和流量;更新受信号、网络与系统省电影响。调整名单或频率前,先关闭共享。",14,shareControls); + text("定位采集频率",16,shareControls);sampleCadence=new Spinner(this);sampleCadence.setAdapter(new ArrayAdapter(this,android.R.layout.simple_spinner_dropdown_item,new String[]{"每 10 秒(较耗电)","每 1 分钟(默认)","每 5 分钟(省电)"}));sampleCadence.setSelection(1);shareControls.addView(sampleCadence); + text("集中上传周期",16,shareControls);cadence=new Spinner(this);cadence.setAdapter(new ArrayAdapter(this,android.R.layout.simple_spinner_dropdown_item,new String[]{"实时(约 10 秒)","每 1 分钟","每 5 分钟(默认)","每 1 小时","每 2 小时","每 3 小时","每 4 小时","每 5 小时","每 1 天","每 2 天","每 3 天","自定义小时 / 天"}));cadence.setSelection(2);shareControls.addView(cadence); + customPeriod=new LinearLayout(this);customPeriod.setOrientation(0);customAmount=new EditText(this);customAmount.setInputType(InputType.TYPE_CLASS_NUMBER);customAmount.setHint("正整数");customAmount.setText("6");customAmount.setFilters(new android.text.InputFilter[]{new android.text.InputFilter.LengthFilter(3)});customPeriod.addView(customAmount,new LinearLayout.LayoutParams(0,-2,1));customUnit=new Spinner(this);customUnit.setAdapter(new ArrayAdapter(this,android.R.layout.simple_spinner_dropdown_item,new String[]{"小时","天"}));customPeriod.addView(customUnit);shareControls.addView(customPeriod);customPeriod.setVisibility(View.GONE); + cadence.setOnItemSelectedListener(new AdapterView.OnItemSelectedListener(){public void onItemSelected(AdapterView p,View v,int position,long id){customPeriod.setVisibility(position==uploadIntervals.length-1?View.VISIBLE:View.GONE);}public void onNothingSelected(AdapterView p){}}); + text("采集与上传分开:例如每分钟采集、每天集中上传。自定义 1—720 小时或 1—30 天。断网时本地暂存,恢复后自动补传;长周期期间家人无法看到实时移动。调整名单或频率前,先关闭共享。",14,shareControls); historyConsent=new CheckBox(this);historyConsent.setText("另行同意保存我的历史轨迹到家庭网盘,长期保留至我手动删除;共享期间允许所选查看人读取其获授权期间的记录。");shareControls.addView(historyConsent); historyStatus=text("未开启时不保存历史轨迹。关闭共享只清除当前位置,已保存历史可在下方删除。",14,shareControls); button("查看我的历史轨迹",shareControls).setOnClickListener(v->history("")); - button("删除我的全部历史轨迹",shareControls).setOnClickListener(v->new AlertDialog.Builder(this).setTitle("删除自己的历史轨迹").setMessage("历史将立即隐藏,网盘文件随后删除;此操作不能撤销。若仍开启共享和历史保存,之后的新位置会继续记录。").setNegativeButton("取消",null).setPositiveButton("确认删除",(d,w)->deleteHistory()).show()); - consent=new CheckBox(this);consent.setText("我已核对本人身份、有效期和所选查看人,同意按上述频率共享实时位置。关闭后停止采集并清除当前位置。");shareControls.addView(consent); + queueStatus=text("",15,shareControls); + button("立即同步待上传轨迹",shareControls).setOnClickListener(v->syncNow()); + text("本机待同步上限:50,000 个点或 12 MiB 密文,先到为准。达到上限暂停新增历史,保留未上传记录。只有网盘完整回读校验通过才自动清理对应批次;手机数据库文件最多 32 MiB,空页循环复用。",13,shareControls); + button("放弃本机待同步记录",shareControls).setOnClickListener(v->new AlertDialog.Builder(this).setTitle("放弃尚未同步完的轨迹").setMessage("将停止本机共享并删除本机待同步副本,未上传内容无法恢复。已经被平台接收的记录不受此操作影响;如需彻底删除,请使用“删除我的全部历史轨迹”。").setNegativeButton("保留记录",null).setPositiveButton("确认放弃",(d,w)->discardLocal()).show()); + button("删除我的全部历史轨迹",shareControls).setOnClickListener(v->new AlertDialog.Builder(this).setTitle("删除自己的历史轨迹").setMessage("将暂停共享、清空本机待同步轨迹并隐藏平台历史,网盘文件随后删除;此操作不能撤销。以后可重新开启共享和记录。").setNegativeButton("取消",null).setPositiveButton("确认删除",(d,w)->deleteHistory()).show()); + consent=new CheckBox(this);consent.setText("我已核对本人身份、有效期和所选查看人,同意按上述周期采集和共享位置。启用历史保存后,断网会加密暂存并补传。关闭后停止新采集并清除当前位置,关闭前已采集轨迹仍会完成上传。");shareControls.addView(consent); sharing=new Switch(this);sharing.setText("共享我的位置");sharing.setTextSize(20);sharing.setPadding(0,20,0,20);shareControls.addView(sharing); sharing.setOnCheckedChangeListener((v,checked)->{if(rendering)return;if(checked)start();else{startService(new Intent(this,LocationService.class).setAction("STOP"));consent.setChecked(false);}render();}); permissionStatus=text("",14,shareControls); @@ -80,23 +90,26 @@ public class LocationActivity extends Activity { long expires=prefs.getLong("expires",0); identity.setText(prefs.getString("memberName","尚未配对本人")+" · "+prefs.getString("home","请在我的位置设置中配对")+(expires>0?"\n配对有效至 "+java.text.DateFormat.getDateTimeInstance().format(new Date(expires)):"")); status.setText(settingsError.isEmpty()?"我的位置:"+prefs.getString("status","共享关闭,不采集定位"):settingsError); + queueStatus.setText(String.format(Locale.CHINA,"本机待同步:%d 个点 · %.1f KB\n累计校验清理:%d 个点 · %.1f KB\n%s%s",prefs.getLong("pendingPoints",0),prefs.getLong("pendingBytes",0)/1024d,prefs.getLong("uploadedPoints",0),prefs.getLong("freedBytes",0)/1024d,prefs.getBoolean("cacheFull",false)?"缓存已满,暂停新增历史。\n":"",prefs.getString("syncStatus","尚无待同步轨迹"))); rendering=true;sharing.setChecked(active);rendering=false; sharing.setEnabled(paired&&!pairing&&(active||!busy&&settingsReady)); pair.setEnabled(!active&&!busy);cadence.setEnabled(!active&&!busy);consent.setEnabled(!active&&!busy);historyConsent.setEnabled(!active&&!busy&&settingsReady); + sampleCadence.setEnabled(!active&&!busy);customAmount.setEnabled(!active&&!busy);customUnit.setEnabled(!active&&!busy); for(List list:choices.values())for(CheckBox c:list)c.setEnabled(!active&&!busy); reload.setEnabled(paired&&!loading&&!pairing); } void remember(JSONObject response)throws Exception{ StringBuilder names=new StringBuilder();for(String type:new String[]{"viewers","phones","displays"}){JSONArray list=response.optJSONArray(type);if(list==null)continue;for(int i=0;i0)names.append("、");names.append(list.getJSONObject(i).getString("name"));if(type.equals("displays"))names.append("(显示终端)");}} - prefs.edit().putString("receipt",response.getString("receipt")).putString("recipients",names.toString()).putInt("intervalSeconds",response.optInt("intervalSeconds",300)).apply(); + prefs.edit().putString("receipt",response.getString("receipt")).putString("recipients",names.toString()).putInt("intervalSeconds",response.optInt("intervalSeconds",300)).putInt("sampleIntervalSeconds",response.optInt("sampleIntervalSeconds",60)).apply(); } void pair(){ if(pairing||LocationService.busy||prefs.getBoolean("active",false))return; + if(outbox.total()>0){Toast.makeText(this,"还有本机待同步轨迹,请先完成同步,或明确放弃后再更换配对",1).show();return;} String value=code.getText().toString().trim();if(!value.matches("[0-9]{8}")){Toast.makeText(this,"请输入八位手机配对码",1).show();return;} pairing=true;render(); new Thread(()->{try{ JSONObject response=DisplayApi.call("/api/location/pair",null,new JSONObject().put("code",value).put("consentProtocol",3));remember(response); - prefs.edit().putString("memberName",response.getString("memberName")).putString("token",response.getString("token")).putString("home",response.getString("home")).putLong("expires",(long)(response.getDouble("expires")*1000)).putBoolean("active",false).putString("status","已配对;共享关闭,可查看获授权家人").apply(); + stopService(new Intent(this,LocationService.class));prefs.edit().putString("memberName",response.getString("memberName")).putString("token",response.getString("token")).putString("home",response.getString("home")).putLong("expires",(long)(response.getDouble("expires")*1000)).putBoolean("active",false).putString("status","已配对;共享关闭,可查看获授权家人").apply();refreshQueueStats(); runOnUiThread(()->{if(isDestroyed())return;pairing=false;generation++;loading=false;familyList.removeAllViews();map.setItems(new JSONArray());code.setText("");consent.setChecked(false);settingsReady=false;settings.setVisibility(View.GONE);voice.rebound();loadSettings();loadFamily();}); }catch(Exception e){runOnUiThread(()->{if(!isDestroyed())Toast.makeText(this,"配对未成功,请检查手机配对码或安装新版 App",1).show();});}finally{pairing=false;runOnUiThread(()->{if(!isDestroyed())render();});}},"location-pair").start(); } @@ -106,9 +119,9 @@ public class LocationActivity extends Activity { new Thread(()->{try{ JSONObject response=DisplayApi.call("/api/location/update",token,new JSONObject().put("action","list")); runOnUiThread(()->{if(!visible||g!=generation)return;JSONArray list=response.optJSONArray("items");map.setItems(list);familyList.removeAllViews();viewStatus.setText(list==null||list.length()==0?"尚无家人授权给这台手机的位置。请对方在自己的位置设置里勾选你的手机,并开启共享。":"只显示仍在授权有效期内的最新位置。"); - if(list!=null)for(int i=0;i{if(pos!=null)map.focus(pos);});button("查看 "+row.optString("name")+" 的已授权历史",familyList).setOnClickListener(v->history(row.optString("id")));} + if(list!=null)for(int i=0;i{if(pos!=null)map.focus(pos);});button("查看 "+row.optString("name")+" 的已授权历史",familyList).setOnClickListener(v->history(row.optString("id")));} }); - }catch(Exception e){runOnUiThread(()->{if(!visible||g!=generation)return;familyList.removeAllViews();map.setItems(new JSONArray());if(e instanceof DisplayApi.ApiError&&(((DisplayApi.ApiError)e).status==401||((DisplayApi.ApiError)e).status==403)){prefs.edit().remove("token").putBoolean("active",false).apply();startService(new Intent(this,LocationService.class).setAction("STOP"));voice.rebound();settings.setVisibility(View.VISIBLE);}viewStatus.setText(e instanceof DisplayApi.ApiError&&((DisplayApi.ApiError)e).status==401?"手机配对已过期或解除,请重新配对。":"位置未能刷新,已隐藏旧画面,请检查网络。");});}finally{runOnUiThread(()->{if(g==generation){loading=false;render();}});}},"family-positions").start(); + }catch(Exception e){runOnUiThread(()->{if(!visible||g!=generation)return;familyList.removeAllViews();map.setItems(new JSONArray());if(e instanceof DisplayApi.ApiError&&(((DisplayApi.ApiError)e).status==401||((DisplayApi.ApiError)e).status==403)){boolean wasSharing=prefs.getBoolean("active",false);prefs.edit().putBoolean("active",false).apply();if(wasSharing||LocationService.busy)startService(new Intent(this,LocationService.class).setAction("STOP"));voice.rebound();settings.setVisibility(View.VISIBLE);}viewStatus.setText(e instanceof DisplayApi.ApiError&&((DisplayApi.ApiError)e).status==401?"手机配对已过期或解除,请重新配对。":"位置未能刷新,已隐藏旧画面,请检查网络。");});}finally{runOnUiThread(()->{if(g==generation){loading=false;render();}});}},"family-positions").start(); } void loadSettings(){ String token=prefs.getString("token","");if(token.isEmpty()||pairing)return;int g=generation,request=++settingsRequest;settingsReady=false;settingsError="";render(); @@ -116,7 +129,7 @@ public class LocationActivity extends Activity { JSONObject result=DisplayApi.call("/api/location/update",token,new JSONObject().put("action","settings")); runOnUiThread(()->{if(!visible||g!=generation||request!=settingsRequest)return;settingsReceipt=result.optString("receipt");recipients.removeAllViews();choices.clear(); for(String type:new String[]{"viewers","phones","displays"}){String key=type.equals("viewers")?"viewerIds":type.equals("phones")?"phoneIds":"displayIds";text(type.equals("viewers")?"平台查看账号":type.equals("phones")?"已配对的家人手机":"公共显示终端",16,recipients);JSONArray options=result.optJSONArray(type),selected=result.optJSONArray(key);Set ids=new HashSet<>();if(selected!=null)for(int i=0;i list=new ArrayList<>();choices.put(key,list);if(options!=null)for(int i=0;i{if(visible&&g==generation&&request==settingsRequest){settingsReady=false;settingsError="无法读取我的位置设置,请检查网络或配对有效期,重新打开设置重试。";render();}});}},"location-settings").start(); } void start(){ @@ -125,12 +138,17 @@ public class LocationActivity extends Activity { if(historyConsent.isChecked()&&!historyAcknowledged){new AlertDialog.Builder(this).setTitle("同意长期保存我的轨迹").setMessage("定位点将加密上传家庭百度网盘,按天、周、月、年或全部历史查看,长期保留直到你手动删除。共享时所选查看人能读取其获授权期间的历史。关闭实时共享不会删除历史。是否同意?").setNegativeButton("暂不启用",null).setPositiveButton("本人同意并开启",(d,w)->{historyAcknowledged=true;start();}).show();return;} if(checkSelfPermission(Manifest.permission.ACCESS_FINE_LOCATION)!=PackageManager.PERMISSION_GRANTED&&checkSelfPermission(Manifest.permission.ACCESS_COARSE_LOCATION)!=PackageManager.PERMISSION_GRANTED){requestPermissions(new String[]{Manifest.permission.ACCESS_FINE_LOCATION,Manifest.permission.ACCESS_COARSE_LOCATION},45);return;} if(!LocationService.locationEnabled((android.location.LocationManager)getSystemService(LOCATION_SERVICE))){Toast.makeText(this,"请先打开手机系统定位开关",1).show();return;} - final JSONObject body=new JSONObject();try{int total=0;for(Map.Entry> e:choices.entrySet()){JSONArray ids=new JSONArray();for(CheckBox c:e.getValue())if(c.isChecked()){ids.put((String)c.getTag());total++;}body.put(e.getKey(),ids);}if(total==0){Toast.makeText(this,"请选择至少一位查看人;只看家人无需开启此开关",1).show();return;}body.put("action","configure").put("consent",true).put("receipt",settingsReceipt).put("intervalSeconds",new int[]{10,60,300}[cadence.getSelectedItemPosition()]).put("historyEnabled",historyConsent.isChecked()).put("historyConsent",historyConsent.isChecked());}catch(Exception e){return;} + final JSONObject body=new JSONObject();try{int total=0;for(Map.Entry> e:choices.entrySet()){JSONArray ids=new JSONArray();for(CheckBox c:e.getValue())if(c.isChecked()){ids.put((String)c.getTag());total++;}body.put(e.getKey(),ids);}if(total==0){Toast.makeText(this,"请选择至少一位查看人;只看家人无需开启此开关",1).show();return;}int upload=uploadPeriod();if(upload>=3600&&!historyConsent.isChecked()){Toast.makeText(this,"按小时或天集中上传需要本人启用历史保存,才能保留期间的轨迹",1).show();return;}body.put("action","configure").put("consent",true).put("receipt",settingsReceipt).put("intervalSeconds",upload).put("sampleIntervalSeconds",new int[]{10,60,300}[sampleCadence.getSelectedItemPosition()]).put("historyEnabled",historyConsent.isChecked()).put("historyConsent",historyConsent.isChecked());}catch(Exception e){Toast.makeText(this,"请填写 1—720 小时或 1—30 天的整数周期",1).show();return;} final int g=generation;final String token=prefs.getString("token","");pairing=true;settingsReady=false;settingsError="";render(); new Thread(()->{try{JSONObject result=DisplayApi.call("/api/location/update",token,body);remember(result);runOnUiThread(()->{if(!visible||g!=generation)return;settingsReceipt=result.optString("receipt");settingsReady=true;LocationService.busy=true;try{startForegroundService(new Intent(this,LocationService.class).setAction("START"));}catch(Exception e){LocationService.busy=false;Toast.makeText(this,"未能启动定位,请保持页面在前台再试",1).show();}render();});} catch(Exception e){runOnUiThread(()->{if(visible&&g==generation)Toast.makeText(this,"开启未成功,请重新读取设置并核对名单",1).show();});} finally{pairing=false;runOnUiThread(()->{if(!isDestroyed()){if(visible&&!settingsReady)loadSettings();render();}});}},"location-configure").start(); } + int uploadPeriod(){int index=cadence.getSelectedItemPosition();return uploadIntervals[index]>0?uploadIntervals[index]:LocationCadence.custom(Integer.parseInt(customAmount.getText().toString().trim()),customUnit.getSelectedItemPosition()==1);} + void setUploadPeriod(int seconds){for(int i=0;i{ String period=new String[]{"day","week","month","year","life"}[choice];Calendar c=Calendar.getInstance(); @@ -156,7 +174,7 @@ public class LocationActivity extends Activity { final Dialog shown=historyDialog;ui.postDelayed(()->{if(shown.isShowing())shown.dismiss();},60000); });}catch(Exception e){runOnUiThread(()->{if(visible&&g==generation&&request==historyRequest){if(historyDialog!=null)historyDialog.dismiss();Toast.makeText(this,"未能读取:请检查本人授权、日期和网盘连接",1).show();}});}},"location-history").start(); } - void deleteHistory(){int g=generation;new Thread(()->{try{DisplayApi.call("/api/location/update",prefs.getString("token",""),new JSONObject().put("action","history-delete").put("confirm",true));runOnUiThread(()->{if(visible&&g==generation){Toast.makeText(this,"历史已隐藏,云端删除任务会持续重试",1).show();loadSettings();}});}catch(Exception e){runOnUiThread(()->Toast.makeText(this,"删除未完成,请检查连接后重试",1).show());}},"delete-history").start();} + void deleteHistory(){int g=generation;prefs.edit().putLong("queueEpoch",System.currentTimeMillis()).commit();stopService(new Intent(this,LocationService.class));prefs.edit().putBoolean("active",false).apply();new Thread(()->{try{String token=prefs.getString("token","");DisplayApi.call("/api/location/update",token,new JSONObject().put("action","stop"));DisplayApi.call("/api/location/update",token,new JSONObject().put("action","history-delete").put("confirm",true));outbox.discard(queueOwner);refreshQueueStats();runOnUiThread(()->{if(visible&&g==generation){Toast.makeText(this,"本机待同步已清理,历史已隐藏,云端删除会持续重试",1).show();loadSettings();}});}catch(Exception e){runOnUiThread(()->Toast.makeText(this,"删除未完成,本机待同步记录保留,请检查连接后重试",1).show());}},"delete-history").start();} String locationPermissionText(){ boolean foreground=checkSelfPermission(Manifest.permission.ACCESS_FINE_LOCATION)==0||checkSelfPermission(Manifest.permission.ACCESS_COARSE_LOCATION)==0; if(!foreground)return "定位权限:未允许。查看家人不需要开启自己的定位。"; @@ -176,7 +194,7 @@ public class LocationActivity extends Activity { }).show(); } public void onRequestPermissionsResult(int request,String[] permissions,int[] results){super.onRequestPermissionsResult(request,permissions,results);if(request==47||request==48){render();return;}if(request==45){if(checkSelfPermission(Manifest.permission.ACCESS_FINE_LOCATION)==0||checkSelfPermission(Manifest.permission.ACCESS_COARSE_LOCATION)==0){if(visible)start();else pendingStart=true;}else Toast.makeText(this,"未授权定位,不采集自己的位置;仍可查看获授权家人",1).show();render();}} - public void onResume(){super.onResume();visible=true;map.resumeMap();voice.active(true);lastList=0;if(!settingsReady)loadSettings();ui.post(refresh);if(pendingStart){pendingStart=false;start();}} + public void onResume(){super.onResume();visible=true;map.resumeMap();voice.active(true);lastList=0;refreshQueueStats();if(!LocationService.busy&&prefs.getLong("pendingPoints",0)>0)syncNow();if(!settingsReady)loadSettings();ui.post(refresh);if(pendingStart){pendingStart=false;start();}} public void onPause(){visible=false;if(historyDialog!=null)historyDialog.dismiss();voice.active(false);generation++;loading=false;ui.removeCallbacksAndMessages(null);if(map!=null)map.pauseMap();if(familyList!=null)familyList.removeAllViews();super.onPause();} public void onDestroy(){if(map!=null)map.close();if(voice!=null)voice.close();ui.removeCallbacksAndMessages(null);super.onDestroy();} } diff --git a/android-display/src/cn/ucvl/zhaodisplay/LocationCadence.java b/android-display/src/cn/ucvl/zhaodisplay/LocationCadence.java index cebf175..1960819 100644 --- a/android-display/src/cn/ucvl/zhaodisplay/LocationCadence.java +++ b/android-display/src/cn/ucvl/zhaodisplay/LocationCadence.java @@ -2,7 +2,11 @@ package cn.ucvl.zhaodisplay; /** Shared scheduling rule, independent of Android for deterministic testing. */ final class LocationCadence { - static int seconds(int value){return value==10||value==60||value==300?value:300;} + static final int MAX_SECONDS=30*86400; + static boolean valid(int value){return value==10||value==60||value==300||value>=3600&&value<=MAX_SECONDS&&value%3600==0;} + static int seconds(int value){return valid(value)?value:300;} + static int sample(int value){return value==10||value==60||value==300?value:60;} + static int custom(int value,boolean days){long seconds=value*(days?86400L:3600L);if(value<1||seconds>MAX_SECONDS)throw new IllegalArgumentException("周期需在 1 小时至 30 天内");return (int)seconds;} static boolean due(long now,long lastAttempt,int interval,boolean firstFix){ return lastAttempt==0||now-lastAttempt>=1000L*(firstFix?10:seconds(interval)); } diff --git a/android-display/src/cn/ucvl/zhaodisplay/LocationQueue.java b/android-display/src/cn/ucvl/zhaodisplay/LocationQueue.java new file mode 100644 index 0000000..dc4533b --- /dev/null +++ b/android-display/src/cn/ucvl/zhaodisplay/LocationQueue.java @@ -0,0 +1,95 @@ +package cn.ucvl.zhaodisplay; + +import android.content.*; +import android.database.Cursor; +import android.database.sqlite.*; +import android.security.keystore.*; +import org.json.*; +import javax.crypto.*; +import javax.crypto.spec.GCMParameterSpec; +import java.nio.charset.StandardCharsets; +import java.security.*; +import java.util.*; + +/** Private, encrypted outbox. Only a matching cloud-verification receipt releases rows. */ +final class LocationQueue extends SQLiteOpenHelper { + static final int MAX_POINTS=50000, BATCH_POINTS=128, MAX_INFLIGHT=4; + static final long MAX_BYTES=12L*1024*1024, MAX_DATABASE_BYTES=32L*1024*1024; + static final String KEY="zhao-location-outbox-v1"; + LocationQueue(Context context){super(context,"location-outbox.db",null,1);} + public void onCreate(SQLiteDatabase db){ + db.execSQL("CREATE TABLE points(id TEXT PRIMARY KEY,owner TEXT NOT NULL,session TEXT NOT NULL,at INTEGER,payload BLOB NOT NULL,batch TEXT)"); + db.execSQL("CREATE INDEX queue_owner ON points(owner,at)"); + db.execSQL("CREATE TABLE batches(id TEXT PRIMARY KEY,owner TEXT,session TEXT,payload BLOB,digest TEXT,count INTEGER,next_try INTEGER)"); + db.execSQL("CREATE TABLE totals(owner TEXT PRIMARY KEY,uploaded INTEGER NOT NULL,freed INTEGER NOT NULL)"); + } + public void onUpgrade(SQLiteDatabase db,int oldVersion,int newVersion){throw new IllegalStateException("Unsupported location outbox migration");} + public void onOpen(SQLiteDatabase db){super.onOpen(db);db.setMaximumSize(MAX_DATABASE_BYTES);try(Cursor c=db.rawQuery("PRAGMA secure_delete=ON",null)){c.moveToFirst();}} + static String id(){return UUID.randomUUID().toString().replace("-","");} + static String digest(String value)throws Exception{ + byte[] bytes=MessageDigest.getInstance("SHA-256").digest(value.getBytes(StandardCharsets.UTF_8));StringBuilder result=new StringBuilder();for(byte b:bytes)result.append(String.format(Locale.US,"%02x",b&255));return result.toString(); + } + private SecretKey key()throws Exception{ + synchronized(LocationQueue.class){KeyStore store=KeyStore.getInstance("AndroidKeyStore");store.load(null);if(!store.containsAlias(KEY)){ + KeyGenerator generator=KeyGenerator.getInstance(KeyProperties.KEY_ALGORITHM_AES,"AndroidKeyStore"); + generator.init(new KeyGenParameterSpec.Builder(KEY,KeyProperties.PURPOSE_ENCRYPT|KeyProperties.PURPOSE_DECRYPT).setBlockModes(KeyProperties.BLOCK_MODE_GCM).setEncryptionPaddings(KeyProperties.ENCRYPTION_PADDING_NONE).setKeySize(256).build());generator.generateKey(); + }return (SecretKey)store.getKey(KEY,null);} + } + private byte[] encrypt(String value,String aad)throws Exception{ + Cipher cipher=Cipher.getInstance("AES/GCM/NoPadding");cipher.init(Cipher.ENCRYPT_MODE,key());cipher.updateAAD(aad.getBytes(StandardCharsets.UTF_8));byte[] encrypted=cipher.doFinal(value.getBytes(StandardCharsets.UTF_8)),iv=cipher.getIV();byte[] out=new byte[iv.length+encrypted.length];System.arraycopy(iv,0,out,0,iv.length);System.arraycopy(encrypted,0,out,iv.length,encrypted.length);return out; + } + private String decrypt(byte[] value,String aad)throws Exception{ + Cipher cipher=Cipher.getInstance("AES/GCM/NoPadding");cipher.init(Cipher.DECRYPT_MODE,key(),new GCMParameterSpec(128,Arrays.copyOfRange(value,0,12)));cipher.updateAAD(aad.getBytes(StandardCharsets.UTF_8));return new String(cipher.doFinal(value,12,value.length-12),StandardCharsets.UTF_8); + } + synchronized boolean append(String owner,String session,JSONObject position)throws Exception{ + SQLiteDatabase db=getWritableDatabase();String id=id();byte[] encrypted=encrypt(new JSONObject().put("id",id).put("position",position).toString(),owner+id); + db.beginTransaction();try{ + try(Cursor cursor=db.rawQuery("SELECT count(*),coalesce(sum(length(payload)),0) FROM points",null)){cursor.moveToFirst();if(cursor.getLong(0)>=MAX_POINTS||cursor.getLong(1)+encrypted.length>MAX_BYTES)return false;} + ContentValues row=new ContentValues();row.put("id",id);row.put("owner",owner);row.put("session",session);row.put("at",(long)(position.getDouble("at")*1000));row.put("payload",encrypted);db.insertOrThrow("points",null,row);db.setTransactionSuccessful();return true; + }catch(SQLiteFullException full){return false;}finally{db.endTransaction();} + } + static final class Batch { + final String id,payload,digest;final int count; + Batch(String id,String payload,String digest,int count){this.id=id;this.payload=payload;this.digest=digest;this.count=count;} + JSONObject request()throws Exception{return new JSONObject().put("action","history-batch").put("batchId",id).put("sha256",digest).put("payload",payload);} + } + synchronized Batch next(String owner,long cutoff,long now)throws Exception{ + SQLiteDatabase db=getWritableDatabase();db.beginTransaction();try{ + try(Cursor c=db.rawQuery("SELECT id,payload,digest,count FROM batches WHERE owner=? AND next_try<=? ORDER BY next_try,id LIMIT 1",new String[]{owner,Long.toString(now)})){ + if(c.moveToFirst())return new Batch(c.getString(0),decrypt(c.getBlob(1),owner+c.getString(0)),c.getString(2),c.getInt(3)); + } + if(cutoff<=0)return null; + try(Cursor c=db.rawQuery("SELECT count(*) FROM batches WHERE owner=?",new String[]{owner})){c.moveToFirst();if(c.getInt(0)>=MAX_INFLIGHT)return null;} + String session=null; + try(Cursor c=db.rawQuery("SELECT session FROM points WHERE owner=? AND batch IS NULL AND at<=? ORDER BY at,id LIMIT 1",new String[]{owner,Long.toString(cutoff)})){if(c.moveToFirst())session=c.getString(0);} + if(session==null)return null; + JSONArray points=new JSONArray();List ids=new ArrayList<>(); + try(Cursor c=db.rawQuery("SELECT id,payload FROM points WHERE owner=? AND session=? AND batch IS NULL AND at<=? ORDER BY at,id LIMIT "+BATCH_POINTS,new String[]{owner,session,Long.toString(cutoff)})){ + while(c.moveToNext()){ids.add(c.getString(0));points.put(new JSONObject(decrypt(c.getBlob(1),owner+c.getString(0))));} + } + String id=id(),payload=new JSONObject().put("version",1).put("collectionId",session).put("points",points).toString(),sha=digest(payload); + ContentValues row=new ContentValues();row.put("id",id);row.put("owner",owner);row.put("session",session);row.put("payload",encrypt(payload,owner+id));row.put("digest",sha);row.put("count",points.length());row.put("next_try",0);db.insertOrThrow("batches",null,row); + for(String point:ids)db.execSQL("UPDATE points SET batch=? WHERE id=? AND owner=?",new Object[]{id,point,owner}); + db.setTransactionSuccessful();return new Batch(id,payload,sha,points.length()); + }finally{db.endTransaction();} + } + synchronized boolean acknowledge(String owner,Batch batch,JSONObject receipt)throws Exception{ + if(!batch.id.equals(receipt.optString("batchId"))||!batch.digest.equals(receipt.optString("sha256"))||batch.count!=receipt.optInt("count",-1))throw new SecurityException("上传回执不匹配,本地记录已保留"); + String state=receipt.optString("state");if(!"accepted".equals(state)&&!"verified".equals(state))throw new SecurityException("未收到完整校验回执,本地记录已保留"); + SQLiteDatabase db=getWritableDatabase();db.beginTransaction();try{ + if("accepted".equals(state)){db.execSQL("UPDATE batches SET next_try=? WHERE id=? AND owner=?",new Object[]{System.currentTimeMillis()+30000,batch.id,owner});db.setTransactionSuccessful();return false;} + long count,bytes;try(Cursor c=db.rawQuery("SELECT count(*),coalesce(sum(length(payload)),0) FROM points WHERE owner=? AND batch=?",new String[]{owner,batch.id})){c.moveToFirst();count=c.getLong(0);bytes=c.getLong(1);} + if(count!=batch.count)throw new SecurityException("本地批次条数不匹配,未清理"); + db.delete("points","owner=? AND batch=?",new String[]{owner,batch.id});db.delete("batches","owner=? AND id=?",new String[]{owner,batch.id}); + db.execSQL("INSERT OR IGNORE INTO totals VALUES (?,0,0)",new Object[]{owner});db.execSQL("UPDATE totals SET uploaded=uploaded+?,freed=freed+? WHERE owner=?",new Object[]{count,bytes,owner});db.setTransactionSuccessful();return true; + }finally{db.endTransaction();} + } + synchronized long[] stats(String owner){ + SQLiteDatabase db=getReadableDatabase();long[] values=new long[4]; + try(Cursor c=db.rawQuery("SELECT count(*),coalesce(sum(length(payload)),0) FROM points WHERE owner=?",new String[]{owner})){c.moveToFirst();values[0]=c.getLong(0);values[1]=c.getLong(1);} + try(Cursor c=db.rawQuery("SELECT uploaded,freed FROM totals WHERE owner=?",new String[]{owner})){if(c.moveToFirst()){values[2]=c.getLong(0);values[3]=c.getLong(1);}} + return values; + } + synchronized long total(){try(Cursor c=getReadableDatabase().rawQuery("SELECT count(*) FROM points",null)){c.moveToFirst();return c.getLong(0);}} + synchronized void discard(String owner){SQLiteDatabase db=getWritableDatabase();db.beginTransaction();try{db.delete("points","owner=?",new String[]{owner});db.delete("batches","owner=?",new String[]{owner});db.setTransactionSuccessful();}finally{db.endTransaction();}} +} diff --git a/android-display/src/cn/ucvl/zhaodisplay/LocationService.java b/android-display/src/cn/ucvl/zhaodisplay/LocationService.java index c0702b3..36f6e6b 100644 --- a/android-display/src/cn/ucvl/zhaodisplay/LocationService.java +++ b/android-display/src/cn/ucvl/zhaodisplay/LocationService.java @@ -4,97 +4,140 @@ import android.app.*; import android.content.*; import android.os.*; import android.location.*; +import android.net.*; import android.content.pm.PackageManager; import android.Manifest; import org.json.JSONObject; import java.util.concurrent.*; -/** Visible, bounded sharing session. No boot receiver starts location collection. */ +/** Visible sharing plus an encrypted outbox. No boot receiver starts GPS collection. */ public class LocationService extends Service implements LocationListener { static volatile boolean busy=false; - String sessionToken=""; - volatile boolean destroyed=false; - ScheduledExecutorService worker;LocationManager manager;android.content.SharedPreferences prefs; - volatile Location latest;volatile boolean active=false,stopping=false,starting=false; - long lastAttempt=0;boolean sentFix=false;int intervalSeconds=300;String lastSignal=""; + String sessionToken="",owner="",collection=""; + volatile boolean destroyed=false,active=false,stopping=false,starting=false,forceSync=false,failedNetwork=false,networkBlocked=false; + boolean historyEnabled=false,sentFix=false,cacheFull=false,ticking=false; + ScheduledExecutorService worker;ExecutorService recorder;LocationManager manager;LocationQueue queue;ConnectivityManager connectivity; + android.content.SharedPreferences prefs;volatile Location latest; + long lastUpload=0,lastSample=0,flushCutoff=0,collectionStarted=0;volatile long nextAttempt=0; + int failures=0,intervalSeconds=300,sampleSeconds=60;String lastSignal=""; final Handler ui=new Handler(); + final ConnectivityManager.NetworkCallback networkCallback=new ConnectivityManager.NetworkCallback(){ + public void onAvailable(Network network){nextAttempt=0;} + public void onLost(Network network){failedNetwork=true;} + public void onBlockedStatusChanged(Network network,boolean blocked){networkBlocked=blocked;if(blocked)failedNetwork=true;else if(failedNetwork){forceSync=true;nextAttempt=0;}} + public void onCapabilitiesChanged(Network network,NetworkCapabilities caps){if(failedNetwork&&caps.hasCapability(NetworkCapabilities.NET_CAPABILITY_VALIDATED))nextAttempt=0;} + }; public void onCreate(){ - super.onCreate();prefs=getSharedPreferences("location",0);manager=(LocationManager)getSystemService(LOCATION_SERVICE); - sessionToken=prefs.getString("token",""); - NotificationManager nm=(NotificationManager)getSystemService(NOTIFICATION_SERVICE); - nm.createNotificationChannel(new NotificationChannel("location","本人位置共享",NotificationManager.IMPORTANCE_LOW)); - worker=Executors.newSingleThreadScheduledExecutor(); + super.onCreate();prefs=getSharedPreferences("location",0);manager=(LocationManager)getSystemService(LOCATION_SERVICE);queue=new LocationQueue(this); + sessionToken=prefs.getString("token","");try{owner=LocationQueue.digest(sessionToken);}catch(Exception e){stopSelf();return;} + NotificationManager nm=(NotificationManager)getSystemService(NOTIFICATION_SERVICE);nm.createNotificationChannel(new NotificationChannel("location","本人位置与轨迹同步",NotificationManager.IMPORTANCE_LOW)); + connectivity=(ConnectivityManager)getSystemService(CONNECTIVITY_SERVICE);worker=Executors.newSingleThreadScheduledExecutor();recorder=Executors.newSingleThreadExecutor(); + try{connectivity.registerDefaultNetworkCallback(networkCallback);}catch(Exception ignored){} } void notification(String text){ PendingIntent stop=PendingIntent.getService(this,1,new Intent(this,LocationService.class).setAction("STOP"),PendingIntent.FLAG_IMMUTABLE|PendingIntent.FLAG_UPDATE_CURRENT); PendingIntent open=PendingIntent.getActivity(this,1,new Intent(this,LocationActivity.class),PendingIntent.FLAG_IMMUTABLE|PendingIntent.FLAG_UPDATE_CURRENT); - Notification notice=new Notification.Builder(this,"location").setContentTitle("赵府 · 位置共享").setContentText(text).setSmallIcon(android.R.drawable.ic_menu_mylocation).setContentIntent(open).setOngoing(true).addAction(new Notification.Action.Builder(null,"停止共享",stop).build()).build(); - if(android.os.Build.VERSION.SDK_INT>=29)startForeground(45,notice,stopping?0:android.content.pm.ServiceInfo.FOREGROUND_SERVICE_TYPE_LOCATION);else startForeground(45,notice); + Notification.Builder notice=new Notification.Builder(this,"location").setContentTitle(active||starting?"赵府 · 位置共享":"赵府 · 轨迹同步").setContentText(text).setSmallIcon(android.R.drawable.ic_menu_mylocation).setContentIntent(open).setOngoing(true); + if(active||starting)notice.addAction(new Notification.Action.Builder(null,"停止共享",stop).build()); + if(Build.VERSION.SDK_INT>=29)startForeground(45,notice.build(),active||starting?android.content.pm.ServiceInfo.FOREGROUND_SERVICE_TYPE_LOCATION:android.content.pm.ServiceInfo.FOREGROUND_SERVICE_TYPE_DATA_SYNC);else startForeground(45,notice.build()); } public int onStartCommand(Intent intent,int flags,int id){ - if(intent!=null&&"STOP".equals(intent.getAction())){stopSharing();return START_NOT_STICKY;} - if(intent==null){stopSelf();return START_NOT_STICKY;} + if(intent==null||sessionToken.isEmpty()){stopSelf();return START_NOT_STICKY;} + if(!ticking){ticking=true;worker.scheduleWithFixedDelay(this::tick,1,10,TimeUnit.SECONDS);} + String action=intent.getAction(); + if("STOP".equals(action)){stopSharing();return START_NOT_STICKY;} + if("SYNC".equals(action)){forceSync=true;nextAttempt=0;notification(active?"位置共享中 · 正在补传轨迹":"只同步已采集轨迹,不开启定位");return START_NOT_STICKY;} if(active||stopping||starting)return START_NOT_STICKY; - starting=true;busy=true; - final String receipt=prefs.getString("receipt",""); - notification("正在确认本人的共享授权"); + starting=true;busy=true;notification("正在确认本人的共享授权"); worker.execute(()->{try{ - JSONObject r=DisplayApi.call("/api/location/update",sessionToken,new JSONObject().put("action","start").put("consent",true).put("receipt",receipt)); + JSONObject result=DisplayApi.call("/api/location/update",sessionToken,new JSONObject().put("action","start").put("consent",true).put("receipt",prefs.getString("receipt","")).put("bufferedHistory",true)); if(stopping||destroyed)return; - intervalSeconds=LocationCadence.seconds(r.optInt("intervalSeconds",300)); - active=true;prefs.edit().putBoolean("active",true).putLong("expires",(long)(r.getDouble("expires")*1000)).putString("status","共享中,等待定位").apply(); - ui.post(()->{if(!stopping){listen();notification("共享给 "+prefs.getString("recipients","")+" · 可随时停止");}}); - worker.scheduleWithFixedDelay(this::upload,1,10,TimeUnit.SECONDS); - }catch(Exception e){if(!destroyed){prefs.edit().putBoolean("active",false).putString("status","未开启:请检查网络、配对有效期").apply();stopSelf();}}}); + intervalSeconds=LocationCadence.seconds(result.optInt("intervalSeconds",300));sampleSeconds=LocationCadence.sample(result.optInt("sampleIntervalSeconds",60)); + collection=result.optString("collectionId");historyEnabled=result.optBoolean("historyEnabled",false)&&!collection.isEmpty(); + collectionStarted=(long)(result.optDouble("collectionStartedAt",System.currentTimeMillis()/1000d)*1000); + active=true;starting=false;sentFix=false;lastUpload=0;lastSample=0;forceSync=true; + prefs.edit().putBoolean("active",true).putLong("lastFlushAt",System.currentTimeMillis()).putLong("expires",(long)(result.getDouble("expires")*1000)).putString("status","共享中,等待定位").apply(); + ui.post(()->{if(!stopping&&!destroyed){listen();notification("共享给 "+prefs.getString("recipients","")+" · 可随时停止");}}); + }catch(Exception e){starting=false;busy=false;if(!destroyed){prefs.edit().putBoolean("active",false).putString("status","未开启:请检查网络、配对有效期").apply();stopSelf();}}}); return START_NOT_STICKY; } void listen(){ if(!active||stopping)return; - try{for(String provider:new String[]{LocationManager.GPS_PROVIDER,LocationManager.NETWORK_PROVIDER})if(manager.getAllProviders().contains(provider))manager.requestLocationUpdates(provider,intervalSeconds*1000L,0,this);} + try{for(String provider:new String[]{LocationManager.GPS_PROVIDER,LocationManager.NETWORK_PROVIDER})if(manager.getAllProviders().contains(provider))manager.requestLocationUpdates(provider,sampleSeconds*1000L,0,this);} catch(SecurityException e){prefs.edit().putString("status","定位权限未开启").apply();} } - void upload(){ - if(!active||stopping)return; - if(System.currentTimeMillis()>prefs.getLong("expires",0)){ui.post(this::stopSharing);return;} + boolean connected(){try{Network network=connectivity.getActiveNetwork();NetworkCapabilities caps=connectivity.getNetworkCapabilities(network);return !networkBlocked&&caps!=null&&caps.hasCapability(NetworkCapabilities.NET_CAPABILITY_INTERNET);}catch(Exception e){return false;}} + void tick(){ + if(destroyed||starting)return; try{ - String signal=checkSelfPermission(Manifest.permission.ACCESS_FINE_LOCATION)==PackageManager.PERMISSION_GRANTED||checkSelfPermission(Manifest.permission.ACCESS_COARSE_LOCATION)==PackageManager.PERMISSION_GRANTED?locationEnabled(manager)?"waiting":"location_disabled":"permission_denied"; - // Permission/setting loss must clear the server fix without waiting five minutes. - boolean safetyChange=(!"waiting".equals(signal)&&!signal.equals(lastSignal)); - if(!LocationCadence.due(SystemClock.elapsedRealtime(),lastAttempt,intervalSeconds,safetyChange||latest!=null&&!sentFix))return; - lastAttempt=SystemClock.elapsedRealtime(); - JSONObject body=new JSONObject().put("action","update");Location fix=latest; - if(fix!=null&&"waiting".equals(signal)&&SystemClock.elapsedRealtimeNanos()-fix.getElapsedRealtimeNanos()<900000000000L){ - body.put("position",new JSONObject().put("latitude",fix.getLatitude()).put("longitude",fix.getLongitude()).put("accuracy",fix.getAccuracy()).put("at",fix.getTime()/1000d));signal="available"; + if(active&&System.currentTimeMillis()>prefs.getLong("expires",0)){ui.post(this::stopSharing);return;} + updateQueueStatus(); + if(!active&&!stopping&&queue.stats(owner)[0]==0){stopSelf();return;} + if(!connected()){failedNetwork=true;prefs.edit().putString("syncStatus","网络不可用,已采集轨迹加密保留在本机,恢复后自动补传").apply();return;} + if(SystemClock.elapsedRealtime()=intervalSeconds*1000L){ + flushCutoff=now;prefs.edit().putLong("lastFlushAt",now).apply();forceSync=false; + } + for(int i=0;i=28)return manager.isLocationEnabled(); - return manager.isProviderEnabled(LocationManager.GPS_PROVIDER)||manager.isProviderEnabled(LocationManager.NETWORK_PROVIDER); + void retry(String message){failedNetwork=true;failures=Math.min(failures+1,5);nextAttempt=SystemClock.elapsedRealtime()+Math.min(300000,10000L*(1L<=28?manager.isLocationEnabled():manager.isProviderEnabled(LocationManager.GPS_PROVIDER)||manager.isProviderEnabled(LocationManager.NETWORK_PROVIDER);} void stopSharing(){ - if(stopping)return;stopping=true;busy=true;active=false;latest=null; + if(stopping)return;stopping=true;starting=false;busy=true;active=false;latest=null; try{manager.removeUpdates(this);}catch(Exception ignored){} - prefs.edit().putBoolean("active",false).putString("status","本机已停止定位,正在通知平台清除").apply(); - notification("本机已停止定位 · 正在通知平台清除"); - worker.scheduleWithFixedDelay(()->{try{ - String token=sessionToken; - if(!token.isEmpty())try{DisplayApi.call("/api/location/update",token,new JSONObject().put("action","stop"));}catch(DisplayApi.ApiError e){if(e.status!=401&&e.status!=403)throw e;} - if(destroyed)return; - prefs.edit().putBoolean("active",false).putString("status","共享关闭,平台已清除当前位置").apply();stopSelf(); - }catch(Exception e){prefs.edit().putString("status","本机已停止,联网后清除平台位置,旧坐标最长 15 分钟后隐藏,也可在平台解除授权").apply();}},0,30,TimeUnit.SECONDS); + prefs.edit().putBoolean("active",false).putString("status","本机已停止采集,联网后通知平台清除当前位置;关闭前轨迹仍会补传").apply();notification("已停止定位 · 联网后完成同步");nextAttempt=0; + } + public void onLocationChanged(Location value){ + if(!active||stopping)return;latest=new Location(value);if(!historyEnabled)return; + Location fix=new Location(value);String session=collection;long epoch=prefs.getLong("queueEpoch",0),started=collectionStarted; + recorder.execute(()->{try{ + if(epoch!=prefs.getLong("queueEpoch",0))return; + long elapsed=fix.getElapsedRealtimeNanos()/1000000; + if(lastSample!=0&&elapsed-lastSampleSystem.currentTimeMillis()+60000||System.currentTimeMillis()-fix.getTime()>900000)return; + if(queue.append(owner,session,position(fix))){lastSample=elapsed;cacheFull=false;} + else{cacheFull=true;prefs.edit().putString("syncStatus","本地缓存已达上限,暂停新增历史;未上传记录没有覆盖,请联网补传").apply();notification("轨迹缓存已满 · 请联网补传");} + updateQueueStatus(); + }catch(Exception error){cacheFull=true;prefs.edit().putString("syncStatus","本地轨迹未能写入,请检查手机存储空间;已有记录保留").apply();}}); } - public void onLocationChanged(Location value){if(active&&!stopping)latest=new Location(value);} public void onStatusChanged(String provider,int status,Bundle extras){} public void onProviderEnabled(String provider){} public void onProviderDisabled(String provider){} public IBinder onBind(Intent intent){return null;} - public void onDestroy(){destroyed=true;active=false;latest=null;try{manager.removeUpdates(this);}catch(Exception ignored){}if(worker!=null)worker.shutdownNow();prefs.edit().putBoolean("active",false).apply();busy=false;super.onDestroy();} + public void onDestroy(){ + destroyed=true;active=false;latest=null;try{manager.removeUpdates(this);}catch(Exception ignored){}try{connectivity.unregisterNetworkCallback(networkCallback);}catch(Exception ignored){} + if(worker!=null)worker.shutdownNow();if(recorder!=null)recorder.shutdown();prefs.edit().putBoolean("active",false).apply();busy=false;stopForeground(true);super.onDestroy(); + } } diff --git a/android-display/tests/LocationCadenceTest.java b/android-display/tests/LocationCadenceTest.java index e273cd5..9f6823c 100644 --- a/android-display/tests/LocationCadenceTest.java +++ b/android-display/tests/LocationCadenceTest.java @@ -5,7 +5,7 @@ public class LocationCadenceTest { static void require(boolean value){if(!value)throw new AssertionError();} public static void main(String[] args){ int assertions=0; - for(int seconds:new int[]{10,60,300}){ + for(int seconds:new int[]{10,60,300,3600,7200,10800,14400,18000,23*3600,86400,172800,259200,30*86400}){ require(LocationCadence.seconds(seconds)==seconds);assertions++; require(LocationCadence.due(100000,0,seconds,false));assertions++; require(!LocationCadence.due(1000+seconds*1000L-1,1000,seconds,false));assertions++; @@ -13,7 +13,10 @@ public class LocationCadenceTest { require(!LocationCadence.due(10999,1000,seconds,true));assertions++; require(LocationCadence.due(11000,1000,seconds,true));assertions++; } - for(int invalid:new int[]{-1,0,9,59,301}){require(LocationCadence.seconds(invalid)==300);assertions++;} + for(int invalid:new int[]{-1,0,9,59,301,3601,31*86400,Integer.MAX_VALUE}){require(LocationCadence.seconds(invalid)==300);assertions++;} + require(LocationCadence.custom(3,true)==259200);assertions++; + require(LocationCadence.custom(5,false)==18000);assertions++; + for(int invalid:new int[]{-1,0,721,Integer.MAX_VALUE}){try{LocationCadence.custom(invalid,false);throw new AssertionError();}catch(IllegalArgumentException expected){assertions++;}} System.out.println("Location cadence: "+assertions+" assertions passed"); } } diff --git a/android-display/tests/QueueInstrumentation.java b/android-display/tests/QueueInstrumentation.java new file mode 100644 index 0000000..03d383a --- /dev/null +++ b/android-display/tests/QueueInstrumentation.java @@ -0,0 +1,43 @@ +package cn.ucvl.zhaodisplay; + +import android.app.*; +import android.os.Bundle; +import android.database.Cursor; +import org.json.*; +import java.nio.charset.StandardCharsets; + +/** Isolated test package only. No GPS permission, family token or production data. */ +public final class QueueInstrumentation extends Instrumentation { + int assertions=0; + void check(boolean condition){assertions++;if(!condition)throw new AssertionError("Assertion "+assertions);} + JSONObject position(double at)throws Exception{return new JSONObject().put("latitude",12.345678).put("longitude",45.678901).put("accuracy",7).put("at",at);} + JSONObject receipt(LocationQueue.Batch b,String state)throws Exception{return new JSONObject().put("batchId",b.id).put("sha256",b.digest).put("count",b.count).put("state",state);} + public void onCreate(Bundle args){super.onCreate(args);start();} + public void onStart(){Bundle result=new Bundle();LocationQueue queue=null;try{ + getTargetContext().deleteDatabase("location-outbox.db");queue=new LocationQueue(getTargetContext());String owner=LocationQueue.digest("synthetic-owner"),other=LocationQueue.digest("synthetic-other"),session="a1111111111111111111111111111111"; + for(int i=0;i<130;i++)check(queue.append(owner,session,position(1700000000+i))); + check(queue.append(other,session,position(1700000000))); + check(queue.stats(owner)[0]==130);check(queue.stats(other)[0]==1); + try(Cursor c=queue.getReadableDatabase().rawQuery("SELECT payload FROM points LIMIT 1",null)){c.moveToFirst();check(!new String(c.getBlob(0),StandardCharsets.UTF_8).contains("latitude"));} + LocationQueue.Batch batch=queue.next(owner,Long.MAX_VALUE,System.currentTimeMillis());check(batch.count==128);check(new JSONObject(batch.payload).getJSONArray("points").length()==128); + String digest=batch.digest,id=batch.id;queue.close();queue=new LocationQueue(getTargetContext()); + batch=queue.next(owner,Long.MAX_VALUE,System.currentTimeMillis());check(batch.id.equals(id));check(batch.digest.equals(digest));check(queue.stats(owner)[0]==130); + try{queue.acknowledge(owner,batch,receipt(batch,"verified").put("sha256","f"));throw new AssertionError("Accepted corrupt receipt");}catch(SecurityException expected){assertions++;} + try{queue.acknowledge(owner,batch,receipt(batch,"verified").put("count",127));throw new AssertionError("Accepted partial receipt");}catch(SecurityException expected){assertions++;} + check(queue.stats(owner)[0]==130);check(!queue.acknowledge(owner,batch,receipt(batch,"accepted")));check(queue.stats(owner)[0]==130); + check(queue.append(owner,session,position(1700000500)));check(queue.acknowledge(owner,batch,receipt(batch,"verified")));check(queue.stats(owner)[0]==3);check(queue.stats(owner)[2]==128);check(queue.stats(other)[0]==1); + check(queue.next(owner,0,System.currentTimeMillis())==null); + batch=queue.next(owner,Long.MAX_VALUE,System.currentTimeMillis());check(batch.count==3);check(queue.acknowledge(owner,batch,receipt(batch,"verified")));check(queue.stats(owner)[0]==0);check(queue.stats(owner)[2]==131);check(queue.stats(owner)[3]>0); + queue.getWritableDatabase().beginTransaction();try{ + for(int i=0;i + + + + +'@ | Set-Content -LiteralPath "$stage\AndroidManifest.xml" -Encoding utf8 +& "$bt\aapt2.exe" link -o "$stage\unsigned.apk" -I $android --manifest "$stage\AndroidManifest.xml" +if($LASTEXITCODE){throw 'Test resource linking failed'} +& "$jdk\bin\javac.exe" -encoding UTF-8 -source 8 -target 8 -cp $android -d "$stage\classes" "$source\src\cn\ucvl\zhaodisplay\LocationQueue.java" "$tests\QueueInstrumentation.java" +if($LASTEXITCODE){throw 'Test Java compile failed'} +& "$jdk\bin\jar.exe" cf "$stage\classes.jar" -C "$stage\classes" . +& "$bt\d8.bat" --lib $android --min-api 26 --output "$stage\dex" "$stage\classes.jar" +if($LASTEXITCODE){throw 'Test Dex compile failed'} +Add-Type -AssemblyName System.IO.Compression.FileSystem +$zip=[IO.Compression.ZipFile]::Open("$stage\unsigned.apk",[IO.Compression.ZipArchiveMode]::Update) +try{[IO.Compression.ZipFileExtensions]::CreateEntryFromFile($zip,"$stage\dex\classes.dex",'classes.dex',[IO.Compression.CompressionLevel]::Optimal) | Out-Null}finally{$zip.Dispose()} +& "$bt\zipalign.exe" -f 4 "$stage\unsigned.apk" "$stage\aligned.apk" +$keystore=Join-Path $env:LOCALAPPDATA 'ZhaoDisplay\display-signing.jks' +& "$bt\apksigner.bat" sign --ks $keystore --ks-pass pass:android --key-pass pass:android --ks-key-alias zhaodisplay --out "$source\build\QueueCheck.apk" "$stage\aligned.apk" +if($LASTEXITCODE){throw 'Test APK signing failed'} +& "$bt\apksigner.bat" verify "$source\build\QueueCheck.apk" +if($LASTEXITCODE){throw 'Test APK verification failed'} +Write-Output "$source\build\QueueCheck.apk" diff --git a/app.py b/app.py index 9ccc5e6..1d52b16 100644 --- a/app.py +++ b/app.py @@ -704,7 +704,7 @@ class Handler(BaseHTTPRequestHandler): return if path == '/api/location/update': authorization=self.headers.get('Authorization','') - self.answer(LOCATIONS.native(authorization[7:] if authorization.startswith('Bearer ') else '',self.body(16384))) + self.answer(LOCATIONS.native(authorization[7:] if authorization.startswith('Bearer ') else '',self.body(131072))) return if path in ('/api/display/heartbeat','/api/display/preview'): authorization = self.headers.get('Authorization','') diff --git a/frontend/package.json b/frontend/package.json index a0ba047..bba79d8 100644 --- a/frontend/package.json +++ b/frontend/package.json @@ -1,7 +1,7 @@ { "name": "zhao-steward-ui", "private": true, - "version": "0.1.49", + "version": "0.1.50", "type": "module", "scripts": { "build": "vite build", diff --git a/frontend/src/components/FamilyLocations.vue b/frontend/src/components/FamilyLocations.vue index 1415d87..0690b4b 100644 --- a/frontend/src/components/FamilyLocations.vue +++ b/frontend/src/components/FamilyLocations.vue @@ -11,7 +11,7 @@ const home=computed(()=>snapshot.value.state.households?.find(x=>x.id===snapshot let timer,epoch=0,requestId=0 const items=computed(()=>result.value?.items||[]) const time=n=>n?new Date(n*1000).toLocaleString('zh-CN'):'尚未收到' -const status=d=>d.status==='stale'?'位置更新中断':d.status==='live'?'位置已更新':'等待手机定位' +const status=d=>d.status==='scheduled'?'等待下次定时上传':d.status==='stale'?'位置更新中断':d.status==='live'?'位置已更新':'等待手机定位' const location=d=>d.position?`${d.position.latitude.toFixed(4)}°, ${d.position.longitude.toFixed(4)}° · 精度约 ${Math.round(d.position.accuracy)} 米`:'尚无有效位置' async function load(){const e=epoch,r=++requestId;if(!active.value)return try{const value=await bridge().api('/api/locations');if(e===epoch&&r===requestId){result.value=value;error.value=''}} @@ -28,9 +28,9 @@ onBeforeUnmount(()=>{epoch++;clearTimeout(timer)}) diff --git a/frontend/src/tv/Television.vue b/frontend/src/tv/Television.vue index a2b8dfa..f7a0f7c 100644 --- a/frontend/src/tv/Television.vue +++ b/frontend/src/tv/Television.vue @@ -20,7 +20,7 @@ const angles=computed(()=>({hour:(+time.value.hour%12)*30+(+time.value.minute)/2 const devices=computed(()=>{const all=data.value?.devices||[],start=(paging.value%Math.max(1,Math.ceil(all.length/3)))*3;return all.slice(start,start+3)}) const positions=computed(()=>{if(clock.value-lastSync.value>90000||error.value)return [];const all=data.value?.locations||[];return all.slice((paging.value%Math.max(1,Math.ceil(all.length/3)))*3,(paging.value%Math.max(1,Math.ceil(all.length/3)))*3+3)}) const mapPositions=computed(()=>clock.value-lastSync.value>90000||error.value?[]:data.value?.locations||[]) -const locationText=d=>d.status==='stale'?'位置更新中断 · 请检查手机':d.position?`${d.position.latitude.toFixed(3)}°, ${d.position.longitude.toFixed(3)}°`:'等待手机定位' +const locationText=d=>d.status==='scheduled'?'按设定周期上传 · 等待下次更新':d.status==='stale'?'位置更新中断 · 请检查手机':d.position?`${d.position.latitude.toFixed(3)}°, ${d.position.longitude.toFixed(3)}°`:'等待手机定位' const weather=computed(()=>data.value?.weather) const syncLabel=computed(()=>authRequired.value?'等待重新连接':!lastSync.value?'正在连接家庭':error.value||clock.value-lastSync.value>90000?'网络暂时中断 · 显示上次资料':'家庭资料已同步') diff --git a/location_sync.py b/location_sync.py new file mode 100644 index 0000000..680ee4e --- /dev/null +++ b/location_sync.py @@ -0,0 +1,129 @@ +"""Durable, consent-scoped upload batches; acknowledge only verified cloud files.""" +import hashlib +import json +import math +import re +import secrets +import shutil +import time +import datetime as dt + +MAX_INTERVAL = 30 * 86400 +MAX_POINTS = 128 +MAX_PAYLOAD = 64000 + + +def interval_valid(value): + return type(value) is int and (value in (10, 60, 300) or 3600 <= value <= MAX_INTERVAL and value % 3600 == 0) + + +class Sync: + def __init__(self, app): + self.a = app + + def initialize(self): + with self.a.LOCK, self.a.DB: + self.a.DB.execute('CREATE TABLE IF NOT EXISTS location_collection_sessions ' + '(id TEXT PRIMARY KEY,share_id TEXT,family TEXT,member TEXT,started REAL,ended REAL,expires REAL,grant_json TEXT)') + self.a.DB.execute('CREATE INDEX IF NOT EXISTS collection_share ON location_collection_sessions(share_id)') + self.a.DB.execute('CREATE TABLE IF NOT EXISTS location_upload_timing (share_id TEXT PRIMARY KEY,started REAL,last_received REAL)') + + def close(self, sid): + self.a.DB.execute('UPDATE location_collection_sessions SET ended=? WHERE share_id=? AND ended IS NULL', (time.time(), sid)) + + def start(self, row, grant): + self.close(row['id']) + self.a.DB.execute('INSERT OR REPLACE INTO location_upload_timing VALUES (?,?,0)', (row['id'], time.time())) + if not grant.get('historyEnabled'): + return dict(historyEnabled=False, collectionId='') + key = secrets.token_hex(16) + now = time.time() + self.a.DB.execute('INSERT INTO location_collection_sessions VALUES (?,?,?,?,?,NULL,?,?)', + (key, row['id'], row['family_id'], row['member_id'], now, row['expires'], json.dumps(grant))) + return dict(historyEnabled=True, collectionId=key, collectionStartedAt=now) + + def seen(self, sid, started, now): + self.a.DB.execute('INSERT OR REPLACE INTO location_upload_timing VALUES (?,?,?)', (sid, started, now)) + + def timing(self, sid): + row=self.a.DB.execute('SELECT started,last_received FROM location_upload_timing WHERE share_id=?', (sid,)).fetchone() + return dict(started=row['started'],seen=row['last_received']) if row else {} + + def batch(self, token, body): + a = self.a + if not isinstance(token, str) or len(token) != 43: + raise a.Problem('需要手机配对授权', 401) + batch_id, digest = body.get('batchId'), body.get('sha256') + if not isinstance(batch_id, str) or not re.fullmatch('[a-f0-9]{32}', batch_id) or not isinstance(digest, str) or not re.fullmatch('[a-f0-9]{64}', digest): + raise a.Problem('轨迹批次标识或校验值不正确') + with a.LOCK, a.DB: + row = a.DB.execute('SELECT * FROM member_location_shares WHERE token_hash=?', (hashlib.sha256(token.encode()).hexdigest(),)).fetchone() + if not row or not a.LOCATIONS.eligible(row['family_id'], row['member_id']): + raise a.Problem('手机绑定已解除,未接收本地轨迹', 401) + # Expiration stops new collection/viewing. A still-bound phone may finish + # uploading points collected inside its previously authorized window. + key = hashlib.sha256((row['id'] + ':' + batch_id).encode()).hexdigest()[:32] + existing = a.DB.execute('SELECT * FROM location_history_files WHERE id=?', (key,)).fetchone() + if existing: + meta = json.loads(existing['body']) + if meta.get('uploadDigest') != digest or meta.get('uploadShare') != row['id']: + raise a.Problem('批次内容与已接收记录不一致,未清除手机记录', 409) + if meta['state'] == 'deleting': + raise a.Problem('此历史已由本人删除,请在手机清理相应待上传记录', 409) + return self.receipt(batch_id, meta) + raw = body.get('payload') + if not isinstance(raw, str) or len(raw.encode('utf-8')) > MAX_PAYLOAD or hashlib.sha256(raw.encode('utf-8')).hexdigest() != digest: + raise a.Problem('轨迹内容校验失败,未接收记录') + try: + payload = json.loads(raw) + if not isinstance(payload, dict) or payload.get('version') != 1: raise ValueError() + session_id, points = payload['collectionId'], payload['points'] + if not isinstance(session_id, str) or not isinstance(points, list) or not 1 <= len(points) <= MAX_POINTS: raise ValueError() + except (ValueError, KeyError, TypeError): + raise a.Problem('轨迹批次格式不正确') from None + session = a.DB.execute('SELECT * FROM location_collection_sessions WHERE id=? AND share_id=?', (session_id, row['id'])).fetchone() + if not session or session['member'] != row['member_id'] or session['family'] != row['family_id']: + raise a.Problem('找不到该批轨迹的本人采集授权', 403) + grant = json.loads(session['grant_json']) + now = time.time() + upper = min(session['expires'], session['ended'] if session['ended'] is not None else now + 60) + deleted = a.setting('history_deleted:' + row['member_id'], 0) + values, ids = [], set() + for item in points: + if not isinstance(item, dict): raise a.Problem('定位点格式不正确') + point_id, pos = item.get('id'), item.get('position') + if not isinstance(point_id, str) or not re.fullmatch('[a-f0-9]{32}', point_id) or point_id in ids or not isinstance(pos, dict): + raise a.Problem('定位点标识不正确或重复') + ids.add(point_id) + for name, low, high in [('latitude', -90, 90), ('longitude', -180, 180), ('accuracy', 0, 100000), ('at', session['started'] - 5, min(upper, now + 60))]: + value = pos.get(name) + if type(value) not in (int, float) or not math.isfinite(value) or not low <= value <= high: + raise a.Problem('定位点超出采集授权时间或范围:' + name) + if pos['at'] <= deleted: + raise a.Problem('此历史已由本人删除,不能重新上传', 409) + values.append(dict(position={k:pos[k] for k in ('latitude', 'longitude', 'accuracy', 'at')}, + viewers=[v['id'] for v in grant['viewers']], phones=[v['id'] for v in grant.get('phones', [])])) + values.sort(key=lambda item:item['position']['at']) + encrypted = [] + for index, value in enumerate(values): + point_key = key + ':' + str(index) + encrypted.append((point_key, row['family_id'], row['member_id'], value['position']['at'], a.HISTORY.seal(value, point_key), key)) + import location_history + used = a.DB.execute('SELECT coalesce(sum(length(payload)),0) FROM location_history_points').fetchone()[0] + if used + sum(len(item[4]) for item in encrypted) > location_history.LIMIT or shutil.disk_usage(a.DATA).free < 1024**3: + raise a.Problem('服务器待上传空间不足,请保留手机记录,稍后重试', 507) + stamp = dt.datetime.fromtimestamp(values[0]['position']['at'], dt.timezone(dt.timedelta(hours=8))) + remote = '/apps/' + a.BAIDU.public_config()['appFolder'] + '/家庭轨迹/' + row['family_id'] + '/' + row['member_id'] + '/' + stamp.strftime('%Y/%m/%d/') + key + '.track' + meta = dict(state='pending', remote=remote, attempts=0, nextTry=0, uploadBatch=batch_id, + uploadShare=row['id'], uploadDigest=digest, uploadCount=len(values)) + a.DB.execute('INSERT INTO location_history_files VALUES (?,?,?,?,?,?)', + (key, row['family_id'], row['member_id'], values[0]['position']['at'], values[-1]['position']['at'], json.dumps(meta))) + a.DB.executemany('INSERT INTO location_history_points VALUES (?,?,?,?,?,?)', encrypted) + # The surrounding SQLite transaction commits before an accepted response. + # Phone deletion requires a later cloud-verified response, not this one. + return self.receipt(batch_id, meta) + + @staticmethod + def receipt(batch_id, meta): + return dict(ok=True, batchId=batch_id, sha256=meta['uploadDigest'], count=meta['uploadCount'], + state='verified' if meta['state'] == 'cloud' else 'accepted', retryAfterSeconds=30) diff --git a/member_locations.py b/member_locations.py index 99ff305..eed1c25 100644 --- a/member_locations.py +++ b/member_locations.py @@ -4,11 +4,12 @@ import json import math import secrets import time +from location_sync import Sync, interval_valid class Locations: def __init__(self, app): - self.a=app; self.codes={}; self.attempts={}; self.latest={} + self.a=app; self.codes={}; self.attempts={}; self.latest={}; self.sync=Sync(app) def initialize(self): with self.a.LOCK,self.a.DB: @@ -19,6 +20,7 @@ class Locations: if self.a.DB.execute("SELECT name FROM sqlite_master WHERE name='location_shares'").fetchone(): self.a.DB.execute('UPDATE location_shares SET enabled=0') self.codes.clear(); self.latest.clear(); self.attempts.clear() + self.sync.initialize() def eligible(self, family, key): try: return self.a.MEMBERS.member(family,key,active=True) @@ -116,6 +118,7 @@ class Locations: return dict(token=token,**{k:grant[k] for k in ('home','memberName','viewers','displays','phones','viewOnly','intervalSeconds','expires','receipt','consentProtocol')}) def native(self, token, body): + if body.get('action')=='history-batch':return self.sync.batch(token,body) if body.get('action') in ('history-list','history-delete'): return self.a.HISTORY.native(token,body) result=self._native(token,body) @@ -125,7 +128,7 @@ class Locations: if row: fix=self.latest.get(row['id'],{}).get('fix');grant=json.loads(row['grant_json']) if fix and fix['at']==body['position']['at']: - self.a.HISTORY.record(row,grant,fix) + if not body.get('bufferedHistory'):self.a.HISTORY.record(row,grant,fix) else:fix=None else:fix=None if fix: @@ -141,6 +144,7 @@ class Locations: if not row:raise a.Problem('手机绑定已解除,请重新配对',401) sid=row['id'];action=body.get('action');grant=json.loads(row['grant_json']) if action in ('stop','revoke'): + self.sync.close(sid) if action=='revoke':a.DB.execute('DELETE FROM member_location_shares WHERE id=?',(sid,)) else:a.DB.execute('UPDATE member_location_shares SET enabled=0 WHERE id=?',(sid,)) self.latest.pop(sid,None);return {'ok':True} @@ -154,27 +158,32 @@ class Locations: viewerIds=[v['id'] for v in grant['viewers']],displayIds=[v['id'] for v in grant['displays']], phoneIds=[v['id'] for v in grant.get('phones',[])],receipt=grant['receipt'], intervalSeconds=grant.get('intervalSeconds',300),viewOnly=grant.get('viewOnly',False), + sampleIntervalSeconds=grant.get('sampleIntervalSeconds',60), historyEnabled=grant.get('historyEnabled',False),historyDefault=grant.get('historyDefault',False) and 'historyEnabled' not in grant, history=self.a.HISTORY.own_status(row['member_id'])) if action=='configure': if body.get('consent') is not True or body.get('receipt')!=grant['receipt']:raise a.Problem('请本人确认新的共享设置',403) chosen=self.select_recipients(row['family_id'],body,own_id=sid) interval=body.get('intervalSeconds',300) - if type(interval) is not int or interval not in (10,60,300):raise a.Problem('请选择实时、1 分钟或 5 分钟') + if not interval_valid(interval):raise a.Problem('上传周期可选 10 秒、1/5 分钟,或 1 至 720 小时(最多 30 天)') + sample=body.get('sampleIntervalSeconds',60) + if type(sample) is not int or sample not in (10,60,300):raise a.Problem('采集周期可选 10 秒、1 分钟或 5 分钟') if not any(chosen.values()):raise a.Problem('至少选择一位查看人;只查看家人无需开启自己的共享') history=body.get('historyEnabled',False) if type(history) is not bool or history and body.get('historyConsent') is not True:raise a.Problem('长期保存轨迹需要本人单独同意',403) - grant.update(chosen,viewOnly=False,intervalSeconds=interval,consentProtocol=3,historyEnabled=history) + self.sync.close(sid) + grant.update(chosen,viewOnly=False,intervalSeconds=interval,sampleIntervalSeconds=sample,consentProtocol=3,historyEnabled=history) self.refresh_receipt(grant) a.DB.execute('UPDATE member_location_shares SET enabled=0,grant_json=? WHERE id=?',(json.dumps(grant),sid)) self.latest.pop(sid,None) - return dict(ok=True,receipt=grant['receipt'],intervalSeconds=interval,**chosen) + return dict(ok=True,receipt=grant['receipt'],intervalSeconds=interval,sampleIntervalSeconds=sample,historyEnabled=history,**chosen) if action=='start': if grant.get('viewOnly'):raise a.Problem('此手机仅用于查看家人,请先由本人设置共享对象',403) if body.get('consent') is not True or body.get('receipt')!=grant['receipt']:raise a.Problem('请本人核对姓名及查看人,并同意开启共享',403) a.DB.execute('UPDATE member_location_shares SET enabled=1 WHERE id=?',(sid,)) self.latest[sid]=dict(seen=0,started=now,fix=None,signal='waiting') - return dict(ok=True,expires=row['expires'],intervalSeconds=grant.get('intervalSeconds',300)) + collection=self.sync.start(row,grant) if body.get('bufferedHistory') is True else {} + return dict(ok=True,expires=row['expires'],intervalSeconds=grant.get('intervalSeconds',300),sampleIntervalSeconds=grant.get('sampleIntervalSeconds',60),**collection) if action!='update' or not row['enabled']:raise a.Problem('位置共享尚未开启',403) old=self.latest.get(sid,dict(started=now,fix=None)) if now-old.get('seen',0)<10:raise a.Problem('位置更新过于频繁',429) @@ -189,6 +198,7 @@ class Locations: if not fix or pos['at']>fix['at']:fix={k:pos[k] for k in ('latitude','longitude','accuracy','at')} if signal in ('permission_denied','location_disabled'):fix=None self.latest[sid]=dict(started=old['started'],seen=now,fix=fix,signal=signal) + self.sync.seen(sid,old['started'],now) return dict(ok=True,expires=row['expires']) def listing(self, family, user=None, display_id=None, phone_id=None): @@ -213,12 +223,15 @@ class Locations: if user and user['id'] not in {v['id'] for v in grant['viewers']}:continue if display_id and display_id not in {v['id'] for v in grant['displays']}:continue if phone_id and phone_id!=row['id'] and phone_id not in {v['id'] for v in grant.get('phones',[])}:continue - recent=self.latest.get(row['id'],{});fix=recent.get('fix');seen=recent.get('seen',0) + recent=self.latest.get(row['id']) or self.sync.timing(row['id']);fix=recent.get('fix');seen=recent.get('seen',0) age=now-(fix['at'] if fix else recent.get('started',row['created'])) - state='stale' if age>900 or seen and now-seen>900 else 'live' if fix else 'waiting' + scheduled=grant.get('intervalSeconds',300)>900 and now-(seen or recent.get('started',row['created']))<=grant['intervalSeconds']+900 + stale=age>900 or seen and now-seen>900 + state='scheduled' if stale and scheduled else 'stale' if stale else 'live' if fix else 'waiting' position=fix if fix and state=='live' else None items.append(dict(id=row['member_id'],personId=valid[1]['id'],name=valid[1]['name'],status=state, - signal=recent.get('signal','waiting'),lastSeen=seen or None,position=position,expires=row['expires'])) + signal=recent.get('signal','waiting'),lastSeen=seen or None,position=position,expires=row['expires'], + intervalSeconds=grant.get('intervalSeconds',300),nextUploadAt=(seen or recent.get('started',row['created']))+grant.get('intervalSeconds',300))) return items def snapshot(self,user): diff --git a/test_android_location.py b/test_android_location.py index 82d2200..de6d165 100644 --- a/test_android_location.py +++ b/test_android_location.py @@ -44,7 +44,7 @@ class AndroidLocationContractTests(unittest.TestCase): manifest = ET.parse(ANDROID/'AndroidManifest.xml').getroot() service = next(s for s in manifest.findall('application/service') if s.get(NS+'name') == '.LocationService') self.assertEqual(service.get(NS+'exported'), 'false') - self.assertEqual(service.get(NS+'foregroundServiceType'), 'location') + self.assertEqual(set(service.get(NS+'foregroundServiceType').split('|')), {'location','dataSync'}) boot = (ANDROID/'src/cn/ucvl/zhaodisplay/BootReceiver.java').read_text() self.assertNotIn('LocationService', boot) self.assertIn('phoneMode', boot) @@ -52,6 +52,11 @@ class AndroidLocationContractTests(unittest.TestCase): self.assertNotIn('WebView', ui) self.assertIn('共享我的位置', ui) self.assertIn('new int[]{10,60,300}', ui) + self.assertIn('自定义小时 / 天',ui) + self.assertIn('LocationCadence.custom',ui) + queue=(ANDROID/'src/cn/ucvl/zhaodisplay/LocationQueue.java').read_text(encoding='utf-8') + for contract in ('AndroidKeyStore','AES/GCM/NoPadding','MAX_POINTS=50000','MAX_DATABASE_BYTES','batch.digest.equals','"verified".equals(state)','db.beginTransaction()'): + self.assertIn(contract,queue) self.assertIn('consent.isChecked()', ui) def test_map_uses_first_party_tiles_and_never_exposes_pairing_token(self): diff --git a/test_location_sync.py b/test_location_sync.py new file mode 100644 index 0000000..e61e77d --- /dev/null +++ b/test_location_sync.py @@ -0,0 +1,147 @@ +"""Offline batches use synthetic coordinates and an isolated database/cloud stub.""" +import hashlib +import json +import time +import unittest +from unittest.mock import patch +import test_phone_locations as fixtures +app=fixtures.app + + +class LocationSyncTests(unittest.TestCase): + setUp=fixtures.PhoneLocationTests.setUp + stop_server=fixtures.PhoneLocationTests.stop_server + phone=fixtures.PhoneLocationTests.phone + configure=fixtures.PhoneLocationTests.configure + + def enabled(self, **options): + phone=self.phone('离线测试成员') + self.configure(phone,viewerIds=[self.owner['id']],historyEnabled=True,historyConsent=True,**options) + result=app.LOCATIONS.native(phone['token'],dict(action='start',consent=True,receipt=phone['receipt'],bufferedHistory=True)) + phone.update(result) + return phone + + def body(self,phone,count=2,at=None,batch='a'*32): + at=at or phone['collectionStartedAt'] + points=[dict(id=f'{i:032x}',position=dict(latitude=36.61,longitude=117.1,accuracy=8,at=at+i)) for i in range(count)] + raw=json.dumps(dict(version=1,collectionId=phone['collectionId'],points=points),separators=(',',':')) + return dict(action='history-batch',batchId=batch,sha256=hashlib.sha256(raw.encode()).hexdigest(),payload=raw) + + def send(self,phone,body=None):return app.LOCATIONS.native(phone['token'],body or self.body(phone)) + def file(self):return dict(app.DB.execute('SELECT * FROM location_history_files').fetchone()) + def verify_cloud(self): + with patch.object(app.BAIDU,'upload',return_value={'fs_id':123}),patch.object(app.BAIDU,'verify_file'): + app.HISTORY.process(self.file()) + + def test_acceptance_is_not_cloud_confirmation(self): + phone=self.enabled();body=self.body(phone);reply=self.send(phone,body) + self.assertEqual(reply['state'],'accepted');self.assertEqual(reply['count'],2);self.assertEqual(reply['sha256'],body['sha256']) + self.assertEqual(app.DB.execute('SELECT count(*) FROM location_history_points').fetchone()[0],2) + self.verify_cloud();reply=self.send(phone,body) + self.assertEqual(reply['state'],'verified');self.assertEqual(reply['batchId'],body['batchId']) + self.assertEqual(app.DB.execute('SELECT count(*) FROM location_history_points').fetchone()[0],0) + + def test_repeated_batches_before_and_after_cloud_are_idempotent(self): + phone=self.enabled();body=self.body(phone) + for _ in range(3):self.send(phone,body) + self.assertEqual(app.DB.execute('SELECT count(*) FROM location_history_files').fetchone()[0],1) + self.assertEqual(app.DB.execute('SELECT count(*) FROM location_history_points').fetchone()[0],2) + self.verify_cloud() + for _ in range(3):self.assertEqual(self.send(phone,body)['state'],'verified') + self.assertEqual(app.DB.execute('SELECT count(*) FROM location_history_files').fetchone()[0],1) + + def test_network_and_cloud_verification_failures_never_acknowledge(self): + phone=self.enabled();self.send(phone) + for operation in ('upload','verify_file'): + with patch.object(app.BAIDU,'upload',return_value={'fs_id':123}),patch.object(app.BAIDU,operation,side_effect=OSError('offline')):app.HISTORY.process(self.file()) + self.assertEqual(self.send(phone)['state'],'accepted') + self.assertEqual(app.DB.execute('SELECT count(*) FROM location_history_points').fetchone()[0],2) + + def test_old_points_accepted_after_three_days_without_becoming_live_position(self): + phone=self.enabled(intervalSeconds=3*86400);body=self.body(phone);later=time.time()+3*86400 + with patch('location_sync.time.time',return_value=later):self.assertEqual(self.send(phone,body)['state'],'accepted') + self.assertIsNone(app.LOCATIONS.latest[phone['sid']]['fix']) + + def test_expired_still_bound_phone_can_only_finish_prior_collection(self): + phone=self.enabled();body=self.body(phone) + with patch('location_sync.time.time',return_value=phone['expires']+86400): + self.assertEqual(self.send(phone,body)['state'],'accepted') + with self.assertRaises(app.Problem):app.LOCATIONS.native(phone['token'],dict(action='start',consent=True,receipt=phone['receipt'])) + + def test_wrong_digest_different_payload_and_duplicate_points_rejected(self): + phone=self.enabled();body=self.body(phone) + for changed in (dict(body,sha256='f'*64),dict(body,payload='{}')): + with self.assertRaises(app.Problem):self.send(phone,changed) + self.send(phone,body) + with self.assertRaises(app.Problem):self.send(phone,self.body(phone,count=1)) + raw=json.loads(body['payload']);raw['points'][1]['id']=raw['points'][0]['id'];serialized=json.dumps(raw) + with self.assertRaises(app.Problem):self.send(phone,dict(body,batchId='b'*32,payload=serialized,sha256=hashlib.sha256(serialized.encode()).hexdigest())) + + def test_batch_is_atomic_for_bad_coordinates_or_time(self): + phone=self.enabled() + for at in (phone['collectionStartedAt']-60,phone['expires']+100): + with self.assertRaises(app.Problem):self.send(phone,self.body(phone,at=at)) + body=self.body(phone);raw=json.loads(body['payload']);raw['points'][1]['position']['latitude']=float('nan');serialized=json.dumps(raw) + with self.assertRaises(app.Problem):self.send(phone,dict(body,payload=serialized,sha256=hashlib.sha256(serialized.encode()).hexdigest())) + self.assertEqual(app.DB.execute('SELECT count(*) FROM location_history_files').fetchone()[0],0) + + def test_other_phone_cannot_submit_or_confirm_ones_batch(self): + phone=self.enabled();other=self.phone('其他手机');body=self.body(phone);self.send(phone,body) + with self.assertRaises(app.Problem):self.send(other,body) + + def test_stop_allows_previously_collected_but_not_later_points(self): + phone=self.enabled();body=self.body(phone,count=1) + app.LOCATIONS.native(phone['token'],dict(action='stop')) + self.assertEqual(self.send(phone,body)['state'],'accepted') + with self.assertRaises(app.Problem):self.send(phone,self.body(phone,count=1,at=time.time()+30,batch='b'*32)) + + def test_revocation_blocks_even_existing_receipts(self): + phone=self.enabled();body=self.body(phone);self.send(phone,body) + app.LOCATIONS.native(phone['token'],dict(action='revoke')) + with self.assertRaises(app.Problem):self.send(phone,body) + + def test_new_viewer_does_not_get_old_offline_points(self): + phone=self.enabled();body=self.body(phone,count=1);viewer=self.phone('新增查看人') + self.configure(phone,phoneIds=[viewer['sid']],historyEnabled=True,historyConsent=True) + app.LOCATIONS.native(phone['token'],dict(action='start',consent=True,receipt=phone['receipt'])) + self.send(phone,body) + result=app.HISTORY.native(viewer['token'],dict(action='history-list',memberId=phone['member']['id'],period='life',date='2026-10-19')) + self.assertEqual(result['points'],[]) + + def test_deleted_history_cannot_be_recreated_by_offline_retry(self): + phone=self.enabled();body=self.body(phone,count=1);self.send(phone,body) + app.HISTORY.native(phone['token'],dict(action='history-delete',confirm=True)) + with self.assertRaises(app.Problem):self.send(phone,body) + with patch.object(app.BAIDU,'delete_history_file'):app.HISTORY.process(self.file()) + with self.assertRaises(app.Problem):self.send(phone,body) + + def test_capacity_rejects_without_accepting_or_losing_phone_receipt(self): + phone=self.enabled() + with patch('location_history.LIMIT',0),self.assertRaises(app.Problem):self.send(phone) + self.assertEqual(app.DB.execute('SELECT count(*) FROM location_history_files').fetchone()[0],0) + + def test_payload_is_encrypted_at_rest(self): + phone=self.enabled();self.send(phone) + dump='\n'.join(app.DB.iterdump()) + self.assertNotIn('latitude',dump);self.assertNotIn(phone['token'],dump) + + def test_long_periods_and_independent_sampling(self): + phone=self.phone('周期测试') + for seconds in (3600,7200,10800,14400,18000,23*3600,86400,172800,259200,30*86400): + reply=self.configure(phone,viewerIds=[self.owner['id']],intervalSeconds=seconds,sampleIntervalSeconds=60) + self.assertEqual(reply['intervalSeconds'],seconds);self.assertEqual(reply['sampleIntervalSeconds'],60) + for invalid in (True,3601,31*86400,3600.0,'3600'): + with self.assertRaises(app.Problem):self.configure(phone,viewerIds=[self.owner['id']],intervalSeconds=invalid) + + def test_long_period_wait_does_not_trigger_stale_alarm(self): + phone=self.enabled(intervalSeconds=86400);started=phone['collectionStartedAt'] + with patch('member_locations.time.time',return_value=started+3600): + row=app.LOCATIONS.listing(self.aid,user=self.owner)[0];self.assertEqual(row['status'],'scheduled');self.assertIsNone(row['position']) + with patch('member_locations.time.time',return_value=started+86400+901):self.assertEqual(app.LOCATIONS.listing(self.aid,user=self.owner)[0]['status'],'stale') + + def test_schedule_survives_server_memory_reset(self): + phone=self.enabled(intervalSeconds=3*86400);started=phone['collectionStartedAt'];app.LOCATIONS.latest.clear() + with patch('member_locations.time.time',return_value=started+86400):self.assertEqual(app.LOCATIONS.listing(self.aid,user=self.owner)[0]['status'],'scheduled') + + +if __name__=='__main__':unittest.main() diff --git a/web/downloads.html b/web/downloads.html index a4e0e45..b2eb29e 100644 --- a/web/downloads.html +++ b/web/downloads.html @@ -1,6 +1,6 @@ 配套 App · 赵府智家
← 返回赵府智家
赵府
家庭成员均可下载

赵府智家 · 配套 App

按设备选择手机或显示终端安装包。使用平台账号登录下载;安装后凭配对码使用,无需在 App 注册。两种版本使用同一个应用身份,请按实际用途选择。

-

家庭显示终端

用于显示时间、天气、家人位置及家庭设备。安装后使用管理员提供的配对码,绑定指定家庭。

手机家人位置

手机打开“赵府家人位置”,输入绑定本人档案的手机配对码,无需注册或登录。可查看获授权的家人;“我的位置设置”可选择查看人、实时(约 10 秒)/ 1 分钟 / 5 分钟上传,再由本人打开共享开关。查看家人无需开启自己的定位。

+

家庭显示终端

用于显示时间、天气、家人位置及家庭设备。安装后使用管理员提供的配对码,绑定指定家庭。

手机家人位置

手机打开“赵府家人位置”,输入绑定本人档案的手机配对码,无需注册或登录。可查看获授权的家人;“我的位置设置”可选择查看人,分别设置定位采集频率和上传周期:实时、分钟、小时或天(最多 30 天)。启用历史保存后,断网轨迹在手机加密暂存,恢复网络自动补传,网盘完整校验后清理本机副本。由本人打开共享开关。查看家人无需开启自己的定位。

正在检查登录状态…


支持 Android 8.0 及以上,ARM64 / ARMv7。下载后打开 APK,按系统提示完成安装。iPhone 可使用网页;此安装包不适用于 iOS。安装后仍按家庭授权访问资料。两端均提供“按住说话,松开发送”;接收方需先允许具体喊话人并打开 App。显示终端无需麦克风即可接收,接上话筒后可以发送。

diff --git a/web/ui/assets/index-CgbLhMOE.css b/web/ui/assets/index-gJyED1pB.css similarity index 99% rename from web/ui/assets/index-CgbLhMOE.css rename to web/ui/assets/index-gJyED1pB.css index 923dfc9..7532bfd 100644 --- a/web/ui/assets/index-CgbLhMOE.css +++ b/web/ui/assets/index-gJyED1pB.css @@ -1 +1 @@ -:root{font-family:Inter,Microsoft YaHei,system-ui,sans-serif;color:#dae4e6;background:#10191d;font-synthesis:none;--muted:#8faaaF;--line:#2b3b40;--panel:#18252b;--accent:#74d5bb}*{box-sizing:border-box}body{margin:0}button,input,select{font:inherit}button,.button{border:1px solid transparent;background:var(--accent);color:#153b31;padding:11px 18px;border-radius:8px;font-weight:600;cursor:pointer;white-space:nowrap;text-decoration:none;font-size:14px}button:hover,.button:hover{filter:brightness(1.08)}button:disabled{opacity:.5;cursor:wait}.secondary{background:#263a40;color:#cfe7e5;border-color:#385058}.quiet{background:transparent;border-color:var(--line);color:var(--muted);padding:9px 13px;font-size:13px}input,select{background:#111e24;border:1px solid #3a4e55;color:#e3f0ef;border-radius:7px;padding:10px 11px;min-width:0;max-width:100%;outline:none}input:focus,select:focus{border-color:var(--accent)}label{font-size:13px;color:#a5bec1;display:flex;gap:8px;align-items:center}h1,h2,h3,p{margin-top:0}h1{font-size:30px;letter-spacing:1px;margin:8px 0}h2{font-size:19px;font-weight:600}h3{font-size:16px}p{line-height:1.8}small{font-weight:400}.sidebar{position:fixed;left:0;top:0;bottom:0;width:238px;background:#111e24;border-right:1px solid var(--line);padding:32px 20px;display:flex;flex-direction:column}.brand{display:flex;gap:12px;align-items:center;color:#e9f3f1;text-decoration:none;font-size:21px;font-weight:600;padding:5px 8px 40px}.brand-icon{color:var(--accent);font-size:39px}.brand small{display:block;font-size:9px;letter-spacing:1.1px;margin-top:7px;color:var(--muted)}.nav-label{color:#6b868b;font-size:11px;letter-spacing:3px;padding:14px 15px}nav{display:grid;gap:8px}nav button{text-align:left;background:transparent;color:#8fa9ae;display:flex;gap:15px;font-size:18px;padding:14px 16px}nav button span{font-size:14px}nav button.active{background:#244038;color:#9ee8d3}.side-note{margin-top:auto;padding:20px 9px;font-size:12px;color:#8ebdb1}.side-note p{color:#5e8086;font-size:11px;margin:16px 0}.dot{display:inline-block;width:7px;height:7px;background:#7bd5b5;border-radius:50%;margin-right:5px}main{margin-left:238px;padding:38px 42px 18px;max-width:1800px}header{display:flex;justify-content:space-between;align-items:flex-start;margin-bottom:27px}.eyebrow{font-size:10px;letter-spacing:3px;color:#77aa9e}header p{color:var(--muted);font-size:13px;margin:0}.header-status{display:grid;justify-items:end;gap:13px;padding-top:4px;font-size:11px;color:#718f96}.badge{font-size:11px;background:#243c36;color:#8bddbd;padding:6px 10px;border-radius:5px}.badge.off{background:#372d27;color:#d7ae87}.metrics{display:grid;grid-template-columns:repeat(4,1fr);border:1px solid var(--line);background:#152329;border-radius:12px;overflow:hidden}.metrics>div{padding:21px 25px;border-right:1px solid var(--line);display:flex;justify-content:space-between;align-items:center;gap:10px}.metrics>div:last-child{border:0}.metrics span{font-size:12px;color:var(--muted)}.metrics strong{font-size:26px;font-weight:500}.filter-row{display:flex;gap:16px;align-items:center;margin:26px 0;color:#728c93;font-size:12px}.filter-row select{max-width:280px}.section-head{display:flex;align-items:center;justify-content:space-between;gap:16px;margin:28px 0 17px}.section-head h2{margin:0}.section-head small{font-size:9px;color:#637f87;letter-spacing:2px;margin-left:12px}.section-head>div{display:flex;align-items:center;gap:16px}.live-grid{display:grid;grid-template-columns:repeat(2,minmax(0,1fr));gap:20px}.camera-card{border:1px solid var(--line);border-radius:11px;background:var(--panel);overflow:hidden}.camera-card .video-panel{border:0;border-radius:0;margin:0}.video-panel{position:relative;aspect-ratio:16/9;background:#070e12;overflow:hidden;border:1px solid var(--line);border-radius:10px;margin-bottom:16px}.video-panel video{width:100%;height:100%;object-fit:contain;display:block}.video-empty{position:absolute;inset:0;display:flex;flex-direction:column;align-items:center;justify-content:center;gap:13px;color:#5c7b85;font-size:13px;pointer-events:none;background:radial-gradient(ellipse at center,#142a32 0,transparent 70%)}.video-empty .lens{font-size:36px;color:#456773}.video-error{position:absolute;left:14px;right:14px;bottom:48px;background:#271d1ce6;border-radius:6px;color:#e3b7a1;padding:9px 12px;font-size:12px}.camera-meta{display:flex;justify-content:space-between;gap:12px;padding:16px 18px}.camera-meta strong{font-size:14px}.camera-meta p{color:#728f96;font-size:11px;margin:6px 0 0}.camera-meta .badge{align-self:flex-start}.camera-actions{display:flex;gap:8px;padding:0 18px 14px}.camera-actions button{font-size:11px;padding:7px 10px}.empty{grid-column:1/-1;padding:62px 20px;text-align:center;background:var(--panel);border:1px dashed #354b52;border-radius:12px;color:#819da5}.empty h3{font-size:19px;color:#c4d5d6;font-weight:500}.empty p{font-size:13px;margin-bottom:22px}.panel{padding:22px;background:var(--panel);border:1px solid var(--line);border-radius:10px;margin-bottom:18px}.playback-controls{display:flex;align-items:end;gap:15px;flex-wrap:wrap}.playback-controls label{display:grid}.playback-controls>span{font-size:12px;color:var(--muted);margin:auto 0}.timeline-head{display:flex;justify-content:space-between;font-size:12px;margin-bottom:20px}.timeline-head span{color:var(--muted)}.legend{display:inline-block;background:var(--accent);width:15px;height:6px;margin-right:7px}#timeline{width:100%;height:76px;display:block;cursor:crosshair}.time-labels{display:flex;justify-content:space-between;font-size:10px;color:#74949c}.seek-row{margin-top:22px;display:flex;align-items:center;gap:12px;flex-wrap:wrap}.recording-list{display:grid;grid-template-columns:repeat(3,1fr);gap:12px}.recording-item{text-align:left;background:#203139;color:#bdd5d8;font-size:12px;border:1px solid var(--line);white-space:normal}.recording-item small{display:block;color:#719499;margin-top:7px}.discovery{display:flex;align-items:center;gap:14px}.discovery>div{margin-right:auto}.discovery p{font-size:12px;color:var(--muted);margin:5px 0 0}.discovery input{width:190px}.scan-chip{display:inline-flex;gap:16px;align-items:center;margin:0 12px 14px 0;padding:12px 16px;border:1px solid var(--line);border-radius:8px;font-size:13px}.scan-chip button{padding:6px 10px;font-size:11px}.table-wrap{overflow:auto}.device-table{width:100%;border-collapse:collapse;background:var(--panel);border:1px solid var(--line);font-size:13px}.device-table th{text-align:left;font-size:11px;color:#8ba9ae;font-weight:400;padding:15px}.device-table td{padding:18px 15px;border-top:1px solid var(--line)}.device-table td small{display:block;margin-top:7px;color:#75969d}.site-grid{display:grid;grid-template-columns:repeat(2,minmax(0,1fr));gap:18px}.site-card{background:var(--panel);border:1px solid var(--line);padding:24px;border-radius:10px}.site-heading{display:flex;justify-content:space-between;gap:12px}.site-card h3{margin:12px 0}.site-card dl{font-size:12px}.site-card dl>div{display:flex;gap:18px;padding:7px 0}.site-card dt{color:#718d94;width:80px;flex-shrink:0}.site-card dd{margin:0;color:#b6cccf;word-break:break-word}.description{font-size:12px;color:var(--muted);line-height:1.9}.storage-grid{display:grid;grid-template-columns:1fr 1.2fr;gap:22px}.storage-grid form>label{display:grid;margin:20px 0}.storage-grid dl{font-size:13px}.storage-grid dl div{display:flex;justify-content:space-between;gap:15px;padding:15px 0;border-bottom:1px solid var(--line)}.storage-grid dt{color:var(--muted)}.storage-grid dd{margin:0}.audit-item{font-size:11px;padding:10px 0;border-top:1px solid var(--line);color:#9ab8bd}.audit-item small{display:block;color:#607f89;margin-bottom:5px}.banner{background:#493c24;border:1px solid #6b5430;color:#e1c69a;border-radius:8px;padding:13px 17px;font-size:13px;margin-bottom:22px}dialog{color:#dae4e6;background:#192a31;border:1px solid #3b555d;border-radius:15px;width:min(760px,94vw);max-height:90vh;padding:30px;box-shadow:0 25px 120px #0008}dialog::backdrop{background:#061015dd;backdrop-filter:blur(8px)}#auth-dialog{max-width:430px;padding:38px}#auth-form h2{font-size:28px;margin:18px 0 10px}#auth-form>label{display:grid;margin:22px 0}#auth-form p{color:#93afb5;font-size:13px}.dialog-heading{display:flex;justify-content:space-between;align-items:center;margin-bottom:25px}.dialog-heading h2{margin:0}.form-grid{display:grid;grid-template-columns:1fr 1fr;gap:18px}.form-grid label{display:grid;gap:8px}.form-grid .check{display:flex}.check input{accent-color:var(--accent);width:16px;height:16px}.dialog-footer{display:flex;justify-content:flex-end;margin-top:20px;padding-top:20px;border-top:1px solid var(--line)}.form-error{font-size:12px;color:#efab97;line-height:1.6}.wide{width:100%}footer{font-size:10px;color:#54727c;display:flex;justify-content:space-between;margin-top:40px;padding-top:18px;border-top:1px solid var(--line)}#toast{position:fixed;bottom:28px;left:50%;transform:translate(-50%);border:1px solid #4a7d70;background:#1a3c32;color:#b5efd9;padding:13px 22px;border-radius:9px;z-index:5;box-shadow:0 10px 30px #0005;font-size:13px}:focus-visible{outline:2px solid var(--accent);outline-offset:3px}@media(min-width:1600px){.live-grid{grid-template-columns:repeat(3,minmax(0,1fr))}}@media(max-width:1100px){.sidebar{width:190px;padding:25px 14px}.brand{font-size:17px}.brand-icon{font-size:30px}.brand small{font-size:8px}main{margin-left:190px;padding:25px}.metrics>div{padding:18px 14px}.metrics strong{font-size:22px}.storage-grid{grid-template-columns:1fr}.section-head small{display:none}}@media(max-width:760px){.sidebar{position:static;width:auto;padding:18px 16px 8px;border-right:0;border-bottom:1px solid var(--line)}.brand{padding:0 3px 16px}.brand small{font-size:9px}.sidebar nav{display:flex;gap:3px;overflow:auto}.sidebar nav button{padding:10px;font-size:14px;gap:6px}.sidebar nav button span{font-size:11px}.nav-label,.side-note,.sidebar #logout{display:none}main{margin:0;padding:23px 16px}h1{font-size:25px}.header-status{font-size:9px}.metrics{grid-template-columns:1fr 1fr}.metrics>div{border-bottom:1px solid var(--line)}.metrics>div:nth-child(2){border-right:0}.live-grid,.site-grid{grid-template-columns:1fr}.filter-row{flex-wrap:wrap;gap:10px}.filter-row>span{display:none}.filter-row select{max-width:200px}.section-head{align-items:start}.section-head>div{flex-wrap:wrap;justify-content:flex-end;gap:8px}.section-head button{padding:9px 11px;font-size:12px}.section-head h2{font-size:16px}.section-head label{font-size:11px}.section-head select{padding:6px}.discovery{flex-wrap:wrap}.discovery>div{width:100%}.discovery input{flex:1}.recording-list{grid-template-columns:1fr 1fr}.timeline-head{gap:10px;font-size:10px}.form-grid{gap:13px}.form-grid label{font-size:12px}dialog{padding:23px}.form-grid .full{grid-column:1/-1}.playback-controls label{flex:1}.video-empty{font-size:11px}.camera-meta{padding:14px}.seek-row label{width:100%}#auth-dialog{padding:30px}footer{font-size:9px}}.sidebar{overflow-y:auto}.sidebar .brand{padding-bottom:18px}.sidebar nav{gap:3px}.sidebar nav button{padding-top:10px;padding-bottom:10px}.sidebar .side-note{padding-bottom:0}.sidebar .side-note p{display:none}textarea{font:inherit;color:#e3f0ef;background:#111e24;border:1px solid #3a4e55;border-radius:7px;padding:10px;resize:vertical;max-width:100%}textarea:focus{outline:2px solid var(--accent)}fieldset{border:1px solid var(--line);border-radius:8px;padding:15px}legend{color:var(--muted);font-size:13px}#user-sites{display:flex;flex-wrap:wrap;gap:16px}.family-toolbar{display:flex;align-items:center;gap:16px;flex-wrap:wrap}.family-toolbar>span{margin-left:auto;font-size:12px;color:var(--muted)}.family-layout{display:grid;grid-template-columns:260px minmax(0,1fr);gap:20px;align-items:start}.family-people{display:grid;gap:10px;max-height:720px;overflow:auto}.person-card{text-align:left;display:grid;gap:8px;white-space:normal;background:var(--panel);color:#dae4e6;border:1px solid var(--line);padding:18px}.person-card.selected{border-color:var(--accent);background:#234037}.person-card span{font-size:12px;color:var(--accent)}.person-card small{font-size:11px;color:var(--muted)}#family-detail .section-head{margin-top:0}#family-detail h2{margin:10px 0}.family-prose{white-space:pre-wrap;overflow-wrap:anywhere;font-size:14px}.family-link{display:flex;gap:15px;justify-content:space-between;align-items:center;padding:12px 0;border-bottom:1px solid var(--line);font-size:13px}.family-link small{display:block;color:var(--muted);margin-top:7px}.family-tree{display:grid;grid-template-columns:1fr 1fr;gap:25px;overflow:auto}.family-tree ul{padding-left:20px;list-style:none;border-left:1px solid #3f6359}.family-tree li{padding:6px 0}.family-tree button{max-width:100%;white-space:normal}.family-tree small{color:var(--muted);font-size:11px}.family-spouses{grid-column:1/-1}#family-error:empty{display:none}.family-people .empty{padding:30px 12px}.family-people .empty h3{font-size:16px}#current-user{font-size:12px;margin:12px 0}@media(max-width:900px){.family-layout{grid-template-columns:1fr}.family-people{grid-template-columns:repeat(2,minmax(0,1fr));max-height:350px}.family-tree{grid-template-columns:1fr}.family-spouses{grid-column:auto}.family-toolbar label{flex-wrap:wrap}.family-toolbar input{width:100%}}@media(max-width:760px){.sidebar #logout{display:block;align-self:flex-end}.sidebar #current-user{position:absolute;right:130px;top:15px;font-size:10px}.form-grid{grid-template-columns:1fr}.family-tree ul{padding-left:12px}}#family-detail dl{display:grid;grid-template-columns:1fr 1fr;gap:14px 28px;margin:20px 0 26px}#family-detail dl>div{display:grid;grid-template-columns:105px 1fr;gap:10px;border-bottom:1px solid var(--line);padding-bottom:10px}#family-detail dt{font-size:12px;color:var(--muted)}#family-detail dd{margin:0;font-size:13px;overflow-wrap:anywhere}@media(max-width:1000px){#family-detail dl{grid-template-columns:1fr}}.brand-icon{width:44px;height:44px;object-fit:cover;border-radius:12px;flex-shrink:0}.wall-toolbar{display:flex;align-items:center;gap:15px;flex-wrap:wrap;margin:16px 0}.wall-toolbar select{padding:8px}.wall-paging{display:flex;align-items:center;gap:9px;color:var(--muted);font-size:12px}#wall-clock{margin-left:auto;color:var(--muted);font-size:12px}.live-grid[data-layout="1"]{grid-template-columns:1fr}.live-grid[data-layout="2"],.live-grid[data-layout="4"]{grid-template-columns:repeat(2,minmax(0,1fr))}.live-grid[data-layout="6"],.live-grid[data-layout="9"]{grid-template-columns:repeat(3,minmax(0,1fr))}.live-grid[data-layout="16"]{grid-template-columns:repeat(4,minmax(0,1fr))}.wall-reorder{display:none;padding:8px 12px;align-items:center;gap:8px}.arranging .wall-reorder{display:flex}.wall-reorder span{cursor:grab;margin-right:auto;font-size:12px;color:var(--muted)}.wall-reorder button{padding:4px 9px;font-size:11px}#page-live:is(:fullscreen,.wall-expanded){background:#070f12;padding:12px;width:100vw;height:100dvh;display:flex;flex-direction:column;overflow:hidden}#page-live:is(:fullscreen,.wall-expanded)>.section-head,#page-live:is(:fullscreen,.wall-expanded)>#quality-note{display:none}#page-live:is(:fullscreen,.wall-expanded) .wall-toolbar{margin:0 0 10px;flex-shrink:0}#page-live:is(:fullscreen,.wall-expanded) .live-grid{flex:1;min-height:0;gap:8px;grid-template-rows:repeat(2,minmax(0,1fr))}#page-live:is(:fullscreen,.wall-expanded) .live-grid[data-layout="1"],#page-live:is(:fullscreen,.wall-expanded) .live-grid[data-layout="2"]{grid-template-rows:1fr}#page-live:is(:fullscreen,.wall-expanded) .live-grid[data-layout="9"]{grid-template-rows:repeat(3,minmax(0,1fr))}#page-live:is(:fullscreen,.wall-expanded) .live-grid[data-layout="16"]{grid-template-rows:repeat(4,minmax(0,1fr))}#page-live:is(:fullscreen,.wall-expanded) .camera-card{display:flex;flex-direction:column;min-height:0;position:relative}#page-live:is(:fullscreen,.wall-expanded) .video-panel{flex:1;min-height:0;aspect-ratio:auto}#page-live:is(:fullscreen,.wall-expanded) .camera-meta{padding:7px 10px;align-items:center}#page-live:is(:fullscreen,.wall-expanded) .camera-meta p,#page-live:is(:fullscreen,.wall-expanded) .camera-meta .badge{display:none}#page-live:is(:fullscreen,.wall-expanded) .camera-meta strong{font-size:12px}#page-live:is(:fullscreen,.wall-expanded) .camera-actions{position:absolute;bottom:34px;right:6px;padding:4px;background:#10191ddd;border-radius:6px;opacity:0}#page-live:is(:fullscreen,.wall-expanded) .camera-card:hover .camera-actions,#page-live:is(:fullscreen,.wall-expanded) .camera-card:focus-within .camera-actions{opacity:1}#page-live:is(:fullscreen,.wall-expanded) .camera-actions [data-edit-camera],#page-live:is(:fullscreen,.wall-expanded) .camera-actions [data-play-camera]{display:none}.ptz-panel{background:#1a3038;border:1px solid #41656c;border-radius:12px;padding:16px;display:flex;align-items:center;gap:22px;position:fixed;bottom:22px;right:22px;z-index:4;max-width:calc(100vw - 32px);box-shadow:0 12px 50px #0008}.ptz-panel p{font-size:12px;color:var(--muted);max-width:320px;margin:8px 0 0}.ptz-pad{display:grid;grid-template-columns:repeat(3,46px);grid-template-rows:repeat(3,40px);gap:4px}.ptz-pad button{padding:5px;font-size:17px}.ptz-pad [data-ptz-action=up]{grid-column:2}.ptz-pad [data-ptz-action=left]{grid-column:1;grid-row:2}.ptz-pad [data-ptz-action=stop]{grid-column:2;grid-row:2;background:#f0bda6;font-size:12px}.ptz-pad [data-ptz-action=right]{grid-column:3;grid-row:2}.ptz-pad [data-ptz-action=down]{grid-column:2;grid-row:3}.family-date{border:1px solid var(--line);border-radius:8px;padding:14px;margin:0;min-width:0}.family-date legend{font-size:13px;color:#a5bec1}.family-date label{margin-bottom:10px}.family-date output{display:block;font-size:12px;line-height:1.7;color:var(--accent)}@media(max-width:760px){.wall-toolbar{gap:9px}#wall-clock{display:none}.camera-meta strong{font-size:12px}.camera-actions{flex-wrap:wrap;padding:0 8px 8px}.camera-meta{padding:9px}.ptz-panel{flex-wrap:wrap;gap:12px}.ptz-panel>div:first-child{flex:1;min-width:160px}.family-date{grid-column:1/-1}#page-live:is(:fullscreen,.wall-expanded) .camera-actions{opacity:1}.live-grid[data-layout="16"] .camera-meta strong{font-size:9px}}#page-live:is(:fullscreen,.wall-expanded) .live-grid[data-layout=auto]{grid-template-columns:repeat(3,minmax(0,1fr))}.wall-reorder [data-wall-drag]{touch-action:none;user-select:none;padding:5px 0}.camera-card.wall-drop-target{outline:2px solid var(--accent);outline-offset:-3px}#camera-settings-dialog{width:min(1060px,94vw)}#camera-settings-info dl{display:grid;grid-template-columns:repeat(3,minmax(0,1fr));gap:12px;margin:18px 0 24px;padding:16px;border:1px solid var(--line);border-radius:10px}#camera-settings-info dt{font-size:12px;color:var(--muted);margin-bottom:6px}#camera-settings-info dd{font-size:13px;margin:0;overflow-wrap:anywhere}#camera-image-fields,#camera-video-fields{grid-template-columns:repeat(3,minmax(0,1fr))}#camera-settings-status:empty{display:none}#camera-settings-dialog details{margin-top:20px;color:var(--muted);font-size:13px;line-height:1.8}#page-live:is(:fullscreen,.wall-expanded) .camera-actions [data-camera-settings]{display:none}@media(max-width:700px){#camera-settings-info dl,#camera-image-fields,#camera-video-fields{grid-template-columns:1fr 1fr}}@media(max-width:420px){#camera-settings-info dl,#camera-image-fields,#camera-video-fields{grid-template-columns:1fr}}.ptz-panel{width:620px;display:grid;grid-template-columns:1fr auto;max-height:80dvh;overflow:auto;align-items:start}.ptz-panel>div:first-child{grid-column:1}.ptz-panel .ptz-pad{grid-column:2;grid-row:1/3}#ptz-presets{grid-column:1/-1;min-width:0;border-top:1px solid var(--line);padding-top:12px}#ptz-presets .section-head{margin:0;gap:10px}#ptz-presets p{max-width:none;line-height:1.6}#preset-count{color:var(--muted);font-size:12px}.preset-row{display:flex;align-items:center;gap:5px;padding:9px 0;border-bottom:1px solid var(--line);flex-wrap:wrap}.preset-row strong{font-size:13px;flex:1;overflow-wrap:anywhere}.preset-row button{padding:5px 8px;font-size:12px}#preset-form{display:flex;align-items:end;gap:10px;margin-top:12px}#preset-form label{flex:1;margin:0}#preset-name{width:100%}#preset-confirmation{padding:12px;background:#553b31;border-radius:8px;margin-top:10px}#ptz-close{justify-self:start}.playback-tools{display:flex;align-items:center;gap:12px;flex-wrap:wrap;margin:12px 0}.playback-tools .check{margin:0}.clip-editor{border-top:1px solid var(--line);padding-top:12px}.clip-editor summary{cursor:pointer;margin-bottom:14px}#snapshot-dialog{width:min(1000px,92vw)}#snapshot-image{width:100%;max-height:65vh;object-fit:contain;background:#000;border-radius:8px}#play-position{font-size:13px;color:var(--muted)}@media(max-width:600px){.ptz-panel{right:12px;bottom:12px;padding:12px;gap:12px}.ptz-panel .ptz-pad{grid-column:2}#preset-form{flex-wrap:wrap}#preset-form label{flex-basis:100%}}.settings-sections,.view-presets{display:flex;gap:10px;flex-wrap:wrap;margin:12px 0 22px}.settings-sections button[aria-pressed=true],.view-presets button[aria-pressed=true]{background:var(--accent,#30594e);color:var(--paper,#fff);border-color:var(--accent,#30594e)}.group-custom{margin:16px 0}.group-custom summary{cursor:pointer;padding:10px 0}.device-search-row>button{align-self:end}.journal-entry.just-saved{outline:2px solid var(--accent,#30594e);outline-offset:4px;scroll-margin-block:24px}.family-workspace{display:grid;grid-template-columns:minmax(0,1fr) 310px;gap:18px;align-items:start}.family-canvas-panel{background:#17262b;border:1px solid #39504f;border-radius:14px;overflow:hidden;min-width:0}.family-map-heading{padding:22px 22px 16px;display:flex;justify-content:space-between;align-items:center;gap:14px}.family-map-heading h2{font-size:23px;margin:8px 0 0;letter-spacing:2px}.family-map-heading .eyebrow{font-size:9px}.family-view-tabs{display:flex;border:1px solid var(--line);border-radius:8px;padding:3px;flex-shrink:0}.family-view-tabs button{border:0;padding:8px 12px;border-radius:5px;font-size:12px}.family-view-tabs [aria-pressed=true]{background:#30574c;color:#b8f2df}.family-map-controls{padding:0 20px 16px;display:flex;align-items:center;gap:8px;flex-wrap:wrap}.family-map-controls button{font-size:12px;padding:7px 10px}.family-zoom-controls{display:flex;gap:5px;align-items:center;margin-right:auto}.family-zoom-controls output{font-size:11px;min-width:38px;text-align:center;color:var(--muted)}.family-map-viewport{height:clamp(440px,65vh,740px);overflow:auto;background-color:#e8eeea;background-image:radial-gradient(#b5c5bb 1px,transparent 1px);background-size:22px 22px;position:relative;overscroll-behavior:contain;cursor:grab;scrollbar-color:#82988b #dce5de;scrollbar-width:thin;outline-offset:-3px}.family-map-viewport.panning{cursor:grabbing;user-select:none}.family-map-space{position:relative;min-width:100%;min-height:100%}.family-map-surface{position:absolute;left:0;top:0;transform-origin:0 0}.family-map-lines{position:absolute;inset:0;overflow:visible;pointer-events:none}.family-edge{fill:none;stroke:#86a299;stroke-width:1.6;stroke-linecap:round;stroke-linejoin:round}.family-edge.spouse{stroke:#bd9050;stroke-dasharray:5 4;stroke-width:2}.family-edge.nonbiological{stroke:#9987b4;stroke-dasharray:4 3}.family-edge.focused{stroke-width:2.6;stroke:#337b66}.family-edge.spouse.focused{stroke:#ab791e}.family-edge.nonbiological.focused{stroke:#7b55a2}.family-branch-label{position:absolute;color:#536c60;font-size:12px;letter-spacing:1px;pointer-events:none}.family-node{position:absolute;border:1px solid #c4d0c7;border-radius:12px;background:#fffef9;color:#273e33;padding:13px 15px;text-align:left;white-space:normal;box-shadow:0 4px 11px #263c3010;display:flex;flex-direction:column;gap:4px;overflow:visible;cursor:pointer;transition:box-shadow .15s,border-color .15s}.family-node:hover{filter:none;box-shadow:0 6px 20px #30583d30;border-color:#5b9179}.family-node:focus-visible{outline:3px solid #205a48;outline-offset:4px}.family-node>strong{font-size:16px;line-height:1.3;overflow:hidden;text-overflow:ellipsis;white-space:nowrap;padding-right:30px}.family-node-top{position:absolute;right:12px;top:12px}.family-node-avatar{display:flex;width:28px;height:28px;align-items:center;justify-content:center;background:#e9f0e8;border-radius:9px;font-family:"Noto Serif SC",SimSun,serif;color:#48745c;font-size:17px}.family-node-flags{position:absolute;right:0;top:36px;display:grid;gap:4px;justify-items:end;white-space:nowrap}.family-node-flags>small{font-size:9px;color:#748375}.family-node .family-node-relation{display:block;font-size:11px;color:#577868;max-width:120px;text-overflow:ellipsis;white-space:nowrap;overflow:hidden}.family-node>small{font-size:10px;color:#7a8a80;margin-top:auto}.family-node.self{background:#f6d795;border:2px solid #c49337;box-shadow:0 5px 18px #b487242e}.family-node.self .family-node-avatar{background:#fbe8bd;color:#82561f}.family-node.self>strong{color:#5d3d15}.family-node.self .family-node-relation,.family-node.self>small{color:#7d622f}.self-badge{display:inline-block;border-radius:4px;background:#996e2b;color:#fff4d7;padding:2px 5px;font-size:9px;font-weight:600;letter-spacing:.5px}.family-node.selected{outline:3px solid #3d9175;outline-offset:4px}.family-node.search-hit:after{content:"匹配";position:absolute;left:12px;top:-12px;padding:2px 6px;border-radius:4px;background:#315f8d;color:#fff;font-size:9px;box-shadow:0 2px 4px #0002}.family-node.archived{border-style:dashed}.family-map-footer{padding:15px 20px;border-top:1px solid #a4b7a41f}.family-map-legend{display:flex;gap:15px;flex-wrap:wrap;font-size:11px;color:#a5bbb4;margin-bottom:9px}.family-map-legend>span{display:flex;align-items:center;gap:6px}.family-map-legend i{display:inline-block;width:19px;height:2px;background:#86a299}.family-map-legend i.legend-self{width:11px;height:11px;background:#f6d795;border-radius:3px}.family-map-legend i.legend-selected{width:11px;height:11px;background:transparent;border:2px solid #64bc9d;border-radius:3px}.family-map-legend i.legend-spouse{background:none;border-top:2px dashed #bd9050}.family-map-legend i.legend-adoptive{background:none;border-top:2px dashed #aa98c4}.family-map-footer .description{font-size:11px;margin:0;line-height:1.8}.family-map-footer #family-map-note:not(:empty){padding:8px 0;color:#c9bc9a}.family-inspector{position:sticky;top:18px;max-height:calc(100vh - 36px);overflow:auto;margin:0;padding:20px;min-width:0;scrollbar-width:thin}.family-inspector.is-self{border-color:#b08848;background:linear-gradient(145deg,#343323,#18272a 55%)}.family-self-heading{color:#e8c780;font-size:12px;margin-bottom:18px}.family-back-to-map{display:block;margin:0 0 18px auto;font-size:11px}#family-detail .section-head{gap:12px;flex-wrap:wrap}#family-detail .section-head>div{display:block}#family-detail .section-head h2{font-size:23px;overflow-wrap:anywhere}#family-detail dl{grid-template-columns:1fr;gap:12px;margin:18px 0 24px}#family-detail dl>div{grid-template-columns:76px minmax(0,1fr);gap:9px}#family-detail h3{font-size:14px;margin-top:24px}#family-detail .family-link{align-items:flex-start;overflow-wrap:anywhere;font-size:12px}#family-detail .family-link .quiet{padding:5px 8px;font-size:11px}#family-detail .family-prose{font-size:13px}.family-register{grid-template-columns:repeat(auto-fill,minmax(180px,1fr));max-height:clamp(440px,65vh,740px);overflow:auto;padding:20px;align-content:start;background:#132226}.person-card.self{background:#463e27;border-color:#b28f50;color:#f1dca7}.person-card.self span:not(.self-badge){color:#e0c995}.person-card.self small{color:#b8a98b}.person-card.selected{outline:2px solid #63b89c;outline-offset:-2px}.family-map-viewport>.empty{border:0;background:transparent;color:#5c7567;height:100%;display:flex;flex-direction:column;justify-content:center;margin:0}.family-map-viewport>.empty h3{color:#314d3d}.family-toolbar #family-search{width:190px}.family-toolbar #family-reference{max-width:180px}.family-toolbar{gap:12px}.family-workspace:is(:fullscreen,.family-expanded){width:100vw;height:100dvh;background:#10191d;padding:16px;align-items:stretch;overflow:auto}.family-workspace:is(:fullscreen,.family-expanded) .family-canvas-panel{height:100%;display:flex;flex-direction:column}.family-workspace:is(:fullscreen,.family-expanded) .family-map-viewport{flex:1;height:auto;min-height:200px}.family-workspace:is(:fullscreen,.family-expanded) .family-register{max-height:none;flex:1}.family-workspace:is(:fullscreen,.family-expanded) .family-inspector{position:static;max-height:100%;overflow:auto}.family-workspace:is(:fullscreen,.family-expanded) .family-map-heading{padding:14px 20px}.family-workspace:is(:fullscreen,.family-expanded) .family-map-footer{padding:10px 20px}@media(max-width:1250px){.family-workspace{grid-template-columns:minmax(0,1fr) 270px}.family-map-heading{align-items:flex-start;flex-wrap:wrap}.family-map-controls{gap:6px}.family-map-controls button{padding:7px 8px}.family-inspector{padding:16px}.family-toolbar>span{margin-left:0}}@media(max-width:1000px){.family-workspace{grid-template-columns:1fr}.family-inspector{position:static;max-height:none}.family-map-viewport{height:560px}.family-register{grid-template-columns:repeat(auto-fill,minmax(180px,1fr));max-height:560px}.family-workspace:is(:fullscreen,.family-expanded){display:flex;flex-direction:column;gap:10px}.family-workspace:is(:fullscreen,.family-expanded) .family-canvas-panel{min-height:65vh;flex:1;flex-shrink:0}.family-workspace:is(:fullscreen,.family-expanded) .family-inspector{max-height:35vh;flex-shrink:0}}@media(max-width:600px){#page-family>.section-head{align-items:flex-start;flex-wrap:wrap}#page-family>.section-head>div{gap:7px;flex-wrap:wrap}#page-family>.section-head button{font-size:12px;padding:8px 10px}.family-toolbar{padding:15px}.family-toolbar label{width:100%;display:flex;justify-content:space-between;flex-wrap:nowrap}.family-toolbar label.check{justify-content:flex-start}.family-toolbar input,.family-toolbar #family-search,.family-toolbar #family-reference{width:60%;max-width:60%}.family-toolbar input[type=checkbox]{width:16px}.family-map-heading{padding:17px 15px}.family-map-heading h2{font-size:21px}.family-map-controls{padding:0 12px 14px}.family-map-footer{padding:13px 15px}.family-map-legend{gap:10px}.family-map-viewport{height:470px}.family-register{grid-template-columns:1fr 1fr;padding:12px;gap:10px}.family-register .person-card{padding:12px}.family-workspace:is(:fullscreen,.family-expanded){padding:8px}.family-map-footer>.description:last-child{font-size:10px}}.family-map-heading{flex-wrap:wrap}.family-view-tabs{max-width:100%;flex-wrap:wrap}.family-view-tabs button{font-size:11px}.family-event-intro{display:flex;justify-content:space-between;gap:15px;padding:8px 22px 12px;align-items:flex-start}.family-event-intro h3{font-size:16px;line-height:1.7;margin:0 0 7px}.family-event-intro p{margin:0}.family-event-intro button{font-size:12px;padding:9px 12px}.family-event-filters{display:flex;gap:12px;flex-wrap:wrap;padding:15px 22px;background:#101e2366;border-top:1px solid var(--line);border-bottom:1px solid var(--line)}.family-event-filters label{display:flex;font-size:12px;gap:7px;flex-wrap:wrap}.family-event-filters input:not([type=checkbox]){width:170px}.family-event-filters select{max-width:180px;font-size:12px;padding:8px}.family-event-filters .check{width:100%;font-size:11px}.family-event-filters button{font-size:11px;padding:7px 10px}.family-event-filters #family-event-state-label{margin-right:auto}#family-event-count{padding:16px 22px 0;margin-bottom:0}.family-timeline{padding:0 22px 28px;max-height:680px;overflow:auto;scrollbar-width:thin}.timeline-year{font-family:Georgia,SimSun,serif;color:#a4d6c3;font-size:27px;margin:30px 0 18px;letter-spacing:1px}.timeline-year span{font-family:inherit;font-size:12px;color:var(--muted);margin-left:8px}.timeline-event{display:flex;align-items:flex-start;gap:18px;position:relative;width:100%;background:transparent;color:inherit;text-align:left;padding:0 0 24px;border-radius:0;border:0;white-space:normal}.timeline-event:hover{filter:none}.timeline-event:before{content:"";position:absolute;left:85px;top:10px;bottom:-10px;border-left:1px solid #466659}.timeline-event:after{content:"";position:absolute;left:81px;top:6px;width:9px;height:9px;border-radius:50%;background:#7eccac;box-shadow:0 0 0 4px #1c342d}.timeline-event>time{font-size:12px;font-weight:400;color:#9bb3ae;flex:0 0 70px;margin-top:1px}.timeline-event-body{margin-left:12px;flex:1;min-width:0;border:1px solid #345248;border-radius:10px;padding:17px 19px;background:#20352f;display:flex;flex-direction:column;gap:11px}.timeline-event:hover .timeline-event-body{border-color:#71ad94;background:#264037}.timeline-event-body>strong{font-size:17px;line-height:1.6;color:#dfebe5;overflow-wrap:anywhere}.timeline-event-status{font-size:9px;color:#9fc8b7;letter-spacing:1px}.timeline-summary{font-size:12px;color:#a4beb2;line-height:1.8;font-weight:400;display:-webkit-box;-webkit-line-clamp:3;-webkit-box-orient:vertical;overflow:hidden;white-space:pre-line;overflow-wrap:anywhere}.timeline-event-body>small{font-size:11px;color:#acc9b5;font-weight:400}.timeline-read{font-size:11px;color:#83d6b5;font-weight:400}.timeline-event.draft .timeline-event-body{border-style:dashed;background:#282e30}.timeline-event.draft:after{background:#aea087}.event-associated{display:flex;gap:8px;align-items:center;flex-wrap:wrap;margin:22px 0}.event-associated button{font-size:12px}.event-detail-meta{display:flex;gap:15px;justify-content:space-between;align-items:flex-start;margin:20px 0;color:#97baac;font-size:12px}.event-detail-meta time{line-height:1.8}#event-detail-title{font-size:26px;line-height:1.6;overflow-wrap:anywhere}.event-lead{border-left:3px solid #8cb8a1;background:#233a32;padding:14px 18px;white-space:pre-wrap;font-size:14px;overflow-wrap:anywhere}.event-article{font-size:15px;line-height:2;margin:28px 0;color:#c9d9d1}.event-source{display:inline-block;white-space:normal;overflow-wrap:anywhere;line-height:1.7;margin:8px 0}.event-updated{border-top:1px solid var(--line);padding-top:18px;margin-top:22px}#event-person-choices{display:flex;gap:12px;flex-wrap:wrap;max-height:170px;overflow:auto;padding:14px 0}#event-person-choices label{display:flex;flex-direction:row;align-items:center}.event-editor-actions{gap:12px}.person-events{border-top:1px solid var(--line);margin-top:25px;padding-top:15px}.person-events .section-head{gap:8px}.person-events .section-head h3{margin:0!important;font-size:13px!important}.person-events .section-head small{letter-spacing:0;margin-left:4px}.person-events .section-head button{font-size:10px;padding:6px 7px}.person-event-link{display:flex;flex-direction:column;gap:6px;border:0;background:transparent;color:#c0d6c9;text-align:left;padding:10px 0;margin-bottom:8px;white-space:normal;line-height:1.7;font-size:12px}.person-event-link time{font-size:10px;color:#87a495}.family-workspace:is(:fullscreen,.family-expanded) #family-events{overflow:auto}.family-workspace:is(:fullscreen,.family-expanded) .family-timeline{max-height:none}@media(max-width:600px){.family-event-intro{flex-wrap:wrap;padding:8px 15px 15px}.family-event-filters{padding:15px;gap:10px}.family-event-filters label{font-size:11px}.family-event-filters .check{line-height:1.8;flex-wrap:nowrap}.family-timeline{padding:0 15px 22px}.timeline-event{gap:8px}.timeline-event>time{font-size:10px;flex-basis:55px}.timeline-event:before{left:62px}.timeline-event:after{left:58px}.timeline-event-body{padding:13px;margin-left:9px}.timeline-event-body>strong{font-size:15px}.family-view-tabs button{padding:8px 10px}#event-detail-title{font-size:22px}.event-detail-meta,.event-editor-actions{flex-wrap:wrap}}.family-workspace.family-expanded{position:fixed;inset:0;z-index:8}.family-map-viewport{scrollbar-gutter:stable;overflow-anchor:none}.family-map-space{min-width:0;min-height:0;overflow:clip}.family-workspace:is(:fullscreen,.family-expanded){min-height:0;grid-template-rows:minmax(0,1fr)}.family-workspace:is(:fullscreen,.family-expanded) .family-canvas-panel{min-height:0}.family-workspace:is(:fullscreen,.family-expanded) .family-map-heading,.family-workspace:is(:fullscreen,.family-expanded) .family-map-controls,.family-workspace:is(:fullscreen,.family-expanded) .family-map-footer{flex-shrink:0}.family-workspace.family-expanded{z-index:1100}@media(max-width:1000px){.family-workspace:is(:fullscreen,.family-expanded) .family-canvas-panel{min-height:65vh}}#history-dialog{width:min(1040px,94vw)}#history-list{display:grid;grid-template-columns:repeat(auto-fit,minmax(220px,1fr));gap:10px;max-height:260px;overflow:auto;margin:16px 0}.history-entry{text-align:left;display:flex;flex-direction:column;align-items:flex-start;gap:6px;white-space:normal}.history-entry small,.history-entry span{color:var(--muted);font-size:12px}.history-columns{display:grid;grid-template-columns:1fr 1fr;gap:20px}.history-columns section{min-width:0}.history-columns dd{white-space:pre-wrap;overflow-wrap:anywhere;max-height:240px;overflow:auto}.history-columns dl>div{padding:10px;border-bottom:1px solid #30434a}.history-changed{background:#27443e66;border-radius:8px}#history-confirm{padding:16px;border:1px solid #74d0b7;border-radius:12px;margin-top:18px}#history-confirm button{margin:6px}#history-error:empty{display:none}@media(max-width:650px){.history-columns{grid-template-columns:1fr}#history-list{max-height:200px}}:root{color-scheme:light;--paper: #f4f0e7;--ink: #2d3932;--muted: #6e6b5f;--line: #dcd5c6;--panel: #fffdf8;--accent: #315b4d;--cinnabar: #9e4b3d;--gold: #86682f;--serif: "Songti SC", "STSong", "SimSun", serif;--timeline-paper: #ede8dd;--timeline-grid: #d3ccbc;--timeline-range: #4c7761;color:var(--ink);background:var(--paper);font-family:Microsoft YaHei,PingFang SC,system-ui,sans-serif}body{background-image:radial-gradient(ellipse at 85% 0,#e4e9df80,transparent 50%);min-width:0}::selection{background:#e8d7ad;color:#2d3932}button,.button,input,select,textarea,fieldset{border-radius:5px}button,.button{background:var(--accent);color:#fffdf6;font-weight:500;transition:background .15s,border-color .15s,box-shadow .15s}button:hover,.button:hover{filter:brightness(.95)}.secondary{background:#e8ede5;color:#315b4d;border-color:#c7d3c4}.quiet{background:transparent;color:#586653;border-color:#cfcfbf}input,select,textarea{color:var(--ink);background:#fffefa;border-color:#cbc5b6}input::placeholder,textarea::placeholder{color:#847f72}input:focus,select:focus,textarea:focus{border-color:var(--accent);box-shadow:0 0 0 3px #315b4d12}input[type=range],input[type=checkbox]{accent-color:var(--accent)}label,.family-date legend{color:#625f53}h1,h2,h3{font-family:var(--serif);font-weight:600}h1{font-size:34px;letter-spacing:4px;margin-top:17px}h2{letter-spacing:1px}.sidebar{width:222px;background:#213d34;background-image:linear-gradient(145deg,#2d4b3d,transparent 60%);border-right:1px solid #425344;padding:30px 18px 20px;color:#ebe7d8;scrollbar-width:thin;scrollbar-color:#6f8271 #213d34}.sidebar .brand{gap:11px;padding:4px 5px 30px;color:#f3eddf;font-family:var(--serif);font-size:22px;letter-spacing:2px}.brand-icon{width:44px;height:44px;border-radius:5px;outline:1px solid #c6b98c66;outline-offset:3px}.brand small{font-family:Microsoft YaHei,sans-serif;color:#c0c7b5;font-size:9px;letter-spacing:2px;margin-top:10px}.nav-label{color:#b2bba6;font-size:10px;padding:12px 13px 17px;letter-spacing:3px;border-top:1px solid #b9c2aa24}.sidebar nav{gap:5px}.sidebar nav button{color:#c9d1be;border-radius:4px;padding:12px 13px;gap:13px;position:relative;border:1px solid transparent;background:transparent}.sidebar nav button span{font-size:13px;letter-spacing:.6px}.sidebar nav button:hover{background:#ffffff09;filter:none}.sidebar nav button.active{background:#efebdc;border-color:#e0d6b8;color:#244638}.sidebar nav button.active:after{content:"";width:5px;height:5px;background:var(--cinnabar);position:absolute;right:13px;transform:rotate(45deg)}.sidebar .side-note{padding:22px 5px 8px;color:#c4ccb9;font-size:11px}.sidebar .dot{background:#afc39c;width:5px;height:5px}.sidebar #current-user{color:#d3d7c8;padding:10px 5px 0;border-top:1px solid #b9c2aa24}.sidebar .quiet{color:#d1d6c6;border-color:#8b9a813f;padding:9px;font-size:11px}.sidebar #account-password{margin-bottom:8px}.sidebar :focus-visible{outline-color:#e7c887}main{margin-left:222px;padding:30px 38px 22px;max-width:1900px}main>header{min-height:142px;padding:13px 0 23px;margin-bottom:25px;border-bottom:1px solid #b4b5a2;position:relative;gap:24px;isolation:isolate}main>header:after{content:"";position:absolute;bottom:-2px;left:0;height:3px;width:48px;background:var(--cinnabar)}main>header>div{position:relative;z-index:1}.eyebrow{color:var(--gold);font-size:10px;letter-spacing:3px}header p{color:#686f60;font-size:12px;letter-spacing:.5px}.header-status{color:#666e5e;gap:12px;font-size:11px;flex-shrink:0}.courtyard-landscape{position:absolute;width:330px;height:125px;right:5px;bottom:0;z-index:0;pointer-events:none;opacity:.55}.badge{background:#e4eddf;color:#355b3d;border:1px solid #c8d6be;border-radius:3px;font-size:10px}.badge.off{background:#f2e8d9;color:#835428;border-color:#dfc6a3}.metrics{background:#fcfaf4;border-radius:6px;box-shadow:0 3px 12px #3a402905}.metrics>div{padding:20px 22px;align-items:baseline}.metrics span{color:#6f7260}.metrics strong{font-family:Georgia,var(--serif);color:#365846;font-size:29px}.filter-row{color:#6e6b5f;margin:24px 0}.household-context{display:flex;flex-wrap:wrap;align-items:center;gap:12px 24px;margin:-5px 0 24px;padding:12px 16px;border-left:3px solid var(--gold);background:#eae8dc}.household-context span{font-size:11px;color:var(--muted)}.household-context select{min-width:140px;max-width:240px}.section-head{margin-top:25px}.section-head small{color:#8a7859;font-size:9px;letter-spacing:2px}.wall-toolbar{padding:12px 15px;background:#eae8dc;border:1px solid var(--line);border-radius:5px;gap:14px}.wall-toolbar select{background:#f9f6ed}.live-grid{gap:22px}.camera-card,.site-card,.panel,.empty,.family-canvas-panel{border-radius:6px;box-shadow:0 4px 18px #39422a05}.camera-card{border-color:#d2cebe}.camera-meta{padding:17px 18px 13px}.camera-meta strong{font-family:var(--serif);font-size:16px;letter-spacing:.5px}.camera-meta p{color:#737464;margin-top:7px}.camera-actions{flex-wrap:wrap;gap:7px;padding-bottom:16px}.camera-actions .quiet{border-color:#dbd9cb;color:#52604d;background:#faf9f2}.video-panel{border-radius:5px;border-color:#c1c6b8}.video-empty{color:#b0bdae;background:radial-gradient(ellipse at center,#243d34 0,transparent 70%)}.video-empty .lens{color:#a5bca4}.video-error{color:#f6d7c1;background:#472c26ed}.empty{color:#6c7462;border-color:#c3c6b6}.empty h3{color:#384e3b;font-size:21px}.panel{padding:24px}.time-labels{color:#6e705e}.recording-item{color:#35533f;background:#f9f7ee;border-color:#d5d1c0}.recording-item small{color:#737261}.scan-chip{background:#fffdf7;border-radius:5px}.device-table{border-radius:5px}.device-table th{color:#6a6d5c;background:#ecebde}.device-table td small{color:#737261}.device-table tbody tr:hover{background:#f2f1e7}.site-card h3{font-size:20px}.site-card dt{color:#737261}.site-card dd{color:#384e3b}.audit-item{color:#56654f}.audit-item small{color:#767461}.banner{color:#784c26;background:#f6e9cf;border-color:#dfc797}dialog{background:#fbf8ef;color:var(--ink);border:1px solid #d5c8ac;border-radius:8px;box-shadow:0 28px 100px #172c3455;padding:30px}dialog::backdrop{background:#20382cb8;backdrop-filter:blur(5px)}.dialog-heading{border-bottom:1px solid var(--line);padding-bottom:20px;gap:16px}.dialog-heading h2{font-size:23px}.dialog-footer{gap:10px;flex-wrap:wrap}#auth-dialog{border-top:4px solid var(--cinnabar);padding:38px;background-image:radial-gradient(ellipse at 100% 0,#e4e9dd,transparent 65%)}#auth-dialog .brand-icon{width:52px;height:52px}#auth-form h2{font-size:32px;letter-spacing:3px;margin-top:26px}#auth-form p{color:#6b725d}.form-error{color:#994437}footer{color:#716b5b;font-size:10px;letter-spacing:.5px}#toast{background:#2a4c3c;color:#f3efdc;border-color:#819672;border-radius:5px;box-shadow:0 8px 25px #30433726;max-width:calc(100vw - 30px)}.ptz-panel{background:#f8f5eb;border-color:#b9c5ad;border-radius:7px;box-shadow:0 12px 50px #26392d44;color:var(--ink)}.ptz-pad [data-ptz-action=stop]{color:#8b4236;background:#efdbd0;border-color:#d5b2a4}#preset-confirmation{background:#f4e2d5}#snapshot-image{border-radius:4px}.family-canvas-panel{background:#fcfaf3;border-color:#c7cbb7}.family-map-heading{padding-top:24px}.family-map-heading h2{letter-spacing:3px;font-size:25px}.family-view-tabs{background:#f1eee2;border-color:#d7d0bf;border-radius:4px}.family-view-tabs button{color:#606650;border-radius:2px}.family-view-tabs [aria-pressed=true]{background:#365945;color:#fffbed}.family-map-viewport{background-color:#efece0;background-image:radial-gradient(#c9cbbb 1px,transparent 1px);scrollbar-color:#8b9a7b #e8e6d8}.family-map-lines marker path{fill:#678b71}.family-edge{stroke:#94a58a}.family-edge.focused{stroke:#446b50}.family-edge.spouse{stroke:#a9854f}.family-edge.nonbiological{stroke:#93829e}.family-node{background:#fffdf6;border-color:#c9cdb9;border-radius:5px;color:#304632;box-shadow:0 3px 12px #3943250d}.family-node>strong{font-family:var(--serif);font-size:17px}.family-node-avatar{background:#e8ecdf;color:#536e45;border-radius:4px}.family-node .family-node-relation{color:#53664a}.family-node>small,.family-node-flags>small{color:#6f775f}.family-node.self{background:#f1ddb0;border-color:#af873f;box-shadow:0 5px 18px #b4872425}.family-node.self .family-node-avatar{background:#f8eac9}.family-node.selected{outline-color:#426c50}.family-node.search-hit:after{background:#596b78}.self-badge{background:#94682f;color:#fff8e9;border-radius:2px}.family-map-footer{border-color:#d0d3c0}.family-map-legend{color:#69705b}.family-map-footer #family-map-note:not(:empty){color:#87652f}.family-inspector.is-self{background:linear-gradient(135deg,#f3e3bd,#fcfaf1 65%);border-color:#c3a66b}.family-self-heading{color:#88652d;letter-spacing:1px}.family-register{background:#eeecdf}.person-card{color:#344732;border-color:#c9cbb9}.person-card.selected{background:#e6ecdc;outline-color:#66845b}.person-card.self{background:#f1ddb0;border-color:#b89553;color:#5f461f}.person-card.self span:not(.self-badge),.person-card.self small{color:#765b2e}.family-tree ul{border-color:#a2b197}.family-workspace:is(:fullscreen,.family-expanded){background:var(--paper)}.family-event-filters{background:#f0eee2}.timeline-year{color:#456344;font-family:var(--serif)}.timeline-event:before{border-color:#b7c2a5}.timeline-event:after{background:#768d5f;box-shadow:0 0 0 4px #e7ebdc}.timeline-event>time{color:#6c745d}.timeline-event-body{background:#fffdf6;border-color:#d3d6c2;border-radius:5px}.timeline-event:hover .timeline-event-body{background:#f7f7ec;border-color:#8caa78}.timeline-event-body>strong{color:#344d32;font-family:var(--serif);font-size:18px}.timeline-event-status,.timeline-summary,.timeline-event-body>small{color:#6b725b}.timeline-read{color:#41623b}.timeline-event.draft .timeline-event-body{background:#efede3}.timeline-event.draft:after{background:#a28a62}.event-detail-meta,.person-event-link time{color:#71745e}.event-lead{background:#eaecdd;border-color:#8e9f77;color:#46553b}.event-article{color:#424c3a}.person-event-link{color:#455a3c}.history-columns dl>div{border-color:#d9d6c4}.history-changed{background:#e8ecda;border-radius:4px}#history-confirm{border-color:#b3be98;border-radius:5px;background:#efefdf}#page-live:fullscreen{--muted: #c0c9b4;--line: #52614d;--panel: #25352c;color:#efecdd;background:#111c16;color-scheme:dark}#page-live:fullscreen .wall-toolbar{background:#24372b;border-color:#40543e}#page-live:fullscreen label{color:#d9deca}#page-live:fullscreen select{background:#1a2a20;color:#ebeede;border-color:#65765a}#page-live:fullscreen .quiet{color:#d9dfca;border-color:#66765a;background:transparent}#page-live:fullscreen .camera-card{border-color:#394f38}#page-live:fullscreen .camera-actions{background:#17251ee8}#page-live:fullscreen .ptz-panel{--muted: #6e6b5f;--line: #dcd5c6;color-scheme:light}#page-live:fullscreen .ptz-panel label,#page-live:fullscreen .ptz-panel .quiet{color:#586653;border-color:#cfcfbf}@media(min-width:1600px){main{padding-left:46px;padding-right:46px}}@media(max-width:1100px){.sidebar{width:200px;padding:27px 14px 18px}.sidebar .brand{font-size:20px;gap:9px}.brand-icon{width:38px;height:38px}main{margin-left:200px;padding:24px}.metrics>div{padding:18px 14px}.metrics strong{font-size:25px}.courtyard-landscape{width:260px;opacity:.4}}@media(max-width:760px){.sidebar{position:static;width:auto;padding:22px 17px 14px;display:grid;grid-template-columns:1fr auto;gap:0 10px;overflow:visible}.sidebar .brand{padding:2px 4px 20px;font-size:22px;grid-column:1/-1}.brand-icon{width:38px;height:38px}.brand small{font-size:9px}.sidebar nav{grid-column:1/-1;display:flex;overflow-x:auto;gap:5px;padding-bottom:12px;scrollbar-width:thin;scrollbar-color:#819573 #213d34}.sidebar nav button{padding:10px 12px;gap:7px;flex-shrink:0}.sidebar nav button span{font-size:12px}.sidebar nav button.active:after{display:none}.sidebar #current-user{position:static;grid-column:1/-1;margin:4px 0 10px;padding-top:12px;font-size:11px}.sidebar #account-password,.sidebar #logout{margin:0;font-size:11px;padding:8px 12px;align-self:center;width:fit-content}.sidebar #logout{justify-self:end}main{margin:0;padding:20px 17px}main>header{min-height:132px;padding-top:9px;gap:10px;margin-bottom:20px}h1{font-size:28px;letter-spacing:3px}.eyebrow{font-size:9px;letter-spacing:2px}.header-status{font-size:9px;gap:9px;max-width:123px;padding-top:2px}.header-status .badge{font-size:9px}header p{max-width:205px;font-size:11px;line-height:1.8}.courtyard-landscape{width:170px;height:90px;right:0;opacity:.38}.metrics>div{padding:16px}.metrics strong{font-size:25px}.metrics>div:nth-last-child(-n+2){border-bottom:0}.filter-row{margin:20px 0}.filter-row select{max-width:155px}.filter-row>button{padding:9px}.section-head{flex-wrap:wrap}.section-head>div{gap:10px}.wall-toolbar{padding:11px;gap:10px}.wall-toolbar label{font-size:12px}#wall-fullscreen{padding:10px 12px}.camera-meta{padding:14px}.camera-meta strong{font-size:15px}.camera-actions{padding:0 14px 14px;gap:8px}.camera-actions button{padding:9px 11px}.panel,.site-card{padding:18px}.family-map-heading h2{font-size:23px}dialog{padding:22px}#auth-dialog{padding:30px 26px}.dialog-heading h2{font-size:21px}.dialog-footer{gap:8px}footer{gap:16px;flex-wrap:wrap;font-size:9px}}@media(prefers-reduced-motion:reduce){*,*:before,*:after{scroll-behavior:auto!important;transition:none!important}}.household-actions{display:flex;gap:10px;flex-wrap:wrap;margin:18px 0}.household-context select{max-width:100%}.household-context label{min-width:0}.device-actions,.device-search-row,.device-group-order,.group-step{display:flex;gap:10px;flex-wrap:wrap;align-items:center}.device-search-row{align-items:end}.device-search-row label{flex:1;min-width:160px}.device-group-order{margin:12px 0}.group-step{padding:7px;background:var(--paper);border:1px solid var(--line);border-radius:5px}.group-step select{width:auto;max-width:145px}.group-step button{padding:7px 11px}.group-step>span{color:var(--muted)}.device-group{margin:26px 0}.device-group>h3{font-family:var(--serif);font-size:20px;overflow-wrap:anywhere}.device-group>h3>span{color:var(--gold);padding:0 8px}.device-group>h3 small{font:12px var(--sans);color:var(--muted);white-space:nowrap}.device-tags{display:flex;flex-wrap:wrap;gap:6px}.device-tags span{font-size:11px;padding:3px 8px;background:var(--paper);border:1px solid var(--line)}.site-card dd,.site-card .description{overflow-wrap:anywhere;min-width:0}@media(max-width:600px){.device-actions{width:100%}.device-actions button{flex:1;white-space:normal}.group-step{width:100%}.group-step select{flex:1;max-width:none;min-width:0}.device-group>h3{font-size:18px}}#scope-navigation{border-left:1px solid #6d8270;margin:12px 0 12px 10px;padding-left:9px}#scope-navigation .nav-label{padding:10px 12px;overflow-wrap:anywhere}.device-context{padding:18px 22px;margin:20px 0;border:1px solid var(--line);border-left:4px solid var(--accent);background:var(--panel)}.device-context p{color:var(--muted);overflow-wrap:anywhere;margin:0 0 14px}.device-context [role=group]{display:flex;flex-wrap:wrap;gap:8px}.device-context button.active{color:var(--paper);background:var(--accent)}.device-title{border:0;padding:0;background:transparent;color:var(--ink);font:inherit;text-align:left;box-shadow:none;white-space:normal;overflow-wrap:anywhere}.device-title:hover{color:var(--accent);background:transparent}.device-title span{color:var(--accent)}.scope-intro{padding:28px 0}.scope-intro h2{font:500 32px var(--serif);margin:12px 0}.scope-intro p{color:var(--muted);line-height:1.8}.steward-grid{display:grid;grid-template-columns:repeat(2,minmax(0,1fr));gap:20px}.steward-tile{display:flex;flex-direction:column;text-align:left;gap:12px;min-height:190px;padding:28px;border:1px solid var(--line);border-top:3px solid var(--accent);background:var(--panel);color:var(--ink);white-space:normal;box-shadow:0 3px 12px #22332208}.steward-tile strong{font-size:23px;font-family:var(--serif);font-weight:500}.steward-tile span,.steward-tile small{color:var(--muted);line-height:1.7}.steward-tile:hover{background:var(--paper);border-color:var(--accent)}#device-detail dl,#heritage-detail dl{display:grid;grid-template-columns:repeat(2,minmax(0,1fr));gap:18px}#device-detail dl>div,#heritage-detail dl>div{border-bottom:1px solid var(--line);padding-bottom:12px}#device-detail dt,#heritage-detail dt{font-size:12px;color:var(--muted);margin-bottom:6px}#device-detail dd,#heritage-detail dd{margin:0;overflow-wrap:anywhere}.heritage-prose{white-space:pre-wrap;line-height:1.9;overflow-wrap:anywhere;margin:24px 0}#heritage-detail{margin-top:24px}.heritage-controls{display:flex;gap:18px;flex-wrap:wrap;align-items:center;margin-bottom:22px}.heritage-controls label{min-width:0}.household-context{flex-wrap:wrap}@media(max-width:720px){.steward-grid{grid-template-columns:1fr}.steward-tile{min-height:150px;padding:22px}.device-context{padding:16px}.device-context button{flex:1 1 40%;min-width:0}#device-detail dl,#heritage-detail dl{grid-template-columns:1fr}#scope-navigation{display:flex;flex-wrap:wrap;border:0;margin:0;padding:0;width:100%}#scope-navigation .nav-label{width:100%;padding:8px 4px}.scope-intro h2{font-size:26px}}#household-list{display:block}.home-city-group{margin:24px 0 36px}.home-city-group>h3{font-size:21px}.home-city-group>h3 small{font:12px sans-serif;color:var(--muted);margin-left:12px}.home-card{padding:0;overflow:hidden}.home-cover{position:relative;min-height:210px;background:linear-gradient(145deg,#4b6957,#253d34);isolation:isolate;color:#fffdf6}.home-cover>img{position:absolute;width:100%;height:100%;object-fit:cover;inset:0;z-index:-2}.home-cover:after{content:"";position:absolute;inset:0;background:linear-gradient(0deg,#102019db,transparent);z-index:-1}.home-cover-content{padding:24px;min-height:210px;display:flex;flex-direction:column;justify-content:end}.home-cover .site-heading{margin-bottom:auto}.home-cover h3{margin:26px 0 4px;color:#fffdf6;text-shadow:0 1px 3px #000a;font-size:25px}.home-cover .quiet{background:#172a25ba;color:#fff;border-color:#bccabd80}.home-cover .badge{background:#f9f5e5e8;color:#244638;border-color:transparent}.home-location{font-size:12px;margin:8px 0 0;color:#fffdf6}.home-cover-placeholder{position:absolute;top:88px;right:22px;opacity:.3;font:18px var(--serif);letter-spacing:5px}.home-card-body{padding:24px}.home-card-body .household-actions{margin-bottom:0}.cover-editor img{width:100%;max-height:230px;object-fit:contain;border:1px solid var(--line);margin-bottom:12px;background:var(--paper)}#page-settings h3{font-size:21px;margin-top:8px}#page-settings .form-grid{margin:22px 0}#page-settings input:not([type=checkbox]),#page-settings select{width:100%;min-width:0}.brand-image-grid{display:grid;grid-template-columns:1fr 1fr;gap:24px;margin:28px 0}.brand-image-grid>div{border:1px solid var(--line);padding:18px;border-radius:6px;min-width:0}.brand-image-grid img{width:80px;height:80px;object-fit:contain;background:var(--paper);border-radius:6px;display:block;margin-bottom:18px}.brand-image-grid label{display:grid;gap:12px;margin-bottom:14px}.config-import{font-size:12px;max-width:300px}.backup-row{display:grid;gap:8px;padding:18px 0;border-bottom:1px solid var(--line);font-size:12px}.backup-row small,.backup-row code{overflow-wrap:anywhere}.backup-row span{color:var(--muted)}#settings-error,#brand-status,#preferences-status,#backup-save-status,#backup-result{line-height:1.8;font-size:13px;overflow-wrap:anywhere}.brand #brand-name{overflow-wrap:anywhere;letter-spacing:1px}.brand #brand-subtitle{overflow-wrap:anywhere;line-height:1.8;letter-spacing:1px}html[data-backdrop=plain] body{background-image:none}html[data-backdrop=plain] .courtyard-landscape{display:none}html[data-font=sans]{--serif:"Microsoft YaHei","PingFang SC",system-ui,sans-serif}html[data-density=compact] main{padding:20px 26px}html[data-density=compact] main>header{min-height:100px;padding:6px 0 15px;margin-bottom:20px}html[data-density=compact] .panel,html[data-density=compact] .site-card:not(.home-card),html[data-density=compact] .home-card-body{padding:17px}html[data-density=compact] .sidebar nav button{padding:9px 12px}html[data-density=compact] .steward-tile{min-height:150px;padding:20px}html[data-density=compact] .metrics>div{padding:13px 18px}html[data-density=compact] .home-cover,html[data-density=compact] .home-cover-content{min-height:180px}html[data-theme=clean]{--paper:#f3f6fa;--ink:#203349;--muted:#53667d;--panel:#ffffff;--line:#d2dce7;--accent:#285ca0;--gold:#52657f;--cinnabar:#386ea8;--timeline-paper:#edf2f8;--timeline-grid:#cbd6e4;--timeline-range:#4c72a5;--surface-alt:#e8eff8;--side:#1e3551;--on-accent:#ffffff;color-scheme:light}html[data-theme=ink]{--paper:#151d22;--ink:#e3e9e5;--muted:#afbdb5;--panel:#202c32;--line:#46565a;--accent:#a2cab4;--gold:#d6bd83;--cinnabar:#e0a390;--timeline-paper:#26343b;--timeline-grid:#516369;--timeline-range:#91bda6;--surface-alt:#2a3940;--side:#132020;--on-accent:#13231c;color-scheme:dark}html[data-theme=clean] body,html[data-theme=ink] body{background-color:var(--paper);color:var(--ink)}html:is([data-theme=clean],[data-theme=ink]) .sidebar{background:var(--side);border-color:var(--line)}html:is([data-theme=clean],[data-theme=ink]) main>header{border-color:var(--line)}html:is([data-theme=clean],[data-theme=ink]) :is(.metrics,.panel,.site-card,.camera-card,.empty,.family-canvas-panel,.scan-chip,dialog){background-color:var(--panel);border-color:var(--line);color:var(--ink)}html:is([data-theme=clean],[data-theme=ink]) :is(.household-context,.wall-toolbar,.device-table th,.family-view-tabs,.family-map-viewport,#preset-confirmation){background-color:var(--surface-alt);color:var(--ink);border-color:var(--line)}html:is([data-theme=clean],[data-theme=ink]) :is(input,select,textarea){background:var(--panel);border-color:var(--line);color:var(--ink)}html:is([data-theme=clean],[data-theme=ink]) :is(input,textarea)::placeholder{color:var(--muted)}html:is([data-theme=clean],[data-theme=ink]) :is(label,header p,.header-status,.metrics span,.filter-row,.section-head small,.camera-meta p,.empty,.time-labels,.recording-item small,.device-table td small,.site-card dt,.audit-item,.audit-item small,footer,#auth-form p,.family-date legend){color:var(--muted)}html:is([data-theme=clean],[data-theme=ink]) :is(.metrics strong,.empty h3,.site-card dd){color:var(--ink)}html:is([data-theme=clean],[data-theme=ink]) button:not(.quiet):not(.secondary):not(.device-title):not(.steward-tile),html:is([data-theme=clean],[data-theme=ink]) .button{background:var(--accent);color:var(--on-accent)}html:is([data-theme=clean],[data-theme=ink]) :is(.quiet,.secondary,.recording-item,.camera-actions .quiet){background:var(--surface-alt);color:var(--ink);border-color:var(--line)}html:is([data-theme=clean],[data-theme=ink]) .sidebar nav button{background:transparent;color:#dbe5e4}html:is([data-theme=clean],[data-theme=ink]) .sidebar nav button.active{background:var(--accent);color:var(--on-accent);border-color:var(--accent)}html:is([data-theme=clean],[data-theme=ink]) .sidebar>.quiet{background:transparent;color:#dbe5e4}html:is([data-theme=clean],[data-theme=ink]) #auth-dialog{background-image:none;background-color:var(--panel)}html:is([data-theme=clean],[data-theme=ink]) .device-table tbody tr:hover{background:var(--surface-alt)}html:is([data-theme=clean],[data-theme=ink]) .family-node{background:var(--panel);border-color:var(--line);color:var(--ink)}html:is([data-theme=clean],[data-theme=ink]) .family-node.self{background:#ebd6aa;color:#2b3b30;border-color:#b79a59}html:is([data-theme=clean],[data-theme=ink]) .family-node.self :is(small,span,strong){color:#2b3b30}html[data-theme=ink] :is(.form-error,.family-warning){color:#ffc8b6}html[data-theme=ink] .ptz-panel{background:var(--panel);color:var(--ink);border-color:var(--line)}html[data-theme=ink] .home-cover .quiet{background:#172a25df;color:#fff}html[data-theme=ink] body{background-image:radial-gradient(ellipse at 90% 0,#263c3340,transparent 65%)}@media(min-width:761px){html[data-layout=top] .sidebar{position:relative;width:100%;padding:16px 30px;display:flex;align-items:center;flex-wrap:wrap;gap:12px 22px;min-height:0;height:auto;border-right:0;border-bottom:1px solid var(--line)}html[data-layout=top] .sidebar .brand{padding:0;max-width:250px}html[data-layout=top] .sidebar>.nav-label,html[data-layout=top] .side-note{display:none}html[data-layout=top] .sidebar nav{display:flex;flex:1;flex-wrap:wrap;min-width:250px;gap:6px}html[data-layout=top] #scope-navigation{display:flex;flex-wrap:wrap;width:100%;order:1;margin:0;padding:0;border:0}html[data-layout=top] #scope-navigation .nav-label{display:none}html[data-layout=top] .sidebar #current-user{margin:0;padding:0;border:0}html[data-layout=top] .sidebar>.quiet{margin:0}html[data-layout=top] main{margin-right:auto;margin-left:auto}html[data-layout=top] .sidebar nav button{width:auto;white-space:nowrap}}@media(max-width:760px){.brand-image-grid{grid-template-columns:1fr}.home-cover-content,.home-card-body{padding:20px}.home-cover-placeholder{font-size:15px}.sidebar #logout{display:block}#page-settings .form-grid{grid-template-columns:1fr}html[data-density=compact] main{padding:18px 14px}#household-form .form-grid{grid-template-columns:1fr}.home-city-group>h3 small{display:block;margin:8px 0}}.journal-feed{max-width:1080px;margin:0 auto}.journal-compose textarea{resize:vertical;min-height:130px}.journal-compose>label{display:grid;gap:12px}.journal-add-media,.journal-reactions{display:flex;flex-wrap:wrap;gap:12px;margin:20px 0}.journal-add-media>label{display:flex;align-items:center;gap:10px;flex-wrap:wrap}.journal-add-media input{max-width:260px}.journal-filters{display:flex;align-items:end;flex-wrap:wrap;gap:16px}.journal-filters label{flex:1;min-width:145px;display:grid;gap:7px}.journal-entry{border-left:3px solid #a98964;margin-bottom:26px}.journal-entry .section-head small{display:block;color:var(--muted);margin-top:6px}.journal-text{white-space:pre-wrap;overflow-wrap:anywhere;line-height:1.95;font-size:17px}.journal-author{font-size:20px!important;font-family:serif}.journal-media{display:grid;grid-template-columns:repeat(auto-fit,minmax(min(100%,240px),1fr));gap:14px}.journal-media figure{margin:0;min-width:0}.journal-media img,.journal-media video{width:100%;max-height:450px;object-fit:contain;border-radius:8px;background:#1a2925}.journal-media audio{width:100%;max-width:100%}.journal-media figcaption{font-size:13px;overflow-wrap:anywhere;margin-top:6px}.journal-image-load{width:100%;min-height:150px;background:#e9eee2!important}.journal-upload{display:flex;align-items:center;justify-content:space-between;gap:10px;flex-wrap:wrap;border-bottom:1px solid #d9d7c8;padding:12px 0}.journal-upload label{flex:1;overflow-wrap:anywhere}.journal-upload small{display:block}.journal-upload input[type=checkbox]{width:auto}.journal-resume input{max-width:220px}.journal-comments{border-top:1px solid #d9d7c8;padding-top:15px}.journal-comments form{display:flex;align-items:end;gap:12px;flex-wrap:wrap}.journal-comments form label{flex:1;min-width:170px}.journal-comment{padding:10px 0;border-bottom:1px dashed #d9d7c8;overflow-wrap:anywhere}.journal-comment small{font-size:11px;color:var(--muted)}.journal-reactions [aria-pressed=true]{color:#ad5842!important}.journal-comments .quiet{padding:4px 8px;font-size:12px}.journal-feed .panel{overflow:hidden}html[data-theme=ink] .journal-image-load{background:#293f37!important}.journal-upload-grid{display:grid;grid-template-columns:repeat(auto-fill,minmax(min(100%,280px),1fr));gap:18px;margin:20px 0}.journal-upload-card{border:1px solid var(--line,#d9d7c8);border-radius:12px;padding:16px;background:var(--surface,#fffdf8);min-width:0;display:flex;flex-direction:column;gap:14px}.journal-upload-card:has(input:checked){border-color:#456f5f;box-shadow:0 0 0 1px #456f5f}.journal-upload-select{display:flex!important;align-items:flex-start;gap:10px;overflow-wrap:anywhere;line-height:1.5}.journal-upload-select input[type=checkbox]{width:18px;min-width:18px;height:18px;margin-top:3px;accent-color:#315a4e}.journal-upload-select small{display:block;font-size:12px;color:var(--muted);margin-top:4px}.journal-card-actions{display:flex;align-items:center;flex-wrap:wrap;gap:10px;margin-top:auto}.journal-card-actions button{padding:8px 13px;font-size:13px}.journal-card-actions [data-remove-upload]{margin-left:auto;color:#954f40}.journal-card-actions a,.journal-media-caption a{font-size:13px;color:var(--accent,#315a4e)}.journal-attachment{margin:0;min-width:0}.journal-photo{display:block;position:relative;width:100%;padding:0!important;border:0!important;background:#e6e9df!important;border-radius:9px;overflow:hidden;color:#fff!important}.journal-photo img{display:block;width:100%;min-height:120px;max-height:450px;object-fit:contain;aspect-ratio:16/10;background:#e6e9df;border-radius:9px}.journal-photo-hint{position:absolute;right:10px;bottom:10px;padding:4px 9px;background:#213a30c9;border-radius:5px;font-size:12px}.journal-upload-card .journal-photo img{height:180px;min-height:0;object-fit:cover}.journal-attachment video{width:100%;max-height:450px;border-radius:8px;background:#1a2925}.journal-upload-card video{height:180px}.journal-attachment audio{width:100%;max-width:100%}.journal-audio{background:#e9eee5;border:1px solid #d5decd;border-radius:10px;padding:14px}.journal-audio-label{display:flex;align-items:center;gap:10px;color:#42614f;font-size:13px;letter-spacing:1px;margin:0 0 14px}.journal-audio-label span{font-size:28px}.journal-media-state{display:block;font-size:12px;color:var(--muted);padding-top:6px;min-height:0}.journal-media-state:empty{display:none}.journal-media-caption{font-size:12px;color:var(--muted);overflow-wrap:anywhere;margin:8px 0 16px}.journal-trash{padding:12px 0;border-top:1px solid #d9d7c8}.journal-trash-row{display:flex;align-items:center;gap:15px;justify-content:space-between;padding:10px 0;border-bottom:1px solid #d9d7c8;overflow-wrap:anywhere}.journal-preview{width:min(960px,94vw);max-width:94vw;padding:24px;max-height:94vh}.journal-preview header,.journal-preview footer{display:flex;align-items:center;justify-content:space-between;gap:18px;position:static}.journal-preview header{margin-bottom:20px}.journal-preview h2{font-size:22px;overflow-wrap:anywhere;margin:0}.journal-preview footer{font-size:13px;margin-top:18px}.journal-preview .journal-photo img{max-height:65vh;min-height:0;aspect-ratio:auto}.journal-preview .journal-photo{pointer-events:none}.journal-preview .journal-photo-hint{display:none}.journal-preview video{max-height:65vh}html[data-theme=ink] .journal-upload-card{background:#20352d}html[data-theme=ink] .journal-audio{background:#293f37;border-color:#436152}html[data-theme=ink] .journal-audio-label{color:#d5e2ce}@media(max-width:600px){.journal-upload-grid{grid-template-columns:1fr}.journal-preview{padding:16px}.journal-preview h2{font-size:17px}.journal-preview header button{flex-shrink:0}.journal-media{grid-template-columns:1fr}}@media(max-width:760px){.sidebar{display:grid;grid-template-columns:minmax(0,1fr) auto;gap:12px;align-items:center;padding:14px 16px;height:auto;min-height:0}.sidebar .brand{min-width:0;padding:0;gap:10px}.sidebar .brand>span{min-width:0}.sidebar #brand-name{font-size:23px;display:block;overflow:hidden;text-overflow:ellipsis;white-space:nowrap}.sidebar .brand-icon{width:38px;height:44px}.sidebar #brand-subtitle{font-size:11px;letter-spacing:1px}.sidebar .mobile-nav-toggle{display:block;margin:0;min-height:44px;color:#f7f3e5;border-color:#8faaa0;padding:9px 14px}.sidebar:not(.mobile-open)>nav,.sidebar:not(.mobile-open)>#current-user,.sidebar:not(.mobile-open)>#account-password,.sidebar:not(.mobile-open)>#logout{display:none}.sidebar>nav,.sidebar>#current-user{grid-column:1/-1}.sidebar.mobile-open>nav{display:grid;grid-template-columns:1fr 1fr;gap:6px;margin:0;padding:8px 0 0}.sidebar #scope-navigation{display:contents}.sidebar #scope-navigation[hidden]{display:none}.sidebar nav button{width:100%;text-align:left;min-height:44px;white-space:normal;margin:0;font-size:14px}.sidebar.mobile-open>#current-user{margin:0;padding:12px 0 0}.sidebar.mobile-open>#account-password,.sidebar.mobile-open>#logout{display:block;min-height:44px;margin:0}main{padding:22px 16px}main>header{margin-bottom:22px}.header-status #clock{display:none}input:not([type=checkbox]):not([type=radio]):not([type=range]),select,textarea{font-size:16px!important;min-height:44px}button,.button{min-height:44px;touch-action:manipulation}.form-grid{grid-template-columns:1fr}.form-grid>*{min-width:0}.form-grid .wide{grid-column:1/-1}.section-head{flex-wrap:wrap;gap:12px}.section-head>div{max-width:100%}.section-head button{white-space:normal}.household-context{gap:10px;padding:12px}.household-context label{width:100%;display:flex;flex-wrap:wrap}.household-context select{flex:1;min-width:0}.household-context #household-context-note{display:none}.filter-row{gap:10px;flex-wrap:wrap}.filter-row label{width:100%;display:grid;grid-template-columns:1fr}.filter-row select{width:100%}.settings-sections,.view-presets{gap:8px}.settings-sections button,.view-presets button{flex:1 1 100px;white-space:normal}.device-actions,.device-search-row{gap:10px}.device-search-row{display:grid;grid-template-columns:1fr}dialog{width:calc(100% - 24px);max-width:calc(100% - 24px);max-height:90vh;max-height:90dvh;padding:18px;overscroll-behavior:contain}dialog header,dialog .dialog-heading{gap:12px;align-items:flex-start}dialog h2{font-size:22px}dialog footer{flex-wrap:wrap}.journal-compose,.journal-entry{padding:18px}.journal-filters{gap:12px}.journal-filters label{flex-basis:100%;min-width:0}.journal-add-media input{max-width:100%;width:100%}.journal-add-media>label{width:100%}.journal-preview{padding:16px}.journal-preview .journal-photo img,.journal-preview video{max-height:60vh;max-height:60dvh}.journal-upload-card{padding:12px}.journal-media audio{min-width:0}.journal-comments form label{min-width:0;flex-basis:100%}.device-context [role=group]{display:flex;flex-wrap:wrap;gap:8px}.device-context button{flex:1 1 42%;white-space:normal}.metrics{margin-bottom:20px}}@media(max-width:760px){.sidebar .brand{grid-column:1;max-width:100%;width:auto}.sidebar>.mobile-nav-toggle{grid-column:2;grid-row:1;width:auto;max-width:110px}.sidebar .brand-icon{flex-shrink:0}.sidebar .brand>span{overflow:hidden}.sidebar #brand-name{font-size:21px}}.geo-picker{min-width:0;border:1px solid var(--line,#d8d2c3);border-radius:10px;padding:14px;margin:0}.geo-picker legend{padding:0 8px}.geo-picker .geo-path{display:block;overflow-wrap:anywhere;margin-top:10px;font-size:.9rem}.geo-picker .form-grid{min-width:0}.geo-picker input,.geo-picker select{width:100%;min-width:0}#household-cover-status[data-error=true]{color:#ad3c28;font-weight:600}#household-cover-preview{max-width:100%;max-height:240px;object-fit:contain}.home-layout-controls{padding:16px 20px}.home-layout-controls .device-actions{align-items:end;flex-wrap:wrap}.home-layout-controls label{margin:0;min-width:90px}.home-layout-controls label.check{min-width:0;align-self:center}.home-card-grid{display:grid;grid-template-columns:repeat(var(--home-columns,2),minmax(0,1fr));gap:20px;align-items:start}.home-card-grid .home-card{min-width:0}.home-card-grid .home-card-body{padding:18px}.home-card-grid .home-cover-content{min-height:190px;padding:18px}.home-card-grid .home-cover{min-height:190px}.home-card-grid .home-card-body dl{margin:12px 0}.home-card-grid .home-card-body .description{font-size:13px}.home-card-grid .household-actions{display:flex;flex-wrap:wrap;gap:8px}.home-card-grid .household-actions button{font-size:13px;padding:10px 12px}.home-order-actions{display:flex;gap:8px;align-items:center;flex-wrap:wrap;margin-bottom:14px}.home-order-actions span{font-size:12px;color:var(--muted)}.home-order-actions button{font-size:12px;padding:8px}.home-card[draggable=true]{cursor:grab;outline:1px dashed var(--accent);outline-offset:3px}.home-pagination{display:flex;gap:18px;justify-content:center;align-items:center;margin:24px 0;flex-wrap:wrap}.home-pagination span{font-size:13px;color:var(--muted)}@media(max-width:1100px){.home-card-grid{grid-template-columns:repeat(min(var(--home-columns,2),2),minmax(0,1fr))}}@media(max-width:650px){.home-card-grid{grid-template-columns:minmax(0,1fr)}.home-layout-controls{padding:12px}.home-layout-controls .device-actions{gap:10px}.home-layout-controls button{padding:10px 12px}.home-pagination{gap:10px}.home-card-grid .home-cover-content{padding:16px}}.device-network{min-width:0;border:1px solid var(--line);padding:16px}.device-network legend{padding:0 8px}.topology-tree,.topology-tree ul{list-style:none;padding:0;margin:20px 0}.topology-tree ul{margin-left:24px;padding-left:24px;border-left:2px solid var(--accent,#31584a)}.topology-tree li{position:relative;margin:18px 0;min-width:0}.topology-tree ul>li:before{content:"";position:absolute;left:-24px;top:28px;width:24px;border-top:2px solid var(--accent,#31584a)}.topology-node{border:1px solid var(--line);border-radius:10px;padding:20px;background:var(--paper);max-width:800px;overflow-wrap:anywhere}.topology-node h3{margin:12px 0}.topology-node dl{display:grid;gap:8px}.topology-node dl>div{display:grid;grid-template-columns:100px minmax(0,1fr);gap:10px}.topology-node dd{margin:0}.topology-node dt,.topology-node p{font-size:13px;color:var(--muted)}.topology-node .device-title{text-align:left}@media(max-width:650px){.topology-tree ul{margin-left:8px;padding-left:12px}.topology-tree ul>li:before{left:-12px;width:12px}.topology-node{padding:14px}.topology-node dl>div{grid-template-columns:72px minmax(0,1fr)}.device-network .form-grid{grid-template-columns:1fr}}.platform-topology-root{border:1px solid var(--line);border-top:4px solid var(--accent,#31584a);background:var(--paper);padding:22px;text-align:center;margin:24px auto;max-width:420px;border-radius:10px}.platform-place-grid{display:grid;grid-template-columns:repeat(auto-fit,minmax(min(100%,260px),1fr));gap:24px;border-top:2px solid var(--line);padding-top:24px}.platform-place-node{position:relative;text-align:left;white-space:normal;min-width:0;border:1px solid var(--line);border-radius:10px;background:var(--paper);color:var(--text);padding:22px}.platform-place-node:before{position:absolute;content:"";height:25px;top:-25px;left:50%;border-left:2px solid var(--line)}.platform-place-node h3{margin:16px 0}.platform-place-node p,.platform-place-node small{color:var(--muted)}.platform-place-node>span:last-child{display:block;margin-top:18px}.platform-place-node:hover{border-color:var(--accent,#31584a);background:var(--surface,#f1f2e9)}.topology-tree{display:flex;gap:24px;align-items:start;flex-wrap:wrap}.topology-tree>li{flex:1 1 400px}.topology-tree ul{display:flex;gap:16px;flex-wrap:wrap}.topology-tree ul>li{flex:1 1 260px;max-width:560px}.topology-node{max-width:560px;padding:16px}.device-actions #devices-card-view[aria-pressed=true],.device-actions #devices-topology-view[aria-pressed=true],.device-actions #home-card-view[aria-pressed=true],.device-actions #home-topology-view[aria-pressed=true]{background:var(--accent,#31584a);color:#fff}.home-card-grid[hidden],.home-layout-controls[hidden],.home-pagination[hidden]{display:none!important}:root{--bs-primary: #28624f;--bs-primary-rgb: 40, 98, 79;--bs-body-color: #263f36;--bs-body-bg: #f4f6f4;--bs-border-color: #dde4df;--bs-border-radius: .65rem;--ui-surface: #fff;--ui-muted: #67776d;--ui-line: #dfe6e1;--ui-sidebar: #193c32;--ui-accent: #28624f;--ui-bg: #f4f6f4;--ink: #263f36;--muted: #67776d;--paper: #fff;--line: #dfe6e1;--green: #28624f;--green-dark: #193c32;--cream: #f4f6f4}html,body{min-width:320px;margin:0;background:var(--ui-bg)!important;color:var(--ink);font-family:Inter,Segoe UI,Microsoft YaHei,system-ui,sans-serif;font-size:14px;line-height:1.65}body{display:block!important;background-image:none!important}body:before,body:after{display:none!important}#app{min-height:100vh;display:grid;grid-template-columns:232px minmax(0,1fr)}*,*:before,*:after{box-sizing:border-box}[hidden]{display:none!important}button,input,select,textarea{font:inherit}button,a,input,select,textarea{touch-action:manipulation}button{letter-spacing:0!important}.app-icon{width:20px;height:20px;flex:0 0 20px;vertical-align:middle}.btn .app-icon{width:17px;height:17px}.sidebar{width:232px!important;position:fixed!important;inset:0 auto 0 0;z-index:20;background:var(--ui-sidebar)!important;color:#e6f0eb;padding:28px 18px 20px!important;display:flex;flex-direction:column;height:100dvh;overflow:auto;border:0!important;box-shadow:none!important}.brand{padding:0 6px 24px!important;gap:12px;text-decoration:none;color:#fff!important;border-bottom:1px solid #ffffff14!important;margin:0 0 24px!important;display:flex;align-items:center}.brand-icon{width:42px!important;height:42px!important;object-fit:contain;border-radius:10px}.brand>span>span{font-size:22px!important;line-height:1.2;letter-spacing:2px}.brand small{font-size:11px!important;letter-spacing:1px;color:#acc4b8!important;margin-top:6px;display:block}.nav-label{font-size:10px!important;letter-spacing:2px;padding:0 12px;margin-bottom:12px;color:#95b5a6!important}.sidebar nav{display:flex!important;flex-direction:column!important;gap:5px}.sidebar nav button{display:flex;gap:12px;align-items:center;text-align:left;width:100%;color:#c0d6c9!important;background:transparent!important;border:0!important;box-shadow:none!important;border-radius:8px!important;min-height:44px;padding:10px 13px!important;font-size:13px!important;white-space:normal}.sidebar nav button:hover{background:#ffffff0d!important;color:#fff!important}.sidebar nav button.active{background:#ffffffed!important;color:#234c3d!important;font-weight:600}.sidebar nav .app-icon{opacity:.85}#scope-navigation{border:0!important;padding:18px 0 10px!important;margin:7px 0!important;box-shadow:0 -1px #ffffff14,0 1px #ffffff14}#scope-nav-name{max-width:185px;white-space:nowrap;overflow:hidden;text-overflow:ellipsis;margin:0 0 12px}.side-note{margin-top:auto;padding:36px 12px 16px;font-size:10px;color:#9abbab}.side-note p{display:none}.sidebar #current-user{color:#c1d3c8!important;border-top:1px solid #ffffff18;padding-top:14px;font-size:11px;margin:0 0 8px}.sidebar>#account-password,.sidebar>#logout{border-color:#ffffff20!important;color:#c1d3c8!important;background:transparent!important;font-size:11px;min-height:32px;padding:5px;margin:4px 0}.mobile-nav-toggle{display:none}#app>main{grid-column:2;margin:0!important;padding:28px 34px 20px!important;width:100%;min-width:0;max-width:1800px;min-height:100vh;background:none!important}main>header{padding:0 0 24px!important;margin:0 0 24px!important;border-bottom:1px solid var(--ui-line)!important;display:flex;align-items:center;justify-content:space-between;gap:20px;min-height:0!important;background:none!important;position:relative}main>header:after,main>header:before{display:none!important}.eyebrow{font-size:10px;letter-spacing:2px;color:var(--ui-muted)!important;margin-bottom:7px}h1,#page-title{font-family:inherit!important;font-size:26px!important;font-weight:650!important;line-height:1.35;letter-spacing:-.5px!important;margin:0 0 7px!important}h2{font-size:19px!important;font-weight:600!important;line-height:1.45;letter-spacing:0!important;margin:0 0 5px!important}h3{font-size:16px!important;line-height:1.5;font-weight:600!important;letter-spacing:0!important}h2,h3,h4{font-family:inherit!important}#page-note{font-size:12px!important;color:var(--ui-muted);margin:0!important}.header-status{align-items:flex-end;gap:8px;font-size:10px!important;white-space:nowrap}#service-status{font-size:10px}#clock{color:var(--ui-muted);background:none!important;padding:0!important}#clock:before{display:none!important}.btn{border-radius:7px!important;min-height:36px;padding:7px 13px;font-size:12px;font-weight:500;box-shadow:none;line-height:1.65;display:inline-flex;align-items:center;justify-content:center;gap:5px;white-space:normal}.btn-primary{--bs-btn-bg: var(--ui-accent);--bs-btn-border-color: var(--ui-accent);--bs-btn-hover-bg: #1d4d3c;--bs-btn-hover-border-color: #1d4d3c;--bs-btn-disabled-bg: #80988d;--bs-btn-disabled-border-color: #80988d;--bs-btn-active-bg: #1d4d3c;--bs-btn-active-border-color: #1d4d3c;color:#fff!important}.btn-outline-secondary{--bs-btn-color: #54685d;--bs-btn-border-color: #d8e1da;--bs-btn-hover-bg: #edf3ee;--bs-btn-hover-border-color: #bacdc0;--bs-btn-hover-color: #264d3b;--bs-btn-active-bg: #e0ece4;--bs-btn-active-border-color: #a7c0ae;--bs-btn-active-color: #254e3b;--bs-btn-disabled-color: #9faea4;--bs-btn-disabled-border-color: #e0e5e2;background:transparent}.btn-sm{min-height:30px;padding:4px 9px;font-size:11px}.btn-link{color:var(--ui-accent);text-decoration:none;background:transparent;border:0}.btn-link:hover{text-decoration:underline}.btn:focus-visible,.form-control:focus,.form-select:focus{box-shadow:0 0 0 3px #28744c1c!important;outline:0!important;border-color:#679b79}.btn-group>.btn{border-radius:0!important}.btn-group>.btn:first-child{border-radius:7px 0 0 7px!important}.btn-group>.btn:last-child{border-radius:0 7px 7px 0!important}.form-control,.form-select{color:var(--ink);background-color:var(--ui-surface);border:1px solid var(--ui-line);border-radius:7px!important;font-size:13px;padding:9px 12px;min-height:40px;max-width:100%;box-shadow:none}.form-select{padding-right:32px}.form-check-input{width:16px;height:16px;min-height:0;margin:0 6px 0 0;vertical-align:middle;flex:0 0 16px}.form-check-input:checked{background-color:var(--ui-accent);border-color:var(--ui-accent)}label{font-size:12px;color:#617367;gap:7px}.form-grid{gap:16px 20px!important}.form-grid label{min-width:0}.form-grid .full{grid-column:1/-1}textarea.form-control{min-height:100px}input[type=file]{font-size:12px;padding:8px;overflow:hidden}input[type=range]{max-width:100%}fieldset{border:1px solid var(--ui-line)!important;border-radius:9px;padding:14px!important}legend{float:none;width:auto;padding:0 6px;font-size:12px}.description,.hint{font-size:12px!important;line-height:1.8!important;color:var(--ui-muted)!important}p{overflow-wrap:anywhere}code{color:#3b6755;font-size:12px}.table{font-size:12px;--bs-table-bg: transparent}.table td,.table th{padding:12px!important;border-color:var(--ui-line)}.table-wrap{overflow:auto;border-radius:8px;border:1px solid var(--ui-line)}.panel,.site-card,.card,.camera-card,.person-card{background:var(--ui-surface)!important;border:1px solid var(--ui-line)!important;border-radius:11px!important;box-shadow:0 3px 12px #193c3204!important;overflow:hidden}.panel{padding:22px!important;margin-bottom:18px}.site-card{padding:22px!important}.card-body{padding:20px}.card-footer{background:transparent;border-top:1px solid var(--ui-line);padding:12px 18px}.section-head{display:flex;align-items:center;justify-content:space-between;gap:16px;margin-bottom:18px!important}.section-head h2 small,.section-head h3 small{display:none}.badge{font-size:10px;line-height:1.4;font-weight:500!important;letter-spacing:0!important;background:#edf4ee!important;color:#3c7056!important;border:1px solid #d6e6d9!important;border-radius:5px!important;padding:5px 8px!important}.badge.off{background:#f7eeea!important;border-color:#ecd9d0!important;color:#a66044!important}.count-pill{display:inline-block;padding:2px 7px;background:#e6ede8;color:#4b705b;border-radius:5px;font-size:11px;vertical-align:middle;margin-left:7px}.group-title{font-size:13px!important;color:#6a7c70;margin:24px 0 12px!important;display:flex;gap:5px;align-items:center}.site-heading{display:flex;align-items:center;justify-content:space-between;gap:12px}.household-context{padding:12px 16px!important;border-radius:9px!important;background:#eaf0eb!important;border:1px solid var(--ui-line);gap:12px;display:flex;align-items:center;flex-wrap:wrap;margin-bottom:18px!important}.household-context label{display:flex;align-items:center;gap:10px;margin:0}.household-context select{width:auto;max-width:260px;min-height:34px;padding-top:6px;padding-bottom:6px}.household-context span{font-size:11px;color:var(--ui-muted)}#scope-back{margin-left:auto}.device-context{border-radius:9px;background:#eaf0eb!important;padding:16px!important;margin-bottom:18px}.device-context p{font-size:12px;margin:0 0 10px}.device-context .btn.active{background:var(--ui-accent)!important;color:#fff!important}.filter-row{display:flex;align-items:center;gap:12px;flex-wrap:wrap;margin:0 0 18px;padding:0!important;font-size:12px}.filter-row label{display:flex;align-items:center;gap:8px;margin:0}.filter-row select{width:180px}.filter-row>button{margin-left:auto}.metrics{display:grid;grid-template-columns:repeat(4,minmax(0,1fr));gap:14px;margin:0 0 22px!important;padding:0!important;background:none!important;border:0!important}.metrics>div{background:var(--ui-surface);border:1px solid var(--ui-line);border-radius:9px;padding:14px 18px!important;display:flex;justify-content:space-between;align-items:center;border-right:1px solid var(--ui-line)!important}.metrics span{font-size:11px;color:var(--ui-muted)}.metrics strong{font-family:inherit;font-size:23px!important;font-weight:600;color:var(--ui-accent)}.home-toolbar{display:flex;gap:16px;flex-wrap:wrap;align-items:center;padding:13px 0;margin:0 0 7px;border-top:1px solid var(--ui-line);border-bottom:1px solid var(--ui-line)}.home-layout-controls{display:flex;align-items:center;gap:10px;flex-wrap:wrap;margin-left:auto}.home-layout-controls label{display:flex;align-items:center;gap:7px;margin:0}.home-layout-controls select{width:80px!important;min-height:34px;padding-top:5px;padding-bottom:5px}.home-layout-controls>.form-select{width:80px!important}.inline-check{white-space:nowrap;font-size:11px}#home-layout-status{margin-bottom:18px;font-size:11px!important}.home-card-grid{display:grid!important;grid-template-columns:repeat(var(--home-columns, 2),minmax(0,1fr));gap:20px!important}.home-city-group{display:block}.home-card{padding:0!important;margin:0!important;min-width:0;align-self:start}.home-cover{position:relative;height:178px!important;min-height:178px!important;background:linear-gradient(135deg,#567d65,#203e36)!important;overflow:hidden}.home-cover img{position:absolute;inset:0;width:100%;height:100%;object-fit:cover}.cover-shade{position:absolute;inset:0;background:linear-gradient(180deg,#132e2430 10%,#0e261ccc)}.home-cover-content{position:relative;z-index:1;height:100%;padding:17px 20px!important;display:flex;flex-direction:column;justify-content:space-between;background:none!important}.home-cover-content h3{font-family:inherit!important;font-size:21px!important;color:#fff!important;margin:0 0 6px!important;letter-spacing:0}.home-cover-content .badge{background:#ffffffd9!important;color:#244d3a!important;border-color:transparent!important;font-size:10px}.home-location{font-size:11px!important;color:#e8f0eb!important;line-height:1.6;margin:0!important}.cover-edit{color:#fff!important;background:#213e3670!important;border:1px solid #ffffff60!important;backdrop-filter:blur(8px)}.home-summary{font-size:12px;color:var(--ui-muted);margin-bottom:15px;min-height:20px}.home-numbers{display:grid;grid-template-columns:repeat(3,1fr);gap:12px;padding:0 0 17px;border-bottom:1px solid var(--ui-line);margin-bottom:13px}.home-numbers span{display:flex;align-items:baseline;gap:7px;color:var(--ui-muted);font-size:11px}.home-numbers b{font-size:21px;font-weight:600;color:var(--ink)}.compact-details{margin:0!important;display:grid;gap:7px!important;font-size:12px}.compact-details>div{display:grid;grid-template-columns:100px minmax(0,1fr);gap:12px!important;padding:0!important}.compact-details dt{font-weight:400;color:var(--ui-muted)}.compact-details dd{margin:0;overflow-wrap:anywhere;color:var(--ink)}.home-card-actions{display:flex;flex-wrap:wrap;gap:8px;margin-top:17px;padding-top:14px;border-top:1px solid var(--ui-line)}.home-card-actions .btn-primary{flex:1}.home-order-actions{display:flex;align-items:center;gap:5px;margin-bottom:12px}.home-order-actions span{font-size:10px;flex:1}.home-pagination{display:flex;justify-content:flex-end;align-items:center;gap:10px;margin:22px 0}.home-pagination span{margin-right:auto;font-size:11px;color:var(--ui-muted)}.device-card-grid{display:grid;grid-template-columns:repeat(auto-fill,minmax(min(100%,330px),1fr));gap:18px}.device-card{min-width:0}.device-card-heading{display:flex;align-items:center;gap:12px;margin-bottom:15px}.device-symbol{width:42px;height:42px;border-radius:10px;background:#eaf2ec;color:var(--ui-accent);display:grid;place-items:center}.device-symbol .app-icon{width:23px;height:23px}.device-card-heading h3{margin:0!important;font-size:16px!important}.device-title{padding:0!important;border:0!important;background:none!important;text-align:left!important;min-height:0!important;color:var(--ink)!important;font-weight:600!important;font-size:16px!important;box-shadow:none!important}.device-title:hover{color:var(--ui-accent)!important;text-decoration:underline}.device-location{font-size:11px;color:var(--ui-muted);margin-bottom:15px}.device-card-actions{display:flex;flex-wrap:wrap;gap:8px}.device-tags{display:flex;flex-wrap:wrap;gap:5px;margin:12px 0 0}.device-tags span{background:#edf1ee;font-size:10px;color:#667e6d;padding:2px 8px;border-radius:4px}.device-view-controls{display:flex;flex-wrap:wrap;gap:12px}.device-view-controls label{display:flex;align-items:center;gap:9px}.group-custom{font-size:12px}.group-step{max-width:100%}.group-step select{max-width:200px}.view-presets{display:flex;gap:6px;flex-wrap:wrap}#device-count{font-size:11px!important}.device-group:first-child>.group-title{margin-top:4px!important}#asset-list .empty{min-height:160px}.device-tags+.network-status-block{margin-top:12px}.network-status-block{padding-top:12px;margin-top:14px;border-top:1px solid var(--ui-line);font-size:11px}.network-status-title{display:flex;align-items:center;justify-content:space-between;gap:8px;margin-bottom:6px}.network-status-title>span{font-weight:600}.status-dot{width:7px;height:7px;border-radius:50%;background:#b4b9b5;display:inline-block;margin-right:6px}.status-dot.online{background:#37a06a;box-shadow:0 0 0 3px #38a16a12}.network-target{display:flex;align-items:center;flex-wrap:wrap;gap:7px;margin:4px 0}.network-target>span:first-child{width:65px;color:var(--ui-muted)}.network-target code{font-size:11px}.network-target>span:last-child{margin-left:auto;font-size:10px}.network-status-block p{margin:6px 0;font-size:11px!important}.management-links{display:flex;gap:6px;flex-wrap:wrap;margin:9px 0}.network-check-time{font-size:10px;color:#8b9c90;line-height:1.5;display:block}.network-platform{display:flex;align-items:center;gap:15px;background:#edf3ee;border:1px solid #d6e4d9;padding:20px;border-radius:10px;margin-bottom:16px}.network-platform>.app-icon{width:32px;height:32px;flex-basis:32px;color:var(--ui-accent)}.network-platform h3{margin:0 0 3px!important;font-size:18px!important}.network-platform p{margin:0;font-size:11px;color:var(--ui-muted)}.platform-place-grid{display:grid;grid-template-columns:repeat(auto-fill,minmax(min(100%,260px),1fr));gap:18px}.platform-place-node{display:flex!important;flex-direction:column;align-items:flex-start!important;text-align:left!important;padding:20px!important;gap:9px;border:1px solid var(--ui-line)!important;position:relative;color:var(--ink)!important}.platform-place-node:hover{border-color:#81ad90!important;box-shadow:0 4px 16px #2d4b3610!important}.platform-place-node h3{font-size:17px!important;margin:3px 0}.platform-place-node p,.platform-place-node small{font-size:11px;color:var(--ui-muted);margin:0}.network-open{padding-top:12px;margin-top:auto;color:var(--ui-accent);font-size:11px}.network-node{margin:0 0 14px calc(var(--depth) * 22px);overflow:visible!important;position:relative}.network-node.nested:before{position:absolute;content:"";border-left:2px solid #c1d3c6;border-bottom:2px solid #c1d3c6;width:15px;left:-17px;top:-15px;height:50px;border-bottom-left-radius:6px}.network-node .card-body{padding:18px}.network-node .device-card-heading{margin-bottom:9px}.network-facts{display:flex;flex-wrap:wrap;gap:8px 24px;font-size:11px;color:var(--ui-muted)}.network-facts b{font-weight:500;color:var(--ink);margin-left:7px;overflow-wrap:anywhere}.network-map{overflow:hidden}.network-map .network-platform{max-width:none}.network-overview{margin-top:18px}.scope-intro{padding:0!important;margin-bottom:24px!important}.scope-intro h2{font-size:24px!important}.scope-intro p{font-size:13px!important;color:var(--ui-muted)}.steward-grid{display:grid;grid-template-columns:repeat(auto-fit,minmax(min(100%,300px),1fr));gap:18px}.steward-tile{padding:22px!important;min-height:160px!important;background:var(--ui-surface)!important;border:1px solid var(--ui-line)!important;border-radius:10px!important;text-align:left!important;display:flex;align-items:flex-start!important;flex-direction:column;justify-content:flex-start!important;gap:10px;color:var(--ink)!important;box-shadow:none!important}.steward-tile:before{display:none!important}.steward-tile:hover{border-color:#8caf99!important;background:#f9fcf9!important;transform:translateY(-1px)}.steward-tile strong{font-family:inherit!important;font-size:19px!important;font-weight:600!important}.steward-tile span{font-size:12px!important}.steward-tile small{font-size:11px!important;color:var(--ui-muted);line-height:1.8}.camera-meta{padding:16px!important}.camera-meta strong{font-size:14px!important}.camera-meta p{font-size:11px!important;margin:4px 0!important}.camera-actions{padding:0 16px 16px;display:flex;flex-wrap:wrap;gap:7px}.camera-card{background:var(--ui-surface)!important}.live-grid{gap:18px}.video-panel{background:#152720!important}.video-error{font-size:12px}.video-empty{color:#9bad9f}.wall-toolbar{padding:12px!important;border-radius:9px;gap:10px}.wall-toolbar label{font-size:11px}.wall-toolbar select{width:auto}#live-stage:fullscreen{background:#101c17}.wall-fullscreen .camera-card{border-color:#284336!important}.playback-panel{background:var(--ui-surface)!important}.settings-sections{display:flex;gap:7px;flex-wrap:wrap;margin-bottom:20px}.settings-sections .btn[aria-pressed=true]{background:var(--ui-accent)!important;color:#fff!important}.journal-card{max-width:100%!important;background:var(--ui-surface)!important;border-radius:11px!important;padding:22px!important;border:1px solid var(--ui-line)!important}.journal-attachments{gap:14px}.journal-attachments img{border-radius:8px}.journal-media-library{max-width:100%}.journal-pager{font-size:12px}.family-toolbar{flex-wrap:wrap}.family-card,.person-card{padding:16px}.family-detail h2{font-size:20px!important}dialog{max-width:min(900px,calc(100vw - 32px))!important;width:800px;padding:26px!important;border:1px solid var(--ui-line)!important;border-radius:14px!important;background:var(--ui-surface)!important;color:var(--ink)!important;box-shadow:0 24px 80px #0f2d3d38!important;max-height:calc(100dvh - 48px);overflow:auto;margin:auto!important}dialog::backdrop{background:#10291e70;backdrop-filter:blur(3px)}dialog h2{font-size:21px!important}dialog .dialog-heading,dialog>header,dialog form>header{padding:0 0 18px!important;margin:0 0 20px!important;border-bottom:1px solid var(--ui-line);display:flex;align-items:center;justify-content:space-between;gap:15px;background:none}dialog form>.form-grid{margin-top:5px}dialog footer,dialog .dialog-actions{padding:18px 0 0!important;margin:20px 0 0!important;border-top:1px solid var(--ui-line);display:flex;justify-content:flex-end;gap:10px}#auth-dialog{width:420px!important;padding:32px!important}#auth-dialog h2{font-size:25px!important}#auth-dialog p{font-size:12px}#auth-form{display:grid;gap:15px}#auth-form label{margin:0}.form-error{font-size:12px;color:#b15a3c;min-height:0}#toast{position:fixed;bottom:24px;right:24px;z-index:200;background:#234c39!important;color:#fff!important;padding:12px 20px!important;border-radius:9px!important;font-size:13px!important;box-shadow:0 6px 22px #193c3226;max-width:calc(100vw - 32px)}main>footer{padding:22px 0 0!important;margin:30px 0 0!important;border-top:1px solid var(--ui-line);font-size:10px!important;color:var(--ui-muted)}.empty{border:1px dashed #cfdbd2;background:#f8faf8;border-radius:9px;color:var(--ui-muted);text-align:center;padding:40px 20px!important}.empty h3{margin-top:10px}.empty p{font-size:12px}.banner{padding:12px 16px;border-radius:8px;font-size:12px}html[data-theme=clean]{--ui-bg: #f4f6f9;--ui-accent: #31655b;--ui-surface: #fff}html[data-theme=ink]{--ui-bg: #14221e;--ui-surface: #1c2e26;--ui-line: #334a3e;--ui-muted: #a5baad;--ink: #e1ece5;--bs-body-color: #e1ece5;--bs-border-color: #334a3e;--ui-accent: #397359;--bs-secondary-color: #a5baad}html[data-theme=ink] .form-control,html[data-theme=ink] .form-select{background-color:#20352a;color:#e1ece5}html[data-theme=ink] .network-platform,html[data-theme=ink] .household-context,html[data-theme=ink] .device-context,html[data-theme=ink] .empty{background:#213d2d!important}html[data-theme=ink] .description,html[data-theme=ink] label{color:#a5baad!important}html[data-theme=ink] .btn-outline-secondary{color:#b9cec0;border-color:#476152}html[data-density=compact] #app>main{padding:20px 25px!important}html[data-density=compact] .panel,html[data-density=compact] .card-body{padding:15px!important}html[data-density=compact] .home-cover{height:150px!important;min-height:150px!important}html[data-layout=top] #app{display:block}html[data-layout=top] .sidebar{position:relative!important;width:100%!important;height:auto;padding:12px 24px!important;display:flex;flex-direction:row;flex-wrap:wrap;align-items:center;gap:12px}html[data-layout=top] .sidebar .brand{padding:0 15px 0 0!important;margin:0!important;border:0!important}html[data-layout=top] .sidebar>.nav-label,html[data-layout=top] .side-note,html[data-layout=top] #current-user,html[data-layout=top] #scope-nav-name{display:none}html[data-layout=top] .sidebar nav{flex-direction:row!important;flex:1;flex-wrap:wrap}html[data-layout=top] #scope-navigation{display:flex;padding:0!important;margin:0!important;box-shadow:none}html[data-layout=top] .sidebar nav button{width:auto!important;padding:8px 10px!important}html[data-layout=top] #app>main{margin:auto!important;max-width:1800px}@media(min-width:1500px){.home-card-grid[style]{gap:22px}}@media(max-width:1200px){#app>main{padding:24px!important}#app{grid-template-columns:210px minmax(0,1fr)}.sidebar{width:210px!important;padding:24px 14px!important}.home-toolbar{align-items:flex-start}.home-layout-controls{margin-left:0}.home-card-grid{grid-template-columns:repeat(min(var(--home-columns, 2),2),minmax(0,1fr))}.metrics>div{padding:12px!important}.metrics strong{font-size:19px!important}.compact-details>div{grid-template-columns:90px minmax(0,1fr)}}@media(max-width:767px){html,body{font-size:14px}#app{display:block!important}.sidebar,html[data-layout=top] .sidebar{position:relative!important;width:100%!important;height:auto!important;padding:13px 16px!important;display:grid!important;grid-template-columns:1fr auto!important;overflow:visible!important}.brand,html[data-layout=top] .sidebar .brand{padding:0!important;margin:0!important;border:0!important;gap:10px}.brand-icon{width:34px!important;height:34px!important}.brand>span>span{font-size:19px!important}.brand small{font-size:9px!important;margin-top:2px}.sidebar>.nav-label,.side-note,#current-user,.sidebar>#account-password,.sidebar>#logout{display:none!important}.mobile-nav-toggle{display:flex!important;color:#e8f1ec!important;border:1px solid #ffffff30!important;background:transparent!important;font-size:12px;min-height:36px}.sidebar nav,html[data-layout=top] .sidebar nav{display:none!important;grid-column:1/-1}.sidebar.mobile-open nav,html[data-layout=top] .sidebar.mobile-open nav{display:flex!important;flex-direction:column!important;margin-top:15px}.sidebar.mobile-open>#account-password,.sidebar.mobile-open>#logout{display:block!important}.sidebar.mobile-open>#current-user{display:block!important;grid-column:1/-1}.sidebar.mobile-open>#account-password{grid-column:1}.sidebar.mobile-open>#logout{grid-column:2}html[data-layout=top] #scope-navigation{display:block}.sidebar nav button{width:100%!important}.sidebar #scope-navigation{padding:14px 0!important}#app>main,html[data-density=compact] #app>main{padding:20px 15px!important;min-height:calc(100vh - 65px);width:100%!important}main>header{gap:12px;align-items:flex-start;margin-bottom:20px!important;padding-bottom:18px!important}#page-title{font-size:22px!important}#page-note{font-size:11px!important}.eyebrow{font-size:9px;margin-bottom:5px;letter-spacing:1px}.header-status{font-size:9px!important;gap:5px;max-width:100px;white-space:normal;text-align:right}#service-status{font-size:9px!important;padding:4px 6px!important}#clock{font-size:9px}.section-head{gap:12px;align-items:flex-start;flex-wrap:wrap}.section-head>.btn{margin-left:0;font-size:11px}h2{font-size:17px!important}.home-toolbar{gap:13px}.home-layout-controls{gap:9px;width:100%;font-size:11px}.home-layout-controls .form-select{min-height:32px;font-size:11px}.home-layout-controls .btn{font-size:11px;min-height:32px}.home-card-grid{grid-template-columns:minmax(0,1fr)!important;gap:17px!important}.home-cover{height:170px!important;min-height:170px!important}.home-cover-content{padding:16px 18px!important}.card-body{padding:17px}.home-numbers b{font-size:21px}.home-pagination{flex-wrap:wrap}.home-pagination span{width:100%}.home-pagination .btn{flex:1}.household-context{padding:10px!important;gap:9px}.household-context label{width:100%}.household-context select{max-width:none;flex:1;min-width:0}#household-context-note{display:none}#scope-back{width:100%;margin:0}.metrics{grid-template-columns:repeat(2,minmax(0,1fr));gap:10px}.metrics>div{padding:11px 13px!important}.metrics strong{font-size:20px!important}.filter-row{gap:9px}.filter-row label{flex:1;min-width:0}.filter-row select{width:100%;min-width:0}#filter-caption{display:none}.filter-row>button{font-size:11px}.panel{padding:17px!important}.form-grid{grid-template-columns:minmax(0,1fr)!important;gap:14px!important}.form-grid>*{min-width:0;grid-column:auto}.form-grid .full{grid-column:1}.site-grid,.steward-grid,.platform-place-grid,.device-card-grid{grid-template-columns:minmax(0,1fr)!important}.device-view-controls{display:flex;flex-direction:column;align-items:stretch}.device-view-controls label{width:100%}.device-view-controls input,.device-view-controls select{width:100%;min-width:0}.network-node{margin-left:calc(min(var(--depth),2)*12px)}.network-node.nested:before{left:-10px;width:8px}.network-node .card-body{padding:14px}.network-facts{display:grid;gap:6px}.network-platform{padding:16px}.network-platform h3{font-size:16px!important}.network-target{font-size:10px}.network-target code{font-size:10px;word-break:break-all}.management-links a{max-width:100%;font-size:10px}.network-node .device-card-heading h3,.network-node .device-title{font-size:14px!important}.device-context [role=group]{display:flex;flex-wrap:wrap;gap:7px}.device-context .btn{flex:1;min-width:100px;font-size:11px}.steward-tile{min-height:145px!important}.steward-tile strong{font-size:18px!important}.journal-card{padding:17px!important}.journal-attachments{grid-template-columns:minmax(0,1fr)!important}.journal-attachments audio,.journal-attachments video{width:100%;max-width:100%}.journal-upload-controls{display:flex;flex-wrap:wrap}.journal-upload-controls>*{max-width:100%}.settings-sections{gap:6px}.settings-sections .btn{flex:1;min-width:calc(50% - 6px);font-size:11px}dialog{max-width:calc(100vw - 20px)!important;padding:20px!important;max-height:calc(100dvh - 20px);border-radius:12px!important}dialog h2{font-size:19px!important}dialog .dialog-heading{padding-bottom:14px!important;margin-bottom:16px!important}dialog .dialog-heading .btn{min-width:54px}#auth-dialog{padding:25px!important}.brand-image-grid{grid-template-columns:1fr!important}#toast{bottom:16px;right:16px;font-size:12px!important}.wall-toolbar{gap:7px}.wall-toolbar label{width:auto}.table-wrap{max-width:100%}main>footer{font-size:9px!important;gap:10px;flex-wrap:wrap}.network-node .device-card-heading>.btn{font-size:10px;min-height:28px;padding:3px 7px}html[data-layout=top] .sidebar.mobile-open nav button{width:100%!important}}@media(min-width:768px){.sidebar>.mobile-nav-toggle{display:none!important}}.sidebar nav button{justify-content:flex-start!important}.sidebar nav button.active:after{display:none!important}.section-head>div:first-child{display:block}.inline-check .form-check-input{width:16px!important;height:16px!important;min-height:0!important;padding:0!important}.form-check-input{padding:0!important}.dialog-footer{display:flex;justify-content:flex-end;gap:10px;margin-top:20px;padding-top:18px;border-top:1px solid var(--ui-line)}html[data-font=serif] #page-title,html[data-font=serif] .scope-intro h2{font-family:"Noto Serif SC",Songti SC,SimSun,serif!important;font-weight:600!important}.live-help{margin:10px 0;color:var(--ui-muted);font-size:13px}.live-help summary{cursor:pointer;padding:8px 0}.live-help p{margin:8px 0}#page-live.wall-expanded{position:fixed;inset:0;z-index:10000;margin:0}#page-live:is(:fullscreen,.wall-expanded)>.live-help{display:none}#page-live:is(:fullscreen,.wall-expanded) .live-grid[data-visible-count="1"]{grid-template-columns:minmax(0,1fr);grid-template-rows:minmax(0,1fr)}.leadership-member-actions .btn{white-space:normal}#leadership-grant{align-items:flex-start;padding:14px}#leadership-grant span{line-height:1.7}@media(max-width:767px){#app>main{padding-bottom:max(20px,env(safe-area-inset-bottom))!important}main[data-page=live]>header{margin-bottom:12px!important;padding-bottom:12px!important}main[data-page=live]>header .eyebrow,main[data-page=live] #page-note,main[data-page=live]>.metrics{display:none!important}main[data-page=live] .household-context{margin-bottom:12px;flex-wrap:nowrap}main[data-page=live] .household-context label{flex:1;width:auto;font-size:0}main[data-page=live] .household-context select{font-size:16px;width:100%}main[data-page=live] #scope-back{width:auto;min-width:82px}main[data-page=live]>.filter-row{margin:12px 0}#page-live:not([hidden]){display:flex;flex-direction:column}#page-live>.section-head{order:0;margin:6px 0 12px}#page-live>.live-grid{order:1}#page-live>.wall-toolbar{order:2}#page-live>.live-help{order:3}#page-live:not(:fullscreen):not(.wall-expanded) .live-grid[data-layout=auto]{grid-template-columns:minmax(0,1fr)}.camera-actions{display:grid;grid-template-columns:repeat(2,minmax(0,1fr));padding:0 12px 12px}.camera-actions .btn{min-height:44px;white-space:normal;font-size:13px}.camera-meta{padding:12px}.camera-meta strong{font-size:15px!important}.wall-toolbar .wall-paging{flex:1;justify-content:space-between}.wall-toolbar .btn{min-width:44px;min-height:44px}#page-live:is(:fullscreen,.wall-expanded){padding:max(8px,env(safe-area-inset-top)) max(8px,env(safe-area-inset-right)) max(8px,env(safe-area-inset-bottom)) max(8px,env(safe-area-inset-left))}#page-live:is(:fullscreen,.wall-expanded)>.wall-toolbar{order:0}#page-live:is(:fullscreen,.wall-expanded) .live-grid[data-layout=auto]{grid-template-columns:repeat(2,minmax(0,1fr))}#page-live:is(:fullscreen,.wall-expanded) .live-grid[data-visible-count="1"]{grid-template-columns:minmax(0,1fr);grid-template-rows:minmax(0,1fr)}#page-live:is(:fullscreen,.wall-expanded) .camera-actions{display:none}.network-target{display:grid;grid-template-columns:76px minmax(0,1fr) auto;font-size:12px;gap:8px}.network-target code{font-size:13px!important}.network-check-time{font-size:12px;line-height:1.7}.management-links{display:grid;grid-template-columns:minmax(0,1fr)}.management-links .btn{min-height:44px!important;font-size:13px!important;white-space:normal}dialog .description,dialog label{font-size:14px!important}dialog .dialog-footer{position:sticky;bottom:-20px;background:var(--ui-surface);padding:14px 0;margin-bottom:-10px}dialog .dialog-footer .btn{flex:1;min-height:44px;white-space:normal}.leadership-member-actions .btn{flex:1;min-width:120px}#leadership-grant{display:flex;gap:10px}#leadership-grant[hidden]{display:none}}html[data-backdrop=mountains] #app>main{background-image:linear-gradient(150deg,transparent 70%,#8ba58f08 70%,transparent 85%),linear-gradient(170deg,transparent 60%,#8ba58f06 60%,transparent 90%)!important;background-size:100% 360px!important;background-repeat:no-repeat!important}@media(max-width:767px){.form-control,.form-select{font-size:16px!important;min-height:44px}.btn{min-height:42px;font-size:13px}.home-layout-controls .form-select{font-size:14px!important;min-height:40px}.home-layout-controls .btn,.network-status-title .btn,.management-links .btn{min-height:40px;font-size:12px}.network-target code{font-size:12px}.mobile-nav-toggle{min-height:42px}.device-card-actions .btn{min-height:42px;font-size:12px}}:root{--ui-bg: #f3f6fa;--ui-surface: #fff;--ui-line: #e3e9ef;--ui-muted: #5e6f7e;--ui-sidebar: #172e35;--ui-accent: #217964;--ink: #253b46;--muted: #5e6f7e;--paper: var(--ui-surface);--line: var(--ui-line);--green: var(--ui-accent);--bs-primary: #217964;--bs-primary-rgb: 33, 121, 100;--bs-body-color: var(--ink);--bs-body-bg: var(--ui-bg);--bs-border-color: var(--ui-line);--ui-shadow: 0 3px 16px #223d5010;--ui-soft: #f5f8fa}html[data-theme=paper]{--ui-bg: #f5f6f4;--ui-soft: #f5f7f3}html[data-theme=clean]{--ui-bg: #f1f5f9;--ui-soft: #f4f7fb}html[data-theme=ink]{--ui-bg: #111e26;--ui-surface: #1a2b35;--ui-line: #30444e;--ui-soft: #21353f;--ink: #e0ecef;--ui-muted: #a8bdc5;--muted: #a8bdc5;--ui-shadow: 0 3px 16px #0002;--paper: #1a2b35;--line: #30444e}html,body{min-width:0}body{-webkit-font-smoothing:antialiased}#app>main{max-width:2000px;padding:30px 38px 24px!important}main>header{margin-bottom:26px!important;padding-bottom:24px!important}#page-title{font-size:clamp(24px,2.3vw,32px)!important;letter-spacing:-.7px!important}html[data-font=serif] #page-title{font-weight:600!important}#brand-motto{color:var(--ui-accent)!important;letter-spacing:2.4px}#page-note{font-size:13px!important}.header-status{gap:9px}#clock{font-variant-numeric:tabular-nums;font-size:11px}#service-status{padding:6px 10px;border-radius:20px!important}.sidebar{background:linear-gradient(165deg,#1d3940,#152b32 70%)!important}.brand{padding-bottom:26px!important}.brand-icon{width:46px!important;height:46px!important;box-shadow:0 3px 12px #071d2860}.sidebar nav button{border-radius:10px!important;min-height:46px;transition:background .15s,color .15s}.sidebar nav button.active{background:#e1f2eb!important;color:#155b48!important;box-shadow:0 2px 7px #0002!important}.sidebar nav button.active .app-icon{opacity:1}.sidebar #current-user{padding:14px 9px 2px}.section-head{align-items:center;margin-bottom:18px}.section-head h2{font-size:21px!important}.count-pill{background:#e7f0ec;color:#286752;border:0;border-radius:7px;padding:3px 9px;font-size:12px}.btn{border-radius:9px!important;min-height:38px;padding:8px 14px;transition:background .15s,border-color .15s,box-shadow .15s}.btn-primary{--bs-btn-bg: var(--ui-accent);--bs-btn-border-color: var(--ui-accent);box-shadow:0 3px 8px #21796416}.btn-primary:hover{box-shadow:0 4px 12px #21796428}.btn-outline-secondary{--bs-btn-color: var(--ink);--bs-btn-border-color: var(--ui-line);background:var(--ui-surface)}.btn-link{color:var(--ui-accent)}html:is([data-theme=clean],[data-theme=ink]) :is(main,dialog) .btn-primary:not(.steward-tile):not(.device-title):not(.platform-place-node){background:var(--ui-accent)!important;color:#fff!important;border-color:var(--ui-accent)!important}html:is([data-theme=clean],[data-theme=ink]) :is(main,dialog) .btn-outline-secondary{background:var(--ui-surface)!important;color:var(--ink)!important}html:is([data-theme=clean],[data-theme=ink]) :is(main,dialog) .btn-outline-secondary:is(.active,[aria-pressed=true]){background:var(--ui-soft)!important;border-color:#629987!important}html:is([data-theme=clean],[data-theme=ink]) .btn-link{background:transparent!important;color:var(--ink)!important}html[data-theme=ink] #brand-motto{color:#a7d7c4!important}.btn:focus-visible,button:focus-visible,a:focus-visible{outline:3px solid #529cce;outline-offset:3px}.form-control,.form-select{border-radius:9px!important;border-color:var(--ui-line)!important;min-height:40px;background-color:var(--ui-surface);color:var(--ink)}.form-control:focus,.form-select:focus{border-color:#51a18b!important;box-shadow:0 0 0 3px #21856819!important}.card,.panel{border:1px solid var(--ui-line)!important;border-radius:14px!important;background:var(--ui-surface);box-shadow:var(--ui-shadow)!important}.card{overflow:hidden}.card-body{padding:24px}dialog{border-radius:16px!important;box-shadow:0 24px 100px #10293040!important}dialog::backdrop{background:#132a3670;backdrop-filter:blur(4px)}dialog h2{font-size:22px!important}.household-context,.device-context{border:1px solid var(--ui-line)!important;background:var(--ui-surface)!important;border-radius:12px;box-shadow:var(--ui-shadow)}.home-insights{display:grid;grid-template-columns:1.4fr .7fr 1fr;gap:18px;margin:22px 0 26px}.home-insights>article{border-radius:15px;padding:24px;min-width:0}.insight-welcome{position:relative;overflow:hidden;color:#fff;background:linear-gradient(115deg,#20534d,#297562);box-shadow:0 6px 22px #21594c1c}.insight-welcome:after{content:"";position:absolute;right:-28px;bottom:-64px;width:200px;height:200px;border:32px solid #fff07;border-radius:50%;pointer-events:none}.insight-kicker{color:#cae4d9;font-size:10px;letter-spacing:2px}.insight-welcome h2{color:#fff!important;font-size:23px!important;margin:14px 0 8px!important}.insight-welcome p{color:#d0e7df;font-size:12px;margin-bottom:22px}.insight-scope{display:flex;gap:7px;align-items:center;color:#d7ebe4;font-size:10px}.insight-scope .app-icon{width:15px;height:15px;flex-basis:15px}.insight-number,.insight-distribution{background:var(--ui-surface);border:1px solid var(--ui-line);box-shadow:var(--ui-shadow)}.insight-number{position:relative;display:flex;flex-direction:column;justify-content:center}.insight-icon{position:absolute;right:20px;top:22px;width:36px;height:36px;display:grid;place-items:center;background:#e8f1fb;color:#527ec0;border-radius:11px}.insight-label{color:var(--ui-muted);font-size:12px;padding-right:35px}.insight-number>strong{font-size:40px;line-height:1.3;font-weight:650;margin:10px 0;color:var(--ink);font-variant-numeric:tabular-nums}.insight-number strong small{font-size:12px;font-weight:400;margin-left:10px;color:var(--ui-muted)}.insight-foot{color:var(--ui-muted);font-size:11px}.insight-distribution{display:flex;align-items:center;justify-content:center;gap:20px}.insight-donut{width:126px;flex:0 0 126px;position:relative}.insight-donut svg{width:100%;display:block}.donut-track{stroke:var(--ui-line)}.insight-donut>div{position:absolute;inset:0;display:flex;flex-direction:column;align-items:center;justify-content:center;pointer-events:none}.insight-donut strong{font-size:28px;line-height:1.3}.insight-donut small{font-size:10px;color:var(--ui-muted)}.insight-legend{flex:1;min-width:60px;max-width:145px}.insight-legend h3{font-size:12px!important;margin-bottom:13px;white-space:nowrap}.insight-legend>span{display:flex;align-items:center;gap:7px;font-size:11px;margin-top:7px;color:var(--ui-muted)}.insight-legend i{width:7px;height:7px;border-radius:2px;flex-shrink:0}.insight-legend b{margin-left:auto;color:var(--ink)}.home-toolbar{padding:13px 16px;border:1px solid var(--ui-line);border-radius:12px;background:var(--ui-surface);gap:14px}.home-layout-toggle{display:none}#home-layout-status{margin:10px 3px 18px;font-size:11px}.home-card-grid{gap:24px}.home-card{transition:box-shadow .18s,border-color .18s}.home-card:hover{box-shadow:0 8px 26px #223d5019!important;border-color:#b4cac0!important}.home-cover{height:220px;background:linear-gradient(120deg,#35595b,#193a40)}.home-cover .cover-shade{background:linear-gradient(180deg,#142b3830,#10282b05 30%,#0a232bcc)}.home-cover-content{padding:22px 25px}.home-cover-content h3{font-size:24px!important;font-weight:600!important;letter-spacing:.5px!important}.home-cover-content .badge{border:1px solid #ffffff38;background:#f6fffaed!important;color:#27594a!important;border-radius:6px!important;font-size:11px}.home-location{font-size:11px;color:#ebf3f0}.cover-edit{background:#142a3560!important;border:1px solid #ffffff80!important;color:#fff!important;backdrop-filter:blur(4px)}.home-summary{color:var(--ui-muted);font-size:12px}.home-numbers{background:var(--ui-soft);border:0;border-radius:10px;padding:14px 0;margin:16px 0 20px}.home-numbers span{border-right:1px solid var(--ui-line);color:var(--ui-muted);font-size:11px}.home-numbers span:last-child{border:0}.home-numbers b{font-size:24px;color:var(--ink)}.home-card-actions{border-top:1px solid var(--ui-line);padding-top:18px;margin-top:18px}.compact-details dt{color:var(--ui-muted)}.compact-details dd{color:var(--ink)}.home-pagination{margin-top:24px;font-size:11px}.metrics{gap:16px}.metrics>div{border:1px solid var(--ui-line);border-radius:12px;background:var(--ui-surface);box-shadow:var(--ui-shadow);border-top:3px solid #438979}.metrics>div:nth-child(2){border-top-color:#658cd1}.metrics>div:nth-child(3){border-top-color:#b69c70}.metrics>div:nth-child(4){border-top-color:#8391b5}.metrics strong{font-variant-numeric:tabular-nums;color:var(--ink)}.device-card-heading .device-symbol{background:#e9f3ef;color:#287e65;border-radius:12px;width:44px;height:44px}.device-card .card-footer{border-top:1px solid var(--ui-line);background:var(--ui-soft);padding:14px 22px}.device-card-grid{gap:20px}.device-view-controls{padding:20px 24px}.device-search-row{border-bottom:1px solid var(--ui-line);padding-bottom:18px;margin-bottom:15px}.group-title{margin:24px 0 14px}.device-location{color:var(--ui-muted)}.network-map{padding:24px}.network-platform{background:var(--ui-soft);border:1px solid var(--ui-line);border-radius:12px;padding:20px}.network-platform>.app-icon{width:30px;height:30px;flex-basis:30px;color:var(--ui-accent)}.network-diagram{margin:20px 0 28px;border:1px solid var(--ui-line);border-radius:12px;overflow:hidden}.diagram-toolbar{display:flex;justify-content:space-between;align-items:center;gap:16px;padding:14px 18px;background:var(--ui-surface)}.diagram-toolbar>div{display:flex;gap:10px;align-items:center;flex-wrap:wrap}.diagram-toolbar strong{font-size:13px}.diagram-dot{width:7px;height:7px;border-radius:50%;background:#4d8dbe}.diagram-toolbar label{display:flex;align-items:center;gap:8px;font-size:11px;margin:0}.diagram-toolbar select{width:86px}.diagram-scroll{max-height:480px;overflow:auto;background-color:var(--ui-soft);background-image:radial-gradient(var(--ui-line) 1px,transparent 1px);background-size:18px 18px;border-block:1px solid var(--ui-line)}.network-svg{display:block}.network-edge{stroke:#82a79c;stroke-width:2}.diagram-node{cursor:pointer;outline:none}.diagram-node-bg{fill:var(--ui-surface);stroke:var(--ui-line);stroke-width:1.5}.diagram-node:hover .diagram-node-bg,.diagram-node:focus .diagram-node-bg{stroke:#328d78;stroke-width:2.5}.diagram-node-type{fill:var(--ui-muted);font-size:10px}.diagram-node-title{fill:var(--ink);font-size:14px;font-weight:600}.diagram-node-ip{fill:var(--ui-muted);font-size:11px;font-family:ui-monospace,Consolas,monospace}.diagram-note{margin:0;padding:11px 18px;font-size:11px;color:var(--ui-muted)}.network-details-heading{margin:20px 0 14px}.platform-place-node{position:relative;text-align:left;padding:24px}.platform-place-node:before{content:"";position:absolute;inset:0 auto 0 0;width:4px;background:#438979}.platform-place-node:hover{border-color:#8db4a7!important;background:var(--ui-soft)}.network-open{color:var(--ui-accent);font-weight:600}.scope-intro{border-bottom:1px solid var(--ui-line);padding-bottom:20px}.steward-tile{border-radius:14px!important;border:1px solid var(--ui-line)!important;border-top:3px solid #438979!important;box-shadow:var(--ui-shadow)!important;padding:28px!important;background:var(--ui-surface)!important}.steward-tile:nth-child(2n){border-top-color:#6c8fbc!important}.steward-tile:nth-child(3n){border-top-color:#b29a72!important}.steward-tile strong{font-size:19px!important}.steward-tile:hover{border-color:#9dbab0!important;box-shadow:0 8px 22px #223d5016!important}.journal-card{border-radius:14px;box-shadow:var(--ui-shadow)}#page-live:is(:fullscreen,.wall-expanded) .camera-meta{background:#172e35!important;color:#e8f3ef!important}#page-live:is(:fullscreen,.wall-expanded) .camera-meta strong{color:#e8f3ef!important}#page-live:is(:fullscreen,.wall-expanded) .wall-toolbar{background:#172e35!important;border-color:#45616a!important}#page-live:is(:fullscreen,.wall-expanded) .form-select{background-color:#213b44!important;color:#e8f3ef!important;border-color:#64818b!important}main>footer{color:var(--ui-muted);font-size:10px}html[data-density=compact] .home-insights>article{padding:18px}html[data-density=compact] .home-cover{height:165px}html[data-density=compact] .card-body{padding:18px}@media(min-width:1100px){html[data-layout=top] #app>main{padding-top:28px!important}}@media(max-width:1250px){.home-insights{grid-template-columns:1.2fr .75fr 1fr;gap:12px}.home-insights>article{padding:19px}.insight-distribution{gap:10px}.insight-donut{width:102px;flex-basis:102px}.insight-welcome h2{font-size:20px!important}}@media(max-width:1000px)and (min-width:761px){#app>main{padding:26px 24px!important}.home-insights{grid-template-columns:1fr 1fr}.insight-welcome{grid-column:1/-1}.insight-welcome p{margin-bottom:12px}}@media(max-width:760px){#app>main{padding:20px 16px!important}.sidebar{background:#17353b!important}main>header{margin-bottom:20px!important;padding-bottom:18px!important}#page-title{font-size:25px!important}#page-note{font-size:12px!important}.home-insights{grid-template-columns:1fr 1fr;gap:12px;margin:16px 0 20px}.home-insights>article{padding:18px}.insight-welcome{grid-column:1/-1}.insight-welcome h2{margin:7px 0 0!important;font-size:20px!important}.insight-welcome p,.insight-scope{display:none}.insight-number>strong{font-size:34px}.insight-icon{width:29px;height:29px;top:14px;right:13px}.insight-distribution{flex-direction:column;gap:5px}.insight-donut{width:94px;flex-basis:auto}.insight-legend{width:100%;display:flex;flex-wrap:wrap;justify-content:center;gap:6px}.insight-legend h3{display:none}.insight-legend>span{margin:0;font-size:10px;gap:4px}.insight-number .insight-label{padding-right:24px;font-size:11px}.insight-donut strong{font-size:25px}.insight-donut small{font-size:9px}.home-toolbar{padding:12px}.home-layout-toggle{display:inline-flex;margin-left:auto}.home-toolbar .home-layout-controls{display:none}.home-toolbar.home-options-open .home-layout-controls{display:flex;flex-basis:100%;border-top:1px solid var(--ui-line);padding-top:12px}.home-cover{height:200px}.home-cover-content{padding:20px}.home-cover-content h3{font-size:23px!important}.card-body{padding:20px}.home-numbers{padding:12px 0}.home-card-grid{gap:18px}.home-card-actions{gap:8px;flex-wrap:wrap}.btn{min-height:44px}.form-control,.form-select{min-height:44px;font-size:16px}#page-playback .playback-controls{display:grid;grid-template-columns:minmax(0,1fr);gap:14px}#page-playback .playback-controls label{width:100%;min-width:0}#page-playback .playback-controls input,#page-playback .playback-controls select,#page-playback .playback-controls button{width:100%}#play-info{overflow-wrap:anywhere}.device-view-controls{padding:16px}.network-map{padding:14px}.network-platform{padding:16px}.diagram-toolbar{padding:12px;align-items:flex-start}.diagram-toolbar>div{gap:6px}.diagram-toolbar>div .small{flex-basis:100%;font-size:10px}.diagram-toolbar label{flex-direction:column;align-items:flex-start}.diagram-toolbar select{width:82px}.diagram-scroll{max-height:360px}.steward-tile{padding:22px!important}main[data-page=live]>header{margin-bottom:10px!important;padding-bottom:12px!important}}@media(prefers-reduced-motion:reduce){*,*:before,*:after{transition:none!important;scroll-behavior:auto!important}}:root{--ui-shadow: 0 4px 22px #223d500a;--bs-body-font-family: system-ui,"Microsoft YaHei",sans-serif}html[data-theme=paper]{--ui-bg: #f5f5f1;--ui-soft: #f4f6f2}.dashboard-grid{margin-top:4px}.dashboard-grid>div,.row>div{min-width:0}.dashboard-welcome{position:relative;overflow:hidden;padding:28px;border-radius:16px;background:linear-gradient(140deg,#234a49,#2e7964);color:#fff}.dashboard-welcome:after{content:"";position:absolute;right:-85px;top:-95px;width:260px;height:260px;border:40px solid #ffffff07;border-radius:50%;pointer-events:none}.dashboard-welcome h2{font-size:clamp(21px,2vw,26px)!important;color:#fff!important;margin:16px 0 8px;letter-spacing:.2px}.dashboard-welcome>p{color:#d3e7df;font-size:12px}.dashboard-totals{display:flex;gap:28px;margin:22px 0}.dashboard-totals>div{display:flex;flex-direction:column}.dashboard-totals strong{color:#fff;font-size:32px;font-weight:600;line-height:1.3;font-variant-numeric:tabular-nums}.dashboard-totals span{color:#d3e7df;font-size:11px;margin-top:5px}.chart-card{padding:22px;border:1px solid var(--ui-line);border-radius:16px;background:var(--ui-surface);box-shadow:var(--ui-shadow);min-width:0}.chart-heading{display:flex;gap:12px;align-items:center;justify-content:space-between;flex-wrap:wrap;margin-bottom:10px}.chart-heading h3{font-size:15px!important;font-weight:650;margin:0}.chart-heading .small{font-size:11px}.chart-legend{display:flex;gap:10px 18px;flex-wrap:wrap;justify-content:center;padding-top:8px}.chart-legend span{display:flex;align-items:center;gap:6px;font-size:12px;color:var(--ui-muted)}.chart-legend i{width:8px;height:8px;border-radius:3px}.chart-legend b{color:var(--ink);font-variant-numeric:tabular-nums}.chart-data{color:var(--ui-muted);font-size:11px;margin-top:8px}.chart-data summary{cursor:pointer;padding:6px 0}.chart-data ul{padding-left:20px;margin:8px 0 0}.chart-empty{min-height:150px;display:grid;place-items:center;color:var(--ui-muted);margin:0;font-size:13px}.local-chart-wrap,.local-chart{width:100%;min-width:0}.chart-network-surface{background:var(--ui-soft);border-radius:12px;background-image:radial-gradient(var(--ui-line) 1px,transparent 1px);background-size:20px 20px;overflow:hidden}.chart-network-surface .local-chart{touch-action:none}.household-context{border-left:3px solid #488b76!important}.section-head>div>.description{margin-top:7px}.home-toolbar,.device-view-controls,.playback-controls{box-shadow:var(--ui-shadow)}.home-card .card-body{padding:22px}.home-cover{height:200px}.form-grid label{align-items:stretch}dialog .dialog-heading{position:sticky;top:0;background:var(--ui-surface);z-index:2;padding-block:12px}dialog .dialog-footer{padding-top:18px;border-top:1px solid var(--ui-line)}html[data-theme=ink] .chart-card{color:var(--ink)}html[data-theme=ink] .chart-heading .badge{background:#2c493e!important;color:#c2e9d7!important}@media(max-width:767px){.dashboard-grid:not(.charts-expanded) .dashboard-chart-column{display:none}.dashboard-welcome{padding:22px}.dashboard-welcome h2{font-size:22px!important}.dashboard-totals{justify-content:space-between;gap:14px;margin:18px 0 14px}.dashboard-welcome .insight-scope{display:flex;font-size:10px}.chart-card{padding:18px}.dashboard-grid .chart-card{height:auto!important}.chart-network-surface .local-chart{max-height:340px}.diagram-toolbar{flex-wrap:wrap}.diagram-toolbar .btn{min-height:40px}.household-context{padding:14px!important}.section-head{gap:12px;flex-wrap:wrap}.dialog-footer button{flex:1}.table-wrap{overscroll-behavior-x:contain}}.hardware-grid>div[data-v-2d075cdb]{display:flex;flex-direction:column;gap:4px;background:#f5f7f7;padding:12px;border:3px solid white;border-radius:12px}.hardware-grid span[data-v-2d075cdb],.hardware-grid small[data-v-2d075cdb]{font-size:12px;color:#637471}.hardware-grid strong[data-v-2d075cdb]{font-size:18px}.tv-remote-preview[data-v-2d075cdb]{margin:16px 0;text-align:center}.tv-remote-preview img[data-v-2d075cdb]{max-height:640px;max-width:100%;border:6px solid #303b38;border-radius:12px}.display-manager summary[data-v-2d075cdb]{cursor:pointer}details p[data-v-2d075cdb]{margin-top:12px}form>label[data-v-3234de1e]{display:flex;flex-direction:column;align-items:stretch;gap:.35rem;min-width:0}form>label select[data-v-3234de1e],form>label input[data-v-3234de1e]{width:100%;min-width:0}.family-locations h2[data-v-e83725a4]{font-size:1.3rem}.location-empty[data-v-e83725a4]{display:grid;align-content:center;min-height:270px;text-align:center;color:var(--ui-muted,#64776f);padding:1rem}.location-empty>span[data-v-e83725a4]{font-size:3rem;color:#6c9685}.location-person[data-v-e83725a4]{display:flex;flex-direction:column;gap:.35rem;background:var(--panel,#fff);border:1px solid var(--ui-line,#d9e3dd);border-radius:12px;padding:14px;margin-bottom:10px;color:var(--ink,#243c32)}.location-person>span[data-v-e83725a4],.location-person small[data-v-e83725a4]{font-size:.85rem}.location-selected[data-v-e83725a4]{border-color:#257a68;box-shadow:inset 3px 0 #257a68}.family-locations summary[data-v-e83725a4]{cursor:pointer}.family-locations input[type=checkbox][data-v-e83725a4]{min-width:18px;width:18px;min-height:18px}button.location-person[data-v-e83725a4]{color:var(--ink,#243c32)!important;background:var(--panel,#fff)!important;align-items:stretch;text-align:left!important}.location-person strong[data-v-e83725a4],.location-person small[data-v-e83725a4]{color:var(--ink,#243c32)}.upload-metric[data-v-0c20c09f]{height:100%;padding:1rem;border:1px solid var(--ui-line,#e3e9ef);border-radius:12px;background:var(--panel,#fff);display:flex;flex-direction:column;gap:.35rem}.upload-metric>span[data-v-0c20c09f],.upload-metric>small[data-v-0c20c09f]{color:var(--ui-muted,#64748b);font-size:.8rem}.upload-metric>strong[data-v-0c20c09f]{font-size:1.65rem;line-height:1.5;font-variant-numeric:tabular-nums}.upload-metric.freed[data-v-0c20c09f]{background:color-mix(in srgb,var(--panel,#fff) 90%,#2e876e)}.upload-current[data-v-0c20c09f]{padding:1rem;border-radius:12px;background:color-mix(in srgb,var(--panel,#fff) 90%,#419be1)}.upload-filters[data-v-0c20c09f]{display:flex;flex-wrap:wrap;gap:1rem}.upload-filters label[data-v-0c20c09f]{flex:1;min-width:160px;max-width:330px;font-size:.85rem}.upload-task[data-v-0c20c09f]{padding:1rem 0;border-top:1px solid var(--ui-line,#e3e9ef)}.upload-task-heading[data-v-0c20c09f]{display:flex;justify-content:space-between;gap:.75rem;align-items:center;margin-bottom:.4rem}.upload-details[data-v-0c20c09f]{margin:1rem 0 0}.upload-details>div[data-v-0c20c09f]{display:grid;grid-template-columns:110px 1fr;gap:10px}.upload-details dd[data-v-0c20c09f]{overflow-wrap:anywhere}.upload-tasks summary[data-v-0c20c09f]{cursor:pointer}.upload-tasks .progress[data-v-0c20c09f]{height:8px}.upload-tasks .badge[data-v-0c20c09f]{white-space:normal}.upload-tasks button[data-v-0c20c09f]{min-height:40px}@media(max-width:576px){.upload-metric[data-v-0c20c09f]{padding:.75rem}.upload-metric>strong[data-v-0c20c09f]{font-size:1.2rem}.upload-filters label[data-v-0c20c09f]{min-width:100%;max-width:none}.upload-details>div[data-v-0c20c09f]{grid-template-columns:1fr;gap:0}}.journal-rich-editor{border:1px solid var(--bs-border-color,#ccd9d7);border-radius:12px;overflow:hidden;background:var(--bs-body-bg,#fff);margin:10px 0 20px}.journal-editor-toolbar{display:flex;flex-wrap:wrap;gap:6px;padding:10px;background:var(--bs-tertiary-bg,#f3f7f5);border-bottom:1px solid var(--bs-border-color,#ccd9d7)}.journal-editor-toolbar button{min-height:40px;padding:6px 12px}.journal-editor-toolbar button[aria-pressed=true]{background:#d8eae2;color:#153d31}.journal-rich-input{padding:20px;min-height:200px;outline:none;overflow-wrap:anywhere}.journal-rich-input:focus{box-shadow:inset 0 0 0 2px #669c89}.journal-rich-input p{min-height:1.5em;margin-bottom:12px;white-space:pre-wrap}.journal-rich-input blockquote,.journal-rich-body blockquote{border-left:3px solid #84ad9d;padding-left:16px;color:#5f7870}.journal-editor-foot{display:flex;justify-content:space-between;gap:12px;font-size:12px;color:#667b75;padding:10px 16px;border-top:1px solid #e1e9e5}.journal-inline-media{display:flex;flex-direction:column;align-items:flex-start;gap:10px;padding:12px;border:1px solid #d4e1da;border-radius:10px;background:#f8faf9;max-width:680px}.journal-inline-media img,.journal-inline-media video{max-width:100%;max-height:380px;object-fit:contain;border-radius:6px}.journal-inline-media audio{width:min(100%,540px)}.journal-inline-media figcaption{font-size:12px;color:#60766c;overflow-wrap:anywhere}.journal-inline-media.ProseMirror-selectednode{outline:2px solid #368268}.journal-rich-body{line-height:1.8;overflow-wrap:anywhere}.journal-rich-body p{white-space:pre-wrap}.journal-rich-body .journal-attachment{max-width:760px;margin:16px 0}.journal-rich-body img,.journal-rich-body video{max-height:480px;object-fit:contain}.journal-materials .journal-add-media{display:flex;flex-wrap:wrap;align-items:center;gap:10px}.journal-materials input[type=file]{max-width:100%}.journal-queue-row{display:grid;grid-template-columns:minmax(0,1fr) auto;gap:8px 16px;padding:14px 0;border-bottom:1px solid #e1e9e5}.journal-queue-row strong{overflow-wrap:anywhere}.journal-queue-row progress{width:100%;height:8px}.journal-queue-row small{display:block;color:#63756f}.journal-queue-row .journal-task-error{color:#a43b35}.journal-library-list-tools{display:flex;flex-wrap:wrap;gap:10px;align-items:center;margin:14px 0}.journal-upload-select small{display:block}.journal-editor-heading{display:flex;flex-wrap:wrap;align-items:center;gap:12px;padding:14px 22px;background:#f5f8f6;border:1px solid #d6e2da;border-radius:12px;margin-bottom:16px}.journal-editor-heading strong{margin-right:auto}.journal-editor-heading button{min-height:44px}.journal-editor-fullscreen{position:fixed;inset:0;z-index:1090;background:#f0f4f2;overflow:auto;overscroll-behavior:contain;padding:0 24px 24px;display:grid;grid-template-columns:minmax(0,1fr) 360px;gap:18px;align-content:start}.journal-editor-fullscreen>.journal-editor-heading{grid-column:1/-1;position:sticky;top:0;z-index:3;margin:0 -24px;border-radius:0;padding:14px 24px;box-shadow:0 2px 10px #183b2412}.journal-editor-fullscreen>.journal-compose{margin:0;min-height:calc(100dvh - 110px);display:flex;flex-direction:column}.journal-editor-fullscreen .journal-rich-editor{flex:1;display:flex;flex-direction:column}.journal-editor-fullscreen .journal-rich-editor>div:has(>.tiptap){flex:1}.journal-editor-fullscreen .journal-rich-input{min-height:52dvh;font-size:19px;line-height:1.9}.journal-editor-fullscreen .journal-editor-toolbar{position:sticky;top:0;z-index:1}.journal-editor-fullscreen>.journal-materials{margin:0;padding:18px;max-height:calc(100dvh - 110px);overflow:auto;position:sticky;top:92px}.journal-editor-fullscreen .journal-upload-grid{grid-template-columns:1fr}.journal-editor-fullscreen .journal-upload-card video,.journal-editor-fullscreen .journal-upload-card img{max-height:160px}.journal-editor-fullscreen .journal-upload-select span{min-width:0;overflow-wrap:anywhere}#journal-record-elapsed{font-variant-numeric:tabular-nums;color:#bd4338}.journal-inline-media .recording-indicator{color:#bd4338}@media(max-width:900px){.journal-editor-fullscreen{display:block;padding:0 12px 20px}.journal-editor-fullscreen>.journal-editor-heading{margin:0 -12px 12px;padding:10px 12px}.journal-editor-fullscreen>.journal-compose{min-height:calc(100dvh - 140px)}.journal-editor-fullscreen>.journal-materials{position:static;max-height:none;margin-top:12px}.journal-editor-fullscreen .journal-rich-input{min-height:48dvh;font-size:17px}.journal-editor-heading{padding:12px;gap:8px}.journal-editor-heading strong{width:100%}}@media(max-width:600px){.journal-rich-input{padding:14px;min-height:190px}.journal-editor-toolbar{gap:4px}.journal-editor-toolbar button{padding:7px 10px}.journal-editor-foot{flex-wrap:wrap}.journal-inline-media{max-width:100%}.journal-queue-row{gap:8px}.journal-compose,.journal-materials{min-width:0}} +:root{font-family:Inter,Microsoft YaHei,system-ui,sans-serif;color:#dae4e6;background:#10191d;font-synthesis:none;--muted:#8faaaF;--line:#2b3b40;--panel:#18252b;--accent:#74d5bb}*{box-sizing:border-box}body{margin:0}button,input,select{font:inherit}button,.button{border:1px solid transparent;background:var(--accent);color:#153b31;padding:11px 18px;border-radius:8px;font-weight:600;cursor:pointer;white-space:nowrap;text-decoration:none;font-size:14px}button:hover,.button:hover{filter:brightness(1.08)}button:disabled{opacity:.5;cursor:wait}.secondary{background:#263a40;color:#cfe7e5;border-color:#385058}.quiet{background:transparent;border-color:var(--line);color:var(--muted);padding:9px 13px;font-size:13px}input,select{background:#111e24;border:1px solid #3a4e55;color:#e3f0ef;border-radius:7px;padding:10px 11px;min-width:0;max-width:100%;outline:none}input:focus,select:focus{border-color:var(--accent)}label{font-size:13px;color:#a5bec1;display:flex;gap:8px;align-items:center}h1,h2,h3,p{margin-top:0}h1{font-size:30px;letter-spacing:1px;margin:8px 0}h2{font-size:19px;font-weight:600}h3{font-size:16px}p{line-height:1.8}small{font-weight:400}.sidebar{position:fixed;left:0;top:0;bottom:0;width:238px;background:#111e24;border-right:1px solid var(--line);padding:32px 20px;display:flex;flex-direction:column}.brand{display:flex;gap:12px;align-items:center;color:#e9f3f1;text-decoration:none;font-size:21px;font-weight:600;padding:5px 8px 40px}.brand-icon{color:var(--accent);font-size:39px}.brand small{display:block;font-size:9px;letter-spacing:1.1px;margin-top:7px;color:var(--muted)}.nav-label{color:#6b868b;font-size:11px;letter-spacing:3px;padding:14px 15px}nav{display:grid;gap:8px}nav button{text-align:left;background:transparent;color:#8fa9ae;display:flex;gap:15px;font-size:18px;padding:14px 16px}nav button span{font-size:14px}nav button.active{background:#244038;color:#9ee8d3}.side-note{margin-top:auto;padding:20px 9px;font-size:12px;color:#8ebdb1}.side-note p{color:#5e8086;font-size:11px;margin:16px 0}.dot{display:inline-block;width:7px;height:7px;background:#7bd5b5;border-radius:50%;margin-right:5px}main{margin-left:238px;padding:38px 42px 18px;max-width:1800px}header{display:flex;justify-content:space-between;align-items:flex-start;margin-bottom:27px}.eyebrow{font-size:10px;letter-spacing:3px;color:#77aa9e}header p{color:var(--muted);font-size:13px;margin:0}.header-status{display:grid;justify-items:end;gap:13px;padding-top:4px;font-size:11px;color:#718f96}.badge{font-size:11px;background:#243c36;color:#8bddbd;padding:6px 10px;border-radius:5px}.badge.off{background:#372d27;color:#d7ae87}.metrics{display:grid;grid-template-columns:repeat(4,1fr);border:1px solid var(--line);background:#152329;border-radius:12px;overflow:hidden}.metrics>div{padding:21px 25px;border-right:1px solid var(--line);display:flex;justify-content:space-between;align-items:center;gap:10px}.metrics>div:last-child{border:0}.metrics span{font-size:12px;color:var(--muted)}.metrics strong{font-size:26px;font-weight:500}.filter-row{display:flex;gap:16px;align-items:center;margin:26px 0;color:#728c93;font-size:12px}.filter-row select{max-width:280px}.section-head{display:flex;align-items:center;justify-content:space-between;gap:16px;margin:28px 0 17px}.section-head h2{margin:0}.section-head small{font-size:9px;color:#637f87;letter-spacing:2px;margin-left:12px}.section-head>div{display:flex;align-items:center;gap:16px}.live-grid{display:grid;grid-template-columns:repeat(2,minmax(0,1fr));gap:20px}.camera-card{border:1px solid var(--line);border-radius:11px;background:var(--panel);overflow:hidden}.camera-card .video-panel{border:0;border-radius:0;margin:0}.video-panel{position:relative;aspect-ratio:16/9;background:#070e12;overflow:hidden;border:1px solid var(--line);border-radius:10px;margin-bottom:16px}.video-panel video{width:100%;height:100%;object-fit:contain;display:block}.video-empty{position:absolute;inset:0;display:flex;flex-direction:column;align-items:center;justify-content:center;gap:13px;color:#5c7b85;font-size:13px;pointer-events:none;background:radial-gradient(ellipse at center,#142a32 0,transparent 70%)}.video-empty .lens{font-size:36px;color:#456773}.video-error{position:absolute;left:14px;right:14px;bottom:48px;background:#271d1ce6;border-radius:6px;color:#e3b7a1;padding:9px 12px;font-size:12px}.camera-meta{display:flex;justify-content:space-between;gap:12px;padding:16px 18px}.camera-meta strong{font-size:14px}.camera-meta p{color:#728f96;font-size:11px;margin:6px 0 0}.camera-meta .badge{align-self:flex-start}.camera-actions{display:flex;gap:8px;padding:0 18px 14px}.camera-actions button{font-size:11px;padding:7px 10px}.empty{grid-column:1/-1;padding:62px 20px;text-align:center;background:var(--panel);border:1px dashed #354b52;border-radius:12px;color:#819da5}.empty h3{font-size:19px;color:#c4d5d6;font-weight:500}.empty p{font-size:13px;margin-bottom:22px}.panel{padding:22px;background:var(--panel);border:1px solid var(--line);border-radius:10px;margin-bottom:18px}.playback-controls{display:flex;align-items:end;gap:15px;flex-wrap:wrap}.playback-controls label{display:grid}.playback-controls>span{font-size:12px;color:var(--muted);margin:auto 0}.timeline-head{display:flex;justify-content:space-between;font-size:12px;margin-bottom:20px}.timeline-head span{color:var(--muted)}.legend{display:inline-block;background:var(--accent);width:15px;height:6px;margin-right:7px}#timeline{width:100%;height:76px;display:block;cursor:crosshair}.time-labels{display:flex;justify-content:space-between;font-size:10px;color:#74949c}.seek-row{margin-top:22px;display:flex;align-items:center;gap:12px;flex-wrap:wrap}.recording-list{display:grid;grid-template-columns:repeat(3,1fr);gap:12px}.recording-item{text-align:left;background:#203139;color:#bdd5d8;font-size:12px;border:1px solid var(--line);white-space:normal}.recording-item small{display:block;color:#719499;margin-top:7px}.discovery{display:flex;align-items:center;gap:14px}.discovery>div{margin-right:auto}.discovery p{font-size:12px;color:var(--muted);margin:5px 0 0}.discovery input{width:190px}.scan-chip{display:inline-flex;gap:16px;align-items:center;margin:0 12px 14px 0;padding:12px 16px;border:1px solid var(--line);border-radius:8px;font-size:13px}.scan-chip button{padding:6px 10px;font-size:11px}.table-wrap{overflow:auto}.device-table{width:100%;border-collapse:collapse;background:var(--panel);border:1px solid var(--line);font-size:13px}.device-table th{text-align:left;font-size:11px;color:#8ba9ae;font-weight:400;padding:15px}.device-table td{padding:18px 15px;border-top:1px solid var(--line)}.device-table td small{display:block;margin-top:7px;color:#75969d}.site-grid{display:grid;grid-template-columns:repeat(2,minmax(0,1fr));gap:18px}.site-card{background:var(--panel);border:1px solid var(--line);padding:24px;border-radius:10px}.site-heading{display:flex;justify-content:space-between;gap:12px}.site-card h3{margin:12px 0}.site-card dl{font-size:12px}.site-card dl>div{display:flex;gap:18px;padding:7px 0}.site-card dt{color:#718d94;width:80px;flex-shrink:0}.site-card dd{margin:0;color:#b6cccf;word-break:break-word}.description{font-size:12px;color:var(--muted);line-height:1.9}.storage-grid{display:grid;grid-template-columns:1fr 1.2fr;gap:22px}.storage-grid form>label{display:grid;margin:20px 0}.storage-grid dl{font-size:13px}.storage-grid dl div{display:flex;justify-content:space-between;gap:15px;padding:15px 0;border-bottom:1px solid var(--line)}.storage-grid dt{color:var(--muted)}.storage-grid dd{margin:0}.audit-item{font-size:11px;padding:10px 0;border-top:1px solid var(--line);color:#9ab8bd}.audit-item small{display:block;color:#607f89;margin-bottom:5px}.banner{background:#493c24;border:1px solid #6b5430;color:#e1c69a;border-radius:8px;padding:13px 17px;font-size:13px;margin-bottom:22px}dialog{color:#dae4e6;background:#192a31;border:1px solid #3b555d;border-radius:15px;width:min(760px,94vw);max-height:90vh;padding:30px;box-shadow:0 25px 120px #0008}dialog::backdrop{background:#061015dd;backdrop-filter:blur(8px)}#auth-dialog{max-width:430px;padding:38px}#auth-form h2{font-size:28px;margin:18px 0 10px}#auth-form>label{display:grid;margin:22px 0}#auth-form p{color:#93afb5;font-size:13px}.dialog-heading{display:flex;justify-content:space-between;align-items:center;margin-bottom:25px}.dialog-heading h2{margin:0}.form-grid{display:grid;grid-template-columns:1fr 1fr;gap:18px}.form-grid label{display:grid;gap:8px}.form-grid .check{display:flex}.check input{accent-color:var(--accent);width:16px;height:16px}.dialog-footer{display:flex;justify-content:flex-end;margin-top:20px;padding-top:20px;border-top:1px solid var(--line)}.form-error{font-size:12px;color:#efab97;line-height:1.6}.wide{width:100%}footer{font-size:10px;color:#54727c;display:flex;justify-content:space-between;margin-top:40px;padding-top:18px;border-top:1px solid var(--line)}#toast{position:fixed;bottom:28px;left:50%;transform:translate(-50%);border:1px solid #4a7d70;background:#1a3c32;color:#b5efd9;padding:13px 22px;border-radius:9px;z-index:5;box-shadow:0 10px 30px #0005;font-size:13px}:focus-visible{outline:2px solid var(--accent);outline-offset:3px}@media(min-width:1600px){.live-grid{grid-template-columns:repeat(3,minmax(0,1fr))}}@media(max-width:1100px){.sidebar{width:190px;padding:25px 14px}.brand{font-size:17px}.brand-icon{font-size:30px}.brand small{font-size:8px}main{margin-left:190px;padding:25px}.metrics>div{padding:18px 14px}.metrics strong{font-size:22px}.storage-grid{grid-template-columns:1fr}.section-head small{display:none}}@media(max-width:760px){.sidebar{position:static;width:auto;padding:18px 16px 8px;border-right:0;border-bottom:1px solid var(--line)}.brand{padding:0 3px 16px}.brand small{font-size:9px}.sidebar nav{display:flex;gap:3px;overflow:auto}.sidebar nav button{padding:10px;font-size:14px;gap:6px}.sidebar nav button span{font-size:11px}.nav-label,.side-note,.sidebar #logout{display:none}main{margin:0;padding:23px 16px}h1{font-size:25px}.header-status{font-size:9px}.metrics{grid-template-columns:1fr 1fr}.metrics>div{border-bottom:1px solid var(--line)}.metrics>div:nth-child(2){border-right:0}.live-grid,.site-grid{grid-template-columns:1fr}.filter-row{flex-wrap:wrap;gap:10px}.filter-row>span{display:none}.filter-row select{max-width:200px}.section-head{align-items:start}.section-head>div{flex-wrap:wrap;justify-content:flex-end;gap:8px}.section-head button{padding:9px 11px;font-size:12px}.section-head h2{font-size:16px}.section-head label{font-size:11px}.section-head select{padding:6px}.discovery{flex-wrap:wrap}.discovery>div{width:100%}.discovery input{flex:1}.recording-list{grid-template-columns:1fr 1fr}.timeline-head{gap:10px;font-size:10px}.form-grid{gap:13px}.form-grid label{font-size:12px}dialog{padding:23px}.form-grid .full{grid-column:1/-1}.playback-controls label{flex:1}.video-empty{font-size:11px}.camera-meta{padding:14px}.seek-row label{width:100%}#auth-dialog{padding:30px}footer{font-size:9px}}.sidebar{overflow-y:auto}.sidebar .brand{padding-bottom:18px}.sidebar nav{gap:3px}.sidebar nav button{padding-top:10px;padding-bottom:10px}.sidebar .side-note{padding-bottom:0}.sidebar .side-note p{display:none}textarea{font:inherit;color:#e3f0ef;background:#111e24;border:1px solid #3a4e55;border-radius:7px;padding:10px;resize:vertical;max-width:100%}textarea:focus{outline:2px solid var(--accent)}fieldset{border:1px solid var(--line);border-radius:8px;padding:15px}legend{color:var(--muted);font-size:13px}#user-sites{display:flex;flex-wrap:wrap;gap:16px}.family-toolbar{display:flex;align-items:center;gap:16px;flex-wrap:wrap}.family-toolbar>span{margin-left:auto;font-size:12px;color:var(--muted)}.family-layout{display:grid;grid-template-columns:260px minmax(0,1fr);gap:20px;align-items:start}.family-people{display:grid;gap:10px;max-height:720px;overflow:auto}.person-card{text-align:left;display:grid;gap:8px;white-space:normal;background:var(--panel);color:#dae4e6;border:1px solid var(--line);padding:18px}.person-card.selected{border-color:var(--accent);background:#234037}.person-card span{font-size:12px;color:var(--accent)}.person-card small{font-size:11px;color:var(--muted)}#family-detail .section-head{margin-top:0}#family-detail h2{margin:10px 0}.family-prose{white-space:pre-wrap;overflow-wrap:anywhere;font-size:14px}.family-link{display:flex;gap:15px;justify-content:space-between;align-items:center;padding:12px 0;border-bottom:1px solid var(--line);font-size:13px}.family-link small{display:block;color:var(--muted);margin-top:7px}.family-tree{display:grid;grid-template-columns:1fr 1fr;gap:25px;overflow:auto}.family-tree ul{padding-left:20px;list-style:none;border-left:1px solid #3f6359}.family-tree li{padding:6px 0}.family-tree button{max-width:100%;white-space:normal}.family-tree small{color:var(--muted);font-size:11px}.family-spouses{grid-column:1/-1}#family-error:empty{display:none}.family-people .empty{padding:30px 12px}.family-people .empty h3{font-size:16px}#current-user{font-size:12px;margin:12px 0}@media(max-width:900px){.family-layout{grid-template-columns:1fr}.family-people{grid-template-columns:repeat(2,minmax(0,1fr));max-height:350px}.family-tree{grid-template-columns:1fr}.family-spouses{grid-column:auto}.family-toolbar label{flex-wrap:wrap}.family-toolbar input{width:100%}}@media(max-width:760px){.sidebar #logout{display:block;align-self:flex-end}.sidebar #current-user{position:absolute;right:130px;top:15px;font-size:10px}.form-grid{grid-template-columns:1fr}.family-tree ul{padding-left:12px}}#family-detail dl{display:grid;grid-template-columns:1fr 1fr;gap:14px 28px;margin:20px 0 26px}#family-detail dl>div{display:grid;grid-template-columns:105px 1fr;gap:10px;border-bottom:1px solid var(--line);padding-bottom:10px}#family-detail dt{font-size:12px;color:var(--muted)}#family-detail dd{margin:0;font-size:13px;overflow-wrap:anywhere}@media(max-width:1000px){#family-detail dl{grid-template-columns:1fr}}.brand-icon{width:44px;height:44px;object-fit:cover;border-radius:12px;flex-shrink:0}.wall-toolbar{display:flex;align-items:center;gap:15px;flex-wrap:wrap;margin:16px 0}.wall-toolbar select{padding:8px}.wall-paging{display:flex;align-items:center;gap:9px;color:var(--muted);font-size:12px}#wall-clock{margin-left:auto;color:var(--muted);font-size:12px}.live-grid[data-layout="1"]{grid-template-columns:1fr}.live-grid[data-layout="2"],.live-grid[data-layout="4"]{grid-template-columns:repeat(2,minmax(0,1fr))}.live-grid[data-layout="6"],.live-grid[data-layout="9"]{grid-template-columns:repeat(3,minmax(0,1fr))}.live-grid[data-layout="16"]{grid-template-columns:repeat(4,minmax(0,1fr))}.wall-reorder{display:none;padding:8px 12px;align-items:center;gap:8px}.arranging .wall-reorder{display:flex}.wall-reorder span{cursor:grab;margin-right:auto;font-size:12px;color:var(--muted)}.wall-reorder button{padding:4px 9px;font-size:11px}#page-live:is(:fullscreen,.wall-expanded){background:#070f12;padding:12px;width:100vw;height:100dvh;display:flex;flex-direction:column;overflow:hidden}#page-live:is(:fullscreen,.wall-expanded)>.section-head,#page-live:is(:fullscreen,.wall-expanded)>#quality-note{display:none}#page-live:is(:fullscreen,.wall-expanded) .wall-toolbar{margin:0 0 10px;flex-shrink:0}#page-live:is(:fullscreen,.wall-expanded) .live-grid{flex:1;min-height:0;gap:8px;grid-template-rows:repeat(2,minmax(0,1fr))}#page-live:is(:fullscreen,.wall-expanded) .live-grid[data-layout="1"],#page-live:is(:fullscreen,.wall-expanded) .live-grid[data-layout="2"]{grid-template-rows:1fr}#page-live:is(:fullscreen,.wall-expanded) .live-grid[data-layout="9"]{grid-template-rows:repeat(3,minmax(0,1fr))}#page-live:is(:fullscreen,.wall-expanded) .live-grid[data-layout="16"]{grid-template-rows:repeat(4,minmax(0,1fr))}#page-live:is(:fullscreen,.wall-expanded) .camera-card{display:flex;flex-direction:column;min-height:0;position:relative}#page-live:is(:fullscreen,.wall-expanded) .video-panel{flex:1;min-height:0;aspect-ratio:auto}#page-live:is(:fullscreen,.wall-expanded) .camera-meta{padding:7px 10px;align-items:center}#page-live:is(:fullscreen,.wall-expanded) .camera-meta p,#page-live:is(:fullscreen,.wall-expanded) .camera-meta .badge{display:none}#page-live:is(:fullscreen,.wall-expanded) .camera-meta strong{font-size:12px}#page-live:is(:fullscreen,.wall-expanded) .camera-actions{position:absolute;bottom:34px;right:6px;padding:4px;background:#10191ddd;border-radius:6px;opacity:0}#page-live:is(:fullscreen,.wall-expanded) .camera-card:hover .camera-actions,#page-live:is(:fullscreen,.wall-expanded) .camera-card:focus-within .camera-actions{opacity:1}#page-live:is(:fullscreen,.wall-expanded) .camera-actions [data-edit-camera],#page-live:is(:fullscreen,.wall-expanded) .camera-actions [data-play-camera]{display:none}.ptz-panel{background:#1a3038;border:1px solid #41656c;border-radius:12px;padding:16px;display:flex;align-items:center;gap:22px;position:fixed;bottom:22px;right:22px;z-index:4;max-width:calc(100vw - 32px);box-shadow:0 12px 50px #0008}.ptz-panel p{font-size:12px;color:var(--muted);max-width:320px;margin:8px 0 0}.ptz-pad{display:grid;grid-template-columns:repeat(3,46px);grid-template-rows:repeat(3,40px);gap:4px}.ptz-pad button{padding:5px;font-size:17px}.ptz-pad [data-ptz-action=up]{grid-column:2}.ptz-pad [data-ptz-action=left]{grid-column:1;grid-row:2}.ptz-pad [data-ptz-action=stop]{grid-column:2;grid-row:2;background:#f0bda6;font-size:12px}.ptz-pad [data-ptz-action=right]{grid-column:3;grid-row:2}.ptz-pad [data-ptz-action=down]{grid-column:2;grid-row:3}.family-date{border:1px solid var(--line);border-radius:8px;padding:14px;margin:0;min-width:0}.family-date legend{font-size:13px;color:#a5bec1}.family-date label{margin-bottom:10px}.family-date output{display:block;font-size:12px;line-height:1.7;color:var(--accent)}@media(max-width:760px){.wall-toolbar{gap:9px}#wall-clock{display:none}.camera-meta strong{font-size:12px}.camera-actions{flex-wrap:wrap;padding:0 8px 8px}.camera-meta{padding:9px}.ptz-panel{flex-wrap:wrap;gap:12px}.ptz-panel>div:first-child{flex:1;min-width:160px}.family-date{grid-column:1/-1}#page-live:is(:fullscreen,.wall-expanded) .camera-actions{opacity:1}.live-grid[data-layout="16"] .camera-meta strong{font-size:9px}}#page-live:is(:fullscreen,.wall-expanded) .live-grid[data-layout=auto]{grid-template-columns:repeat(3,minmax(0,1fr))}.wall-reorder [data-wall-drag]{touch-action:none;user-select:none;padding:5px 0}.camera-card.wall-drop-target{outline:2px solid var(--accent);outline-offset:-3px}#camera-settings-dialog{width:min(1060px,94vw)}#camera-settings-info dl{display:grid;grid-template-columns:repeat(3,minmax(0,1fr));gap:12px;margin:18px 0 24px;padding:16px;border:1px solid var(--line);border-radius:10px}#camera-settings-info dt{font-size:12px;color:var(--muted);margin-bottom:6px}#camera-settings-info dd{font-size:13px;margin:0;overflow-wrap:anywhere}#camera-image-fields,#camera-video-fields{grid-template-columns:repeat(3,minmax(0,1fr))}#camera-settings-status:empty{display:none}#camera-settings-dialog details{margin-top:20px;color:var(--muted);font-size:13px;line-height:1.8}#page-live:is(:fullscreen,.wall-expanded) .camera-actions [data-camera-settings]{display:none}@media(max-width:700px){#camera-settings-info dl,#camera-image-fields,#camera-video-fields{grid-template-columns:1fr 1fr}}@media(max-width:420px){#camera-settings-info dl,#camera-image-fields,#camera-video-fields{grid-template-columns:1fr}}.ptz-panel{width:620px;display:grid;grid-template-columns:1fr auto;max-height:80dvh;overflow:auto;align-items:start}.ptz-panel>div:first-child{grid-column:1}.ptz-panel .ptz-pad{grid-column:2;grid-row:1/3}#ptz-presets{grid-column:1/-1;min-width:0;border-top:1px solid var(--line);padding-top:12px}#ptz-presets .section-head{margin:0;gap:10px}#ptz-presets p{max-width:none;line-height:1.6}#preset-count{color:var(--muted);font-size:12px}.preset-row{display:flex;align-items:center;gap:5px;padding:9px 0;border-bottom:1px solid var(--line);flex-wrap:wrap}.preset-row strong{font-size:13px;flex:1;overflow-wrap:anywhere}.preset-row button{padding:5px 8px;font-size:12px}#preset-form{display:flex;align-items:end;gap:10px;margin-top:12px}#preset-form label{flex:1;margin:0}#preset-name{width:100%}#preset-confirmation{padding:12px;background:#553b31;border-radius:8px;margin-top:10px}#ptz-close{justify-self:start}.playback-tools{display:flex;align-items:center;gap:12px;flex-wrap:wrap;margin:12px 0}.playback-tools .check{margin:0}.clip-editor{border-top:1px solid var(--line);padding-top:12px}.clip-editor summary{cursor:pointer;margin-bottom:14px}#snapshot-dialog{width:min(1000px,92vw)}#snapshot-image{width:100%;max-height:65vh;object-fit:contain;background:#000;border-radius:8px}#play-position{font-size:13px;color:var(--muted)}@media(max-width:600px){.ptz-panel{right:12px;bottom:12px;padding:12px;gap:12px}.ptz-panel .ptz-pad{grid-column:2}#preset-form{flex-wrap:wrap}#preset-form label{flex-basis:100%}}.settings-sections,.view-presets{display:flex;gap:10px;flex-wrap:wrap;margin:12px 0 22px}.settings-sections button[aria-pressed=true],.view-presets button[aria-pressed=true]{background:var(--accent,#30594e);color:var(--paper,#fff);border-color:var(--accent,#30594e)}.group-custom{margin:16px 0}.group-custom summary{cursor:pointer;padding:10px 0}.device-search-row>button{align-self:end}.journal-entry.just-saved{outline:2px solid var(--accent,#30594e);outline-offset:4px;scroll-margin-block:24px}.family-workspace{display:grid;grid-template-columns:minmax(0,1fr) 310px;gap:18px;align-items:start}.family-canvas-panel{background:#17262b;border:1px solid #39504f;border-radius:14px;overflow:hidden;min-width:0}.family-map-heading{padding:22px 22px 16px;display:flex;justify-content:space-between;align-items:center;gap:14px}.family-map-heading h2{font-size:23px;margin:8px 0 0;letter-spacing:2px}.family-map-heading .eyebrow{font-size:9px}.family-view-tabs{display:flex;border:1px solid var(--line);border-radius:8px;padding:3px;flex-shrink:0}.family-view-tabs button{border:0;padding:8px 12px;border-radius:5px;font-size:12px}.family-view-tabs [aria-pressed=true]{background:#30574c;color:#b8f2df}.family-map-controls{padding:0 20px 16px;display:flex;align-items:center;gap:8px;flex-wrap:wrap}.family-map-controls button{font-size:12px;padding:7px 10px}.family-zoom-controls{display:flex;gap:5px;align-items:center;margin-right:auto}.family-zoom-controls output{font-size:11px;min-width:38px;text-align:center;color:var(--muted)}.family-map-viewport{height:clamp(440px,65vh,740px);overflow:auto;background-color:#e8eeea;background-image:radial-gradient(#b5c5bb 1px,transparent 1px);background-size:22px 22px;position:relative;overscroll-behavior:contain;cursor:grab;scrollbar-color:#82988b #dce5de;scrollbar-width:thin;outline-offset:-3px}.family-map-viewport.panning{cursor:grabbing;user-select:none}.family-map-space{position:relative;min-width:100%;min-height:100%}.family-map-surface{position:absolute;left:0;top:0;transform-origin:0 0}.family-map-lines{position:absolute;inset:0;overflow:visible;pointer-events:none}.family-edge{fill:none;stroke:#86a299;stroke-width:1.6;stroke-linecap:round;stroke-linejoin:round}.family-edge.spouse{stroke:#bd9050;stroke-dasharray:5 4;stroke-width:2}.family-edge.nonbiological{stroke:#9987b4;stroke-dasharray:4 3}.family-edge.focused{stroke-width:2.6;stroke:#337b66}.family-edge.spouse.focused{stroke:#ab791e}.family-edge.nonbiological.focused{stroke:#7b55a2}.family-branch-label{position:absolute;color:#536c60;font-size:12px;letter-spacing:1px;pointer-events:none}.family-node{position:absolute;border:1px solid #c4d0c7;border-radius:12px;background:#fffef9;color:#273e33;padding:13px 15px;text-align:left;white-space:normal;box-shadow:0 4px 11px #263c3010;display:flex;flex-direction:column;gap:4px;overflow:visible;cursor:pointer;transition:box-shadow .15s,border-color .15s}.family-node:hover{filter:none;box-shadow:0 6px 20px #30583d30;border-color:#5b9179}.family-node:focus-visible{outline:3px solid #205a48;outline-offset:4px}.family-node>strong{font-size:16px;line-height:1.3;overflow:hidden;text-overflow:ellipsis;white-space:nowrap;padding-right:30px}.family-node-top{position:absolute;right:12px;top:12px}.family-node-avatar{display:flex;width:28px;height:28px;align-items:center;justify-content:center;background:#e9f0e8;border-radius:9px;font-family:"Noto Serif SC",SimSun,serif;color:#48745c;font-size:17px}.family-node-flags{position:absolute;right:0;top:36px;display:grid;gap:4px;justify-items:end;white-space:nowrap}.family-node-flags>small{font-size:9px;color:#748375}.family-node .family-node-relation{display:block;font-size:11px;color:#577868;max-width:120px;text-overflow:ellipsis;white-space:nowrap;overflow:hidden}.family-node>small{font-size:10px;color:#7a8a80;margin-top:auto}.family-node.self{background:#f6d795;border:2px solid #c49337;box-shadow:0 5px 18px #b487242e}.family-node.self .family-node-avatar{background:#fbe8bd;color:#82561f}.family-node.self>strong{color:#5d3d15}.family-node.self .family-node-relation,.family-node.self>small{color:#7d622f}.self-badge{display:inline-block;border-radius:4px;background:#996e2b;color:#fff4d7;padding:2px 5px;font-size:9px;font-weight:600;letter-spacing:.5px}.family-node.selected{outline:3px solid #3d9175;outline-offset:4px}.family-node.search-hit:after{content:"匹配";position:absolute;left:12px;top:-12px;padding:2px 6px;border-radius:4px;background:#315f8d;color:#fff;font-size:9px;box-shadow:0 2px 4px #0002}.family-node.archived{border-style:dashed}.family-map-footer{padding:15px 20px;border-top:1px solid #a4b7a41f}.family-map-legend{display:flex;gap:15px;flex-wrap:wrap;font-size:11px;color:#a5bbb4;margin-bottom:9px}.family-map-legend>span{display:flex;align-items:center;gap:6px}.family-map-legend i{display:inline-block;width:19px;height:2px;background:#86a299}.family-map-legend i.legend-self{width:11px;height:11px;background:#f6d795;border-radius:3px}.family-map-legend i.legend-selected{width:11px;height:11px;background:transparent;border:2px solid #64bc9d;border-radius:3px}.family-map-legend i.legend-spouse{background:none;border-top:2px dashed #bd9050}.family-map-legend i.legend-adoptive{background:none;border-top:2px dashed #aa98c4}.family-map-footer .description{font-size:11px;margin:0;line-height:1.8}.family-map-footer #family-map-note:not(:empty){padding:8px 0;color:#c9bc9a}.family-inspector{position:sticky;top:18px;max-height:calc(100vh - 36px);overflow:auto;margin:0;padding:20px;min-width:0;scrollbar-width:thin}.family-inspector.is-self{border-color:#b08848;background:linear-gradient(145deg,#343323,#18272a 55%)}.family-self-heading{color:#e8c780;font-size:12px;margin-bottom:18px}.family-back-to-map{display:block;margin:0 0 18px auto;font-size:11px}#family-detail .section-head{gap:12px;flex-wrap:wrap}#family-detail .section-head>div{display:block}#family-detail .section-head h2{font-size:23px;overflow-wrap:anywhere}#family-detail dl{grid-template-columns:1fr;gap:12px;margin:18px 0 24px}#family-detail dl>div{grid-template-columns:76px minmax(0,1fr);gap:9px}#family-detail h3{font-size:14px;margin-top:24px}#family-detail .family-link{align-items:flex-start;overflow-wrap:anywhere;font-size:12px}#family-detail .family-link .quiet{padding:5px 8px;font-size:11px}#family-detail .family-prose{font-size:13px}.family-register{grid-template-columns:repeat(auto-fill,minmax(180px,1fr));max-height:clamp(440px,65vh,740px);overflow:auto;padding:20px;align-content:start;background:#132226}.person-card.self{background:#463e27;border-color:#b28f50;color:#f1dca7}.person-card.self span:not(.self-badge){color:#e0c995}.person-card.self small{color:#b8a98b}.person-card.selected{outline:2px solid #63b89c;outline-offset:-2px}.family-map-viewport>.empty{border:0;background:transparent;color:#5c7567;height:100%;display:flex;flex-direction:column;justify-content:center;margin:0}.family-map-viewport>.empty h3{color:#314d3d}.family-toolbar #family-search{width:190px}.family-toolbar #family-reference{max-width:180px}.family-toolbar{gap:12px}.family-workspace:is(:fullscreen,.family-expanded){width:100vw;height:100dvh;background:#10191d;padding:16px;align-items:stretch;overflow:auto}.family-workspace:is(:fullscreen,.family-expanded) .family-canvas-panel{height:100%;display:flex;flex-direction:column}.family-workspace:is(:fullscreen,.family-expanded) .family-map-viewport{flex:1;height:auto;min-height:200px}.family-workspace:is(:fullscreen,.family-expanded) .family-register{max-height:none;flex:1}.family-workspace:is(:fullscreen,.family-expanded) .family-inspector{position:static;max-height:100%;overflow:auto}.family-workspace:is(:fullscreen,.family-expanded) .family-map-heading{padding:14px 20px}.family-workspace:is(:fullscreen,.family-expanded) .family-map-footer{padding:10px 20px}@media(max-width:1250px){.family-workspace{grid-template-columns:minmax(0,1fr) 270px}.family-map-heading{align-items:flex-start;flex-wrap:wrap}.family-map-controls{gap:6px}.family-map-controls button{padding:7px 8px}.family-inspector{padding:16px}.family-toolbar>span{margin-left:0}}@media(max-width:1000px){.family-workspace{grid-template-columns:1fr}.family-inspector{position:static;max-height:none}.family-map-viewport{height:560px}.family-register{grid-template-columns:repeat(auto-fill,minmax(180px,1fr));max-height:560px}.family-workspace:is(:fullscreen,.family-expanded){display:flex;flex-direction:column;gap:10px}.family-workspace:is(:fullscreen,.family-expanded) .family-canvas-panel{min-height:65vh;flex:1;flex-shrink:0}.family-workspace:is(:fullscreen,.family-expanded) .family-inspector{max-height:35vh;flex-shrink:0}}@media(max-width:600px){#page-family>.section-head{align-items:flex-start;flex-wrap:wrap}#page-family>.section-head>div{gap:7px;flex-wrap:wrap}#page-family>.section-head button{font-size:12px;padding:8px 10px}.family-toolbar{padding:15px}.family-toolbar label{width:100%;display:flex;justify-content:space-between;flex-wrap:nowrap}.family-toolbar label.check{justify-content:flex-start}.family-toolbar input,.family-toolbar #family-search,.family-toolbar #family-reference{width:60%;max-width:60%}.family-toolbar input[type=checkbox]{width:16px}.family-map-heading{padding:17px 15px}.family-map-heading h2{font-size:21px}.family-map-controls{padding:0 12px 14px}.family-map-footer{padding:13px 15px}.family-map-legend{gap:10px}.family-map-viewport{height:470px}.family-register{grid-template-columns:1fr 1fr;padding:12px;gap:10px}.family-register .person-card{padding:12px}.family-workspace:is(:fullscreen,.family-expanded){padding:8px}.family-map-footer>.description:last-child{font-size:10px}}.family-map-heading{flex-wrap:wrap}.family-view-tabs{max-width:100%;flex-wrap:wrap}.family-view-tabs button{font-size:11px}.family-event-intro{display:flex;justify-content:space-between;gap:15px;padding:8px 22px 12px;align-items:flex-start}.family-event-intro h3{font-size:16px;line-height:1.7;margin:0 0 7px}.family-event-intro p{margin:0}.family-event-intro button{font-size:12px;padding:9px 12px}.family-event-filters{display:flex;gap:12px;flex-wrap:wrap;padding:15px 22px;background:#101e2366;border-top:1px solid var(--line);border-bottom:1px solid var(--line)}.family-event-filters label{display:flex;font-size:12px;gap:7px;flex-wrap:wrap}.family-event-filters input:not([type=checkbox]){width:170px}.family-event-filters select{max-width:180px;font-size:12px;padding:8px}.family-event-filters .check{width:100%;font-size:11px}.family-event-filters button{font-size:11px;padding:7px 10px}.family-event-filters #family-event-state-label{margin-right:auto}#family-event-count{padding:16px 22px 0;margin-bottom:0}.family-timeline{padding:0 22px 28px;max-height:680px;overflow:auto;scrollbar-width:thin}.timeline-year{font-family:Georgia,SimSun,serif;color:#a4d6c3;font-size:27px;margin:30px 0 18px;letter-spacing:1px}.timeline-year span{font-family:inherit;font-size:12px;color:var(--muted);margin-left:8px}.timeline-event{display:flex;align-items:flex-start;gap:18px;position:relative;width:100%;background:transparent;color:inherit;text-align:left;padding:0 0 24px;border-radius:0;border:0;white-space:normal}.timeline-event:hover{filter:none}.timeline-event:before{content:"";position:absolute;left:85px;top:10px;bottom:-10px;border-left:1px solid #466659}.timeline-event:after{content:"";position:absolute;left:81px;top:6px;width:9px;height:9px;border-radius:50%;background:#7eccac;box-shadow:0 0 0 4px #1c342d}.timeline-event>time{font-size:12px;font-weight:400;color:#9bb3ae;flex:0 0 70px;margin-top:1px}.timeline-event-body{margin-left:12px;flex:1;min-width:0;border:1px solid #345248;border-radius:10px;padding:17px 19px;background:#20352f;display:flex;flex-direction:column;gap:11px}.timeline-event:hover .timeline-event-body{border-color:#71ad94;background:#264037}.timeline-event-body>strong{font-size:17px;line-height:1.6;color:#dfebe5;overflow-wrap:anywhere}.timeline-event-status{font-size:9px;color:#9fc8b7;letter-spacing:1px}.timeline-summary{font-size:12px;color:#a4beb2;line-height:1.8;font-weight:400;display:-webkit-box;-webkit-line-clamp:3;-webkit-box-orient:vertical;overflow:hidden;white-space:pre-line;overflow-wrap:anywhere}.timeline-event-body>small{font-size:11px;color:#acc9b5;font-weight:400}.timeline-read{font-size:11px;color:#83d6b5;font-weight:400}.timeline-event.draft .timeline-event-body{border-style:dashed;background:#282e30}.timeline-event.draft:after{background:#aea087}.event-associated{display:flex;gap:8px;align-items:center;flex-wrap:wrap;margin:22px 0}.event-associated button{font-size:12px}.event-detail-meta{display:flex;gap:15px;justify-content:space-between;align-items:flex-start;margin:20px 0;color:#97baac;font-size:12px}.event-detail-meta time{line-height:1.8}#event-detail-title{font-size:26px;line-height:1.6;overflow-wrap:anywhere}.event-lead{border-left:3px solid #8cb8a1;background:#233a32;padding:14px 18px;white-space:pre-wrap;font-size:14px;overflow-wrap:anywhere}.event-article{font-size:15px;line-height:2;margin:28px 0;color:#c9d9d1}.event-source{display:inline-block;white-space:normal;overflow-wrap:anywhere;line-height:1.7;margin:8px 0}.event-updated{border-top:1px solid var(--line);padding-top:18px;margin-top:22px}#event-person-choices{display:flex;gap:12px;flex-wrap:wrap;max-height:170px;overflow:auto;padding:14px 0}#event-person-choices label{display:flex;flex-direction:row;align-items:center}.event-editor-actions{gap:12px}.person-events{border-top:1px solid var(--line);margin-top:25px;padding-top:15px}.person-events .section-head{gap:8px}.person-events .section-head h3{margin:0!important;font-size:13px!important}.person-events .section-head small{letter-spacing:0;margin-left:4px}.person-events .section-head button{font-size:10px;padding:6px 7px}.person-event-link{display:flex;flex-direction:column;gap:6px;border:0;background:transparent;color:#c0d6c9;text-align:left;padding:10px 0;margin-bottom:8px;white-space:normal;line-height:1.7;font-size:12px}.person-event-link time{font-size:10px;color:#87a495}.family-workspace:is(:fullscreen,.family-expanded) #family-events{overflow:auto}.family-workspace:is(:fullscreen,.family-expanded) .family-timeline{max-height:none}@media(max-width:600px){.family-event-intro{flex-wrap:wrap;padding:8px 15px 15px}.family-event-filters{padding:15px;gap:10px}.family-event-filters label{font-size:11px}.family-event-filters .check{line-height:1.8;flex-wrap:nowrap}.family-timeline{padding:0 15px 22px}.timeline-event{gap:8px}.timeline-event>time{font-size:10px;flex-basis:55px}.timeline-event:before{left:62px}.timeline-event:after{left:58px}.timeline-event-body{padding:13px;margin-left:9px}.timeline-event-body>strong{font-size:15px}.family-view-tabs button{padding:8px 10px}#event-detail-title{font-size:22px}.event-detail-meta,.event-editor-actions{flex-wrap:wrap}}.family-workspace.family-expanded{position:fixed;inset:0;z-index:8}.family-map-viewport{scrollbar-gutter:stable;overflow-anchor:none}.family-map-space{min-width:0;min-height:0;overflow:clip}.family-workspace:is(:fullscreen,.family-expanded){min-height:0;grid-template-rows:minmax(0,1fr)}.family-workspace:is(:fullscreen,.family-expanded) .family-canvas-panel{min-height:0}.family-workspace:is(:fullscreen,.family-expanded) .family-map-heading,.family-workspace:is(:fullscreen,.family-expanded) .family-map-controls,.family-workspace:is(:fullscreen,.family-expanded) .family-map-footer{flex-shrink:0}.family-workspace.family-expanded{z-index:1100}@media(max-width:1000px){.family-workspace:is(:fullscreen,.family-expanded) .family-canvas-panel{min-height:65vh}}#history-dialog{width:min(1040px,94vw)}#history-list{display:grid;grid-template-columns:repeat(auto-fit,minmax(220px,1fr));gap:10px;max-height:260px;overflow:auto;margin:16px 0}.history-entry{text-align:left;display:flex;flex-direction:column;align-items:flex-start;gap:6px;white-space:normal}.history-entry small,.history-entry span{color:var(--muted);font-size:12px}.history-columns{display:grid;grid-template-columns:1fr 1fr;gap:20px}.history-columns section{min-width:0}.history-columns dd{white-space:pre-wrap;overflow-wrap:anywhere;max-height:240px;overflow:auto}.history-columns dl>div{padding:10px;border-bottom:1px solid #30434a}.history-changed{background:#27443e66;border-radius:8px}#history-confirm{padding:16px;border:1px solid #74d0b7;border-radius:12px;margin-top:18px}#history-confirm button{margin:6px}#history-error:empty{display:none}@media(max-width:650px){.history-columns{grid-template-columns:1fr}#history-list{max-height:200px}}:root{color-scheme:light;--paper: #f4f0e7;--ink: #2d3932;--muted: #6e6b5f;--line: #dcd5c6;--panel: #fffdf8;--accent: #315b4d;--cinnabar: #9e4b3d;--gold: #86682f;--serif: "Songti SC", "STSong", "SimSun", serif;--timeline-paper: #ede8dd;--timeline-grid: #d3ccbc;--timeline-range: #4c7761;color:var(--ink);background:var(--paper);font-family:Microsoft YaHei,PingFang SC,system-ui,sans-serif}body{background-image:radial-gradient(ellipse at 85% 0,#e4e9df80,transparent 50%);min-width:0}::selection{background:#e8d7ad;color:#2d3932}button,.button,input,select,textarea,fieldset{border-radius:5px}button,.button{background:var(--accent);color:#fffdf6;font-weight:500;transition:background .15s,border-color .15s,box-shadow .15s}button:hover,.button:hover{filter:brightness(.95)}.secondary{background:#e8ede5;color:#315b4d;border-color:#c7d3c4}.quiet{background:transparent;color:#586653;border-color:#cfcfbf}input,select,textarea{color:var(--ink);background:#fffefa;border-color:#cbc5b6}input::placeholder,textarea::placeholder{color:#847f72}input:focus,select:focus,textarea:focus{border-color:var(--accent);box-shadow:0 0 0 3px #315b4d12}input[type=range],input[type=checkbox]{accent-color:var(--accent)}label,.family-date legend{color:#625f53}h1,h2,h3{font-family:var(--serif);font-weight:600}h1{font-size:34px;letter-spacing:4px;margin-top:17px}h2{letter-spacing:1px}.sidebar{width:222px;background:#213d34;background-image:linear-gradient(145deg,#2d4b3d,transparent 60%);border-right:1px solid #425344;padding:30px 18px 20px;color:#ebe7d8;scrollbar-width:thin;scrollbar-color:#6f8271 #213d34}.sidebar .brand{gap:11px;padding:4px 5px 30px;color:#f3eddf;font-family:var(--serif);font-size:22px;letter-spacing:2px}.brand-icon{width:44px;height:44px;border-radius:5px;outline:1px solid #c6b98c66;outline-offset:3px}.brand small{font-family:Microsoft YaHei,sans-serif;color:#c0c7b5;font-size:9px;letter-spacing:2px;margin-top:10px}.nav-label{color:#b2bba6;font-size:10px;padding:12px 13px 17px;letter-spacing:3px;border-top:1px solid #b9c2aa24}.sidebar nav{gap:5px}.sidebar nav button{color:#c9d1be;border-radius:4px;padding:12px 13px;gap:13px;position:relative;border:1px solid transparent;background:transparent}.sidebar nav button span{font-size:13px;letter-spacing:.6px}.sidebar nav button:hover{background:#ffffff09;filter:none}.sidebar nav button.active{background:#efebdc;border-color:#e0d6b8;color:#244638}.sidebar nav button.active:after{content:"";width:5px;height:5px;background:var(--cinnabar);position:absolute;right:13px;transform:rotate(45deg)}.sidebar .side-note{padding:22px 5px 8px;color:#c4ccb9;font-size:11px}.sidebar .dot{background:#afc39c;width:5px;height:5px}.sidebar #current-user{color:#d3d7c8;padding:10px 5px 0;border-top:1px solid #b9c2aa24}.sidebar .quiet{color:#d1d6c6;border-color:#8b9a813f;padding:9px;font-size:11px}.sidebar #account-password{margin-bottom:8px}.sidebar :focus-visible{outline-color:#e7c887}main{margin-left:222px;padding:30px 38px 22px;max-width:1900px}main>header{min-height:142px;padding:13px 0 23px;margin-bottom:25px;border-bottom:1px solid #b4b5a2;position:relative;gap:24px;isolation:isolate}main>header:after{content:"";position:absolute;bottom:-2px;left:0;height:3px;width:48px;background:var(--cinnabar)}main>header>div{position:relative;z-index:1}.eyebrow{color:var(--gold);font-size:10px;letter-spacing:3px}header p{color:#686f60;font-size:12px;letter-spacing:.5px}.header-status{color:#666e5e;gap:12px;font-size:11px;flex-shrink:0}.courtyard-landscape{position:absolute;width:330px;height:125px;right:5px;bottom:0;z-index:0;pointer-events:none;opacity:.55}.badge{background:#e4eddf;color:#355b3d;border:1px solid #c8d6be;border-radius:3px;font-size:10px}.badge.off{background:#f2e8d9;color:#835428;border-color:#dfc6a3}.metrics{background:#fcfaf4;border-radius:6px;box-shadow:0 3px 12px #3a402905}.metrics>div{padding:20px 22px;align-items:baseline}.metrics span{color:#6f7260}.metrics strong{font-family:Georgia,var(--serif);color:#365846;font-size:29px}.filter-row{color:#6e6b5f;margin:24px 0}.household-context{display:flex;flex-wrap:wrap;align-items:center;gap:12px 24px;margin:-5px 0 24px;padding:12px 16px;border-left:3px solid var(--gold);background:#eae8dc}.household-context span{font-size:11px;color:var(--muted)}.household-context select{min-width:140px;max-width:240px}.section-head{margin-top:25px}.section-head small{color:#8a7859;font-size:9px;letter-spacing:2px}.wall-toolbar{padding:12px 15px;background:#eae8dc;border:1px solid var(--line);border-radius:5px;gap:14px}.wall-toolbar select{background:#f9f6ed}.live-grid{gap:22px}.camera-card,.site-card,.panel,.empty,.family-canvas-panel{border-radius:6px;box-shadow:0 4px 18px #39422a05}.camera-card{border-color:#d2cebe}.camera-meta{padding:17px 18px 13px}.camera-meta strong{font-family:var(--serif);font-size:16px;letter-spacing:.5px}.camera-meta p{color:#737464;margin-top:7px}.camera-actions{flex-wrap:wrap;gap:7px;padding-bottom:16px}.camera-actions .quiet{border-color:#dbd9cb;color:#52604d;background:#faf9f2}.video-panel{border-radius:5px;border-color:#c1c6b8}.video-empty{color:#b0bdae;background:radial-gradient(ellipse at center,#243d34 0,transparent 70%)}.video-empty .lens{color:#a5bca4}.video-error{color:#f6d7c1;background:#472c26ed}.empty{color:#6c7462;border-color:#c3c6b6}.empty h3{color:#384e3b;font-size:21px}.panel{padding:24px}.time-labels{color:#6e705e}.recording-item{color:#35533f;background:#f9f7ee;border-color:#d5d1c0}.recording-item small{color:#737261}.scan-chip{background:#fffdf7;border-radius:5px}.device-table{border-radius:5px}.device-table th{color:#6a6d5c;background:#ecebde}.device-table td small{color:#737261}.device-table tbody tr:hover{background:#f2f1e7}.site-card h3{font-size:20px}.site-card dt{color:#737261}.site-card dd{color:#384e3b}.audit-item{color:#56654f}.audit-item small{color:#767461}.banner{color:#784c26;background:#f6e9cf;border-color:#dfc797}dialog{background:#fbf8ef;color:var(--ink);border:1px solid #d5c8ac;border-radius:8px;box-shadow:0 28px 100px #172c3455;padding:30px}dialog::backdrop{background:#20382cb8;backdrop-filter:blur(5px)}.dialog-heading{border-bottom:1px solid var(--line);padding-bottom:20px;gap:16px}.dialog-heading h2{font-size:23px}.dialog-footer{gap:10px;flex-wrap:wrap}#auth-dialog{border-top:4px solid var(--cinnabar);padding:38px;background-image:radial-gradient(ellipse at 100% 0,#e4e9dd,transparent 65%)}#auth-dialog .brand-icon{width:52px;height:52px}#auth-form h2{font-size:32px;letter-spacing:3px;margin-top:26px}#auth-form p{color:#6b725d}.form-error{color:#994437}footer{color:#716b5b;font-size:10px;letter-spacing:.5px}#toast{background:#2a4c3c;color:#f3efdc;border-color:#819672;border-radius:5px;box-shadow:0 8px 25px #30433726;max-width:calc(100vw - 30px)}.ptz-panel{background:#f8f5eb;border-color:#b9c5ad;border-radius:7px;box-shadow:0 12px 50px #26392d44;color:var(--ink)}.ptz-pad [data-ptz-action=stop]{color:#8b4236;background:#efdbd0;border-color:#d5b2a4}#preset-confirmation{background:#f4e2d5}#snapshot-image{border-radius:4px}.family-canvas-panel{background:#fcfaf3;border-color:#c7cbb7}.family-map-heading{padding-top:24px}.family-map-heading h2{letter-spacing:3px;font-size:25px}.family-view-tabs{background:#f1eee2;border-color:#d7d0bf;border-radius:4px}.family-view-tabs button{color:#606650;border-radius:2px}.family-view-tabs [aria-pressed=true]{background:#365945;color:#fffbed}.family-map-viewport{background-color:#efece0;background-image:radial-gradient(#c9cbbb 1px,transparent 1px);scrollbar-color:#8b9a7b #e8e6d8}.family-map-lines marker path{fill:#678b71}.family-edge{stroke:#94a58a}.family-edge.focused{stroke:#446b50}.family-edge.spouse{stroke:#a9854f}.family-edge.nonbiological{stroke:#93829e}.family-node{background:#fffdf6;border-color:#c9cdb9;border-radius:5px;color:#304632;box-shadow:0 3px 12px #3943250d}.family-node>strong{font-family:var(--serif);font-size:17px}.family-node-avatar{background:#e8ecdf;color:#536e45;border-radius:4px}.family-node .family-node-relation{color:#53664a}.family-node>small,.family-node-flags>small{color:#6f775f}.family-node.self{background:#f1ddb0;border-color:#af873f;box-shadow:0 5px 18px #b4872425}.family-node.self .family-node-avatar{background:#f8eac9}.family-node.selected{outline-color:#426c50}.family-node.search-hit:after{background:#596b78}.self-badge{background:#94682f;color:#fff8e9;border-radius:2px}.family-map-footer{border-color:#d0d3c0}.family-map-legend{color:#69705b}.family-map-footer #family-map-note:not(:empty){color:#87652f}.family-inspector.is-self{background:linear-gradient(135deg,#f3e3bd,#fcfaf1 65%);border-color:#c3a66b}.family-self-heading{color:#88652d;letter-spacing:1px}.family-register{background:#eeecdf}.person-card{color:#344732;border-color:#c9cbb9}.person-card.selected{background:#e6ecdc;outline-color:#66845b}.person-card.self{background:#f1ddb0;border-color:#b89553;color:#5f461f}.person-card.self span:not(.self-badge),.person-card.self small{color:#765b2e}.family-tree ul{border-color:#a2b197}.family-workspace:is(:fullscreen,.family-expanded){background:var(--paper)}.family-event-filters{background:#f0eee2}.timeline-year{color:#456344;font-family:var(--serif)}.timeline-event:before{border-color:#b7c2a5}.timeline-event:after{background:#768d5f;box-shadow:0 0 0 4px #e7ebdc}.timeline-event>time{color:#6c745d}.timeline-event-body{background:#fffdf6;border-color:#d3d6c2;border-radius:5px}.timeline-event:hover .timeline-event-body{background:#f7f7ec;border-color:#8caa78}.timeline-event-body>strong{color:#344d32;font-family:var(--serif);font-size:18px}.timeline-event-status,.timeline-summary,.timeline-event-body>small{color:#6b725b}.timeline-read{color:#41623b}.timeline-event.draft .timeline-event-body{background:#efede3}.timeline-event.draft:after{background:#a28a62}.event-detail-meta,.person-event-link time{color:#71745e}.event-lead{background:#eaecdd;border-color:#8e9f77;color:#46553b}.event-article{color:#424c3a}.person-event-link{color:#455a3c}.history-columns dl>div{border-color:#d9d6c4}.history-changed{background:#e8ecda;border-radius:4px}#history-confirm{border-color:#b3be98;border-radius:5px;background:#efefdf}#page-live:fullscreen{--muted: #c0c9b4;--line: #52614d;--panel: #25352c;color:#efecdd;background:#111c16;color-scheme:dark}#page-live:fullscreen .wall-toolbar{background:#24372b;border-color:#40543e}#page-live:fullscreen label{color:#d9deca}#page-live:fullscreen select{background:#1a2a20;color:#ebeede;border-color:#65765a}#page-live:fullscreen .quiet{color:#d9dfca;border-color:#66765a;background:transparent}#page-live:fullscreen .camera-card{border-color:#394f38}#page-live:fullscreen .camera-actions{background:#17251ee8}#page-live:fullscreen .ptz-panel{--muted: #6e6b5f;--line: #dcd5c6;color-scheme:light}#page-live:fullscreen .ptz-panel label,#page-live:fullscreen .ptz-panel .quiet{color:#586653;border-color:#cfcfbf}@media(min-width:1600px){main{padding-left:46px;padding-right:46px}}@media(max-width:1100px){.sidebar{width:200px;padding:27px 14px 18px}.sidebar .brand{font-size:20px;gap:9px}.brand-icon{width:38px;height:38px}main{margin-left:200px;padding:24px}.metrics>div{padding:18px 14px}.metrics strong{font-size:25px}.courtyard-landscape{width:260px;opacity:.4}}@media(max-width:760px){.sidebar{position:static;width:auto;padding:22px 17px 14px;display:grid;grid-template-columns:1fr auto;gap:0 10px;overflow:visible}.sidebar .brand{padding:2px 4px 20px;font-size:22px;grid-column:1/-1}.brand-icon{width:38px;height:38px}.brand small{font-size:9px}.sidebar nav{grid-column:1/-1;display:flex;overflow-x:auto;gap:5px;padding-bottom:12px;scrollbar-width:thin;scrollbar-color:#819573 #213d34}.sidebar nav button{padding:10px 12px;gap:7px;flex-shrink:0}.sidebar nav button span{font-size:12px}.sidebar nav button.active:after{display:none}.sidebar #current-user{position:static;grid-column:1/-1;margin:4px 0 10px;padding-top:12px;font-size:11px}.sidebar #account-password,.sidebar #logout{margin:0;font-size:11px;padding:8px 12px;align-self:center;width:fit-content}.sidebar #logout{justify-self:end}main{margin:0;padding:20px 17px}main>header{min-height:132px;padding-top:9px;gap:10px;margin-bottom:20px}h1{font-size:28px;letter-spacing:3px}.eyebrow{font-size:9px;letter-spacing:2px}.header-status{font-size:9px;gap:9px;max-width:123px;padding-top:2px}.header-status .badge{font-size:9px}header p{max-width:205px;font-size:11px;line-height:1.8}.courtyard-landscape{width:170px;height:90px;right:0;opacity:.38}.metrics>div{padding:16px}.metrics strong{font-size:25px}.metrics>div:nth-last-child(-n+2){border-bottom:0}.filter-row{margin:20px 0}.filter-row select{max-width:155px}.filter-row>button{padding:9px}.section-head{flex-wrap:wrap}.section-head>div{gap:10px}.wall-toolbar{padding:11px;gap:10px}.wall-toolbar label{font-size:12px}#wall-fullscreen{padding:10px 12px}.camera-meta{padding:14px}.camera-meta strong{font-size:15px}.camera-actions{padding:0 14px 14px;gap:8px}.camera-actions button{padding:9px 11px}.panel,.site-card{padding:18px}.family-map-heading h2{font-size:23px}dialog{padding:22px}#auth-dialog{padding:30px 26px}.dialog-heading h2{font-size:21px}.dialog-footer{gap:8px}footer{gap:16px;flex-wrap:wrap;font-size:9px}}@media(prefers-reduced-motion:reduce){*,*:before,*:after{scroll-behavior:auto!important;transition:none!important}}.household-actions{display:flex;gap:10px;flex-wrap:wrap;margin:18px 0}.household-context select{max-width:100%}.household-context label{min-width:0}.device-actions,.device-search-row,.device-group-order,.group-step{display:flex;gap:10px;flex-wrap:wrap;align-items:center}.device-search-row{align-items:end}.device-search-row label{flex:1;min-width:160px}.device-group-order{margin:12px 0}.group-step{padding:7px;background:var(--paper);border:1px solid var(--line);border-radius:5px}.group-step select{width:auto;max-width:145px}.group-step button{padding:7px 11px}.group-step>span{color:var(--muted)}.device-group{margin:26px 0}.device-group>h3{font-family:var(--serif);font-size:20px;overflow-wrap:anywhere}.device-group>h3>span{color:var(--gold);padding:0 8px}.device-group>h3 small{font:12px var(--sans);color:var(--muted);white-space:nowrap}.device-tags{display:flex;flex-wrap:wrap;gap:6px}.device-tags span{font-size:11px;padding:3px 8px;background:var(--paper);border:1px solid var(--line)}.site-card dd,.site-card .description{overflow-wrap:anywhere;min-width:0}@media(max-width:600px){.device-actions{width:100%}.device-actions button{flex:1;white-space:normal}.group-step{width:100%}.group-step select{flex:1;max-width:none;min-width:0}.device-group>h3{font-size:18px}}#scope-navigation{border-left:1px solid #6d8270;margin:12px 0 12px 10px;padding-left:9px}#scope-navigation .nav-label{padding:10px 12px;overflow-wrap:anywhere}.device-context{padding:18px 22px;margin:20px 0;border:1px solid var(--line);border-left:4px solid var(--accent);background:var(--panel)}.device-context p{color:var(--muted);overflow-wrap:anywhere;margin:0 0 14px}.device-context [role=group]{display:flex;flex-wrap:wrap;gap:8px}.device-context button.active{color:var(--paper);background:var(--accent)}.device-title{border:0;padding:0;background:transparent;color:var(--ink);font:inherit;text-align:left;box-shadow:none;white-space:normal;overflow-wrap:anywhere}.device-title:hover{color:var(--accent);background:transparent}.device-title span{color:var(--accent)}.scope-intro{padding:28px 0}.scope-intro h2{font:500 32px var(--serif);margin:12px 0}.scope-intro p{color:var(--muted);line-height:1.8}.steward-grid{display:grid;grid-template-columns:repeat(2,minmax(0,1fr));gap:20px}.steward-tile{display:flex;flex-direction:column;text-align:left;gap:12px;min-height:190px;padding:28px;border:1px solid var(--line);border-top:3px solid var(--accent);background:var(--panel);color:var(--ink);white-space:normal;box-shadow:0 3px 12px #22332208}.steward-tile strong{font-size:23px;font-family:var(--serif);font-weight:500}.steward-tile span,.steward-tile small{color:var(--muted);line-height:1.7}.steward-tile:hover{background:var(--paper);border-color:var(--accent)}#device-detail dl,#heritage-detail dl{display:grid;grid-template-columns:repeat(2,minmax(0,1fr));gap:18px}#device-detail dl>div,#heritage-detail dl>div{border-bottom:1px solid var(--line);padding-bottom:12px}#device-detail dt,#heritage-detail dt{font-size:12px;color:var(--muted);margin-bottom:6px}#device-detail dd,#heritage-detail dd{margin:0;overflow-wrap:anywhere}.heritage-prose{white-space:pre-wrap;line-height:1.9;overflow-wrap:anywhere;margin:24px 0}#heritage-detail{margin-top:24px}.heritage-controls{display:flex;gap:18px;flex-wrap:wrap;align-items:center;margin-bottom:22px}.heritage-controls label{min-width:0}.household-context{flex-wrap:wrap}@media(max-width:720px){.steward-grid{grid-template-columns:1fr}.steward-tile{min-height:150px;padding:22px}.device-context{padding:16px}.device-context button{flex:1 1 40%;min-width:0}#device-detail dl,#heritage-detail dl{grid-template-columns:1fr}#scope-navigation{display:flex;flex-wrap:wrap;border:0;margin:0;padding:0;width:100%}#scope-navigation .nav-label{width:100%;padding:8px 4px}.scope-intro h2{font-size:26px}}#household-list{display:block}.home-city-group{margin:24px 0 36px}.home-city-group>h3{font-size:21px}.home-city-group>h3 small{font:12px sans-serif;color:var(--muted);margin-left:12px}.home-card{padding:0;overflow:hidden}.home-cover{position:relative;min-height:210px;background:linear-gradient(145deg,#4b6957,#253d34);isolation:isolate;color:#fffdf6}.home-cover>img{position:absolute;width:100%;height:100%;object-fit:cover;inset:0;z-index:-2}.home-cover:after{content:"";position:absolute;inset:0;background:linear-gradient(0deg,#102019db,transparent);z-index:-1}.home-cover-content{padding:24px;min-height:210px;display:flex;flex-direction:column;justify-content:end}.home-cover .site-heading{margin-bottom:auto}.home-cover h3{margin:26px 0 4px;color:#fffdf6;text-shadow:0 1px 3px #000a;font-size:25px}.home-cover .quiet{background:#172a25ba;color:#fff;border-color:#bccabd80}.home-cover .badge{background:#f9f5e5e8;color:#244638;border-color:transparent}.home-location{font-size:12px;margin:8px 0 0;color:#fffdf6}.home-cover-placeholder{position:absolute;top:88px;right:22px;opacity:.3;font:18px var(--serif);letter-spacing:5px}.home-card-body{padding:24px}.home-card-body .household-actions{margin-bottom:0}.cover-editor img{width:100%;max-height:230px;object-fit:contain;border:1px solid var(--line);margin-bottom:12px;background:var(--paper)}#page-settings h3{font-size:21px;margin-top:8px}#page-settings .form-grid{margin:22px 0}#page-settings input:not([type=checkbox]),#page-settings select{width:100%;min-width:0}.brand-image-grid{display:grid;grid-template-columns:1fr 1fr;gap:24px;margin:28px 0}.brand-image-grid>div{border:1px solid var(--line);padding:18px;border-radius:6px;min-width:0}.brand-image-grid img{width:80px;height:80px;object-fit:contain;background:var(--paper);border-radius:6px;display:block;margin-bottom:18px}.brand-image-grid label{display:grid;gap:12px;margin-bottom:14px}.config-import{font-size:12px;max-width:300px}.backup-row{display:grid;gap:8px;padding:18px 0;border-bottom:1px solid var(--line);font-size:12px}.backup-row small,.backup-row code{overflow-wrap:anywhere}.backup-row span{color:var(--muted)}#settings-error,#brand-status,#preferences-status,#backup-save-status,#backup-result{line-height:1.8;font-size:13px;overflow-wrap:anywhere}.brand #brand-name{overflow-wrap:anywhere;letter-spacing:1px}.brand #brand-subtitle{overflow-wrap:anywhere;line-height:1.8;letter-spacing:1px}html[data-backdrop=plain] body{background-image:none}html[data-backdrop=plain] .courtyard-landscape{display:none}html[data-font=sans]{--serif:"Microsoft YaHei","PingFang SC",system-ui,sans-serif}html[data-density=compact] main{padding:20px 26px}html[data-density=compact] main>header{min-height:100px;padding:6px 0 15px;margin-bottom:20px}html[data-density=compact] .panel,html[data-density=compact] .site-card:not(.home-card),html[data-density=compact] .home-card-body{padding:17px}html[data-density=compact] .sidebar nav button{padding:9px 12px}html[data-density=compact] .steward-tile{min-height:150px;padding:20px}html[data-density=compact] .metrics>div{padding:13px 18px}html[data-density=compact] .home-cover,html[data-density=compact] .home-cover-content{min-height:180px}html[data-theme=clean]{--paper:#f3f6fa;--ink:#203349;--muted:#53667d;--panel:#ffffff;--line:#d2dce7;--accent:#285ca0;--gold:#52657f;--cinnabar:#386ea8;--timeline-paper:#edf2f8;--timeline-grid:#cbd6e4;--timeline-range:#4c72a5;--surface-alt:#e8eff8;--side:#1e3551;--on-accent:#ffffff;color-scheme:light}html[data-theme=ink]{--paper:#151d22;--ink:#e3e9e5;--muted:#afbdb5;--panel:#202c32;--line:#46565a;--accent:#a2cab4;--gold:#d6bd83;--cinnabar:#e0a390;--timeline-paper:#26343b;--timeline-grid:#516369;--timeline-range:#91bda6;--surface-alt:#2a3940;--side:#132020;--on-accent:#13231c;color-scheme:dark}html[data-theme=clean] body,html[data-theme=ink] body{background-color:var(--paper);color:var(--ink)}html:is([data-theme=clean],[data-theme=ink]) .sidebar{background:var(--side);border-color:var(--line)}html:is([data-theme=clean],[data-theme=ink]) main>header{border-color:var(--line)}html:is([data-theme=clean],[data-theme=ink]) :is(.metrics,.panel,.site-card,.camera-card,.empty,.family-canvas-panel,.scan-chip,dialog){background-color:var(--panel);border-color:var(--line);color:var(--ink)}html:is([data-theme=clean],[data-theme=ink]) :is(.household-context,.wall-toolbar,.device-table th,.family-view-tabs,.family-map-viewport,#preset-confirmation){background-color:var(--surface-alt);color:var(--ink);border-color:var(--line)}html:is([data-theme=clean],[data-theme=ink]) :is(input,select,textarea){background:var(--panel);border-color:var(--line);color:var(--ink)}html:is([data-theme=clean],[data-theme=ink]) :is(input,textarea)::placeholder{color:var(--muted)}html:is([data-theme=clean],[data-theme=ink]) :is(label,header p,.header-status,.metrics span,.filter-row,.section-head small,.camera-meta p,.empty,.time-labels,.recording-item small,.device-table td small,.site-card dt,.audit-item,.audit-item small,footer,#auth-form p,.family-date legend){color:var(--muted)}html:is([data-theme=clean],[data-theme=ink]) :is(.metrics strong,.empty h3,.site-card dd){color:var(--ink)}html:is([data-theme=clean],[data-theme=ink]) button:not(.quiet):not(.secondary):not(.device-title):not(.steward-tile),html:is([data-theme=clean],[data-theme=ink]) .button{background:var(--accent);color:var(--on-accent)}html:is([data-theme=clean],[data-theme=ink]) :is(.quiet,.secondary,.recording-item,.camera-actions .quiet){background:var(--surface-alt);color:var(--ink);border-color:var(--line)}html:is([data-theme=clean],[data-theme=ink]) .sidebar nav button{background:transparent;color:#dbe5e4}html:is([data-theme=clean],[data-theme=ink]) .sidebar nav button.active{background:var(--accent);color:var(--on-accent);border-color:var(--accent)}html:is([data-theme=clean],[data-theme=ink]) .sidebar>.quiet{background:transparent;color:#dbe5e4}html:is([data-theme=clean],[data-theme=ink]) #auth-dialog{background-image:none;background-color:var(--panel)}html:is([data-theme=clean],[data-theme=ink]) .device-table tbody tr:hover{background:var(--surface-alt)}html:is([data-theme=clean],[data-theme=ink]) .family-node{background:var(--panel);border-color:var(--line);color:var(--ink)}html:is([data-theme=clean],[data-theme=ink]) .family-node.self{background:#ebd6aa;color:#2b3b30;border-color:#b79a59}html:is([data-theme=clean],[data-theme=ink]) .family-node.self :is(small,span,strong){color:#2b3b30}html[data-theme=ink] :is(.form-error,.family-warning){color:#ffc8b6}html[data-theme=ink] .ptz-panel{background:var(--panel);color:var(--ink);border-color:var(--line)}html[data-theme=ink] .home-cover .quiet{background:#172a25df;color:#fff}html[data-theme=ink] body{background-image:radial-gradient(ellipse at 90% 0,#263c3340,transparent 65%)}@media(min-width:761px){html[data-layout=top] .sidebar{position:relative;width:100%;padding:16px 30px;display:flex;align-items:center;flex-wrap:wrap;gap:12px 22px;min-height:0;height:auto;border-right:0;border-bottom:1px solid var(--line)}html[data-layout=top] .sidebar .brand{padding:0;max-width:250px}html[data-layout=top] .sidebar>.nav-label,html[data-layout=top] .side-note{display:none}html[data-layout=top] .sidebar nav{display:flex;flex:1;flex-wrap:wrap;min-width:250px;gap:6px}html[data-layout=top] #scope-navigation{display:flex;flex-wrap:wrap;width:100%;order:1;margin:0;padding:0;border:0}html[data-layout=top] #scope-navigation .nav-label{display:none}html[data-layout=top] .sidebar #current-user{margin:0;padding:0;border:0}html[data-layout=top] .sidebar>.quiet{margin:0}html[data-layout=top] main{margin-right:auto;margin-left:auto}html[data-layout=top] .sidebar nav button{width:auto;white-space:nowrap}}@media(max-width:760px){.brand-image-grid{grid-template-columns:1fr}.home-cover-content,.home-card-body{padding:20px}.home-cover-placeholder{font-size:15px}.sidebar #logout{display:block}#page-settings .form-grid{grid-template-columns:1fr}html[data-density=compact] main{padding:18px 14px}#household-form .form-grid{grid-template-columns:1fr}.home-city-group>h3 small{display:block;margin:8px 0}}.journal-feed{max-width:1080px;margin:0 auto}.journal-compose textarea{resize:vertical;min-height:130px}.journal-compose>label{display:grid;gap:12px}.journal-add-media,.journal-reactions{display:flex;flex-wrap:wrap;gap:12px;margin:20px 0}.journal-add-media>label{display:flex;align-items:center;gap:10px;flex-wrap:wrap}.journal-add-media input{max-width:260px}.journal-filters{display:flex;align-items:end;flex-wrap:wrap;gap:16px}.journal-filters label{flex:1;min-width:145px;display:grid;gap:7px}.journal-entry{border-left:3px solid #a98964;margin-bottom:26px}.journal-entry .section-head small{display:block;color:var(--muted);margin-top:6px}.journal-text{white-space:pre-wrap;overflow-wrap:anywhere;line-height:1.95;font-size:17px}.journal-author{font-size:20px!important;font-family:serif}.journal-media{display:grid;grid-template-columns:repeat(auto-fit,minmax(min(100%,240px),1fr));gap:14px}.journal-media figure{margin:0;min-width:0}.journal-media img,.journal-media video{width:100%;max-height:450px;object-fit:contain;border-radius:8px;background:#1a2925}.journal-media audio{width:100%;max-width:100%}.journal-media figcaption{font-size:13px;overflow-wrap:anywhere;margin-top:6px}.journal-image-load{width:100%;min-height:150px;background:#e9eee2!important}.journal-upload{display:flex;align-items:center;justify-content:space-between;gap:10px;flex-wrap:wrap;border-bottom:1px solid #d9d7c8;padding:12px 0}.journal-upload label{flex:1;overflow-wrap:anywhere}.journal-upload small{display:block}.journal-upload input[type=checkbox]{width:auto}.journal-resume input{max-width:220px}.journal-comments{border-top:1px solid #d9d7c8;padding-top:15px}.journal-comments form{display:flex;align-items:end;gap:12px;flex-wrap:wrap}.journal-comments form label{flex:1;min-width:170px}.journal-comment{padding:10px 0;border-bottom:1px dashed #d9d7c8;overflow-wrap:anywhere}.journal-comment small{font-size:11px;color:var(--muted)}.journal-reactions [aria-pressed=true]{color:#ad5842!important}.journal-comments .quiet{padding:4px 8px;font-size:12px}.journal-feed .panel{overflow:hidden}html[data-theme=ink] .journal-image-load{background:#293f37!important}.journal-upload-grid{display:grid;grid-template-columns:repeat(auto-fill,minmax(min(100%,280px),1fr));gap:18px;margin:20px 0}.journal-upload-card{border:1px solid var(--line,#d9d7c8);border-radius:12px;padding:16px;background:var(--surface,#fffdf8);min-width:0;display:flex;flex-direction:column;gap:14px}.journal-upload-card:has(input:checked){border-color:#456f5f;box-shadow:0 0 0 1px #456f5f}.journal-upload-select{display:flex!important;align-items:flex-start;gap:10px;overflow-wrap:anywhere;line-height:1.5}.journal-upload-select input[type=checkbox]{width:18px;min-width:18px;height:18px;margin-top:3px;accent-color:#315a4e}.journal-upload-select small{display:block;font-size:12px;color:var(--muted);margin-top:4px}.journal-card-actions{display:flex;align-items:center;flex-wrap:wrap;gap:10px;margin-top:auto}.journal-card-actions button{padding:8px 13px;font-size:13px}.journal-card-actions [data-remove-upload]{margin-left:auto;color:#954f40}.journal-card-actions a,.journal-media-caption a{font-size:13px;color:var(--accent,#315a4e)}.journal-attachment{margin:0;min-width:0}.journal-photo{display:block;position:relative;width:100%;padding:0!important;border:0!important;background:#e6e9df!important;border-radius:9px;overflow:hidden;color:#fff!important}.journal-photo img{display:block;width:100%;min-height:120px;max-height:450px;object-fit:contain;aspect-ratio:16/10;background:#e6e9df;border-radius:9px}.journal-photo-hint{position:absolute;right:10px;bottom:10px;padding:4px 9px;background:#213a30c9;border-radius:5px;font-size:12px}.journal-upload-card .journal-photo img{height:180px;min-height:0;object-fit:cover}.journal-attachment video{width:100%;max-height:450px;border-radius:8px;background:#1a2925}.journal-upload-card video{height:180px}.journal-attachment audio{width:100%;max-width:100%}.journal-audio{background:#e9eee5;border:1px solid #d5decd;border-radius:10px;padding:14px}.journal-audio-label{display:flex;align-items:center;gap:10px;color:#42614f;font-size:13px;letter-spacing:1px;margin:0 0 14px}.journal-audio-label span{font-size:28px}.journal-media-state{display:block;font-size:12px;color:var(--muted);padding-top:6px;min-height:0}.journal-media-state:empty{display:none}.journal-media-caption{font-size:12px;color:var(--muted);overflow-wrap:anywhere;margin:8px 0 16px}.journal-trash{padding:12px 0;border-top:1px solid #d9d7c8}.journal-trash-row{display:flex;align-items:center;gap:15px;justify-content:space-between;padding:10px 0;border-bottom:1px solid #d9d7c8;overflow-wrap:anywhere}.journal-preview{width:min(960px,94vw);max-width:94vw;padding:24px;max-height:94vh}.journal-preview header,.journal-preview footer{display:flex;align-items:center;justify-content:space-between;gap:18px;position:static}.journal-preview header{margin-bottom:20px}.journal-preview h2{font-size:22px;overflow-wrap:anywhere;margin:0}.journal-preview footer{font-size:13px;margin-top:18px}.journal-preview .journal-photo img{max-height:65vh;min-height:0;aspect-ratio:auto}.journal-preview .journal-photo{pointer-events:none}.journal-preview .journal-photo-hint{display:none}.journal-preview video{max-height:65vh}html[data-theme=ink] .journal-upload-card{background:#20352d}html[data-theme=ink] .journal-audio{background:#293f37;border-color:#436152}html[data-theme=ink] .journal-audio-label{color:#d5e2ce}@media(max-width:600px){.journal-upload-grid{grid-template-columns:1fr}.journal-preview{padding:16px}.journal-preview h2{font-size:17px}.journal-preview header button{flex-shrink:0}.journal-media{grid-template-columns:1fr}}@media(max-width:760px){.sidebar{display:grid;grid-template-columns:minmax(0,1fr) auto;gap:12px;align-items:center;padding:14px 16px;height:auto;min-height:0}.sidebar .brand{min-width:0;padding:0;gap:10px}.sidebar .brand>span{min-width:0}.sidebar #brand-name{font-size:23px;display:block;overflow:hidden;text-overflow:ellipsis;white-space:nowrap}.sidebar .brand-icon{width:38px;height:44px}.sidebar #brand-subtitle{font-size:11px;letter-spacing:1px}.sidebar .mobile-nav-toggle{display:block;margin:0;min-height:44px;color:#f7f3e5;border-color:#8faaa0;padding:9px 14px}.sidebar:not(.mobile-open)>nav,.sidebar:not(.mobile-open)>#current-user,.sidebar:not(.mobile-open)>#account-password,.sidebar:not(.mobile-open)>#logout{display:none}.sidebar>nav,.sidebar>#current-user{grid-column:1/-1}.sidebar.mobile-open>nav{display:grid;grid-template-columns:1fr 1fr;gap:6px;margin:0;padding:8px 0 0}.sidebar #scope-navigation{display:contents}.sidebar #scope-navigation[hidden]{display:none}.sidebar nav button{width:100%;text-align:left;min-height:44px;white-space:normal;margin:0;font-size:14px}.sidebar.mobile-open>#current-user{margin:0;padding:12px 0 0}.sidebar.mobile-open>#account-password,.sidebar.mobile-open>#logout{display:block;min-height:44px;margin:0}main{padding:22px 16px}main>header{margin-bottom:22px}.header-status #clock{display:none}input:not([type=checkbox]):not([type=radio]):not([type=range]),select,textarea{font-size:16px!important;min-height:44px}button,.button{min-height:44px;touch-action:manipulation}.form-grid{grid-template-columns:1fr}.form-grid>*{min-width:0}.form-grid .wide{grid-column:1/-1}.section-head{flex-wrap:wrap;gap:12px}.section-head>div{max-width:100%}.section-head button{white-space:normal}.household-context{gap:10px;padding:12px}.household-context label{width:100%;display:flex;flex-wrap:wrap}.household-context select{flex:1;min-width:0}.household-context #household-context-note{display:none}.filter-row{gap:10px;flex-wrap:wrap}.filter-row label{width:100%;display:grid;grid-template-columns:1fr}.filter-row select{width:100%}.settings-sections,.view-presets{gap:8px}.settings-sections button,.view-presets button{flex:1 1 100px;white-space:normal}.device-actions,.device-search-row{gap:10px}.device-search-row{display:grid;grid-template-columns:1fr}dialog{width:calc(100% - 24px);max-width:calc(100% - 24px);max-height:90vh;max-height:90dvh;padding:18px;overscroll-behavior:contain}dialog header,dialog .dialog-heading{gap:12px;align-items:flex-start}dialog h2{font-size:22px}dialog footer{flex-wrap:wrap}.journal-compose,.journal-entry{padding:18px}.journal-filters{gap:12px}.journal-filters label{flex-basis:100%;min-width:0}.journal-add-media input{max-width:100%;width:100%}.journal-add-media>label{width:100%}.journal-preview{padding:16px}.journal-preview .journal-photo img,.journal-preview video{max-height:60vh;max-height:60dvh}.journal-upload-card{padding:12px}.journal-media audio{min-width:0}.journal-comments form label{min-width:0;flex-basis:100%}.device-context [role=group]{display:flex;flex-wrap:wrap;gap:8px}.device-context button{flex:1 1 42%;white-space:normal}.metrics{margin-bottom:20px}}@media(max-width:760px){.sidebar .brand{grid-column:1;max-width:100%;width:auto}.sidebar>.mobile-nav-toggle{grid-column:2;grid-row:1;width:auto;max-width:110px}.sidebar .brand-icon{flex-shrink:0}.sidebar .brand>span{overflow:hidden}.sidebar #brand-name{font-size:21px}}.geo-picker{min-width:0;border:1px solid var(--line,#d8d2c3);border-radius:10px;padding:14px;margin:0}.geo-picker legend{padding:0 8px}.geo-picker .geo-path{display:block;overflow-wrap:anywhere;margin-top:10px;font-size:.9rem}.geo-picker .form-grid{min-width:0}.geo-picker input,.geo-picker select{width:100%;min-width:0}#household-cover-status[data-error=true]{color:#ad3c28;font-weight:600}#household-cover-preview{max-width:100%;max-height:240px;object-fit:contain}.home-layout-controls{padding:16px 20px}.home-layout-controls .device-actions{align-items:end;flex-wrap:wrap}.home-layout-controls label{margin:0;min-width:90px}.home-layout-controls label.check{min-width:0;align-self:center}.home-card-grid{display:grid;grid-template-columns:repeat(var(--home-columns,2),minmax(0,1fr));gap:20px;align-items:start}.home-card-grid .home-card{min-width:0}.home-card-grid .home-card-body{padding:18px}.home-card-grid .home-cover-content{min-height:190px;padding:18px}.home-card-grid .home-cover{min-height:190px}.home-card-grid .home-card-body dl{margin:12px 0}.home-card-grid .home-card-body .description{font-size:13px}.home-card-grid .household-actions{display:flex;flex-wrap:wrap;gap:8px}.home-card-grid .household-actions button{font-size:13px;padding:10px 12px}.home-order-actions{display:flex;gap:8px;align-items:center;flex-wrap:wrap;margin-bottom:14px}.home-order-actions span{font-size:12px;color:var(--muted)}.home-order-actions button{font-size:12px;padding:8px}.home-card[draggable=true]{cursor:grab;outline:1px dashed var(--accent);outline-offset:3px}.home-pagination{display:flex;gap:18px;justify-content:center;align-items:center;margin:24px 0;flex-wrap:wrap}.home-pagination span{font-size:13px;color:var(--muted)}@media(max-width:1100px){.home-card-grid{grid-template-columns:repeat(min(var(--home-columns,2),2),minmax(0,1fr))}}@media(max-width:650px){.home-card-grid{grid-template-columns:minmax(0,1fr)}.home-layout-controls{padding:12px}.home-layout-controls .device-actions{gap:10px}.home-layout-controls button{padding:10px 12px}.home-pagination{gap:10px}.home-card-grid .home-cover-content{padding:16px}}.device-network{min-width:0;border:1px solid var(--line);padding:16px}.device-network legend{padding:0 8px}.topology-tree,.topology-tree ul{list-style:none;padding:0;margin:20px 0}.topology-tree ul{margin-left:24px;padding-left:24px;border-left:2px solid var(--accent,#31584a)}.topology-tree li{position:relative;margin:18px 0;min-width:0}.topology-tree ul>li:before{content:"";position:absolute;left:-24px;top:28px;width:24px;border-top:2px solid var(--accent,#31584a)}.topology-node{border:1px solid var(--line);border-radius:10px;padding:20px;background:var(--paper);max-width:800px;overflow-wrap:anywhere}.topology-node h3{margin:12px 0}.topology-node dl{display:grid;gap:8px}.topology-node dl>div{display:grid;grid-template-columns:100px minmax(0,1fr);gap:10px}.topology-node dd{margin:0}.topology-node dt,.topology-node p{font-size:13px;color:var(--muted)}.topology-node .device-title{text-align:left}@media(max-width:650px){.topology-tree ul{margin-left:8px;padding-left:12px}.topology-tree ul>li:before{left:-12px;width:12px}.topology-node{padding:14px}.topology-node dl>div{grid-template-columns:72px minmax(0,1fr)}.device-network .form-grid{grid-template-columns:1fr}}.platform-topology-root{border:1px solid var(--line);border-top:4px solid var(--accent,#31584a);background:var(--paper);padding:22px;text-align:center;margin:24px auto;max-width:420px;border-radius:10px}.platform-place-grid{display:grid;grid-template-columns:repeat(auto-fit,minmax(min(100%,260px),1fr));gap:24px;border-top:2px solid var(--line);padding-top:24px}.platform-place-node{position:relative;text-align:left;white-space:normal;min-width:0;border:1px solid var(--line);border-radius:10px;background:var(--paper);color:var(--text);padding:22px}.platform-place-node:before{position:absolute;content:"";height:25px;top:-25px;left:50%;border-left:2px solid var(--line)}.platform-place-node h3{margin:16px 0}.platform-place-node p,.platform-place-node small{color:var(--muted)}.platform-place-node>span:last-child{display:block;margin-top:18px}.platform-place-node:hover{border-color:var(--accent,#31584a);background:var(--surface,#f1f2e9)}.topology-tree{display:flex;gap:24px;align-items:start;flex-wrap:wrap}.topology-tree>li{flex:1 1 400px}.topology-tree ul{display:flex;gap:16px;flex-wrap:wrap}.topology-tree ul>li{flex:1 1 260px;max-width:560px}.topology-node{max-width:560px;padding:16px}.device-actions #devices-card-view[aria-pressed=true],.device-actions #devices-topology-view[aria-pressed=true],.device-actions #home-card-view[aria-pressed=true],.device-actions #home-topology-view[aria-pressed=true]{background:var(--accent,#31584a);color:#fff}.home-card-grid[hidden],.home-layout-controls[hidden],.home-pagination[hidden]{display:none!important}:root{--bs-primary: #28624f;--bs-primary-rgb: 40, 98, 79;--bs-body-color: #263f36;--bs-body-bg: #f4f6f4;--bs-border-color: #dde4df;--bs-border-radius: .65rem;--ui-surface: #fff;--ui-muted: #67776d;--ui-line: #dfe6e1;--ui-sidebar: #193c32;--ui-accent: #28624f;--ui-bg: #f4f6f4;--ink: #263f36;--muted: #67776d;--paper: #fff;--line: #dfe6e1;--green: #28624f;--green-dark: #193c32;--cream: #f4f6f4}html,body{min-width:320px;margin:0;background:var(--ui-bg)!important;color:var(--ink);font-family:Inter,Segoe UI,Microsoft YaHei,system-ui,sans-serif;font-size:14px;line-height:1.65}body{display:block!important;background-image:none!important}body:before,body:after{display:none!important}#app{min-height:100vh;display:grid;grid-template-columns:232px minmax(0,1fr)}*,*:before,*:after{box-sizing:border-box}[hidden]{display:none!important}button,input,select,textarea{font:inherit}button,a,input,select,textarea{touch-action:manipulation}button{letter-spacing:0!important}.app-icon{width:20px;height:20px;flex:0 0 20px;vertical-align:middle}.btn .app-icon{width:17px;height:17px}.sidebar{width:232px!important;position:fixed!important;inset:0 auto 0 0;z-index:20;background:var(--ui-sidebar)!important;color:#e6f0eb;padding:28px 18px 20px!important;display:flex;flex-direction:column;height:100dvh;overflow:auto;border:0!important;box-shadow:none!important}.brand{padding:0 6px 24px!important;gap:12px;text-decoration:none;color:#fff!important;border-bottom:1px solid #ffffff14!important;margin:0 0 24px!important;display:flex;align-items:center}.brand-icon{width:42px!important;height:42px!important;object-fit:contain;border-radius:10px}.brand>span>span{font-size:22px!important;line-height:1.2;letter-spacing:2px}.brand small{font-size:11px!important;letter-spacing:1px;color:#acc4b8!important;margin-top:6px;display:block}.nav-label{font-size:10px!important;letter-spacing:2px;padding:0 12px;margin-bottom:12px;color:#95b5a6!important}.sidebar nav{display:flex!important;flex-direction:column!important;gap:5px}.sidebar nav button{display:flex;gap:12px;align-items:center;text-align:left;width:100%;color:#c0d6c9!important;background:transparent!important;border:0!important;box-shadow:none!important;border-radius:8px!important;min-height:44px;padding:10px 13px!important;font-size:13px!important;white-space:normal}.sidebar nav button:hover{background:#ffffff0d!important;color:#fff!important}.sidebar nav button.active{background:#ffffffed!important;color:#234c3d!important;font-weight:600}.sidebar nav .app-icon{opacity:.85}#scope-navigation{border:0!important;padding:18px 0 10px!important;margin:7px 0!important;box-shadow:0 -1px #ffffff14,0 1px #ffffff14}#scope-nav-name{max-width:185px;white-space:nowrap;overflow:hidden;text-overflow:ellipsis;margin:0 0 12px}.side-note{margin-top:auto;padding:36px 12px 16px;font-size:10px;color:#9abbab}.side-note p{display:none}.sidebar #current-user{color:#c1d3c8!important;border-top:1px solid #ffffff18;padding-top:14px;font-size:11px;margin:0 0 8px}.sidebar>#account-password,.sidebar>#logout{border-color:#ffffff20!important;color:#c1d3c8!important;background:transparent!important;font-size:11px;min-height:32px;padding:5px;margin:4px 0}.mobile-nav-toggle{display:none}#app>main{grid-column:2;margin:0!important;padding:28px 34px 20px!important;width:100%;min-width:0;max-width:1800px;min-height:100vh;background:none!important}main>header{padding:0 0 24px!important;margin:0 0 24px!important;border-bottom:1px solid var(--ui-line)!important;display:flex;align-items:center;justify-content:space-between;gap:20px;min-height:0!important;background:none!important;position:relative}main>header:after,main>header:before{display:none!important}.eyebrow{font-size:10px;letter-spacing:2px;color:var(--ui-muted)!important;margin-bottom:7px}h1,#page-title{font-family:inherit!important;font-size:26px!important;font-weight:650!important;line-height:1.35;letter-spacing:-.5px!important;margin:0 0 7px!important}h2{font-size:19px!important;font-weight:600!important;line-height:1.45;letter-spacing:0!important;margin:0 0 5px!important}h3{font-size:16px!important;line-height:1.5;font-weight:600!important;letter-spacing:0!important}h2,h3,h4{font-family:inherit!important}#page-note{font-size:12px!important;color:var(--ui-muted);margin:0!important}.header-status{align-items:flex-end;gap:8px;font-size:10px!important;white-space:nowrap}#service-status{font-size:10px}#clock{color:var(--ui-muted);background:none!important;padding:0!important}#clock:before{display:none!important}.btn{border-radius:7px!important;min-height:36px;padding:7px 13px;font-size:12px;font-weight:500;box-shadow:none;line-height:1.65;display:inline-flex;align-items:center;justify-content:center;gap:5px;white-space:normal}.btn-primary{--bs-btn-bg: var(--ui-accent);--bs-btn-border-color: var(--ui-accent);--bs-btn-hover-bg: #1d4d3c;--bs-btn-hover-border-color: #1d4d3c;--bs-btn-disabled-bg: #80988d;--bs-btn-disabled-border-color: #80988d;--bs-btn-active-bg: #1d4d3c;--bs-btn-active-border-color: #1d4d3c;color:#fff!important}.btn-outline-secondary{--bs-btn-color: #54685d;--bs-btn-border-color: #d8e1da;--bs-btn-hover-bg: #edf3ee;--bs-btn-hover-border-color: #bacdc0;--bs-btn-hover-color: #264d3b;--bs-btn-active-bg: #e0ece4;--bs-btn-active-border-color: #a7c0ae;--bs-btn-active-color: #254e3b;--bs-btn-disabled-color: #9faea4;--bs-btn-disabled-border-color: #e0e5e2;background:transparent}.btn-sm{min-height:30px;padding:4px 9px;font-size:11px}.btn-link{color:var(--ui-accent);text-decoration:none;background:transparent;border:0}.btn-link:hover{text-decoration:underline}.btn:focus-visible,.form-control:focus,.form-select:focus{box-shadow:0 0 0 3px #28744c1c!important;outline:0!important;border-color:#679b79}.btn-group>.btn{border-radius:0!important}.btn-group>.btn:first-child{border-radius:7px 0 0 7px!important}.btn-group>.btn:last-child{border-radius:0 7px 7px 0!important}.form-control,.form-select{color:var(--ink);background-color:var(--ui-surface);border:1px solid var(--ui-line);border-radius:7px!important;font-size:13px;padding:9px 12px;min-height:40px;max-width:100%;box-shadow:none}.form-select{padding-right:32px}.form-check-input{width:16px;height:16px;min-height:0;margin:0 6px 0 0;vertical-align:middle;flex:0 0 16px}.form-check-input:checked{background-color:var(--ui-accent);border-color:var(--ui-accent)}label{font-size:12px;color:#617367;gap:7px}.form-grid{gap:16px 20px!important}.form-grid label{min-width:0}.form-grid .full{grid-column:1/-1}textarea.form-control{min-height:100px}input[type=file]{font-size:12px;padding:8px;overflow:hidden}input[type=range]{max-width:100%}fieldset{border:1px solid var(--ui-line)!important;border-radius:9px;padding:14px!important}legend{float:none;width:auto;padding:0 6px;font-size:12px}.description,.hint{font-size:12px!important;line-height:1.8!important;color:var(--ui-muted)!important}p{overflow-wrap:anywhere}code{color:#3b6755;font-size:12px}.table{font-size:12px;--bs-table-bg: transparent}.table td,.table th{padding:12px!important;border-color:var(--ui-line)}.table-wrap{overflow:auto;border-radius:8px;border:1px solid var(--ui-line)}.panel,.site-card,.card,.camera-card,.person-card{background:var(--ui-surface)!important;border:1px solid var(--ui-line)!important;border-radius:11px!important;box-shadow:0 3px 12px #193c3204!important;overflow:hidden}.panel{padding:22px!important;margin-bottom:18px}.site-card{padding:22px!important}.card-body{padding:20px}.card-footer{background:transparent;border-top:1px solid var(--ui-line);padding:12px 18px}.section-head{display:flex;align-items:center;justify-content:space-between;gap:16px;margin-bottom:18px!important}.section-head h2 small,.section-head h3 small{display:none}.badge{font-size:10px;line-height:1.4;font-weight:500!important;letter-spacing:0!important;background:#edf4ee!important;color:#3c7056!important;border:1px solid #d6e6d9!important;border-radius:5px!important;padding:5px 8px!important}.badge.off{background:#f7eeea!important;border-color:#ecd9d0!important;color:#a66044!important}.count-pill{display:inline-block;padding:2px 7px;background:#e6ede8;color:#4b705b;border-radius:5px;font-size:11px;vertical-align:middle;margin-left:7px}.group-title{font-size:13px!important;color:#6a7c70;margin:24px 0 12px!important;display:flex;gap:5px;align-items:center}.site-heading{display:flex;align-items:center;justify-content:space-between;gap:12px}.household-context{padding:12px 16px!important;border-radius:9px!important;background:#eaf0eb!important;border:1px solid var(--ui-line);gap:12px;display:flex;align-items:center;flex-wrap:wrap;margin-bottom:18px!important}.household-context label{display:flex;align-items:center;gap:10px;margin:0}.household-context select{width:auto;max-width:260px;min-height:34px;padding-top:6px;padding-bottom:6px}.household-context span{font-size:11px;color:var(--ui-muted)}#scope-back{margin-left:auto}.device-context{border-radius:9px;background:#eaf0eb!important;padding:16px!important;margin-bottom:18px}.device-context p{font-size:12px;margin:0 0 10px}.device-context .btn.active{background:var(--ui-accent)!important;color:#fff!important}.filter-row{display:flex;align-items:center;gap:12px;flex-wrap:wrap;margin:0 0 18px;padding:0!important;font-size:12px}.filter-row label{display:flex;align-items:center;gap:8px;margin:0}.filter-row select{width:180px}.filter-row>button{margin-left:auto}.metrics{display:grid;grid-template-columns:repeat(4,minmax(0,1fr));gap:14px;margin:0 0 22px!important;padding:0!important;background:none!important;border:0!important}.metrics>div{background:var(--ui-surface);border:1px solid var(--ui-line);border-radius:9px;padding:14px 18px!important;display:flex;justify-content:space-between;align-items:center;border-right:1px solid var(--ui-line)!important}.metrics span{font-size:11px;color:var(--ui-muted)}.metrics strong{font-family:inherit;font-size:23px!important;font-weight:600;color:var(--ui-accent)}.home-toolbar{display:flex;gap:16px;flex-wrap:wrap;align-items:center;padding:13px 0;margin:0 0 7px;border-top:1px solid var(--ui-line);border-bottom:1px solid var(--ui-line)}.home-layout-controls{display:flex;align-items:center;gap:10px;flex-wrap:wrap;margin-left:auto}.home-layout-controls label{display:flex;align-items:center;gap:7px;margin:0}.home-layout-controls select{width:80px!important;min-height:34px;padding-top:5px;padding-bottom:5px}.home-layout-controls>.form-select{width:80px!important}.inline-check{white-space:nowrap;font-size:11px}#home-layout-status{margin-bottom:18px;font-size:11px!important}.home-card-grid{display:grid!important;grid-template-columns:repeat(var(--home-columns, 2),minmax(0,1fr));gap:20px!important}.home-city-group{display:block}.home-card{padding:0!important;margin:0!important;min-width:0;align-self:start}.home-cover{position:relative;height:178px!important;min-height:178px!important;background:linear-gradient(135deg,#567d65,#203e36)!important;overflow:hidden}.home-cover img{position:absolute;inset:0;width:100%;height:100%;object-fit:cover}.cover-shade{position:absolute;inset:0;background:linear-gradient(180deg,#132e2430 10%,#0e261ccc)}.home-cover-content{position:relative;z-index:1;height:100%;padding:17px 20px!important;display:flex;flex-direction:column;justify-content:space-between;background:none!important}.home-cover-content h3{font-family:inherit!important;font-size:21px!important;color:#fff!important;margin:0 0 6px!important;letter-spacing:0}.home-cover-content .badge{background:#ffffffd9!important;color:#244d3a!important;border-color:transparent!important;font-size:10px}.home-location{font-size:11px!important;color:#e8f0eb!important;line-height:1.6;margin:0!important}.cover-edit{color:#fff!important;background:#213e3670!important;border:1px solid #ffffff60!important;backdrop-filter:blur(8px)}.home-summary{font-size:12px;color:var(--ui-muted);margin-bottom:15px;min-height:20px}.home-numbers{display:grid;grid-template-columns:repeat(3,1fr);gap:12px;padding:0 0 17px;border-bottom:1px solid var(--ui-line);margin-bottom:13px}.home-numbers span{display:flex;align-items:baseline;gap:7px;color:var(--ui-muted);font-size:11px}.home-numbers b{font-size:21px;font-weight:600;color:var(--ink)}.compact-details{margin:0!important;display:grid;gap:7px!important;font-size:12px}.compact-details>div{display:grid;grid-template-columns:100px minmax(0,1fr);gap:12px!important;padding:0!important}.compact-details dt{font-weight:400;color:var(--ui-muted)}.compact-details dd{margin:0;overflow-wrap:anywhere;color:var(--ink)}.home-card-actions{display:flex;flex-wrap:wrap;gap:8px;margin-top:17px;padding-top:14px;border-top:1px solid var(--ui-line)}.home-card-actions .btn-primary{flex:1}.home-order-actions{display:flex;align-items:center;gap:5px;margin-bottom:12px}.home-order-actions span{font-size:10px;flex:1}.home-pagination{display:flex;justify-content:flex-end;align-items:center;gap:10px;margin:22px 0}.home-pagination span{margin-right:auto;font-size:11px;color:var(--ui-muted)}.device-card-grid{display:grid;grid-template-columns:repeat(auto-fill,minmax(min(100%,330px),1fr));gap:18px}.device-card{min-width:0}.device-card-heading{display:flex;align-items:center;gap:12px;margin-bottom:15px}.device-symbol{width:42px;height:42px;border-radius:10px;background:#eaf2ec;color:var(--ui-accent);display:grid;place-items:center}.device-symbol .app-icon{width:23px;height:23px}.device-card-heading h3{margin:0!important;font-size:16px!important}.device-title{padding:0!important;border:0!important;background:none!important;text-align:left!important;min-height:0!important;color:var(--ink)!important;font-weight:600!important;font-size:16px!important;box-shadow:none!important}.device-title:hover{color:var(--ui-accent)!important;text-decoration:underline}.device-location{font-size:11px;color:var(--ui-muted);margin-bottom:15px}.device-card-actions{display:flex;flex-wrap:wrap;gap:8px}.device-tags{display:flex;flex-wrap:wrap;gap:5px;margin:12px 0 0}.device-tags span{background:#edf1ee;font-size:10px;color:#667e6d;padding:2px 8px;border-radius:4px}.device-view-controls{display:flex;flex-wrap:wrap;gap:12px}.device-view-controls label{display:flex;align-items:center;gap:9px}.group-custom{font-size:12px}.group-step{max-width:100%}.group-step select{max-width:200px}.view-presets{display:flex;gap:6px;flex-wrap:wrap}#device-count{font-size:11px!important}.device-group:first-child>.group-title{margin-top:4px!important}#asset-list .empty{min-height:160px}.device-tags+.network-status-block{margin-top:12px}.network-status-block{padding-top:12px;margin-top:14px;border-top:1px solid var(--ui-line);font-size:11px}.network-status-title{display:flex;align-items:center;justify-content:space-between;gap:8px;margin-bottom:6px}.network-status-title>span{font-weight:600}.status-dot{width:7px;height:7px;border-radius:50%;background:#b4b9b5;display:inline-block;margin-right:6px}.status-dot.online{background:#37a06a;box-shadow:0 0 0 3px #38a16a12}.network-target{display:flex;align-items:center;flex-wrap:wrap;gap:7px;margin:4px 0}.network-target>span:first-child{width:65px;color:var(--ui-muted)}.network-target code{font-size:11px}.network-target>span:last-child{margin-left:auto;font-size:10px}.network-status-block p{margin:6px 0;font-size:11px!important}.management-links{display:flex;gap:6px;flex-wrap:wrap;margin:9px 0}.network-check-time{font-size:10px;color:#8b9c90;line-height:1.5;display:block}.network-platform{display:flex;align-items:center;gap:15px;background:#edf3ee;border:1px solid #d6e4d9;padding:20px;border-radius:10px;margin-bottom:16px}.network-platform>.app-icon{width:32px;height:32px;flex-basis:32px;color:var(--ui-accent)}.network-platform h3{margin:0 0 3px!important;font-size:18px!important}.network-platform p{margin:0;font-size:11px;color:var(--ui-muted)}.platform-place-grid{display:grid;grid-template-columns:repeat(auto-fill,minmax(min(100%,260px),1fr));gap:18px}.platform-place-node{display:flex!important;flex-direction:column;align-items:flex-start!important;text-align:left!important;padding:20px!important;gap:9px;border:1px solid var(--ui-line)!important;position:relative;color:var(--ink)!important}.platform-place-node:hover{border-color:#81ad90!important;box-shadow:0 4px 16px #2d4b3610!important}.platform-place-node h3{font-size:17px!important;margin:3px 0}.platform-place-node p,.platform-place-node small{font-size:11px;color:var(--ui-muted);margin:0}.network-open{padding-top:12px;margin-top:auto;color:var(--ui-accent);font-size:11px}.network-node{margin:0 0 14px calc(var(--depth) * 22px);overflow:visible!important;position:relative}.network-node.nested:before{position:absolute;content:"";border-left:2px solid #c1d3c6;border-bottom:2px solid #c1d3c6;width:15px;left:-17px;top:-15px;height:50px;border-bottom-left-radius:6px}.network-node .card-body{padding:18px}.network-node .device-card-heading{margin-bottom:9px}.network-facts{display:flex;flex-wrap:wrap;gap:8px 24px;font-size:11px;color:var(--ui-muted)}.network-facts b{font-weight:500;color:var(--ink);margin-left:7px;overflow-wrap:anywhere}.network-map{overflow:hidden}.network-map .network-platform{max-width:none}.network-overview{margin-top:18px}.scope-intro{padding:0!important;margin-bottom:24px!important}.scope-intro h2{font-size:24px!important}.scope-intro p{font-size:13px!important;color:var(--ui-muted)}.steward-grid{display:grid;grid-template-columns:repeat(auto-fit,minmax(min(100%,300px),1fr));gap:18px}.steward-tile{padding:22px!important;min-height:160px!important;background:var(--ui-surface)!important;border:1px solid var(--ui-line)!important;border-radius:10px!important;text-align:left!important;display:flex;align-items:flex-start!important;flex-direction:column;justify-content:flex-start!important;gap:10px;color:var(--ink)!important;box-shadow:none!important}.steward-tile:before{display:none!important}.steward-tile:hover{border-color:#8caf99!important;background:#f9fcf9!important;transform:translateY(-1px)}.steward-tile strong{font-family:inherit!important;font-size:19px!important;font-weight:600!important}.steward-tile span{font-size:12px!important}.steward-tile small{font-size:11px!important;color:var(--ui-muted);line-height:1.8}.camera-meta{padding:16px!important}.camera-meta strong{font-size:14px!important}.camera-meta p{font-size:11px!important;margin:4px 0!important}.camera-actions{padding:0 16px 16px;display:flex;flex-wrap:wrap;gap:7px}.camera-card{background:var(--ui-surface)!important}.live-grid{gap:18px}.video-panel{background:#152720!important}.video-error{font-size:12px}.video-empty{color:#9bad9f}.wall-toolbar{padding:12px!important;border-radius:9px;gap:10px}.wall-toolbar label{font-size:11px}.wall-toolbar select{width:auto}#live-stage:fullscreen{background:#101c17}.wall-fullscreen .camera-card{border-color:#284336!important}.playback-panel{background:var(--ui-surface)!important}.settings-sections{display:flex;gap:7px;flex-wrap:wrap;margin-bottom:20px}.settings-sections .btn[aria-pressed=true]{background:var(--ui-accent)!important;color:#fff!important}.journal-card{max-width:100%!important;background:var(--ui-surface)!important;border-radius:11px!important;padding:22px!important;border:1px solid var(--ui-line)!important}.journal-attachments{gap:14px}.journal-attachments img{border-radius:8px}.journal-media-library{max-width:100%}.journal-pager{font-size:12px}.family-toolbar{flex-wrap:wrap}.family-card,.person-card{padding:16px}.family-detail h2{font-size:20px!important}dialog{max-width:min(900px,calc(100vw - 32px))!important;width:800px;padding:26px!important;border:1px solid var(--ui-line)!important;border-radius:14px!important;background:var(--ui-surface)!important;color:var(--ink)!important;box-shadow:0 24px 80px #0f2d3d38!important;max-height:calc(100dvh - 48px);overflow:auto;margin:auto!important}dialog::backdrop{background:#10291e70;backdrop-filter:blur(3px)}dialog h2{font-size:21px!important}dialog .dialog-heading,dialog>header,dialog form>header{padding:0 0 18px!important;margin:0 0 20px!important;border-bottom:1px solid var(--ui-line);display:flex;align-items:center;justify-content:space-between;gap:15px;background:none}dialog form>.form-grid{margin-top:5px}dialog footer,dialog .dialog-actions{padding:18px 0 0!important;margin:20px 0 0!important;border-top:1px solid var(--ui-line);display:flex;justify-content:flex-end;gap:10px}#auth-dialog{width:420px!important;padding:32px!important}#auth-dialog h2{font-size:25px!important}#auth-dialog p{font-size:12px}#auth-form{display:grid;gap:15px}#auth-form label{margin:0}.form-error{font-size:12px;color:#b15a3c;min-height:0}#toast{position:fixed;bottom:24px;right:24px;z-index:200;background:#234c39!important;color:#fff!important;padding:12px 20px!important;border-radius:9px!important;font-size:13px!important;box-shadow:0 6px 22px #193c3226;max-width:calc(100vw - 32px)}main>footer{padding:22px 0 0!important;margin:30px 0 0!important;border-top:1px solid var(--ui-line);font-size:10px!important;color:var(--ui-muted)}.empty{border:1px dashed #cfdbd2;background:#f8faf8;border-radius:9px;color:var(--ui-muted);text-align:center;padding:40px 20px!important}.empty h3{margin-top:10px}.empty p{font-size:12px}.banner{padding:12px 16px;border-radius:8px;font-size:12px}html[data-theme=clean]{--ui-bg: #f4f6f9;--ui-accent: #31655b;--ui-surface: #fff}html[data-theme=ink]{--ui-bg: #14221e;--ui-surface: #1c2e26;--ui-line: #334a3e;--ui-muted: #a5baad;--ink: #e1ece5;--bs-body-color: #e1ece5;--bs-border-color: #334a3e;--ui-accent: #397359;--bs-secondary-color: #a5baad}html[data-theme=ink] .form-control,html[data-theme=ink] .form-select{background-color:#20352a;color:#e1ece5}html[data-theme=ink] .network-platform,html[data-theme=ink] .household-context,html[data-theme=ink] .device-context,html[data-theme=ink] .empty{background:#213d2d!important}html[data-theme=ink] .description,html[data-theme=ink] label{color:#a5baad!important}html[data-theme=ink] .btn-outline-secondary{color:#b9cec0;border-color:#476152}html[data-density=compact] #app>main{padding:20px 25px!important}html[data-density=compact] .panel,html[data-density=compact] .card-body{padding:15px!important}html[data-density=compact] .home-cover{height:150px!important;min-height:150px!important}html[data-layout=top] #app{display:block}html[data-layout=top] .sidebar{position:relative!important;width:100%!important;height:auto;padding:12px 24px!important;display:flex;flex-direction:row;flex-wrap:wrap;align-items:center;gap:12px}html[data-layout=top] .sidebar .brand{padding:0 15px 0 0!important;margin:0!important;border:0!important}html[data-layout=top] .sidebar>.nav-label,html[data-layout=top] .side-note,html[data-layout=top] #current-user,html[data-layout=top] #scope-nav-name{display:none}html[data-layout=top] .sidebar nav{flex-direction:row!important;flex:1;flex-wrap:wrap}html[data-layout=top] #scope-navigation{display:flex;padding:0!important;margin:0!important;box-shadow:none}html[data-layout=top] .sidebar nav button{width:auto!important;padding:8px 10px!important}html[data-layout=top] #app>main{margin:auto!important;max-width:1800px}@media(min-width:1500px){.home-card-grid[style]{gap:22px}}@media(max-width:1200px){#app>main{padding:24px!important}#app{grid-template-columns:210px minmax(0,1fr)}.sidebar{width:210px!important;padding:24px 14px!important}.home-toolbar{align-items:flex-start}.home-layout-controls{margin-left:0}.home-card-grid{grid-template-columns:repeat(min(var(--home-columns, 2),2),minmax(0,1fr))}.metrics>div{padding:12px!important}.metrics strong{font-size:19px!important}.compact-details>div{grid-template-columns:90px minmax(0,1fr)}}@media(max-width:767px){html,body{font-size:14px}#app{display:block!important}.sidebar,html[data-layout=top] .sidebar{position:relative!important;width:100%!important;height:auto!important;padding:13px 16px!important;display:grid!important;grid-template-columns:1fr auto!important;overflow:visible!important}.brand,html[data-layout=top] .sidebar .brand{padding:0!important;margin:0!important;border:0!important;gap:10px}.brand-icon{width:34px!important;height:34px!important}.brand>span>span{font-size:19px!important}.brand small{font-size:9px!important;margin-top:2px}.sidebar>.nav-label,.side-note,#current-user,.sidebar>#account-password,.sidebar>#logout{display:none!important}.mobile-nav-toggle{display:flex!important;color:#e8f1ec!important;border:1px solid #ffffff30!important;background:transparent!important;font-size:12px;min-height:36px}.sidebar nav,html[data-layout=top] .sidebar nav{display:none!important;grid-column:1/-1}.sidebar.mobile-open nav,html[data-layout=top] .sidebar.mobile-open nav{display:flex!important;flex-direction:column!important;margin-top:15px}.sidebar.mobile-open>#account-password,.sidebar.mobile-open>#logout{display:block!important}.sidebar.mobile-open>#current-user{display:block!important;grid-column:1/-1}.sidebar.mobile-open>#account-password{grid-column:1}.sidebar.mobile-open>#logout{grid-column:2}html[data-layout=top] #scope-navigation{display:block}.sidebar nav button{width:100%!important}.sidebar #scope-navigation{padding:14px 0!important}#app>main,html[data-density=compact] #app>main{padding:20px 15px!important;min-height:calc(100vh - 65px);width:100%!important}main>header{gap:12px;align-items:flex-start;margin-bottom:20px!important;padding-bottom:18px!important}#page-title{font-size:22px!important}#page-note{font-size:11px!important}.eyebrow{font-size:9px;margin-bottom:5px;letter-spacing:1px}.header-status{font-size:9px!important;gap:5px;max-width:100px;white-space:normal;text-align:right}#service-status{font-size:9px!important;padding:4px 6px!important}#clock{font-size:9px}.section-head{gap:12px;align-items:flex-start;flex-wrap:wrap}.section-head>.btn{margin-left:0;font-size:11px}h2{font-size:17px!important}.home-toolbar{gap:13px}.home-layout-controls{gap:9px;width:100%;font-size:11px}.home-layout-controls .form-select{min-height:32px;font-size:11px}.home-layout-controls .btn{font-size:11px;min-height:32px}.home-card-grid{grid-template-columns:minmax(0,1fr)!important;gap:17px!important}.home-cover{height:170px!important;min-height:170px!important}.home-cover-content{padding:16px 18px!important}.card-body{padding:17px}.home-numbers b{font-size:21px}.home-pagination{flex-wrap:wrap}.home-pagination span{width:100%}.home-pagination .btn{flex:1}.household-context{padding:10px!important;gap:9px}.household-context label{width:100%}.household-context select{max-width:none;flex:1;min-width:0}#household-context-note{display:none}#scope-back{width:100%;margin:0}.metrics{grid-template-columns:repeat(2,minmax(0,1fr));gap:10px}.metrics>div{padding:11px 13px!important}.metrics strong{font-size:20px!important}.filter-row{gap:9px}.filter-row label{flex:1;min-width:0}.filter-row select{width:100%;min-width:0}#filter-caption{display:none}.filter-row>button{font-size:11px}.panel{padding:17px!important}.form-grid{grid-template-columns:minmax(0,1fr)!important;gap:14px!important}.form-grid>*{min-width:0;grid-column:auto}.form-grid .full{grid-column:1}.site-grid,.steward-grid,.platform-place-grid,.device-card-grid{grid-template-columns:minmax(0,1fr)!important}.device-view-controls{display:flex;flex-direction:column;align-items:stretch}.device-view-controls label{width:100%}.device-view-controls input,.device-view-controls select{width:100%;min-width:0}.network-node{margin-left:calc(min(var(--depth),2)*12px)}.network-node.nested:before{left:-10px;width:8px}.network-node .card-body{padding:14px}.network-facts{display:grid;gap:6px}.network-platform{padding:16px}.network-platform h3{font-size:16px!important}.network-target{font-size:10px}.network-target code{font-size:10px;word-break:break-all}.management-links a{max-width:100%;font-size:10px}.network-node .device-card-heading h3,.network-node .device-title{font-size:14px!important}.device-context [role=group]{display:flex;flex-wrap:wrap;gap:7px}.device-context .btn{flex:1;min-width:100px;font-size:11px}.steward-tile{min-height:145px!important}.steward-tile strong{font-size:18px!important}.journal-card{padding:17px!important}.journal-attachments{grid-template-columns:minmax(0,1fr)!important}.journal-attachments audio,.journal-attachments video{width:100%;max-width:100%}.journal-upload-controls{display:flex;flex-wrap:wrap}.journal-upload-controls>*{max-width:100%}.settings-sections{gap:6px}.settings-sections .btn{flex:1;min-width:calc(50% - 6px);font-size:11px}dialog{max-width:calc(100vw - 20px)!important;padding:20px!important;max-height:calc(100dvh - 20px);border-radius:12px!important}dialog h2{font-size:19px!important}dialog .dialog-heading{padding-bottom:14px!important;margin-bottom:16px!important}dialog .dialog-heading .btn{min-width:54px}#auth-dialog{padding:25px!important}.brand-image-grid{grid-template-columns:1fr!important}#toast{bottom:16px;right:16px;font-size:12px!important}.wall-toolbar{gap:7px}.wall-toolbar label{width:auto}.table-wrap{max-width:100%}main>footer{font-size:9px!important;gap:10px;flex-wrap:wrap}.network-node .device-card-heading>.btn{font-size:10px;min-height:28px;padding:3px 7px}html[data-layout=top] .sidebar.mobile-open nav button{width:100%!important}}@media(min-width:768px){.sidebar>.mobile-nav-toggle{display:none!important}}.sidebar nav button{justify-content:flex-start!important}.sidebar nav button.active:after{display:none!important}.section-head>div:first-child{display:block}.inline-check .form-check-input{width:16px!important;height:16px!important;min-height:0!important;padding:0!important}.form-check-input{padding:0!important}.dialog-footer{display:flex;justify-content:flex-end;gap:10px;margin-top:20px;padding-top:18px;border-top:1px solid var(--ui-line)}html[data-font=serif] #page-title,html[data-font=serif] .scope-intro h2{font-family:"Noto Serif SC",Songti SC,SimSun,serif!important;font-weight:600!important}.live-help{margin:10px 0;color:var(--ui-muted);font-size:13px}.live-help summary{cursor:pointer;padding:8px 0}.live-help p{margin:8px 0}#page-live.wall-expanded{position:fixed;inset:0;z-index:10000;margin:0}#page-live:is(:fullscreen,.wall-expanded)>.live-help{display:none}#page-live:is(:fullscreen,.wall-expanded) .live-grid[data-visible-count="1"]{grid-template-columns:minmax(0,1fr);grid-template-rows:minmax(0,1fr)}.leadership-member-actions .btn{white-space:normal}#leadership-grant{align-items:flex-start;padding:14px}#leadership-grant span{line-height:1.7}@media(max-width:767px){#app>main{padding-bottom:max(20px,env(safe-area-inset-bottom))!important}main[data-page=live]>header{margin-bottom:12px!important;padding-bottom:12px!important}main[data-page=live]>header .eyebrow,main[data-page=live] #page-note,main[data-page=live]>.metrics{display:none!important}main[data-page=live] .household-context{margin-bottom:12px;flex-wrap:nowrap}main[data-page=live] .household-context label{flex:1;width:auto;font-size:0}main[data-page=live] .household-context select{font-size:16px;width:100%}main[data-page=live] #scope-back{width:auto;min-width:82px}main[data-page=live]>.filter-row{margin:12px 0}#page-live:not([hidden]){display:flex;flex-direction:column}#page-live>.section-head{order:0;margin:6px 0 12px}#page-live>.live-grid{order:1}#page-live>.wall-toolbar{order:2}#page-live>.live-help{order:3}#page-live:not(:fullscreen):not(.wall-expanded) .live-grid[data-layout=auto]{grid-template-columns:minmax(0,1fr)}.camera-actions{display:grid;grid-template-columns:repeat(2,minmax(0,1fr));padding:0 12px 12px}.camera-actions .btn{min-height:44px;white-space:normal;font-size:13px}.camera-meta{padding:12px}.camera-meta strong{font-size:15px!important}.wall-toolbar .wall-paging{flex:1;justify-content:space-between}.wall-toolbar .btn{min-width:44px;min-height:44px}#page-live:is(:fullscreen,.wall-expanded){padding:max(8px,env(safe-area-inset-top)) max(8px,env(safe-area-inset-right)) max(8px,env(safe-area-inset-bottom)) max(8px,env(safe-area-inset-left))}#page-live:is(:fullscreen,.wall-expanded)>.wall-toolbar{order:0}#page-live:is(:fullscreen,.wall-expanded) .live-grid[data-layout=auto]{grid-template-columns:repeat(2,minmax(0,1fr))}#page-live:is(:fullscreen,.wall-expanded) .live-grid[data-visible-count="1"]{grid-template-columns:minmax(0,1fr);grid-template-rows:minmax(0,1fr)}#page-live:is(:fullscreen,.wall-expanded) .camera-actions{display:none}.network-target{display:grid;grid-template-columns:76px minmax(0,1fr) auto;font-size:12px;gap:8px}.network-target code{font-size:13px!important}.network-check-time{font-size:12px;line-height:1.7}.management-links{display:grid;grid-template-columns:minmax(0,1fr)}.management-links .btn{min-height:44px!important;font-size:13px!important;white-space:normal}dialog .description,dialog label{font-size:14px!important}dialog .dialog-footer{position:sticky;bottom:-20px;background:var(--ui-surface);padding:14px 0;margin-bottom:-10px}dialog .dialog-footer .btn{flex:1;min-height:44px;white-space:normal}.leadership-member-actions .btn{flex:1;min-width:120px}#leadership-grant{display:flex;gap:10px}#leadership-grant[hidden]{display:none}}html[data-backdrop=mountains] #app>main{background-image:linear-gradient(150deg,transparent 70%,#8ba58f08 70%,transparent 85%),linear-gradient(170deg,transparent 60%,#8ba58f06 60%,transparent 90%)!important;background-size:100% 360px!important;background-repeat:no-repeat!important}@media(max-width:767px){.form-control,.form-select{font-size:16px!important;min-height:44px}.btn{min-height:42px;font-size:13px}.home-layout-controls .form-select{font-size:14px!important;min-height:40px}.home-layout-controls .btn,.network-status-title .btn,.management-links .btn{min-height:40px;font-size:12px}.network-target code{font-size:12px}.mobile-nav-toggle{min-height:42px}.device-card-actions .btn{min-height:42px;font-size:12px}}:root{--ui-bg: #f3f6fa;--ui-surface: #fff;--ui-line: #e3e9ef;--ui-muted: #5e6f7e;--ui-sidebar: #172e35;--ui-accent: #217964;--ink: #253b46;--muted: #5e6f7e;--paper: var(--ui-surface);--line: var(--ui-line);--green: var(--ui-accent);--bs-primary: #217964;--bs-primary-rgb: 33, 121, 100;--bs-body-color: var(--ink);--bs-body-bg: var(--ui-bg);--bs-border-color: var(--ui-line);--ui-shadow: 0 3px 16px #223d5010;--ui-soft: #f5f8fa}html[data-theme=paper]{--ui-bg: #f5f6f4;--ui-soft: #f5f7f3}html[data-theme=clean]{--ui-bg: #f1f5f9;--ui-soft: #f4f7fb}html[data-theme=ink]{--ui-bg: #111e26;--ui-surface: #1a2b35;--ui-line: #30444e;--ui-soft: #21353f;--ink: #e0ecef;--ui-muted: #a8bdc5;--muted: #a8bdc5;--ui-shadow: 0 3px 16px #0002;--paper: #1a2b35;--line: #30444e}html,body{min-width:0}body{-webkit-font-smoothing:antialiased}#app>main{max-width:2000px;padding:30px 38px 24px!important}main>header{margin-bottom:26px!important;padding-bottom:24px!important}#page-title{font-size:clamp(24px,2.3vw,32px)!important;letter-spacing:-.7px!important}html[data-font=serif] #page-title{font-weight:600!important}#brand-motto{color:var(--ui-accent)!important;letter-spacing:2.4px}#page-note{font-size:13px!important}.header-status{gap:9px}#clock{font-variant-numeric:tabular-nums;font-size:11px}#service-status{padding:6px 10px;border-radius:20px!important}.sidebar{background:linear-gradient(165deg,#1d3940,#152b32 70%)!important}.brand{padding-bottom:26px!important}.brand-icon{width:46px!important;height:46px!important;box-shadow:0 3px 12px #071d2860}.sidebar nav button{border-radius:10px!important;min-height:46px;transition:background .15s,color .15s}.sidebar nav button.active{background:#e1f2eb!important;color:#155b48!important;box-shadow:0 2px 7px #0002!important}.sidebar nav button.active .app-icon{opacity:1}.sidebar #current-user{padding:14px 9px 2px}.section-head{align-items:center;margin-bottom:18px}.section-head h2{font-size:21px!important}.count-pill{background:#e7f0ec;color:#286752;border:0;border-radius:7px;padding:3px 9px;font-size:12px}.btn{border-radius:9px!important;min-height:38px;padding:8px 14px;transition:background .15s,border-color .15s,box-shadow .15s}.btn-primary{--bs-btn-bg: var(--ui-accent);--bs-btn-border-color: var(--ui-accent);box-shadow:0 3px 8px #21796416}.btn-primary:hover{box-shadow:0 4px 12px #21796428}.btn-outline-secondary{--bs-btn-color: var(--ink);--bs-btn-border-color: var(--ui-line);background:var(--ui-surface)}.btn-link{color:var(--ui-accent)}html:is([data-theme=clean],[data-theme=ink]) :is(main,dialog) .btn-primary:not(.steward-tile):not(.device-title):not(.platform-place-node){background:var(--ui-accent)!important;color:#fff!important;border-color:var(--ui-accent)!important}html:is([data-theme=clean],[data-theme=ink]) :is(main,dialog) .btn-outline-secondary{background:var(--ui-surface)!important;color:var(--ink)!important}html:is([data-theme=clean],[data-theme=ink]) :is(main,dialog) .btn-outline-secondary:is(.active,[aria-pressed=true]){background:var(--ui-soft)!important;border-color:#629987!important}html:is([data-theme=clean],[data-theme=ink]) .btn-link{background:transparent!important;color:var(--ink)!important}html[data-theme=ink] #brand-motto{color:#a7d7c4!important}.btn:focus-visible,button:focus-visible,a:focus-visible{outline:3px solid #529cce;outline-offset:3px}.form-control,.form-select{border-radius:9px!important;border-color:var(--ui-line)!important;min-height:40px;background-color:var(--ui-surface);color:var(--ink)}.form-control:focus,.form-select:focus{border-color:#51a18b!important;box-shadow:0 0 0 3px #21856819!important}.card,.panel{border:1px solid var(--ui-line)!important;border-radius:14px!important;background:var(--ui-surface);box-shadow:var(--ui-shadow)!important}.card{overflow:hidden}.card-body{padding:24px}dialog{border-radius:16px!important;box-shadow:0 24px 100px #10293040!important}dialog::backdrop{background:#132a3670;backdrop-filter:blur(4px)}dialog h2{font-size:22px!important}.household-context,.device-context{border:1px solid var(--ui-line)!important;background:var(--ui-surface)!important;border-radius:12px;box-shadow:var(--ui-shadow)}.home-insights{display:grid;grid-template-columns:1.4fr .7fr 1fr;gap:18px;margin:22px 0 26px}.home-insights>article{border-radius:15px;padding:24px;min-width:0}.insight-welcome{position:relative;overflow:hidden;color:#fff;background:linear-gradient(115deg,#20534d,#297562);box-shadow:0 6px 22px #21594c1c}.insight-welcome:after{content:"";position:absolute;right:-28px;bottom:-64px;width:200px;height:200px;border:32px solid #fff07;border-radius:50%;pointer-events:none}.insight-kicker{color:#cae4d9;font-size:10px;letter-spacing:2px}.insight-welcome h2{color:#fff!important;font-size:23px!important;margin:14px 0 8px!important}.insight-welcome p{color:#d0e7df;font-size:12px;margin-bottom:22px}.insight-scope{display:flex;gap:7px;align-items:center;color:#d7ebe4;font-size:10px}.insight-scope .app-icon{width:15px;height:15px;flex-basis:15px}.insight-number,.insight-distribution{background:var(--ui-surface);border:1px solid var(--ui-line);box-shadow:var(--ui-shadow)}.insight-number{position:relative;display:flex;flex-direction:column;justify-content:center}.insight-icon{position:absolute;right:20px;top:22px;width:36px;height:36px;display:grid;place-items:center;background:#e8f1fb;color:#527ec0;border-radius:11px}.insight-label{color:var(--ui-muted);font-size:12px;padding-right:35px}.insight-number>strong{font-size:40px;line-height:1.3;font-weight:650;margin:10px 0;color:var(--ink);font-variant-numeric:tabular-nums}.insight-number strong small{font-size:12px;font-weight:400;margin-left:10px;color:var(--ui-muted)}.insight-foot{color:var(--ui-muted);font-size:11px}.insight-distribution{display:flex;align-items:center;justify-content:center;gap:20px}.insight-donut{width:126px;flex:0 0 126px;position:relative}.insight-donut svg{width:100%;display:block}.donut-track{stroke:var(--ui-line)}.insight-donut>div{position:absolute;inset:0;display:flex;flex-direction:column;align-items:center;justify-content:center;pointer-events:none}.insight-donut strong{font-size:28px;line-height:1.3}.insight-donut small{font-size:10px;color:var(--ui-muted)}.insight-legend{flex:1;min-width:60px;max-width:145px}.insight-legend h3{font-size:12px!important;margin-bottom:13px;white-space:nowrap}.insight-legend>span{display:flex;align-items:center;gap:7px;font-size:11px;margin-top:7px;color:var(--ui-muted)}.insight-legend i{width:7px;height:7px;border-radius:2px;flex-shrink:0}.insight-legend b{margin-left:auto;color:var(--ink)}.home-toolbar{padding:13px 16px;border:1px solid var(--ui-line);border-radius:12px;background:var(--ui-surface);gap:14px}.home-layout-toggle{display:none}#home-layout-status{margin:10px 3px 18px;font-size:11px}.home-card-grid{gap:24px}.home-card{transition:box-shadow .18s,border-color .18s}.home-card:hover{box-shadow:0 8px 26px #223d5019!important;border-color:#b4cac0!important}.home-cover{height:220px;background:linear-gradient(120deg,#35595b,#193a40)}.home-cover .cover-shade{background:linear-gradient(180deg,#142b3830,#10282b05 30%,#0a232bcc)}.home-cover-content{padding:22px 25px}.home-cover-content h3{font-size:24px!important;font-weight:600!important;letter-spacing:.5px!important}.home-cover-content .badge{border:1px solid #ffffff38;background:#f6fffaed!important;color:#27594a!important;border-radius:6px!important;font-size:11px}.home-location{font-size:11px;color:#ebf3f0}.cover-edit{background:#142a3560!important;border:1px solid #ffffff80!important;color:#fff!important;backdrop-filter:blur(4px)}.home-summary{color:var(--ui-muted);font-size:12px}.home-numbers{background:var(--ui-soft);border:0;border-radius:10px;padding:14px 0;margin:16px 0 20px}.home-numbers span{border-right:1px solid var(--ui-line);color:var(--ui-muted);font-size:11px}.home-numbers span:last-child{border:0}.home-numbers b{font-size:24px;color:var(--ink)}.home-card-actions{border-top:1px solid var(--ui-line);padding-top:18px;margin-top:18px}.compact-details dt{color:var(--ui-muted)}.compact-details dd{color:var(--ink)}.home-pagination{margin-top:24px;font-size:11px}.metrics{gap:16px}.metrics>div{border:1px solid var(--ui-line);border-radius:12px;background:var(--ui-surface);box-shadow:var(--ui-shadow);border-top:3px solid #438979}.metrics>div:nth-child(2){border-top-color:#658cd1}.metrics>div:nth-child(3){border-top-color:#b69c70}.metrics>div:nth-child(4){border-top-color:#8391b5}.metrics strong{font-variant-numeric:tabular-nums;color:var(--ink)}.device-card-heading .device-symbol{background:#e9f3ef;color:#287e65;border-radius:12px;width:44px;height:44px}.device-card .card-footer{border-top:1px solid var(--ui-line);background:var(--ui-soft);padding:14px 22px}.device-card-grid{gap:20px}.device-view-controls{padding:20px 24px}.device-search-row{border-bottom:1px solid var(--ui-line);padding-bottom:18px;margin-bottom:15px}.group-title{margin:24px 0 14px}.device-location{color:var(--ui-muted)}.network-map{padding:24px}.network-platform{background:var(--ui-soft);border:1px solid var(--ui-line);border-radius:12px;padding:20px}.network-platform>.app-icon{width:30px;height:30px;flex-basis:30px;color:var(--ui-accent)}.network-diagram{margin:20px 0 28px;border:1px solid var(--ui-line);border-radius:12px;overflow:hidden}.diagram-toolbar{display:flex;justify-content:space-between;align-items:center;gap:16px;padding:14px 18px;background:var(--ui-surface)}.diagram-toolbar>div{display:flex;gap:10px;align-items:center;flex-wrap:wrap}.diagram-toolbar strong{font-size:13px}.diagram-dot{width:7px;height:7px;border-radius:50%;background:#4d8dbe}.diagram-toolbar label{display:flex;align-items:center;gap:8px;font-size:11px;margin:0}.diagram-toolbar select{width:86px}.diagram-scroll{max-height:480px;overflow:auto;background-color:var(--ui-soft);background-image:radial-gradient(var(--ui-line) 1px,transparent 1px);background-size:18px 18px;border-block:1px solid var(--ui-line)}.network-svg{display:block}.network-edge{stroke:#82a79c;stroke-width:2}.diagram-node{cursor:pointer;outline:none}.diagram-node-bg{fill:var(--ui-surface);stroke:var(--ui-line);stroke-width:1.5}.diagram-node:hover .diagram-node-bg,.diagram-node:focus .diagram-node-bg{stroke:#328d78;stroke-width:2.5}.diagram-node-type{fill:var(--ui-muted);font-size:10px}.diagram-node-title{fill:var(--ink);font-size:14px;font-weight:600}.diagram-node-ip{fill:var(--ui-muted);font-size:11px;font-family:ui-monospace,Consolas,monospace}.diagram-note{margin:0;padding:11px 18px;font-size:11px;color:var(--ui-muted)}.network-details-heading{margin:20px 0 14px}.platform-place-node{position:relative;text-align:left;padding:24px}.platform-place-node:before{content:"";position:absolute;inset:0 auto 0 0;width:4px;background:#438979}.platform-place-node:hover{border-color:#8db4a7!important;background:var(--ui-soft)}.network-open{color:var(--ui-accent);font-weight:600}.scope-intro{border-bottom:1px solid var(--ui-line);padding-bottom:20px}.steward-tile{border-radius:14px!important;border:1px solid var(--ui-line)!important;border-top:3px solid #438979!important;box-shadow:var(--ui-shadow)!important;padding:28px!important;background:var(--ui-surface)!important}.steward-tile:nth-child(2n){border-top-color:#6c8fbc!important}.steward-tile:nth-child(3n){border-top-color:#b29a72!important}.steward-tile strong{font-size:19px!important}.steward-tile:hover{border-color:#9dbab0!important;box-shadow:0 8px 22px #223d5016!important}.journal-card{border-radius:14px;box-shadow:var(--ui-shadow)}#page-live:is(:fullscreen,.wall-expanded) .camera-meta{background:#172e35!important;color:#e8f3ef!important}#page-live:is(:fullscreen,.wall-expanded) .camera-meta strong{color:#e8f3ef!important}#page-live:is(:fullscreen,.wall-expanded) .wall-toolbar{background:#172e35!important;border-color:#45616a!important}#page-live:is(:fullscreen,.wall-expanded) .form-select{background-color:#213b44!important;color:#e8f3ef!important;border-color:#64818b!important}main>footer{color:var(--ui-muted);font-size:10px}html[data-density=compact] .home-insights>article{padding:18px}html[data-density=compact] .home-cover{height:165px}html[data-density=compact] .card-body{padding:18px}@media(min-width:1100px){html[data-layout=top] #app>main{padding-top:28px!important}}@media(max-width:1250px){.home-insights{grid-template-columns:1.2fr .75fr 1fr;gap:12px}.home-insights>article{padding:19px}.insight-distribution{gap:10px}.insight-donut{width:102px;flex-basis:102px}.insight-welcome h2{font-size:20px!important}}@media(max-width:1000px)and (min-width:761px){#app>main{padding:26px 24px!important}.home-insights{grid-template-columns:1fr 1fr}.insight-welcome{grid-column:1/-1}.insight-welcome p{margin-bottom:12px}}@media(max-width:760px){#app>main{padding:20px 16px!important}.sidebar{background:#17353b!important}main>header{margin-bottom:20px!important;padding-bottom:18px!important}#page-title{font-size:25px!important}#page-note{font-size:12px!important}.home-insights{grid-template-columns:1fr 1fr;gap:12px;margin:16px 0 20px}.home-insights>article{padding:18px}.insight-welcome{grid-column:1/-1}.insight-welcome h2{margin:7px 0 0!important;font-size:20px!important}.insight-welcome p,.insight-scope{display:none}.insight-number>strong{font-size:34px}.insight-icon{width:29px;height:29px;top:14px;right:13px}.insight-distribution{flex-direction:column;gap:5px}.insight-donut{width:94px;flex-basis:auto}.insight-legend{width:100%;display:flex;flex-wrap:wrap;justify-content:center;gap:6px}.insight-legend h3{display:none}.insight-legend>span{margin:0;font-size:10px;gap:4px}.insight-number .insight-label{padding-right:24px;font-size:11px}.insight-donut strong{font-size:25px}.insight-donut small{font-size:9px}.home-toolbar{padding:12px}.home-layout-toggle{display:inline-flex;margin-left:auto}.home-toolbar .home-layout-controls{display:none}.home-toolbar.home-options-open .home-layout-controls{display:flex;flex-basis:100%;border-top:1px solid var(--ui-line);padding-top:12px}.home-cover{height:200px}.home-cover-content{padding:20px}.home-cover-content h3{font-size:23px!important}.card-body{padding:20px}.home-numbers{padding:12px 0}.home-card-grid{gap:18px}.home-card-actions{gap:8px;flex-wrap:wrap}.btn{min-height:44px}.form-control,.form-select{min-height:44px;font-size:16px}#page-playback .playback-controls{display:grid;grid-template-columns:minmax(0,1fr);gap:14px}#page-playback .playback-controls label{width:100%;min-width:0}#page-playback .playback-controls input,#page-playback .playback-controls select,#page-playback .playback-controls button{width:100%}#play-info{overflow-wrap:anywhere}.device-view-controls{padding:16px}.network-map{padding:14px}.network-platform{padding:16px}.diagram-toolbar{padding:12px;align-items:flex-start}.diagram-toolbar>div{gap:6px}.diagram-toolbar>div .small{flex-basis:100%;font-size:10px}.diagram-toolbar label{flex-direction:column;align-items:flex-start}.diagram-toolbar select{width:82px}.diagram-scroll{max-height:360px}.steward-tile{padding:22px!important}main[data-page=live]>header{margin-bottom:10px!important;padding-bottom:12px!important}}@media(prefers-reduced-motion:reduce){*,*:before,*:after{transition:none!important;scroll-behavior:auto!important}}:root{--ui-shadow: 0 4px 22px #223d500a;--bs-body-font-family: system-ui,"Microsoft YaHei",sans-serif}html[data-theme=paper]{--ui-bg: #f5f5f1;--ui-soft: #f4f6f2}.dashboard-grid{margin-top:4px}.dashboard-grid>div,.row>div{min-width:0}.dashboard-welcome{position:relative;overflow:hidden;padding:28px;border-radius:16px;background:linear-gradient(140deg,#234a49,#2e7964);color:#fff}.dashboard-welcome:after{content:"";position:absolute;right:-85px;top:-95px;width:260px;height:260px;border:40px solid #ffffff07;border-radius:50%;pointer-events:none}.dashboard-welcome h2{font-size:clamp(21px,2vw,26px)!important;color:#fff!important;margin:16px 0 8px;letter-spacing:.2px}.dashboard-welcome>p{color:#d3e7df;font-size:12px}.dashboard-totals{display:flex;gap:28px;margin:22px 0}.dashboard-totals>div{display:flex;flex-direction:column}.dashboard-totals strong{color:#fff;font-size:32px;font-weight:600;line-height:1.3;font-variant-numeric:tabular-nums}.dashboard-totals span{color:#d3e7df;font-size:11px;margin-top:5px}.chart-card{padding:22px;border:1px solid var(--ui-line);border-radius:16px;background:var(--ui-surface);box-shadow:var(--ui-shadow);min-width:0}.chart-heading{display:flex;gap:12px;align-items:center;justify-content:space-between;flex-wrap:wrap;margin-bottom:10px}.chart-heading h3{font-size:15px!important;font-weight:650;margin:0}.chart-heading .small{font-size:11px}.chart-legend{display:flex;gap:10px 18px;flex-wrap:wrap;justify-content:center;padding-top:8px}.chart-legend span{display:flex;align-items:center;gap:6px;font-size:12px;color:var(--ui-muted)}.chart-legend i{width:8px;height:8px;border-radius:3px}.chart-legend b{color:var(--ink);font-variant-numeric:tabular-nums}.chart-data{color:var(--ui-muted);font-size:11px;margin-top:8px}.chart-data summary{cursor:pointer;padding:6px 0}.chart-data ul{padding-left:20px;margin:8px 0 0}.chart-empty{min-height:150px;display:grid;place-items:center;color:var(--ui-muted);margin:0;font-size:13px}.local-chart-wrap,.local-chart{width:100%;min-width:0}.chart-network-surface{background:var(--ui-soft);border-radius:12px;background-image:radial-gradient(var(--ui-line) 1px,transparent 1px);background-size:20px 20px;overflow:hidden}.chart-network-surface .local-chart{touch-action:none}.household-context{border-left:3px solid #488b76!important}.section-head>div>.description{margin-top:7px}.home-toolbar,.device-view-controls,.playback-controls{box-shadow:var(--ui-shadow)}.home-card .card-body{padding:22px}.home-cover{height:200px}.form-grid label{align-items:stretch}dialog .dialog-heading{position:sticky;top:0;background:var(--ui-surface);z-index:2;padding-block:12px}dialog .dialog-footer{padding-top:18px;border-top:1px solid var(--ui-line)}html[data-theme=ink] .chart-card{color:var(--ink)}html[data-theme=ink] .chart-heading .badge{background:#2c493e!important;color:#c2e9d7!important}@media(max-width:767px){.dashboard-grid:not(.charts-expanded) .dashboard-chart-column{display:none}.dashboard-welcome{padding:22px}.dashboard-welcome h2{font-size:22px!important}.dashboard-totals{justify-content:space-between;gap:14px;margin:18px 0 14px}.dashboard-welcome .insight-scope{display:flex;font-size:10px}.chart-card{padding:18px}.dashboard-grid .chart-card{height:auto!important}.chart-network-surface .local-chart{max-height:340px}.diagram-toolbar{flex-wrap:wrap}.diagram-toolbar .btn{min-height:40px}.household-context{padding:14px!important}.section-head{gap:12px;flex-wrap:wrap}.dialog-footer button{flex:1}.table-wrap{overscroll-behavior-x:contain}}.hardware-grid>div[data-v-2d075cdb]{display:flex;flex-direction:column;gap:4px;background:#f5f7f7;padding:12px;border:3px solid white;border-radius:12px}.hardware-grid span[data-v-2d075cdb],.hardware-grid small[data-v-2d075cdb]{font-size:12px;color:#637471}.hardware-grid strong[data-v-2d075cdb]{font-size:18px}.tv-remote-preview[data-v-2d075cdb]{margin:16px 0;text-align:center}.tv-remote-preview img[data-v-2d075cdb]{max-height:640px;max-width:100%;border:6px solid #303b38;border-radius:12px}.display-manager summary[data-v-2d075cdb]{cursor:pointer}details p[data-v-2d075cdb]{margin-top:12px}form>label[data-v-3234de1e]{display:flex;flex-direction:column;align-items:stretch;gap:.35rem;min-width:0}form>label select[data-v-3234de1e],form>label input[data-v-3234de1e]{width:100%;min-width:0}.family-locations h2[data-v-6ce851ab]{font-size:1.3rem}.location-empty[data-v-6ce851ab]{display:grid;align-content:center;min-height:270px;text-align:center;color:var(--ui-muted,#64776f);padding:1rem}.location-empty>span[data-v-6ce851ab]{font-size:3rem;color:#6c9685}.location-person[data-v-6ce851ab]{display:flex;flex-direction:column;gap:.35rem;background:var(--panel,#fff);border:1px solid var(--ui-line,#d9e3dd);border-radius:12px;padding:14px;margin-bottom:10px;color:var(--ink,#243c32)}.location-person>span[data-v-6ce851ab],.location-person small[data-v-6ce851ab]{font-size:.85rem}.location-selected[data-v-6ce851ab]{border-color:#257a68;box-shadow:inset 3px 0 #257a68}.family-locations summary[data-v-6ce851ab]{cursor:pointer}.family-locations input[type=checkbox][data-v-6ce851ab]{min-width:18px;width:18px;min-height:18px}button.location-person[data-v-6ce851ab]{color:var(--ink,#243c32)!important;background:var(--panel,#fff)!important;align-items:stretch;text-align:left!important}.location-person strong[data-v-6ce851ab],.location-person small[data-v-6ce851ab]{color:var(--ink,#243c32)}.upload-metric[data-v-0c20c09f]{height:100%;padding:1rem;border:1px solid var(--ui-line,#e3e9ef);border-radius:12px;background:var(--panel,#fff);display:flex;flex-direction:column;gap:.35rem}.upload-metric>span[data-v-0c20c09f],.upload-metric>small[data-v-0c20c09f]{color:var(--ui-muted,#64748b);font-size:.8rem}.upload-metric>strong[data-v-0c20c09f]{font-size:1.65rem;line-height:1.5;font-variant-numeric:tabular-nums}.upload-metric.freed[data-v-0c20c09f]{background:color-mix(in srgb,var(--panel,#fff) 90%,#2e876e)}.upload-current[data-v-0c20c09f]{padding:1rem;border-radius:12px;background:color-mix(in srgb,var(--panel,#fff) 90%,#419be1)}.upload-filters[data-v-0c20c09f]{display:flex;flex-wrap:wrap;gap:1rem}.upload-filters label[data-v-0c20c09f]{flex:1;min-width:160px;max-width:330px;font-size:.85rem}.upload-task[data-v-0c20c09f]{padding:1rem 0;border-top:1px solid var(--ui-line,#e3e9ef)}.upload-task-heading[data-v-0c20c09f]{display:flex;justify-content:space-between;gap:.75rem;align-items:center;margin-bottom:.4rem}.upload-details[data-v-0c20c09f]{margin:1rem 0 0}.upload-details>div[data-v-0c20c09f]{display:grid;grid-template-columns:110px 1fr;gap:10px}.upload-details dd[data-v-0c20c09f]{overflow-wrap:anywhere}.upload-tasks summary[data-v-0c20c09f]{cursor:pointer}.upload-tasks .progress[data-v-0c20c09f]{height:8px}.upload-tasks .badge[data-v-0c20c09f]{white-space:normal}.upload-tasks button[data-v-0c20c09f]{min-height:40px}@media(max-width:576px){.upload-metric[data-v-0c20c09f]{padding:.75rem}.upload-metric>strong[data-v-0c20c09f]{font-size:1.2rem}.upload-filters label[data-v-0c20c09f]{min-width:100%;max-width:none}.upload-details>div[data-v-0c20c09f]{grid-template-columns:1fr;gap:0}}.journal-rich-editor{border:1px solid var(--bs-border-color,#ccd9d7);border-radius:12px;overflow:hidden;background:var(--bs-body-bg,#fff);margin:10px 0 20px}.journal-editor-toolbar{display:flex;flex-wrap:wrap;gap:6px;padding:10px;background:var(--bs-tertiary-bg,#f3f7f5);border-bottom:1px solid var(--bs-border-color,#ccd9d7)}.journal-editor-toolbar button{min-height:40px;padding:6px 12px}.journal-editor-toolbar button[aria-pressed=true]{background:#d8eae2;color:#153d31}.journal-rich-input{padding:20px;min-height:200px;outline:none;overflow-wrap:anywhere}.journal-rich-input:focus{box-shadow:inset 0 0 0 2px #669c89}.journal-rich-input p{min-height:1.5em;margin-bottom:12px;white-space:pre-wrap}.journal-rich-input blockquote,.journal-rich-body blockquote{border-left:3px solid #84ad9d;padding-left:16px;color:#5f7870}.journal-editor-foot{display:flex;justify-content:space-between;gap:12px;font-size:12px;color:#667b75;padding:10px 16px;border-top:1px solid #e1e9e5}.journal-inline-media{display:flex;flex-direction:column;align-items:flex-start;gap:10px;padding:12px;border:1px solid #d4e1da;border-radius:10px;background:#f8faf9;max-width:680px}.journal-inline-media img,.journal-inline-media video{max-width:100%;max-height:380px;object-fit:contain;border-radius:6px}.journal-inline-media audio{width:min(100%,540px)}.journal-inline-media figcaption{font-size:12px;color:#60766c;overflow-wrap:anywhere}.journal-inline-media.ProseMirror-selectednode{outline:2px solid #368268}.journal-rich-body{line-height:1.8;overflow-wrap:anywhere}.journal-rich-body p{white-space:pre-wrap}.journal-rich-body .journal-attachment{max-width:760px;margin:16px 0}.journal-rich-body img,.journal-rich-body video{max-height:480px;object-fit:contain}.journal-materials .journal-add-media{display:flex;flex-wrap:wrap;align-items:center;gap:10px}.journal-materials input[type=file]{max-width:100%}.journal-queue-row{display:grid;grid-template-columns:minmax(0,1fr) auto;gap:8px 16px;padding:14px 0;border-bottom:1px solid #e1e9e5}.journal-queue-row strong{overflow-wrap:anywhere}.journal-queue-row progress{width:100%;height:8px}.journal-queue-row small{display:block;color:#63756f}.journal-queue-row .journal-task-error{color:#a43b35}.journal-library-list-tools{display:flex;flex-wrap:wrap;gap:10px;align-items:center;margin:14px 0}.journal-upload-select small{display:block}.journal-editor-heading{display:flex;flex-wrap:wrap;align-items:center;gap:12px;padding:14px 22px;background:#f5f8f6;border:1px solid #d6e2da;border-radius:12px;margin-bottom:16px}.journal-editor-heading strong{margin-right:auto}.journal-editor-heading button{min-height:44px}.journal-editor-fullscreen{position:fixed;inset:0;z-index:1090;background:#f0f4f2;overflow:auto;overscroll-behavior:contain;padding:0 24px 24px;display:grid;grid-template-columns:minmax(0,1fr) 360px;gap:18px;align-content:start}.journal-editor-fullscreen>.journal-editor-heading{grid-column:1/-1;position:sticky;top:0;z-index:3;margin:0 -24px;border-radius:0;padding:14px 24px;box-shadow:0 2px 10px #183b2412}.journal-editor-fullscreen>.journal-compose{margin:0;min-height:calc(100dvh - 110px);display:flex;flex-direction:column}.journal-editor-fullscreen .journal-rich-editor{flex:1;display:flex;flex-direction:column}.journal-editor-fullscreen .journal-rich-editor>div:has(>.tiptap){flex:1}.journal-editor-fullscreen .journal-rich-input{min-height:52dvh;font-size:19px;line-height:1.9}.journal-editor-fullscreen .journal-editor-toolbar{position:sticky;top:0;z-index:1}.journal-editor-fullscreen>.journal-materials{margin:0;padding:18px;max-height:calc(100dvh - 110px);overflow:auto;position:sticky;top:92px}.journal-editor-fullscreen .journal-upload-grid{grid-template-columns:1fr}.journal-editor-fullscreen .journal-upload-card video,.journal-editor-fullscreen .journal-upload-card img{max-height:160px}.journal-editor-fullscreen .journal-upload-select span{min-width:0;overflow-wrap:anywhere}#journal-record-elapsed{font-variant-numeric:tabular-nums;color:#bd4338}.journal-inline-media .recording-indicator{color:#bd4338}@media(max-width:900px){.journal-editor-fullscreen{display:block;padding:0 12px 20px}.journal-editor-fullscreen>.journal-editor-heading{margin:0 -12px 12px;padding:10px 12px}.journal-editor-fullscreen>.journal-compose{min-height:calc(100dvh - 140px)}.journal-editor-fullscreen>.journal-materials{position:static;max-height:none;margin-top:12px}.journal-editor-fullscreen .journal-rich-input{min-height:48dvh;font-size:17px}.journal-editor-heading{padding:12px;gap:8px}.journal-editor-heading strong{width:100%}}@media(max-width:600px){.journal-rich-input{padding:14px;min-height:190px}.journal-editor-toolbar{gap:4px}.journal-editor-toolbar button{padding:7px 10px}.journal-editor-foot{flex-wrap:wrap}.journal-inline-media{max-width:100%}.journal-queue-row{gap:8px}.journal-compose,.journal-materials{min-width:0}} diff --git a/web/ui/assets/index-xETRcHmQ.js b/web/ui/assets/index-w9su1uwq.js similarity index 81% rename from web/ui/assets/index-xETRcHmQ.js rename to web/ui/assets/index-w9su1uwq.js index 747fbdf..3120ad8 100644 --- a/web/ui/assets/index-xETRcHmQ.js +++ b/web/ui/assets/index-w9su1uwq.js @@ -2,32 +2,32 @@ import"./modulepreload-polyfill-B5Qt9EMX.js";import{o as y,c as x,a,b as ge,d as `+((r.device.networkHosts||[])[0]||"IP 待填写"),detail:[r.device.name,r.device.deviceType,e(r.device.siteId)||"位置待登记",(r.device.networkHosts||[]).join(" / ")||"IP 待填写",{lan:"局域网",tailscale:"Tailscale",public:"公网"}[r.device.networkAccess]||"接入待确认"].join(` `),x:Math.max(0,r.depth||0)*280,y:o*105,itemStyle:{color:r.device.source==="camera"?"#e1ebfb":"#dceddf",borderColor:r.device.source==="camera"?"#648bcc":"#468b73",borderWidth:1},label:{color:"#213f48"}})),i=n.flatMap(r=>{const o=t.get(r.device.uplinkId);return o&&o.depth+1===r.depth?[{source:o.device.id,target:r.device.id}]:[]});return Da(s,i)}function lp(n=[],e="赵府"){return Da([{id:"platform",name:e,x:0,y:0,symbolSize:[160,65],itemStyle:{color:"#286d5d"},label:{color:"#fff"}},...n.map((t,s)=>({id:"home:"+t.id,targetId:t.id,name:t.name,caption:t.name+` `+qs(t.deviceCount)+" 台设备",detail:[t.name,{home:"家庭",office:"办公",factory:"工厂"}[t.kind||"home"]||"场所",[t.province,t.city,t.district].filter(Boolean).join(" · "),qs(t.deviceCount)+" 台已授权设备"].filter(Boolean).join(` -`),x:300,y:(s-(n.length-1)/2)*120,itemStyle:{color:"#e3efe8",borderColor:"#8ebaa6",borderWidth:1},label:{color:"#213f48"}}))],n.map(t=>({source:"platform",target:"home:"+t.id})))}const ap={class:"local-chart-wrap"},cp=["aria-label"],dp={key:0,class:"small text-secondary px-3",role:"status"},wn={__name:"LocalChart",props:{option:{type:Object,required:!0},label:String,active:{type:Boolean,default:!0},height:{type:Number,default:260}},emits:["select"],setup(n,{emit:e}){const t=n,s=e,i=P(null),r=P(!1);let o,l,c,d,u=!0,p=!1,f="",h="";function g(){o==null||o.dispose(),o=null,f="",h=""}function b(){!d&&u&&(d=requestAnimationFrame(()=>{d=null,m()}))}async function m(){if(!u||!i.value||!t.active){g();return}const v=Math.floor(i.value.clientWidth),S=Math.floor(i.value.clientHeight);if(!v||!S)return;if(!o){if(p)return;p=!0;try{const T=await Nu(()=>import("./charts-runtime-DBCaHPDW.js"),[]);if(!u||!t.active||!i.value)return;o=T.init(i.value,null,{renderer:"canvas",devicePixelRatio:Math.min(window.devicePixelRatio||1,2)}),o.on("click",N=>{var I;(I=N.data)!=null&&I.targetId&&s("select",N.data.targetId)}),r.value=!1}catch(T){r.value=!0,console.error("Local chart unavailable",T);return}finally{p=!1}}const A=getComputedStyle(document.documentElement),O=A.getPropertyValue("--ink").trim()||"#253b46",B=A.getPropertyValue("--ui-muted").trim()||"#627485",E=A.getPropertyValue("--ui-line").trim()||"#e3e9ef",M=JSON.stringify(t.option)+O+B+E;if(M!==f){const T={...t.option,animation:!1,backgroundColor:"transparent",textStyle:{color:O,fontFamily:"system-ui, Microsoft YaHei, sans-serif"},aria:{enabled:!0,description:t.label},tooltip:{trigger:"item",renderMode:"richText",confine:!0,...t.option.tooltip}};for(const N of["xAxis","yAxis"])T[N]&&(T[N]={...T[N],axisLabel:{color:B,...T[N].axisLabel},splitLine:{lineStyle:{color:E}}});T.series=(T.series||[]).map(N=>({...N,label:{color:O,...N.label}})),o.setOption(T,{notMerge:!0,lazyUpdate:!1}),f=M}const w=v+":"+S;w!==h&&(o.resize({width:v,height:S}),h=w)}return Ae(()=>[t.option,t.active],b,{deep:!0,flush:"post"}),$i(()=>{l=new ResizeObserver(b),l.observe(i.value),c=new MutationObserver(b),c.observe(document.documentElement,{attributes:!0,attributeFilter:["data-theme","data-density"]}),b()}),Bt(()=>{u=!1,cancelAnimationFrame(d),l==null||l.disconnect(),c==null||c.disconnect(),g()}),(v,S)=>(y(),x("div",ap,[a("div",{ref_key:"host",ref:i,class:"local-chart",role:"img","aria-label":n.label,style:Nn({height:n.height+"px"})},null,12,cp),r.value?(y(),x("p",dp,"图表暂未加载,可查看下方数据。")):D("",!0)]))}},up={class:"col-12 col-xl-4"},pp={class:"dashboard-welcome h-100"},fp={class:"dashboard-totals"},hp={class:"insight-scope"},mp={class:"col-12 d-md-none"},gp=["aria-expanded"],bp={class:"col-12 col-md-5 col-xl-3 dashboard-chart-column"},vp={class:"chart-card h-100"},yp={class:"chart-heading"},kp={class:"badge"},xp={key:1,class:"chart-empty"},wp={class:"chart-legend"},Sp={class:"col-12 col-md-7 col-xl-5 dashboard-chart-column"},Cp={class:"chart-card h-100"},Mp={key:1,class:"chart-empty"},Tp={key:2,class:"chart-data"},Ep={__name:"HomeInsights",setup(n){const e=ee(()=>ip(R.value.state.households)),t=P(!1),s=ee(()=>R.value.loggedIn&&R.value.page==="households"),i=ee(()=>(R.value.state.households||[]).map(r=>({label:r.name,count:r.deviceCount||0})).sort((r,o)=>o.count-r.count).slice(0,8));return(r,o)=>(y(),x("section",{class:De(["dashboard-grid row g-3 mb-4",{"charts-expanded":t.value}]),"aria-label":"已授权场所概览"},[a("div",up,[a("article",pp,[o[5]||(o[5]=a("span",{class:"insight-kicker"},"一处相连 · 各有归属",-1)),o[6]||(o[6]=a("h2",null,"家与日常,尽在掌握",-1)),o[7]||(o[7]=a("p",null,"从一处灯火,连接生活的每个空间。",-1)),a("div",fp,[a("div",null,[a("strong",null,k(e.value.total),1),o[1]||(o[1]=a("span",null,"家庭与场所",-1))]),a("div",null,[a("strong",null,k(e.value.devices),1),o[2]||(o[2]=a("span",null,"已登记设备",-1))]),a("div",null,[a("strong",null,k(e.value.areas),1),o[3]||(o[3]=a("span",null,"区域空间",-1))])]),a("div",hp,[G(be,{name:"shield"}),o[4]||(o[4]=C(" 仅汇总你有权访问的家庭与场所",-1))])])]),a("div",mp,[a("button",{class:"btn btn-outline-secondary w-100","aria-expanded":t.value,onClick:o[0]||(o[0]=l=>t.value=!t.value)},k(t.value?"收起图表统计":"展开图表统计"),9,gp)]),a("div",bp,[a("article",vp,[a("div",yp,[o[8]||(o[8]=a("h3",null,"空间分布",-1)),a("span",kp,k(e.value.total)+" 处",1)]),e.value.total?(y(),Qe(wn,{key:0,option:j(Na)(e.value.kinds),active:s.value,height:160,label:"场所分布:"+e.value.kinds.map(l=>l.label+l.count+"个").join(",")},null,8,["option","active","label"])):(y(),x("p",xp,"添加家庭或场所后显示分布")),a("div",wp,[(y(!0),x(H,null,J(e.value.kinds,l=>(y(),x("span",{key:l.key},[a("i",{style:Nn({background:l.color})},null,4),C(k(l.label)+" ",1),a("b",null,k(l.count),1)]))),128))])])]),a("div",Sp,[a("article",Cp,[o[10]||(o[10]=a("div",{class:"chart-heading"},[a("h3",null,"设备分布"),a("span",{class:"small text-secondary"},"按场所 · 最多显示 8 处")],-1)),i.value.length?(y(),Qe(wn,{key:0,option:j(Ia)(i.value),active:s.value,height:190,label:"各场所已登记设备:"+i.value.map(l=>l.label+l.count+"台").join(",")},null,8,["option","active","label"])):(y(),x("p",Mp,"暂无已授权场所")),i.value.length?(y(),x("details",Tp,[o[9]||(o[9]=a("summary",null,"查看统计数字",-1)),a("ul",null,[(y(!0),x(H,null,J(i.value,l=>(y(),x("li",{key:l.label},k(l.label)+":"+k(l.count)+" 台",1))),128))])])):D("",!0)])])],2))}},Ap={key:0,class:"panel","aria-label":"按世代浏览家庭"},Op={class:"d-flex justify-content-between align-items-start flex-wrap gap-3"},Np={key:0,class:"count-pill"},Ip={class:"mb-3"},Dp=["disabled"],$p={key:0,class:"alert alert-danger",role:"alert"},Rp={key:1,role:"status",class:"text-secondary"},Lp={class:"fw-semibold"},Pp={key:0,class:"mt-3 text-secondary"},Bp={key:0,class:"fs-6"},_p={class:"fw-semibold text-primary"},zp={class:"fw-normal text-secondary ms-2"},jp={class:"row g-3 mt-1"},Fp={class:"card-body"},Vp=["disabled","onClick"],Hp={key:0,class:"badge text-bg-primary ms-2"},qp={key:1,class:"text-secondary ms-2"},Up={class:"small text-secondary mt-2 mb-0"},Wp={class:"d-flex flex-wrap gap-2 mt-3"},Kp=["onClick"],Jp={key:0,class:"small text-secondary"},Gp={class:"d-flex flex-wrap gap-2 mt-3"},Yp=["disabled","onClick"],Xp={key:2,class:"mt-3"},Zp={class:"d-flex flex-wrap gap-2 mt-2"},Qp=["disabled","onClick"],ef={key:2,class:"text-secondary",role:"status"},tf={key:3,class:"alert alert-info"},nf={key:4,class:"border rounded p-3",open:""},sf={class:"d-flex flex-wrap gap-2 mt-3"},rf=["onClick"],of={key:5,class:"small text-secondary mt-3 mb-0"},lf={__name:"GenerationDirectory",props:{active:Boolean},setup(n){const e=n,t=P(null),s=P(""),i=P(""),r=P(!1);let o=0;async function l(){const h=++o;if(t.value=null,s.value="",i.value="",r.value=!1,!(!e.active||!R.value.loggedIn))try{const g=await K().api("/api/family-directory");h===o&&(t.value=g)}catch(g){h===o&&(s.value=g.message)}}Ae(()=>[e.active,R.value.loggedIn,R.value.session],l,{immediate:!0});const c=h=>h?(h<=10?["","一","二","三","四","五","六","七","八","九","十"][h]:"第"+h)+"世":"世次待考",d=h=>[...new Set(h.map(g=>g.generation))],u=ee(()=>{var g;const h=i.value.trim().toLocaleLowerCase();return(((g=t.value)==null?void 0:g.trees)||[]).map(b=>({...b,branches:b.branches.map(m=>({...m,people:m.people.filter(v=>!h||[v.name,...v.homes.map(S=>S.name)].join(" ").toLocaleLowerCase().includes(h))})).filter(m=>m.people.length)})).filter(b=>!h||b.branches.length)}),p=ee(()=>{var h;return new Set((((h=t.value)==null?void 0:h.trees)||[]).flatMap(g=>g.branches.flatMap(b=>b.people.map(m=>m.id)))).size});async function f(h,g,b=!1){if(r.value)return;const m=o;r.value=!0,s.value="";try{b?await K().viewMemberHistory(h.id,h.name,g):await K().viewPerson(h.id,g)}catch(v){m===o&&!v.stale&&(s.value=v.message)}finally{m===o&&(r.value=!1)}}return(h,g)=>{var b,m;return n.active?(y(),x("section",Ap,[a("div",Op,[a("div",null,[a("h2",null,[g[1]||(g[1]=C("家族世代 ",-1)),t.value?(y(),x("span",Np,k(p.value)+" 位家人",1)):D("",!0)]),g[2]||(g[2]=a("p",{class:"text-secondary"},"从长辈到晚辈,查看每个人的亲属、故事与家庭。一个家庭可以包含多代人。",-1))]),a("label",Ip,[g[3]||(g[3]=C("找家人",-1)),Y(a("input",{"onUpdate:modelValue":g[0]||(g[0]=v=>i.value=v),type:"search",class:"form-control",placeholder:"姓名或家庭名称",disabled:!t.value},null,8,Dp),[[At,i.value]])])]),g[7]||(g[7]=a("p",{class:"small text-secondary"},"一世从本支已知最早一代相对起算,不代表历史族谱中的绝对世次。未连接的分支分别展示,关系不足时标为“世次待考”。",-1)),s.value?(y(),x("div",$p,[C(k(s.value)+" ",1),a("button",{class:"btn btn-sm btn-outline-danger ms-2",onClick:l},"重新加载")])):t.value?D("",!0):(y(),x("p",Rp,"正在整理世代关系…")),(y(!0),x(H,null,J(u.value,v=>(y(),x("details",{key:v.id,class:"border rounded p-3 mb-3",open:""},[a("summary",Lp,"共用族谱 · "+k(v.homes.map(S=>S.name).join("、")),1),v.branches.length?D("",!0):(y(),x("p",Pp,"请先登记家庭成员,再连接亲属关系。")),(y(!0),x(H,null,J(v.branches,(S,A)=>{var O;return y(),x("section",{key:S.id,class:"mt-4"},[v.branches.length>1?(y(),x("h3",Bp,"分支 "+k(A+1)+" · "+k((O=S.people[0])==null?void 0:O.name),1)):D("",!0),(y(!0),x(H,null,J(d(S.people),B=>(y(),x("details",{key:B||"unknown",class:"border-start ps-3 mb-4",open:""},[a("summary",_p,[C(k(c(B))+" ",1),a("small",zp,k(S.people.filter(E=>E.generation===B).length)+" 人",1)]),a("div",jp,[(y(!0),x(H,null,J(S.people.filter(E=>E.generation===B),E=>{var M;return y(),x("article",{key:E.id,class:"col-12 col-md-6 col-xl-4"},[a("div",{class:De(["card h-100",{"border-primary bg-primary-subtle":E.self}])},[a("div",Fp,[a("button",{class:"btn btn-link p-0 fw-semibold fs-5 text-start",disabled:r.value,onClick:w=>f(E,v.familyId)},k(E.name),9,Vp),E.self?(y(),x("span",Hp,"本人")):D("",!0),E.lifeStatus==="deceased"?(y(),x("small",qp,"已故")):D("",!0),a("p",Up,k(E.self?"当前账号关联的家人":"人物档案 · 亲属关系 · 生平"),1),a("div",Wp,[(y(!0),x(H,null,J(E.homes,w=>(y(),x("button",{key:w.id,class:"btn btn-sm btn-outline-primary",onClick:T=>j(K)().enterHome(w.id)},k(w.name)+" →",9,Kp))),128)),E.homes.length?D("",!0):(y(),x("span",Jp,"暂无可访问的当前家庭关联"))]),a("div",Gp,[a("button",{class:"btn btn-sm btn-outline-primary",disabled:r.value,onClick:w=>f(E,v.familyId)},"查看人物与亲属",8,Yp)]),(M=E.journalHomes)!=null&&M.length?(y(),x("details",Xp,[g[4]||(g[4]=a("summary",{class:"small"},"个人阅历",-1)),a("div",Zp,[(y(!0),x(H,null,J(E.journalHomes,w=>(y(),x("button",{key:w.id,class:"btn btn-sm btn-outline-secondary",disabled:r.value,onClick:T=>f(E,w.id,!0)},k(w.name)+"的记事",9,Qp))),128))]),g[5]||(g[5]=a("p",{class:"small text-secondary mt-2 mb-0"},"按记事所属家庭查看,仅展示已授权的内容。",-1))])):D("",!0)])],2)])}),128))])]))),128))])}),128))]))),128)),t.value&&i.value.trim()&&!u.value.length?(y(),x("p",ef,"没有找到这位家人,可尝试其他姓名或清空搜索。")):D("",!0),t.value&&!t.value.trees.length?(y(),x("p",tf,"暂无可查看的家族资料。进入下方已授权家庭登记成员,或请家庭管理员授予族谱查看权限。")):D("",!0),(m=(b=t.value)==null?void 0:b.unplaced)!=null&&m.length?(y(),x("details",nf,[g[6]||(g[6]=a("summary",null,"我的家庭与其他场所",-1)),a("div",sf,[(y(!0),x(H,null,J(t.value.unplaced,v=>(y(),x("button",{key:v.id,class:"btn btn-outline-secondary",onClick:S=>j(K)().enterHome(v.id)},k(v.name)+" →",9,rf))),128))])])):D("",!0),t.value?(y(),x("p",of,"家人无需注册账号。人物档案沿用同一份,居住地址不决定亲属关系;这里仅展示你有权查看的资料。")):D("",!0)])):D("",!0)}}},af={id:"page-households",class:"page"},cf={class:"section-head"},df=["hidden"],uf={class:"btn-group",role:"group","aria-label":"浏览方式"},pf=["aria-pressed"],ff=["aria-pressed"],hf=["aria-pressed"],mf=["aria-expanded"],gf={id:"home-layout-options",class:"home-layout-controls"},bf=["disabled"],vf=["value"],yf=["disabled"],kf=["value"],xf={class:"inline-check"},wf=["disabled"],Sf={class:"inline-check"},Cf=["disabled"],Mf=["disabled"],Tf=["disabled"],Ef={key:0,class:"group-title"},Af={class:"home-card-grid"},Of=["draggable","onDragstart","onDrop"],Nf={class:"home-cover"},If=["src","alt"],Df={class:"home-cover-content"},$f={class:"site-heading"},Rf={class:"badge"},Lf=["data-edit-household"],Pf={class:"home-location"},Bf={class:"card-body"},_f={key:0,class:"home-order-actions"},zf=["disabled","aria-label","onClick"],jf=["disabled","aria-label","onClick"],Ff={class:"home-summary"},Vf={class:"home-numbers"},Hf={class:"compact-details"},qf={class:"home-card-actions"},Uf=["onClick"],Wf=["data-leadership"],Kf={key:0,class:"empty"},Jf={id:"home-global-topology",class:"network-overview"},Gf={class:"network-platform"},Yf={key:0,class:"chart-network-surface mb-3"},Xf={class:"platform-place-grid"},Zf=["onClick"],Qf={class:"badge"},eh={class:"home-pagination"},th={id:"home-page-info"},nh=["disabled"],sh=["disabled"],ih={__name:"HomeExplorer",setup(n){const e=P({revision:0,columns:2,rows:2,groupCity:!1,order:[]}),t=P(!1),s=P(!1),i=P(0),r=P(!1),o=P("generations"),l=P(!1),c=P(""),d=P("");let u="";Ae(R,E=>{var w;const M=((w=E.user)==null?void 0:w.id)+":"+E.session;u!==M&&(u=M,t.value=!1,s.value=!1,i.value=0,r.value=!1,o.value="generations",l.value=!1,c.value="",d.value=""),!t.value&&!s.value&&(e.value={revision:0,columns:2,rows:2,groupCity:!1,order:[],...E.state.householdLayout})},{immediate:!0});const p=ee(()=>{const E=R.value.state.households||[],M=new Map(E.map(w=>[w.id,w]));return[...new Set([...e.value.order,...E.map(w=>w.id)])].filter(w=>M.has(w)).map(w=>M.get(w))}),f=ee(()=>e.value.columns*e.value.rows),h=ee(()=>Math.max(1,Math.ceil(p.value.length/f.value)));Ae(h,E=>i.value=Math.min(i.value,E-1));const g=ee(()=>{var w;const E=p.value.slice(i.value*f.value,(i.value+1)*f.value);if(!e.value.groupCity)return[{name:"",items:E}];const M=new Map;for(const T of E){const N=[((w=T.geography)==null?void 0:w.country)||T.country,T.province,T.city||"地区待填写"].filter(Boolean).join(" / ");M.has(N)||M.set(N,[]),M.get(N).push(T)}return[...M].map(([T,N])=>({name:T,items:N}))}),b=E=>({home:"家庭",office:"办公场所",factory:"工厂"})[E.kind||"home"]||"场所",m=E=>{var M,w;return((w=(M=K()).address)==null?void 0:w.call(M,E))||[E.province,E.city,E.district].filter(Boolean).join(" · ")||"地区待填写"};function v(){t.value=!0,i.value=0,e.value.groupCity&&(r.value=!1),d.value="布局已调整,保存后下次登录会沿用。"}function S(E,M,w){if(s.value)return;const T=p.value.map(Z=>Z.id),N=T.indexOf(E),I=w?T.indexOf(w):N+M;N<0||I<0||I>=T.length||N===I||(T.splice(N,1),T.splice(I,0,E),e.value.order=T,t.value=!0,i.value=Math.floor(I/f.value))}function A(){t.value=!1,e.value={...R.value.state.householdLayout},i.value=0,d.value=""}async function O(){const E=u;s.value=!0;try{const M=await K().saveLayout({...e.value});if(E!==u)return;e.value=M,t.value=!1,d.value="布局与卡片顺序已保存"}catch(M){!M.stale&&E===u&&(d.value=M.message)}finally{E===u&&(s.value=!1)}}async function B(E,M=!1){await K().enterHome(E.id,M)}return(E,M)=>(y(),x("section",af,[a("div",cf,[M[13]||(M[13]=a("div",null,[a("h2",null," 家人与家庭 "),a("p",{class:"description mb-0"}," 以家人为起点,串起亲属关系、共同记忆与日常生活。 ")],-1)),a("button",{id:"new-household",class:"btn btn-primary",hidden:!j(R).platformAdmin}," + 新建家庭或场所 ",8,df)]),a("div",{class:De(["home-toolbar",{"home-options-open":l.value}])},[a("div",uf,[a("button",{class:De(["btn btn-outline-secondary",{active:o.value==="generations"}]),"aria-pressed":o.value==="generations",onClick:M[0]||(M[0]=w=>o.value="generations")},[G(be,{name:"tree"}),M[14]||(M[14]=C(" 家族世代",-1))],10,pf),a("button",{id:"home-card-view",class:De(["btn btn-outline-secondary",{active:o.value==="cards"}]),"aria-pressed":o.value==="cards",onClick:M[1]||(M[1]=w=>o.value="cards")},[G(be,{name:"grid"}),M[15]||(M[15]=C(" 家庭卡片",-1))],10,ff),a("button",{id:"home-topology-view",class:De(["btn btn-outline-secondary",{active:o.value==="topology"}]),"aria-pressed":o.value==="topology",onClick:M[2]||(M[2]=w=>o.value="topology")},[G(be,{name:"network"}),M[16]||(M[16]=C(" 场所网络 ",-1))],10,hf)]),Y(a("button",{class:"btn btn-outline-secondary home-layout-toggle","aria-expanded":l.value,"aria-controls":"home-layout-options",onClick:M[3]||(M[3]=w=>l.value=!l.value)},k(l.value?"收起设置":"布局设置"),9,mf),[[dn,o.value==="cards"]]),Y(a("div",gf,[a("label",null,[M[17]||(M[17]=C("每页 ",-1)),Y(a("select",{id:"home-columns","onUpdate:modelValue":M[4]||(M[4]=w=>e.value.columns=w),class:"form-select",disabled:s.value,onChange:v},[(y(),x(H,null,J(4,w=>a("option",{key:w,value:w},k(w)+" 列",9,vf)),64))],40,bf),[[Te,e.value.columns,void 0,{number:!0}]])]),M[20]||(M[20]=a("span",null,"×",-1)),Y(a("select",{id:"home-rows","onUpdate:modelValue":M[5]||(M[5]=w=>e.value.rows=w),"aria-label":"每页行数",class:"form-select",disabled:s.value,onChange:v},[(y(),x(H,null,J(4,w=>a("option",{key:w,value:w},k(w)+" 行",9,kf)),64))],40,yf),[[Te,e.value.rows,void 0,{number:!0}]]),a("label",xf,[Y(a("input",{id:"home-group-city","onUpdate:modelValue":M[6]||(M[6]=w=>e.value.groupCity=w),type:"checkbox",class:"form-check-input",disabled:s.value,onChange:v},null,40,wf),[[st,e.value.groupCity]]),M[18]||(M[18]=C("按城市分组",-1))]),a("label",Sf,[Y(a("input",{id:"home-arrange","onUpdate:modelValue":M[7]||(M[7]=w=>r.value=w),type:"checkbox",class:"form-check-input",disabled:e.value.groupCity||s.value},null,8,Cf),[[st,r.value]]),M[19]||(M[19]=C("调整顺序",-1))]),a("button",{id:"home-layout-save",class:"btn btn-primary",disabled:!t.value||s.value,onClick:O},k(s.value?"保存中…":"保存布局"),9,Mf),a("button",{id:"home-layout-reset",class:"btn btn-outline-secondary",disabled:!t.value||s.value,onClick:A}," 撤销 ",8,Tf)],512),[[dn,o.value==="cards"]])],2),Y(a("p",{id:"home-layout-status",role:"status",class:"small text-secondary"},k(d.value||"布局仅影响你的账号;手机端自动适配为单列。"),513),[[dn,o.value==="cards"]]),G(lf,{active:o.value==="generations"&&j(R).loggedIn&&j(R).page==="households"},null,8,["active"]),o.value==="topology"&&j(R).page==="households"&&j(R).loggedIn?(y(),Qe(Ep,{key:0})):D("",!0),Y(a("div",{id:"household-list",style:Nn({"--home-columns":e.value.columns})},[(y(!0),x(H,null,J(g.value,w=>(y(),x("section",{key:w.name,class:"home-city-group"},[w.name?(y(),x("h3",Ef,k(w.name),1)):D("",!0),a("div",Af,[(y(!0),x(H,null,J(w.items,T=>{var N,I;return y(),x("article",{key:T.id,class:"card home-card",draggable:r.value&&!s.value,onDragstart:Z=>{c.value=T.id,Z.dataTransfer.setData("text/plain",T.id)},onDragend:M[8]||(M[8]=Z=>c.value=""),onDragover:M[9]||(M[9]=Z=>r.value&&c.value&&Z.preventDefault()),onDrop:Ve(Z=>{r.value&&c.value&&S(c.value,0,T.id),c.value=""},["prevent"])},[a("div",Nf,[T.coverUrl?(y(),x("img",{key:0,src:T.coverUrl,alt:T.name+"封面",loading:"lazy"},null,8,If)):D("",!0),M[21]||(M[21]=a("div",{class:"cover-shade"},null,-1)),a("div",Df,[a("div",$f,[a("span",Rf,[C(k(b(T)),1),T.id===j(R).state.familyId?(y(),x(H,{key:0},[C(" · 当前")],64)):D("",!0)]),j(R).admin?(y(),x("button",{key:0,class:"btn btn-sm cover-edit","data-edit-household":T.id}," 编辑 ",8,Lf)):D("",!0)]),a("div",null,[a("h3",null,k(T.name),1),a("p",Pf,k(m(T)),1)])])]),a("div",Bf,[r.value?(y(),x("div",_f,[M[22]||(M[22]=a("span",null,"拖动排序",-1)),a("button",{class:"btn btn-sm btn-outline-secondary",disabled:((N=p.value[0])==null?void 0:N.id)===T.id||s.value,"aria-label":T.name+"前移",onClick:Z=>S(T.id,-1)}," ←",8,zf),a("button",{class:"btn btn-sm btn-outline-secondary",disabled:((I=p.value.at(-1))==null?void 0:I.id)===T.id||s.value,"aria-label":T.name+"后移",onClick:Z=>S(T.id,1)}," → ",8,jf)])):D("",!0),a("p",Ff,k(T.note||"记录家人、共同经历与日常生活。"),1),a("div",Vf,[a("span",null,[a("b",null,k(T.members||0),1),M[23]||(M[23]=C("成员",-1))]),a("span",null,[a("b",null,k(T.accounts||0),1),M[24]||(M[24]=C("授权账号",-1))]),a("span",null,k(b(T)),1)]),a("dl",Hf,[a("div",null,[a("dt",null,k(T.kind==="office"||T.kind==="factory"?"主要负责人":"家庭管理账号"),1),a("dd",null,k(T.ownerName||"待指定"),1)]),a("div",null,[M[25]||(M[25]=a("dt",null,"备用负责人",-1)),a("dd",null,k(T.successorName||"待指定"),1)])]),a("div",qf,[a("button",{class:"btn btn-primary",onClick:Z=>B(T)},[C(" 进入"+k(b(T))+" ",1),G(be,{name:"arrow"})],8,Uf),T.canAssignOwner?(y(),x("button",{key:0,class:"btn btn-link","data-leadership":T.id}," 负责人安排 ",8,Wf)):D("",!0)])])],40,Of)}),128))])]))),128)),p.value.length?D("",!0):(y(),x("div",Kf," 登录后查看已授权的家庭与场所。 "))],4),[[dn,o.value==="cards"]]),Y(a("div",Jf,[a("div",Gf,[G(be,{name:"network"}),a("div",null,[a("h3",null,k(j(R).brandName||"赵府")+" · 数字管家",1),a("p",null,k(p.value.length)+" 个已授权空间",1)])]),M[27]||(M[27]=a("p",{class:"description"}," 平台与场所的管理关系;进入场所查看内部设备及网络。 ",-1)),p.value.length?(y(),x("div",Yf,[G(wn,{option:j(lp)(p.value,j(R).brandName||"赵府"),active:j(R).loggedIn&&j(R).page==="households"&&o.value==="topology",height:340,label:"平台及已授权场所关系图;点击场所进入内部网络,下面也可通过卡片进入。",onSelect:M[10]||(M[10]=w=>B({id:w},!0))},null,8,["option","active"])])):D("",!0),a("div",Xf,[(y(!0),x(H,null,J(p.value,w=>(y(),x("button",{key:w.id,class:"card platform-place-node",onClick:T=>B(w,!0)},[a("span",Qf,k(b(w)),1),a("h3",null,k(w.name),1),a("p",null,k(m(w)),1),a("span",null,k(w.deviceCount||0)+" 台设备",1),a("small",null,k((w.networkAccesses||[]).map(j(Zr)).join(" · ")||"网络待登记"),1),M[26]||(M[26]=a("span",{class:"network-open"},"查看网络拓扑 →",-1))],8,Zf))),128))])],512),[[dn,o.value==="topology"]]),Y(a("div",eh,[a("span",th,"第 "+k(i.value+1)+" / "+k(h.value)+" 页 · 每页最多 "+k(f.value)+" 张",1),a("button",{id:"home-prev",class:"btn btn-outline-secondary",disabled:!i.value,onClick:M[11]||(M[11]=w=>i.value--)}," 上一页",8,nh),a("button",{id:"home-next",class:"btn btn-outline-secondary",disabled:i.value>=h.value-1,onClick:M[12]||(M[12]=w=>i.value++)}," 下一页 ",8,sh)],512),[[dn,o.value==="cards"]])]))}},rh={key:0,class:"network-status-block"},oh={class:"network-status-title"},lh=["disabled"],ah={key:0,class:"text-danger small",role:"status"},ch={key:0,class:"small text-secondary"},dh={key:1,class:"small text-secondary"},uh={key:2,class:"small text-secondary"},ph={class:"management-links"},fh=["href"],hh={key:0},mh={class:"network-check-time"},Qr={__name:"NetworkStatus",props:{device:{type:Object,required:!0},active:{type:Boolean,default:!0}},setup(n){const e=n,t=P(null),s=P(!1),i=P("");let r=0,o;const l=ee(()=>[e.device.id,e.device.source,e.device.managementHost,e.device.tailscaleHost,e.device.networkCidr,R.value.state.familyId,R.value.session,R.value.admin,e.active].join("|"));async function c(){const p=r;if(!(s.value||!R.value.admin||!e.active)){s.value=!0,i.value="";try{const f=await K().api("/api/devices/network?source="+encodeURIComponent(e.device.source)+"&id="+encodeURIComponent(e.device.id));p===r&&(t.value=f)}catch(f){p===r&&!f.stale&&(i.value=f.message)}finally{p===r&&(s.value=!1,o=setTimeout(c,35e3))}}}Ae(l,()=>{r++,clearTimeout(o),s.value=!1,t.value=null,i.value="",R.value.admin&&e.active&&c()},{immediate:!0}),Aa(()=>{r++,clearTimeout(o)});const d=ee(()=>t.value?t.value.targets.some(p=>p.reachable)?"网络可达":"未连通":"等待检查");function u(){clearTimeout(o),c()}return(p,f)=>{var h,g;return j(R).admin?(y(),x("div",rh,[a("div",oh,[a("span",null,[a("i",{class:De(["status-dot",{online:(h=t.value)==null?void 0:h.targets.some(b=>b.reachable)}])},null,2),C(k(s.value?"正在检查…":d.value),1)]),a("button",{class:"btn btn-sm btn-link",disabled:s.value,onClick:u},"检查网络",8,lh)]),i.value?(y(),x("p",ah,k(i.value),1)):D("",!0),t.value?(y(),x(H,{key:1},[(y(!0),x(H,null,J(t.value.targets,b=>(y(),x("div",{key:b.kind,class:"network-target"},[a("span",null,k(b.kind==="tailscale"?"Tailscale":"设备地址"),1),a("code",null,k(b.host),1),a("span",{class:De(b.reachable?"text-success":"text-secondary")},k(b.reachable?"服务可达":"未响应"),3)]))),128)),t.value.targets.length?D("",!0):(y(),x("p",ch,"请编辑设备档案,填写 IP 或域名。")),(g=t.value.tailscale)!=null&&g.available?(y(),x("p",dh,[C("Tailscale 节点"+k(t.value.tailscale.online?"在线":"离线"),1),t.value.tailscale.subnet?(y(),x(H,{key:0},[C(" · "+k(t.value.tailscale.subnetAvailable?"已发布":"未检测到")+" "+k(t.value.tailscale.subnet)+" 路由",1)],64)):D("",!0)])):t.value.tailscale?(y(),x("p",uh,k(t.value.tailscale.note),1)):D("",!0),a("div",ph,[(y(!0),x(H,null,J(t.value.links,b=>(y(),x("a",{key:b.kind,href:b.url,target:"_blank",rel:"noopener noreferrer",class:"btn btn-sm btn-outline-secondary"},[C("打开管理后台 · "+k(b.kind==="tailscale"?"Tailscale":"局域网")+" ↗",1),b.verified?D("",!0):(y(),x("span",hh,"(待连通)"))],8,fh))),128))]),a("small",mh,"检查于 "+k(new Date(t.value.checkedAt*1e3).toLocaleTimeString("zh-CN"))+" · 从服务器探测,打开后台需当前浏览器也能到达。",1)],64)):D("",!0)])):D("",!0)}}},gh={class:"mt-3"},bh=["disabled"],vh={class:"form-check"},yh={class:"d-flex flex-column gap-2 my-3"},kh=["value"],xh={key:0,class:"small text-secondary"},wh={key:0,class:"text-danger small",role:"alert"},Sh={key:1,class:"text-success small",role:"status"},Ch={__name:"VoicePermissions",props:{deviceId:String},setup(n){const e=n,t=P(!1),s=P([]),i=P([]),r=P(!0),o=P(""),l=P("");let c=!0;async function d(){try{const p=await K().api("/api/display-voice",{deviceId:e.deviceId,action:"settings"});c&&(t.value=p.enabled,s.value=p.allowed,i.value=p.candidates)}catch(p){c&&(o.value=p.message)}finally{c&&(r.value=!1)}}async function u(){if(!r.value){r.value=!0,o.value="",l.value="";try{await K().api("/api/display-voice",{deviceId:e.deviceId,action:"configure",enabled:t.value,allowed:s.value,consent:!0}),c&&(l.value="喊话接收权限已保存")}catch(p){c&&(o.value=p.message)}finally{c&&(r.value=!1)}}}return $i(d),Bt(()=>c=!1),(p,f)=>(y(),x("details",gh,[f[3]||(f[3]=a("summary",null,"家人喊话 · 接收权限",-1)),f[4]||(f[4]=a("p",{class:"small text-secondary mt-2"},"选择可以向此终端喊话的家人手机。对方按住说话、松开发送;终端 App 打开时播放,屏幕上可以停止播放。重新配对后需要重新授权。",-1)),a("fieldset",{disabled:r.value},[a("label",vh,[Y(a("input",{"onUpdate:modelValue":f[0]||(f[0]=h=>t.value=h),type:"checkbox",class:"form-check-input"},null,512),[[st,t.value]]),f[2]||(f[2]=C("允许接收所选家人的喊话",-1))]),a("div",yh,[(y(!0),x(H,null,J(i.value,h=>(y(),x("label",{key:h.id,class:"form-check"},[Y(a("input",{"onUpdate:modelValue":f[1]||(f[1]=g=>s.value=g),type:"checkbox",class:"form-check-input",value:h.id},null,8,kh),[[st,s.value]]),C(k(h.name),1)]))),128)),i.value.length?D("",!0):(y(),x("span",xh,"先让家人的手机完成配对,再选择喊话人。"))]),a("button",{class:"btn btn-outline-primary btn-sm",onClick:u},"保存接收权限")],8,bh),o.value?(y(),x("p",wh,k(o.value),1)):D("",!0),l.value?(y(),x("p",Sh,k(l.value),1)):D("",!0)]))}},Mh={key:0,class:"display-manager mt-3"},Th={key:0,class:"border rounded-3 p-3 mt-3"},Eh={class:"d-flex justify-content-between align-items-center gap-2 mb-3"},Ah={class:"small text-secondary"},Oh={class:"row g-2 hardware-grid"},Nh={class:"col-6"},Ih={class:"col-6"},Dh={class:"col-6"},$h={class:"col-6"},Rh={class:"small text-secondary mt-3"},Lh={key:0},Ph={key:0,class:"small text-secondary"},Bh={class:"small mb-3"},_h=["disabled"],zh={key:1,class:"tv-remote-preview"},jh=["src"],Fh={class:"small text-secondary"},Vh={class:"mt-3"},Hh={class:"row g-2 my-2"},qh={class:"col-12"},Uh={class:"col-6"},Wh={class:"col-6"},Kh=["disabled"],Jh={key:0,class:"my-3"},Gh=["value"],Yh=["href"],Xh=["disabled","onClick"],Zh={key:2,class:"alert alert-success mt-3"},Qh={class:"fs-3 font-monospace"},em={key:4,class:"text-danger mt-2",role:"alert"},tm={__name:"DisplayManager",props:{device:Object},setup(n){const e=n,t=P(!1),s=P(null),i=P([]),r=P(""),o=P(!1),l=P(""),c=P(""),d=P(0);let u,p=0,f="";const h=ee(()=>{var w;return(w=R.value.state.households)==null?void 0:w.find(T=>T.id===R.value.state.familyId)}),g=P(""),b=P(""),m=P(""),v=P(""),S=w=>w+"?deviceId="+encodeURIComponent(e.device.id),A=ee(()=>{var w;return((w=s.value)==null?void 0:w.hardware)||{}}),O=(w,T=1)=>typeof w=="number"?w.toFixed(T):"未提供",B=w=>w?new Date(w*1e3).toLocaleString("zh-CN"):"尚未上报";async function E(){const w=p;if(t.value)try{const T=await K().api(S("/api/displays/hardware"));if(w!==p)return;if(s.value=T,Date.now(){var T;if(p++,clearTimeout(u),l.value="",v.value="",r.value="",c.value="",d.value=0,f&&(URL.revokeObjectURL(f),f=""),w){const N=p;g.value=((T=h.value)==null?void 0:T.city)||"",b.value=g.value==="济南市"?"36.67":"",m.value=g.value==="济南市"?"116.99":"",E();try{const I=await K().api(S("/api/displays"));N===p&&(i.value=I.items)}catch(I){N===p&&(r.value=I.message)}}}),Ae(()=>[R.value.state.familyId,R.value.session,R.value.page,e.device.id].join("|"),()=>t.value=!1),Aa(()=>{p++,clearTimeout(u),f&&URL.revokeObjectURL(f)}),(w,T)=>{var N,I,Z,Oe,le,ae,_,fe,rt,yt,F,jt,xs,Ft,cn;return j(R).admin?(y(),x("div",Mh,[a("button",{class:"btn btn-outline-primary btn-sm",onClick:T[0]||(T[0]=te=>t.value=!t.value)},k(t.value?"收起显示终端管理":"显示终端管理 · 状态与模拟屏"),1),t.value?(y(),x("section",Th,[a("div",Eh,[a("strong",null,k(n.device.name),1),a("span",{class:De(["badge",(N=s.value)!=null&&N.online?"text-bg-success":"text-bg-secondary"])},k((I=s.value)!=null&&I.online?"在线 · 心跳正常":(Z=s.value)!=null&&Z.paired?"未收到心跳":"尚未绑定"),3)]),a("p",Ah,"所属:"+k((Oe=h.value)==null?void 0:Oe.name)+" · 最后心跳 "+k(B((le=s.value)==null?void 0:le.lastSeen)),1),a("div",Oh,[a("div",Nh,[T[7]||(T[7]=a("span",null,"处理器温度",-1)),a("strong",null,k(O(A.value.temperatureC))+k(A.value.temperatureC!=null?" °C":""),1),a("small",null,k(A.value.temperatureSource||"等待传感器上报"),1)]),a("div",Ih,[T[8]||(T[8]=a("span",null,"整机功率",-1)),a("strong",null,k(O(A.value.powerW))+k(A.value.powerW!=null?" W":""),1),a("small",null,k(A.value.powerSource||"需设备传感器或计量插座"),1)]),a("div",Dh,[T[9]||(T[9]=a("span",null,"可用内存",-1)),a("strong",null,k(O(A.value.memoryAvailableMB,0))+" / "+k(O(A.value.memoryTotalMB,0))+" MB",1)]),a("div",$h,[T[10]||(T[10]=a("span",null,"可用存储",-1)),a("strong",null,k(O(A.value.storageAvailableGB))+" / "+k(O(A.value.storageTotalGB))+" GB",1)])]),a("p",Rh,[C(k(A.value.model||n.device.model)+" · Android "+k(A.value.osVersion||"—")+" · IP "+k(A.value.ip||n.device.managementHost||"—"),1),T[11]||(T[11]=a("br",null,null,-1)),C(k(A.value.screenWidth||"—")+" × "+k(A.value.screenHeight||"—")+" · "+k(A.value.foreground?"看板在前台":"看板未在前台")+" · "+k(A.value.screenOn?"屏幕亮":"屏幕状态待确认"),1),(ae=s.value)!=null&&ae.online?D("",!0):(y(),x("span",Lh," · 当前数值为最后一次上报"))]),T[22]||(T[22]=a("h4",{class:"fs-6"},"异常与报警",-1)),(fe=(_=s.value)==null?void 0:_.alerts)!=null&&fe.some(te=>!te.cleared)?D("",!0):(y(),x("p",Ph,k((rt=s.value)!=null&&rt.online?"当前无活动报警":"连接恢复后继续检查硬件状态"),1)),(y(!0),x(H,null,J((F=(yt=s.value)==null?void 0:yt.alerts)==null?void 0:F.filter(te=>!te.cleared),te=>(y(),x("div",{key:te.code,class:De(["alert py-2 small",te.severity==="critical"?"alert-danger":"alert-warning"])},k(te.message)+" · "+k(B(te.opened)),3))),128)),a("details",Bh,[T[12]||(T[12]=a("summary",null,"报警记录与规则",-1)),T[13]||(T[13]=a("p",null,"心跳中断超过 100 秒;处理器 ≥75°C 提醒、≥85°C 严重;可用内存低于 5%;可用存储低于 0.5 GB;看板退出前台。数值来自显示终端上报。",-1)),(y(!0),x(H,null,J((jt=s.value)==null?void 0:jt.alerts,(te,ws)=>(y(),x("div",{key:ws},k(te.cleared?"已恢复":"处理中")+" · "+k(te.message)+" · "+k(B(te.opened)),1))),128))]),a("button",{class:"btn btn-primary btn-sm",disabled:o.value||!((xs=s.value)!=null&&xs.online),onClick:T[1]||(T[1]=te=>M("preview"))},"查看模拟屏 · 60 秒",8,_h),T[23]||(T[23]=a("p",{class:"small text-secondary mt-2"},"显示显示终端当前家庭看板的应用画面,约 20 秒更新一次;退出看板后不显示其他应用。预览仅短时保存在内存。",-1)),c.value?(y(),x("figure",zh,[a("img",{src:c.value,alt:"显示终端家庭看板的真实应用画面"},null,8,jh),a("figcaption",Fh,"画面时间:"+k(B((Ft=s.value)==null?void 0:Ft.previewAt)),1)])):D("",!0),a("details",Vh,[T[18]||(T[18]=a("summary",null,"展示授权与天气设置",-1)),a("div",Hh,[a("label",qh,[T[14]||(T[14]=C("天气城市",-1)),Y(a("input",{"onUpdate:modelValue":T[2]||(T[2]=te=>g.value=te),class:"form-control",maxlength:"60"},null,512),[[At,g.value]])]),a("label",Uh,[T[15]||(T[15]=C("纬度",-1)),Y(a("input",{"onUpdate:modelValue":T[3]||(T[3]=te=>b.value=te),class:"form-control",type:"number",step:"0.0001",min:"-90",max:"90"},null,512),[[At,b.value]])]),a("label",Wh,[T[16]||(T[16]=C("经度",-1)),Y(a("input",{"onUpdate:modelValue":T[4]||(T[4]=te=>m.value=te),class:"form-control",type:"number",step:"0.0001",min:"-180",max:"180"},null,512),[[At,m.value]])])]),T[19]||(T[19]=a("p",{class:"small text-secondary"},"链接有效期一年,仅可展示本家庭概况、设备状态与本人同意共享的家人位置。重新生成会停用旧链接。",-1)),a("button",{class:"btn btn-outline-primary btn-sm",disabled:o.value,onClick:T[5]||(T[5]=te=>M("create"))},"生成 App 配对码",8,Kh),l.value?(y(),x("div",Jh,[a("label",null,[T[17]||(T[17]=C("本次展示链接(请仅交给这台显示终端)",-1)),a("input",{class:"form-control",value:l.value,readonly:"",onFocus:T[6]||(T[6]=te=>te.target.select())},null,40,Gh)]),a("a",{class:"btn btn-sm btn-outline-secondary mt-2",href:l.value,target:"_blank",rel:"noreferrer"},"打开看板",8,Yh)])):D("",!0),(y(!0),x(H,null,J(i.value.filter(te=>!te.revoked),te=>(y(),x("div",{key:te.id,class:"d-flex gap-2 align-items-center small mt-2"},[a("span",null,"授权至 "+k(B(te.expires_at)),1),a("button",{class:"btn btn-sm btn-outline-danger",disabled:o.value,onClick:ws=>M("revoke",te.id)},"停用展示权限",8,Xh)]))),128))]),v.value&&l.value?(y(),x("div",Zh,[T[20]||(T[20]=C("App 配对码:",-1)),a("strong",Qh,k(v.value),1),T[21]||(T[21]=a("div",{class:"small"},"在“赵府家庭屏”App 输入,10 分钟内有效,使用一次即失效。App 摄像头画面在本地网络直接播放。",-1))])):D("",!0),(cn=s.value)!=null&&cn.paired?(y(),Qe(Ch,{key:n.device.id,"device-id":n.device.id},null,8,["device-id"])):D("",!0),r.value?(y(),x("p",em,k(r.value),1)):D("",!0)])):D("",!0)])):D("",!0)}}},$a=In(tm,[["__scopeId","data-v-2d075cdb"]]),nm={key:0,class:"mt-3"},sm={key:0,class:"border rounded p-3 mt-2"},im={class:"w-100"},rm=["value"],om={class:"d-flex gap-2 small mb-2"},lm=["disabled"],am={key:1,class:"small mt-2",role:"status"},Ra={__name:"DeviceTransfer",props:{device:Object},setup(n){const e=n,t=P(!1),s=P(""),i=P(!1),r=P(!1),o=P(""),l=ee(()=>(R.value.state.households||[]).filter(d=>d.id!==R.value.state.familyId));Ae(()=>R.value.state.familyId,()=>{t.value=!1,s.value="",i.value=!1,o.value=""});async function c(){if(!(!i.value||!s.value)){r.value=!0,o.value="";try{await K().api("/api/devices/transfer",{source:e.device.source,id:e.device.id,targetFamilyId:s.value}),K().notify("设备已转移,电视需在新家庭重新授权。"),t.value=!1,await K().refresh()}catch(d){o.value=d.message}finally{r.value=!1}}}return(d,u)=>{var p;return((p=j(R).user)==null?void 0:p.role)==="admin"?(y(),x("div",nm,[a("button",{class:"btn btn-sm btn-outline-secondary",onClick:u[0]||(u[0]=f=>t.value=!t.value)},"转移到其他家庭"),t.value?(y(),x("div",sm,[a("label",im,[u[4]||(u[4]=C("目标家庭 / 公司 / 工厂",-1)),Y(a("select",{"onUpdate:modelValue":u[1]||(u[1]=f=>s.value=f),class:"form-select mt-2"},[u[3]||(u[3]=a("option",{value:""},"请选择",-1)),(y(!0),x(H,null,J(l.value,f=>(y(),x("option",{key:f.id,value:f.id},k(f.name),9,rm))),128))],512),[[Te,s.value]])]),u[6]||(u[6]=a("p",{class:"small text-secondary mt-2"},"保留设备编号与基本档案。所属区域、负责人和上级设备需重新设置;电视旧展示授权会停用。关联录像机的摄像头需先解除关联。",-1)),a("label",om,[Y(a("input",{"onUpdate:modelValue":u[2]||(u[2]=f=>i.value=f),type:"checkbox"},null,512),[[st,i.value]]),u[5]||(u[5]=C("确认将这台设备转移给目标家庭管理",-1))]),a("button",{class:"btn btn-primary btn-sm",disabled:r.value||!i.value||!s.value,onClick:c},"确认转移",8,lm)])):D("",!0),o.value?(y(),x("p",am,k(o.value),1)):D("",!0)])):D("",!0)}}},cm={id:"asset-list"},dm={class:"group-title"},um={class:"count-pill"},pm={class:"device-card-grid"},fm={class:"card-body"},hm={class:"device-card-heading"},mm={class:"device-symbol"},gm={class:"flex-grow-1"},bm={class:"small text-secondary"},vm=["onClick"],ym={class:"device-location"},km={class:"compact-details"},xm={class:"font-monospace"},wm={key:0},Sm={key:0,class:"device-tags"},Cm={class:"card-footer device-card-actions"},Mm=["onClick"],Tm=["onClick"],Em=["onClick"],Am={key:0,class:"empty"},Om={__name:"DeviceCollection",setup(n){const e=i=>(R.value.state.cameras||[]).filter(r=>i.source==="camera"?r.assetId===i.id:r.recorderId===i.id||r.archiveRecorderId===i.id),t=i=>({["data-"+(i.source==="camera"?"edit-asset":i.source==="recorder"?"edit-recorder":"edit-device")]:i.id}),s=i=>/路由|网关|服务器/.test(i.deviceType)||/gl\.inet/i.test(i.brand||"");return(i,r)=>(y(),x("div",cm,[(y(!0),x(H,null,J(j(ze).groups,o=>(y(),x("section",{key:o.key,class:"device-group"},[a("h3",dm,[C(k(o.labels.join(" / ")||"全部设备")+" ",1),a("span",um,k(o.items.length),1)]),a("div",pm,[(y(!0),x(H,null,J(o.items,l=>{var c,d,u;return y(),x("article",{key:l.source+l.id,class:"card device-card"},[a("div",fm,[a("div",hm,[a("div",mm,[G(be,{name:l.source==="camera"?"camera":s(l)?"router":"devices"},null,8,["name"])]),a("div",gm,[a("span",bm,k(l.deviceType),1),a("h3",null,[a("button",{class:"device-title",onClick:p=>j(K)().enterDevice(l.source,l.id)},k(l.name),9,vm)])]),j(R).admin?(y(),x("button",Iu({key:0,class:"btn btn-sm btn-outline-secondary"},{ref_for:!0},t(l))," 编辑 ",16)):D("",!0)]),a("p",ym,[C(k(((d=(c=j(K)()).location)==null?void 0:d.call(c,l.siteId))||"区域待填写"),1),l.point?(y(),x(H,{key:0},[C(" · "+k(l.point),1)],64)):D("",!0)]),a("dl",km,[a("div",null,[r[0]||(r[0]=a("dt",null,"品牌型号",-1)),a("dd",null,k([l.brand,l.model].filter(Boolean).join(" / ")||"未填写"),1)]),a("div",null,[r[1]||(r[1]=a("dt",null,"设备地址",-1)),a("dd",xm,k(l.networkHosts.join(" / ")||"未填写"),1)]),a("div",null,[r[2]||(r[2]=a("dt",null,"网络",-1)),a("dd",null,k(j(Zr)(l.networkAccess)),1)]),a("div",null,[r[3]||(r[3]=a("dt",null,"所有人 / 负责人",-1)),a("dd",null,k(l.ownerName||"待指定")+" / "+k(l.managerName||"待指定"),1)]),l.source!=="device"?(y(),x("div",wm,[r[4]||(r[4]=a("dt",null,"镜头通道",-1)),a("dd",null,k(e(l).length)+" 个已配置",1)])):D("",!0)]),(u=l.tags)!=null&&u.length?(y(),x("div",Sm,[(y(!0),x(H,null,J(l.tags,p=>(y(),x("span",{key:p},k(p),1))),128))])):D("",!0),s(l)?(y(),Qe(Qr,{key:1,device:l,active:j(R).page==="objects"&&j(ze).mode==="cards"},null,8,["device","active"])):D("",!0),l.source==="device"&&/电视|显示|大屏/.test(l.deviceType)?(y(),Qe($a,{key:2,device:l},null,8,["device"])):D("",!0),G(Ra,{device:l},null,8,["device"])]),a("div",Cm,[a("button",{class:"btn btn-sm btn-outline-secondary",onClick:p=>j(K)().enterDevice(l.source,l.id,"device")}," 设备详情",8,Mm),l.source!=="device"?(y(),x(H,{key:0},[j(R).admin?(y(),x("button",{key:0,class:"btn btn-sm btn-outline-secondary",onClick:p=>j(K)().enterDevice(l.source,l.id,"cameras")}," 配置镜头",8,Tm)):D("",!0),e(l).length?(y(),x("button",{key:1,class:"btn btn-sm btn-primary",onClick:p=>j(K)().enterDevice(l.source,l.id,"live")}," 实时画面 ",8,Em)):D("",!0)],64)):D("",!0)])])}),128))])]))),128)),j(ze).devices.length?D("",!0):(y(),x("div",Am,[G(be,{name:"devices"}),r[5]||(r[5]=a("h3",null,"当前范围没有设备",-1)),r[6]||(r[6]=a("p",null,"调整筛选条件,或添加摄像机、路由器、灯等设备。",-1))]))]))}},Nm={key:0,class:"network-diagram"},Im={class:"diagram-toolbar"},Dm={class:"small text-secondary"},$m={class:"chart-network-surface"},Rm={__name:"NetworkDiagram",setup(n){const e=P(0),t=ee(()=>op(ze.value.rows,K().location)),s=ee(()=>R.value.loggedIn&&R.value.page==="objects"&&ze.value.mode==="topology");Ae(()=>R.value.session+":"+R.value.state.familyId,()=>e.value++);function i(r){const o=ze.value.rows.find(l=>l.device.id===r);o&&K().enterDevice(o.device.source,r,"device")}return(r,o)=>j(ze).rows.length?(y(),x("div",Nm,[a("div",Im,[a("div",null,[o[1]||(o[1]=a("span",{class:"diagram-dot"},null,-1)),o[2]||(o[2]=a("strong",null,"设备连接图",-1)),a("span",Dm,k(j(ze).rows.length)+" 台设备 · "+k(t.value.series[0].links.length)+" 条已登记连接",1)]),a("button",{class:"btn btn-sm btn-outline-secondary",onClick:o[0]||(o[0]=l=>e.value++)},"重置视图")]),a("div",$m,[(y(),Qe(wn,{key:e.value,option:t.value,active:s.value,height:400,label:"已登记设备连接图,可拖动缩放;下方设备详情提供相同信息及操作。",onSelect:i},null,8,["option","active"]))]),o[3]||(o[3]=a("p",{class:"diagram-note"},"拖动平移、滚轮或双指缩放;点击节点打开档案。未登记上级的设备独立显示;接入方式不代表在线状态。",-1))])):D("",!0)}},Lm={id:"device-topology",hidden:""},Pm={class:"panel network-map"},Bm={class:"network-platform"},_m={class:"topology-nodes"},zm={class:"card-body"},jm={class:"device-card-heading"},Fm={class:"flex-grow-1"},Vm={class:"small text-secondary"},Hm=["onClick"],qm=["onClick"],Um={class:"device-location"},Wm={class:"network-facts"},Km={key:0},Jm={key:1},Gm={key:2},Ym={key:3},Xm={key:0,class:"empty"},Zm={__name:"NetworkMap",setup(n){const e=ee(()=>(R.value.state.households||[]).find(t=>t.id===R.value.state.familyId));return(t,s)=>{var i;return y(),x("div",Lm,[a("section",Pm,[a("div",Bm,[G(be,{name:"network"}),a("div",null,[a("h3",null,k(((i=e.value)==null?void 0:i.name)||"当前场所"),1),a("p",null,k(j(ze).devices.length)+" 台设备 · 随设备档案自动更新",1)])]),s[7]||(s[7]=a("p",{class:"description"}," 连线来自已确认的上级设备关系。上级未填写时单独列出;不代表已自动发现所有交换机或布线。 ",-1)),G(Rm),s[8]||(s[8]=a("h3",{class:"network-details-heading"},"设备与连接详情",-1)),a("div",_m,[(y(!0),x(H,null,J(j(ze).rows,r=>{var o,l;return y(),x("article",{key:r.device.id,class:De(["network-node card",{nested:r.depth>0}]),style:Nn({"--depth":Math.min(r.depth,5)})},[a("div",zm,[a("div",jm,[G(be,{name:r.device.source==="camera"?"camera":"router"},null,8,["name"]),a("div",Fm,[a("span",Vm,k(r.device.deviceType)+" · "+k(j(Zr)(r.device.networkAccess)),1),a("h3",null,[a("button",{class:"device-title",onClick:c=>j(K)().enterDevice(r.device.source,r.device.id)},k(r.device.name),9,Hm)])]),a("button",{class:"btn btn-sm btn-outline-secondary",onClick:c=>j(K)().enterDevice(r.device.source,r.device.id,"device")}," 详情 → ",8,qm)]),a("p",Um,[C(k(((l=(o=j(K)()).location)==null?void 0:l.call(o,r.device.siteId))||"未指定区域")+" ",1),r.device.point?(y(),x(H,{key:0},[C(" · "+k(r.device.point),1)],64)):D("",!0)]),a("div",Wm,[a("span",null,[s[0]||(s[0]=C("IP ",-1)),a("b",null,k(r.device.networkHosts.join(" / ")||"待填写"),1)]),r.device.tailscaleHost?(y(),x("span",Km,[s[1]||(s[1]=C("Tailscale ",-1)),a("b",null,k(r.device.tailscaleHost),1)])):D("",!0),r.device.networkCidr?(y(),x("span",Jm,[s[2]||(s[2]=C("网段 ",-1)),a("b",null,k(r.device.networkCidr),1)])):D("",!0),a("span",null,[s[3]||(s[3]=C("上级 ",-1)),a("b",null,k(r.parentName||"待确认 / 直接接入"),1)]),a("span",null,[s[4]||(s[4]=C("连接 ",-1)),a("b",null,k({wired:"网线",wifi:"Wi-Fi"}[r.device.connectionType]||"待确认"),1)]),r.via.length?(y(),x("span",Gm,[s[5]||(s[5]=C("取流经录像机 ",-1)),a("b",null,k(r.via.join("、")),1)])):D("",!0),r.archiveVia.length?(y(),x("span",Ym,[s[6]||(s[6]=C("录像归档 ",-1)),a("b",null,k(r.archiveVia.join("、")),1)])):D("",!0)]),/路由|网关|服务器/.test(r.device.deviceType)?(y(),Qe(Qr,{key:0,device:r.device,active:j(R).page==="objects"&&j(ze).mode==="topology"},null,8,["device","active"])):D("",!0)])],6)}),128)),j(ze).rows.length?D("",!0):(y(),x("p",Xm," 当前范围尚未登记设备。 "))])])])}}},Qm={key:0,class:"panel"},eg={__name:"DeviceNetworkPanel",setup(n){return(e,t)=>j(R).admin&&j(R).device&&j(R).page==="device"?(y(),x("section",Qm,[t[0]||(t[0]=a("h3",null,"网络状态与管理入口",-1)),j(R).device.source==="device"&&/电视|显示|大屏/.test(j(R).device.deviceType)?(y(),Qe($a,{key:0,device:j(R).device},null,8,["device"])):(y(),Qe(Qr,{key:1,device:j(R).device},null,8,["device"])),G(Ra,{device:j(R).device},null,8,["device"])])):D("",!0)}},tg={key:0,class:"row g-3 mb-4","aria-label":"当前场所设备统计"},ng={class:"col-12 col-lg-7"},sg={class:"chart-card h-100"},ig={class:"chart-heading"},rg={class:"small text-secondary"},og={class:"chart-data"},lg={class:"col-12 col-lg-5"},ag={class:"chart-card h-100"},cg={class:"chart-legend"},dg={__name:"ScopeInsights",setup(n){const e=ee(()=>rp(R.value.state)),t=ee(()=>R.value.loggedIn&&R.value.page==="objects");return(s,i)=>t.value&&e.value.total?(y(),x("section",tg,[a("div",ng,[a("article",sg,[a("div",ig,[i[0]||(i[0]=a("h3",null,"设备类型",-1)),a("span",rg,k(e.value.total)+" 台已授权设备",1)]),G(wn,{option:j(Ia)(e.value.types.slice(0,8)),height:220,label:"设备类型:"+e.value.types.map(r=>r.label+r.count+"台").join(",")},null,8,["option","label"]),a("details",og,[i[1]||(i[1]=a("summary",null,"查看全部类型",-1)),a("ul",null,[(y(!0),x(H,null,J(e.value.types,r=>(y(),x("li",{key:r.label},k(r.label)+":"+k(r.count)+" 台",1))),128))])])])]),a("div",lg,[a("article",ag,[i[2]||(i[2]=a("div",{class:"chart-heading"},[a("h3",null,"网络接入"),a("span",{class:"small text-secondary"},"来自设备档案")],-1)),G(wn,{option:j(Na)(e.value.networks),height:190,label:"登记的网络接入方式:"+e.value.networks.map(r=>r.label+r.count+"台").join(",")},null,8,["option","label"]),a("div",cg,[(y(!0),x(H,null,J(e.value.networks,(r,o)=>(y(),x("span",{key:r.label},[a("i",{style:Nn({background:j(ns)[o]})},null,4),C(k(r.label)+" ",1),a("b",null,k(r.count),1)]))),128))]),i[3]||(i[3]=a("p",{class:"small text-secondary mt-2 mb-0"},"接入方式不代表设备在线状态。",-1))])])])):D("",!0)}},ug={class:"border-top mt-3 pt-3"},pg={class:"col-sm-3"},fg=["value"],hg={class:"col-sm-2"},mg={key:0,class:"col-sm-3"},gg={key:1,class:"col-sm-3"},bg={class:"col-sm-3 align-self-end"},vg=["disabled"],yg={role:"status"},kg=["disabled"],xg={__name:"LocationHistory",props:{members:{type:Array,default:()=>[]}},setup(n){const e=P(""),t=P(new Intl.DateTimeFormat("sv-SE",{timeZone:"Asia/Shanghai"}).format(new Date)),s=P(t.value),i=P("day"),r=P([]),o=P(""),l=P(!1),c=P(null);let d=0,u;function p(){d++,r.value=[],o.value="",l.value=!1,c.value=null,clearTimeout(u)}Ae([e,t,s,i,()=>R.value.state.familyId,()=>R.value.page,()=>R.value.session],p);async function f(g=!1){const b=g?c.value:0;g||p();const m=d;l.value=!0,o.value="正在从网盘读取…";try{const v=await K().api("/api/location-history?"+new URLSearchParams({memberId:e.value,date:t.value,until:s.value,period:i.value,cursor:b}));if(m===d){const S=[...r.value,...v.points];let O=[...new Map(S.map(B=>[B.at,B])).values()].sort((B,E)=>B.at-E.at);O.length>1e4&&(O=Array.from({length:1e4},(B,E)=>O[Math.round(E*(O.length-1)/9999)])),r.value=O,c.value=v.nextCursor,o.value=`已读取 ${v.loadedFiles} / ${v.totalFiles} 段归档 · 显示 ${O.length} 个采样点${v.nextCursor!==null?",点击继续加载读取其余记录":",本时段已读取完毕"}`,clearTimeout(u),u=setTimeout(p,6e4)}}catch(v){m===d&&(r.value=[],c.value=null,o.value=v.message)}finally{m===d&&(l.value=!1)}}function h(){document.hidden&&p()}return document.addEventListener("visibilitychange",h),Bt(()=>{p(),document.removeEventListener("visibilitychange",h)}),(g,b)=>(y(),x("details",ug,[b[11]||(b[11]=a("summary",null,"历史轨迹 · 每天到一生",-1)),b[12]||(b[12]=a("p",{class:"small text-secondary mt-2"},"仅记录本人同意保存的轨迹,长期保留至本人删除。关闭共享后他人不能读取;新查看人不自动获得过去记录。长时段分批从网盘读取,概览抽样展示,原始定位点仍保留。连线不是实际道路路线。画面 1 分钟后清除,需要时重新读取。",-1)),a("form",{class:"row g-2 my-2",onSubmit:b[4]||(b[4]=Ve(m=>f(!1),["prevent"]))},[a("label",pg,[b[7]||(b[7]=C("家人",-1)),Y(a("select",{"onUpdate:modelValue":b[0]||(b[0]=m=>e.value=m),required:"",class:"form-select"},[b[6]||(b[6]=a("option",{value:""},"请选择",-1)),(y(!0),x(H,null,J(n.members,m=>(y(),x("option",{key:m.id,value:m.id},k(m.name),9,fg))),128))],512),[[Te,e.value]])]),a("label",hg,[b[9]||(b[9]=C("时段",-1)),Y(a("select",{"onUpdate:modelValue":b[1]||(b[1]=m=>i.value=m),class:"form-select"},[...b[8]||(b[8]=[ge('',6)])],512),[[Te,i.value]])]),i.value!=="life"?(y(),x("label",mg,[C(k(i.value==="custom"?"开始日期":"选择该时段内的日期"),1),Y(a("input",{type:"date","onUpdate:modelValue":b[2]||(b[2]=m=>t.value=m),required:"",class:"form-control"},null,512),[[At,t.value]])])):D("",!0),i.value==="custom"?(y(),x("label",gg,[b[10]||(b[10]=C("结束日期",-1)),Y(a("input",{type:"date","onUpdate:modelValue":b[3]||(b[3]=m=>s.value=m),required:"",class:"form-control"},null,512),[[At,s.value]])])):D("",!0),a("div",bg,[a("button",{class:"btn btn-primary",disabled:l.value},k(l.value?"读取中":"查看轨迹"),9,vg)])],32),r.value.length?(y(),Qe(Oa,{key:0,track:r.value,height:420},null,8,["track"])):D("",!0),a("p",yg,k(o.value),1),c.value!==null?(y(),x("button",{key:1,class:"btn btn-outline-primary",disabled:l.value,onClick:b[5]||(b[5]=m=>f(!0))},"继续加载",8,kg)):D("",!0)]))}},wg=In(xg,[["__scopeId","data-v-3234de1e"]]),Sg={key:0,class:"panel family-locations mb-4","aria-label":"家庭位置共享"},Cg={class:"d-flex flex-wrap justify-content-between gap-2"},Mg={class:"text-secondary small"},Tg={key:0,class:"alert alert-warning",role:"status"},Eg={class:"row g-3"},Ag={class:"col-12 col-lg-8"},Og={class:"col-12 col-lg-4"},Ng={key:0,class:"location-empty"},Ig=["onClick"],Dg={key:0},$g={class:"mt-3 border-top pt-3"},Rg={key:0,class:"alert alert-info"},Lg={class:"row g-3"},Pg={class:"col-sm-8"},Bg=["disabled"],_g=["value","disabled"],zg={class:"col-sm-4"},jg=["disabled"],Fg={class:"d-flex gap-2 mt-3"},Vg=["disabled"],Hg={key:0,class:"mt-3"},qg=["value","disabled"],Ug={key:1,class:"mt-3"},Wg=["value","disabled"],Kg={key:2,class:"mt-3"},Jg={key:0,class:"small text-secondary"},Gg=["value","disabled"],Yg={key:3},Xg={class:"d-flex flex-wrap gap-2 mt-3"},Zg=["disabled"],Qg=["disabled"],eb={key:4,class:"alert alert-success mt-3",role:"status"},tb={class:"font-monospace fs-3"},nb={key:1,class:"text-danger mt-2",role:"alert"},sb={__name:"FamilyLocations",setup(n){const e=P(null),t=P(""),s=P(!1),i=P(7),r=P(""),o=P(0),l=P(!1),c=P(""),d=P(""),u=P([]),p=P([]),f=P([]),h=P(!0),g=ee(()=>{var N,I;return(I=(N=e.value)==null?void 0:N.bindings)==null?void 0:I.find(Z=>Z.memberId===d.value)}),b=ee(()=>R.value.loggedIn&&R.value.page==="overview"),m=ee(()=>{var N;return(N=R.value.state.households)==null?void 0:N.find(I=>I.id===R.value.state.familyId)});let v,S=0,A=0;const O=ee(()=>{var N;return((N=e.value)==null?void 0:N.items)||[]}),B=N=>N?new Date(N*1e3).toLocaleString("zh-CN"):"尚未收到",E=N=>N.status==="stale"?"位置更新中断":N.status==="live"?"位置已更新":"等待手机定位",M=N=>N.position?`${N.position.latitude.toFixed(4)}°, ${N.position.longitude.toFixed(4)}° · 精度约 ${Math.round(N.position.accuracy)} 米`:"尚无有效位置";async function w(){const N=S,I=++A;if(b.value)try{const Z=await K().api("/api/locations");N===S&&I===A&&(e.value=Z,t.value="")}catch(Z){N===S&&I===A&&(e.value=null,t.value=Z.message)}finally{N===S&&I===A&&b.value&&(v=setTimeout(w,3e4))}}async function T(N){if(l.value)return;l.value=!0,t.value="";const I=S;A++,clearTimeout(v);try{const Z=await K().api("/api/locations",{action:N,memberId:d.value,viewerIds:u.value,displayIds:p.value,phoneIds:f.value,viewOnly:h.value,days:i.value});if(I!==S)return;r.value=Z.code||"",o.value=Z.expires||0,N==="stop"&&(s.value=!1),clearTimeout(v),await w()}catch(Z){I===S&&(t.value=Z.message)}finally{I===S&&(l.value=!1,clearTimeout(v),b.value&&(v=setTimeout(w,3e4)))}}return Ae([b,()=>R.value.state.familyId,()=>R.value.session],()=>{S++,clearTimeout(v),e.value=null,r.value="",d.value="",u.value=[],p.value=[],f.value=[],h.value=!0,c.value="",s.value=!1,l.value=!1,b.value&&w()},{immediate:!0}),Ae([d,u,p,f,h,i],()=>{r.value=""},{deep:!0}),Bt(()=>{S++,clearTimeout(v)}),(N,I)=>{var Z,Oe,le,ae;return b.value?(y(),x("section",Sg,[a("div",Cg,[a("div",null,[I[10]||(I[10]=a("h2",null,"家人位置",-1)),a("p",Mg,k((Z=m.value)==null?void 0:Z.name)+" · "+k(O.value.length)+" 位家人正在共享 · 只显示本人同意分享的最新位置",1)]),a("button",{class:"btn btn-sm btn-outline-secondary align-self-start",onClick:I[0]||(I[0]=_=>c.value="")},"查看全部位置")]),O.value.some(_=>_.status==="stale")?(y(),x("div",Tg,k(O.value.filter(_=>_.status==="stale").map(_=>_.name).join("、"))+"的位置超过 15 分钟未更新。请检查手机网络、定位权限或省电设置;这不代表人员失联。",1)):D("",!0),a("div",Eg,[a("div",Ag,[G(Oa,{items:O.value,selected:c.value,height:420,onSelect:I[1]||(I[1]=_=>c.value=_)},null,8,["items","selected"]),I[11]||(I[11]=a("p",{class:"small text-secondary mb-0"},"点击家人卡片定位,圆圈表示定位精度范围。底图由智家提供,位置仅对获授权的人显示。",-1))]),a("div",Og,[O.value.length?D("",!0):(y(),x("div",Ng,[...I[12]||(I[12]=[a("span",null,"⌖",-1),a("h3",{class:"fs-5"},"等待家人主动分享",-1),a("p",null,"家人无需注册账号。手机配对、本人同意并开启共享后,获准的查看人才能看到位置。",-1)])])),(y(!0),x(H,null,J(O.value,_=>{var fe;return y(),x("button",{key:_.id,class:De(["location-person w-100 text-start",{"location-selected":c.value===_.id}]),onClick:rt=>c.value=_.id},[a("strong",null,k(_.name),1),a("span",{class:De(_.status==="stale"?"text-warning-emphasis":"text-success")},k(E(_)),3),a("small",null,k(M(_)),1),a("small",null,"定位时间:"+k(B((fe=_.position)==null?void 0:fe.at)),1),_.signal==="permission_denied"||_.signal==="location_disabled"?(y(),x("small",Dg,"手机定位或权限未开启")):D("",!0)],10,Ig)}),128))])]),G(wg,{members:[...O.value,...(((Oe=e.value)==null?void 0:Oe.members)||[]).filter(_=>!O.value.some(fe=>fe.id===_.id))]},null,8,["members"]),a("details",$g,[I[25]||(I[25]=a("summary",null,"为家庭成员配对手机",-1)),I[26]||(I[26]=a("p",{class:"small text-secondary mt-2"},"老人和孩子无需登录。先选择真实成员及具体查看人,再将配对码输入本人的手机。本人核对授权内容、允许定位并打开共享后才上传;管理员生成配对码不能代替本人同意。家庭屏需单独勾选。",-1)),(ae=(le=e.value)==null?void 0:le.members)!=null&&ae.length?(y(),x("form",{key:1,onSubmit:I[9]||(I[9]=Ve(_=>T("pair"),["prevent"]))},[a("div",Lg,[a("label",Pg,[I[14]||(I[14]=C("绑定的家庭成员",-1)),Y(a("select",{"onUpdate:modelValue":I[2]||(I[2]=_=>d.value=_),required:"",class:"form-select",disabled:l.value},[I[13]||(I[13]=a("option",{value:""},"请选择成员",-1)),(y(!0),x(H,null,J(e.value.members,_=>(y(),x("option",{key:_.id,value:_.id,disabled:_.status==="historical"||_.lifeStatus==="deceased"},k(_.name)+" "+k(_.label?`· ${_.label}`:""),9,_g))),128))],8,Bg),[[Te,d.value]])]),a("label",zg,[I[16]||(I[16]=C("手机配对有效期",-1)),Y(a("select",{"onUpdate:modelValue":I[3]||(I[3]=_=>i.value=_),class:"form-select",disabled:l.value},[...I[15]||(I[15]=[a("option",{value:1},"1 天",-1),a("option",{value:7},"7 天",-1),a("option",{value:30},"30 天",-1)])],8,jg),[[Te,i.value,void 0,{number:!0}]])])]),a("label",Fg,[Y(a("input",{type:"checkbox","onUpdate:modelValue":I[4]||(I[4]=_=>h.value=_),disabled:l.value},null,8,Vg),[[st,h.value]]),I[17]||(I[17]=C("先仅配对手机查看家人,本人可稍后在手机设置自己的共享",-1))]),h.value?D("",!0):(y(),x("fieldset",Hg,[I[18]||(I[18]=a("legend",{class:"fs-6"},"允许哪些账号查看",-1)),(y(!0),x(H,null,J(e.value.viewers,_=>(y(),x("label",{key:_.id,class:"d-inline-flex gap-2 me-4 mb-2"},[Y(a("input",{type:"checkbox","onUpdate:modelValue":I[5]||(I[5]=fe=>u.value=fe),value:_.id,disabled:l.value},null,8,qg),[[st,u.value]]),C(k(_.name)+"("+k(_.username)+")",1)]))),128))])),h.value?D("",!0):(y(),x("fieldset",Ug,[I[19]||(I[19]=a("legend",{class:"fs-6"},"允许哪些家人手机查看",-1)),(y(!0),x(H,null,J(e.value.phones||[],_=>(y(),x("label",{key:_.id,class:"d-inline-flex gap-2 me-4 mb-2"},[Y(a("input",{type:"checkbox","onUpdate:modelValue":I[6]||(I[6]=fe=>f.value=fe),value:_.id,disabled:l.value},null,8,Wg),[[st,f.value]]),C(k(_.name)+"的手机",1)]))),128))])),h.value?D("",!0):(y(),x("fieldset",Kg,[I[20]||(I[20]=a("legend",{class:"fs-6"},"允许哪些公共显示终端展示(默认不选)",-1)),e.value.displays.length?D("",!0):(y(),x("p",Jg,"尚无已配对显示终端。")),(y(!0),x(H,null,J(e.value.displays,_=>(y(),x("label",{key:_.id,class:"d-inline-flex gap-2 me-4 mb-2"},[Y(a("input",{type:"checkbox","onUpdate:modelValue":I[7]||(I[7]=fe=>p.value=fe),value:_.id,disabled:l.value},null,8,Gg),[[st,p.value]]),C(k(_.name),1)]))),128))])),g.value?(y(),x("p",Yg,k(g.value.enabled?"手机已开启共享":"手机已绑定,共享关闭")+" · "+k(B(g.value.expires))+" 到期",1)):D("",!0),a("div",Xg,[a("button",{class:"btn btn-primary",disabled:l.value||!d.value||!h.value&&!u.value.length&&!p.value.length&&!f.value.length},"生成配对码",8,Zg),g.value||r.value?(y(),x("button",{key:0,type:"button",class:"btn btn-outline-danger",disabled:l.value,onClick:I[8]||(I[8]=_=>T("stop"))},"解除该手机授权",8,Qg)):D("",!0),I[21]||(I[21]=a("a",{class:"btn btn-outline-secondary",href:"/downloads",target:"_blank",rel:"noreferrer"},"下载配套 App",-1))]),r.value?(y(),x("div",eb,[I[22]||(I[22]=C("配对码 ",-1)),a("strong",tb,k(r.value),1),I[23]||(I[23]=C(" · 10 分钟内使用一次",-1)),I[24]||(I[24]=a("br",null,null,-1)),C("请在成员本人的手机核对姓名与查看名单,手机授权有效至 "+k(B(o.value))+"。重新配对会替换旧手机授权。",1)])):D("",!0)],32)):(y(),x("p",Rg,"请先在“家庭成员”登记本人或家人;普通账号需关联本人档案。")),I[27]||(I[27]=a("p",{class:"small text-secondary mt-3"},"手机可在“我的位置设置”选择实时(约 10 秒)、1 分钟或 5 分钟上传,默认 5 分钟。实时位置仅在内存中保存,关闭共享后清除;本人可另行开启历史保存,长期归档到百度网盘并手动删除。定位或网络中断超过 15 分钟隐藏旧坐标,提示更新中断,不表示人员失联。",-1))]),t.value?(y(),x("p",nb,k(t.value),1)):D("",!0)])):D("",!0)}}},ib=In(sb,[["__scopeId","data-v-e83725a4"]]);function Vt(n=0){const e=Math.max(0,Number(n)||0);return e>=1e9?(e/1e9).toFixed(2)+" GB":e>=1e6?(e/1e6).toFixed(1)+" MB":e>=1e3?(e/1e3).toFixed(1)+" KB":e+" B"}function rb(n,e={}){return n.id===e.id?{preparing:"准备上传",uploading:"正在上传",verifying:"云端校验",cleaning:"清理本机"}[e.stage]||"处理中":n.state==="cloud"?n.releasedAt?"已上传 · 本机已清理":"已存网盘":n.state==="expired"?"云端已到期清理":n.error?"等待重试":n.state==="verified"?"待清理本机":"排队中"}function ob(n,e){return new URLSearchParams({state:n.state,family:n.family,camera:n.camera,page:String(e)}).toString()}const lb={key:0,class:"panel upload-tasks mb-4","aria-label":"上传任务"},ab={class:"row g-3 mb-3"},cb={class:"col-6 col-xl-3"},db={class:"upload-metric"},ub={class:"col-6 col-xl-3"},pb={class:"upload-metric freed"},fb={class:"col-6 col-xl-3"},hb={class:"upload-metric"},mb={class:"col-6 col-xl-3"},gb={class:"upload-metric"},bb={key:0,class:"upload-current mb-3",role:"status"},vb={class:"d-flex justify-content-between gap-2"},yb={key:0},kb={class:"small my-2"},xb=["aria-label","aria-valuenow"],wb={key:1,class:"alert alert-warning"},Sb={class:"my-2"},Cb={class:"d-flex flex-wrap align-items-center gap-2"},Mb={class:"small"},Tb=["disabled"],Eb={key:2,class:"small",role:"status"},Ab={key:3,class:"alert alert-danger",role:"alert"},Ob={class:"upload-filters mb-3"},Nb=["value"],Ib=["value"],Db={key:4,class:"py-4 text-center text-secondary"},$b={key:5,class:"py-4 text-center text-secondary"},Rb={key:6,class:"upload-list list-unstyled mb-0"},Lb={class:"upload-task-heading"},Pb={class:"small mb-1"},Bb={key:0,class:"small text-danger mb-1"},_b={class:"small upload-details"},zb={key:0},jb={key:7,class:"d-flex flex-wrap justify-content-between gap-2 align-items-center mt-3"},Fb={class:"small text-secondary"},Vb={class:"d-flex gap-2"},Hb=["disabled"],qb=["disabled"],Ub={class:"border-top pt-3 mt-3"},Wb={class:"small mt-2"},Kb={class:"list-unstyled small"},Jb={class:"ms-2"},Gb={key:0,class:"text-danger mb-0"},Yb={key:0,class:"small text-secondary"},Xb={__name:"UploadTasks",setup(n){const e=P(null),t=P(null),s=P(""),i=P(!1),r=P(""),o=P(1),l=P({state:"pending",family:"",camera:""}),c=ee(()=>R.value.loggedIn&&R.value.platformAdmin&&R.value.page==="storage"),d=ee(()=>{var M;return((M=e.value)==null?void 0:M.totals)||{}}),u=ee(()=>R.value.state.storage||{}),p=ee(()=>{var M;return(((M=e.value)==null?void 0:M.cameras)||[]).filter(w=>!l.value.family||w.familyId===l.value.family)}),f=M=>M?new Date(M*1e3).toLocaleString("zh-CN",{hour12:!1,timeZone:"Asia/Shanghai"})+" 北京时间":"—",h=ee(()=>{var M,w;return(w=(M=e.value)==null?void 0:M.active)==null?void 0:w.stage}),g=ee(()=>({preparing:"核对本机片段并准备上传",uploading:"上传文件分片",verifying:"回读网盘文件,核对完整性",cleaning:"校验成功,正在删除本机片段"})[h.value]||"");let b,m=0;async function v(){const M=++m;if(clearTimeout(b),!(!c.value||document.hidden))try{const[w,T]=await Promise.all([K().api("/api/uploads/recordings?"+ob(l.value,o.value)),K().api("/api/backups")]);if(M!==m)return;e.value=w,o.value=w.page,t.value=T,s.value=""}catch(w){M===m&&(s.value=w.message)}finally{M===m&&c.value&&(b=setTimeout(v,5e3))}}function S(){o.value=1,r.value="",v()}function A(){l.value.camera="",S()}function O(M){o.value+=M,v()}async function B(){if(i.value)return;i.value=!0,r.value="";const M=m;try{if(await K().api("/api/uploads/recordings/retry",{}),M!==m)return;r.value="已安排重试最早的片段,后续片段仍按时间顺序上传。",v()}catch(w){M===m&&(r.value=w.message)}finally{i.value=!1}}function E(){document.hidden?(m++,clearTimeout(b)):c.value&&v()}return Ae([c,()=>R.value.session],()=>{m++,clearTimeout(b),e.value=null,t.value=null,s.value="",r.value="",i.value=!1,o.value=1,l.value={state:"pending",family:"",camera:""},c.value&&v()},{immediate:!0}),document.addEventListener("visibilitychange",E),Bt(()=>{m++,clearTimeout(b),document.removeEventListener("visibilitychange",E)}),(M,w)=>{var T,N,I,Z,Oe,le,ae,_,fe,rt,yt;return c.value?(y(),x("section",lb,[a("div",{class:"d-flex flex-wrap justify-content-between gap-3 align-items-start mb-3"},[w[5]||(w[5]=a("div",null,[a("span",{class:"eyebrow"},"百度网盘 · 自动归档"),a("h2",{class:"fs-4 mt-1"},"上传任务"),a("p",{class:"small text-secondary mb-0"},"录像按录制时间依次上传,云端校验成功后才清理本机。此页每 5 秒自动更新。")],-1)),a("button",{class:"btn btn-outline-secondary",onClick:v},"刷新任务")]),a("div",ab,[a("div",cb,[a("div",db,[w[6]||(w[6]=a("span",null,"待上传",-1)),a("strong",null,k(j(Vt)(d.value.pendingBytes)),1),a("small",null,k(d.value.pendingCount||0)+" 个片段保留在本机",1)])]),a("div",ub,[a("div",pb,[w[7]||(w[7]=a("span",null,"累计清理本机录像",-1)),a("strong",null,k(j(Vt)(d.value.releasedBytes)),1),a("small",null,"今日清理 "+k(j(Vt)(d.value.releasedTodayBytes)),1)])]),a("div",fb,[a("div",hb,[w[8]||(w[8]=a("span",null,"已归档至网盘",-1)),a("strong",null,k(j(Vt)(d.value.cloudBytes)),1),a("small",null,k(d.value.cloudCount||0)+" 个未到期片段",1)])]),a("div",mb,[a("div",gb,[w[9]||(w[9]=a("span",null,"服务器磁盘可用",-1)),a("strong",null,k((T=u.value.freeGB)!=null?T:"—")+" GB",1),a("small",null,"临时录像分区上限 "+k((N=u.value.temporaryMaxGB)!=null?N:"—")+" GB",1)])])]),w[33]||(w[33]=a("p",{class:"small text-secondary"},"清理量按已删除录像文件的大小累计;磁盘可用空间也会受系统和其他文件影响,两者并非同一个数值。",-1)),(Z=(I=e.value)==null?void 0:I.active)!=null&&Z.id?(y(),x("div",bb,[a("div",vb,[a("strong",null,k(g.value),1),e.value.active.percent!==null?(y(),x("span",yb,k(e.value.active.percent)+"%",1)):D("",!0)]),a("p",kb,k(((Oe=e.value.items.find(F=>F.id===e.value.active.id))==null?void 0:Oe.cameraName)||"正在处理队首片段")+" · "+k(h.value==="verifying"?"校验完成后才释放空间":"上传完成后还需云端校验"),1),e.value.active.percent!==null?(y(),x("div",{key:0,class:"progress",role:"progressbar","aria-label":g.value,"aria-valuenow":e.value.active.percent,"aria-valuemin":"0","aria-valuemax":"100"},[a("div",{class:"progress-bar",style:Nn({width:e.value.active.percent+"%"})},null,4)],8,xb)):D("",!0)])):(le=e.value)!=null&&le.status.error?(y(),x("div",wb,[w[11]||(w[11]=a("strong",null,"队首片段等待重试",-1)),a("p",Sb,k(e.value.status.error)+"。本机文件已保留。",1),a("div",Cb,[a("span",Mb,"预计重试:"+k(f(e.value.status.retryAt)),1),a("button",{class:"btn btn-sm btn-outline-secondary",disabled:i.value,onClick:B},"重试队首任务",8,Tb),w[10]||(w[10]=a("button",{class:"btn btn-sm btn-outline-secondary","data-page":"settings","data-settings-section":"baidu"},"检查网盘连接",-1))])])):D("",!0),r.value?(y(),x("p",Eb,k(r.value),1)):D("",!0),s.value?(y(),x("p",Ab,k(s.value)+" · 当前列表可能尚未更新。",1)):D("",!0),a("div",Ob,[a("label",null,[w[13]||(w[13]=C("任务状态",-1)),Y(a("select",{"onUpdate:modelValue":w[0]||(w[0]=F=>l.value.state=F),class:"form-select",onChange:S},[...w[12]||(w[12]=[ge('',5)])],544),[[Te,l.value.state]])]),a("label",null,[w[15]||(w[15]=C("家庭或场所",-1)),Y(a("select",{"onUpdate:modelValue":w[1]||(w[1]=F=>l.value.family=F),class:"form-select",onChange:A},[w[14]||(w[14]=a("option",{value:""},"全部家庭或场所",-1)),(y(!0),x(H,null,J(((ae=e.value)==null?void 0:ae.families)||[],F=>(y(),x("option",{key:F.id,value:F.id},k(F.name),9,Nb))),128))],544),[[Te,l.value.family]])]),a("label",null,[w[17]||(w[17]=C("摄像机",-1)),Y(a("select",{"onUpdate:modelValue":w[2]||(w[2]=F=>l.value.camera=F),class:"form-select",onChange:S},[w[16]||(w[16]=a("option",{value:""},"全部摄像机",-1)),(y(!0),x(H,null,J(p.value,F=>(y(),x("option",{key:F.id+":"+F.familyId,value:F.id},k(F.name),9,Ib))),128))],544),[[Te,l.value.camera]])])]),e.value?e.value.items.length?(y(),x("ol",Rb,[(y(!0),x(H,null,J(e.value.items,F=>{var jt;return y(),x("li",{key:F.id,class:"upload-task"},[a("div",Lb,[a("strong",null,k(F.cameraName),1),a("span",{class:De(["badge",F.error?"text-bg-warning":F.state==="cloud"?"text-bg-success":"text-bg-light"])},k(j(rb)(F,e.value.active)),3)]),a("p",Pb,k(F.familyName)+" · "+k(f(F.started))+" · "+k(Math.round(F.duration))+" 秒 · "+k(j(Vt)(F.size)),1),F.error&&F.id!==e.value.active.id?(y(),x("p",Bb,k(F.error)+" · 已尝试 "+k(F.attempts)+" 次",1)):D("",!0),a("details",null,[w[30]||(w[30]=a("summary",{class:"small"},"文件与任务详情",-1)),a("dl",_b,[a("div",null,[w[18]||(w[18]=a("dt",null,"文件名称",-1)),a("dd",null,k(F.name),1)]),a("div",null,[w[19]||(w[19]=a("dt",null,"录制开始",-1)),a("dd",null,k(f(F.started)),1)]),a("div",null,[w[20]||(w[20]=a("dt",null,"录制结束",-1)),a("dd",null,k(f(F.ended)),1)]),a("div",null,[w[21]||(w[21]=a("dt",null,"编码 / 保存方式",-1)),a("dd",null,k(((jt=F.metadata.codec)==null?void 0:jt.toUpperCase())||"原始码流")+" · 连续保留原始编码画面",1)]),a("div",null,[w[22]||(w[22]=a("dt",null,"时间属性",-1)),a("dd",null,k(F.metadata.start?"已写入 MP4 文件;服务器录制时钟":"历史文件:时间保存在系统索引中"),1)]),a("div",null,[w[23]||(w[23]=a("dt",null,"网盘文件大小",-1)),a("dd",null,k(j(Vt)(F.archiveSize)),1)]),a("div",null,[w[24]||(w[24]=a("dt",null,"摄像机编号",-1)),a("dd",null,k(F.cameraId),1)]),a("div",null,[w[25]||(w[25]=a("dt",null,"保存位置",-1)),a("dd",null,k(F.remotePath||"家庭 / 摄像头类型 / 摄像机 / 年 / 月 / 日"),1)]),a("div",null,[w[26]||(w[26]=a("dt",null,"云端校验时间",-1)),a("dd",null,k(f(F.verifiedAt)),1)]),a("div",null,[w[27]||(w[27]=a("dt",null,"本机清理时间",-1)),a("dd",null,k(f(F.releasedAt)),1)]),a("div",null,[w[28]||(w[28]=a("dt",null,"清理文件大小",-1)),a("dd",null,k(j(Vt)(F.releasedBytes)),1)]),F.retryAt&&F.error?(y(),x("div",zb,[w[29]||(w[29]=a("dt",null,"下一次重试",-1)),a("dd",null,k(f(F.retryAt)),1)])):D("",!0)])])])}),128))])):(y(),x("div",$b,"当前筛选下暂无任务。正在录制的片段完成后才会进入队列。")):(y(),x("div",Db,"正在读取上传队列…")),e.value?(y(),x("div",jb,[a("span",Fb,"共 "+k(e.value.total)+" 个任务 · 第 "+k(e.value.page)+" / "+k(e.value.pages)+" 页 · 更新于 "+k(f(e.value.updatedAt)),1),a("div",Vb,[a("button",{class:"btn btn-sm btn-outline-secondary",disabled:o.value<=1,onClick:w[3]||(w[3]=F=>O(-1))},"上一页",8,Hb),a("button",{class:"btn btn-sm btn-outline-secondary",disabled:o.value>=e.value.pages,onClick:w[4]||(w[4]=F=>O(1))},"下一页",8,qb)])])):D("",!0),a("details",Ub,[w[31]||(w[31]=a("summary",null,"数据库备份上传",-1)),a("p",Wb,k((_=t.value)!=null&&_.running?t.value.stage:"备份任务未在执行")+"。数据库副本使用独立保留策略,不计入上方录像清理量。",1),a("ul",Kb,[(y(!0),x(H,null,J((((fe=t.value)==null?void 0:fe.history)||[]).filter(F=>F.baiduRequested).slice(0,5),F=>(y(),x("li",{key:F.file||F.at,class:"py-2 border-bottom"},[a("strong",null,k(F.file||"数据库备份"),1),a("span",Jb,k(F.baiduOk?"已上传并校验":"上传未完成"),1),F.error?(y(),x("p",Gb,k(F.error),1)):D("",!0)]))),128))]),(yt=(rt=t.value)==null?void 0:rt.history)!=null&&yt.some(F=>F.baiduRequested)?D("",!0):(y(),x("p",Yb,"尚无网盘备份记录。")),w[32]||(w[32]=a("button",{class:"btn btn-sm btn-outline-secondary","data-page":"settings","data-settings-section":"backup"},"打开备份设置",-1))])])):D("",!0)}}},Zb=In(Xb,[["__scopeId","data-v-0c20c09f"]]);var Bo=Object.defineProperty,Qb=(n,e)=>{let t={};for(var s in n)Bo(t,s,{get:n[s],enumerable:!0});return Bo(t,Symbol.toStringTag,{value:"Module"}),t};function Se(n){this.content=n}Se.prototype={constructor:Se,find:function(n){for(var e=0;e>1}};Se.from=function(n){if(n instanceof Se)return n;var e=[];if(n)for(var t in n)e.push(t,n[t]);return new Se(e)};function La(n,e,t){for(let s=0;;s++){if(s==n.childCount||s==e.childCount)return n.childCount==e.childCount?null:t;let i=n.child(s),r=e.child(s);if(i==r){t+=i.nodeSize;continue}if(!i.sameMarkup(r))return t;if(i.isText&&i.text!=r.text){let o=i.text,l=r.text,c=0;for(;o[c]==l[c];c++)t++;return c&&c0&&f>0&&d[p-1]==u[f-1];)p--,f--,t--,s--;return p&&f&&p=56320&&n<57344}function _a(n){return n>=55296&&n<56320}class ${constructor(e,t){if(this.content=e,this.size=t||0,t==null)for(let s=0;se&&s(c,i+l,r||null,o)!==!1&&c.content.size){let u=l+1;c.nodesBetween(Math.max(0,e-u),Math.min(c.content.size,t-u),s,i+u)}l=d}}descendants(e){this.nodesBetween(0,this.size,e)}textBetween(e,t,s,i){let r="",o=!0;return this.nodesBetween(e,t,(l,c)=>{let d=l.isText?l.text.slice(Math.max(e,c)-c,t-c):l.isLeaf?i?typeof i=="function"?i(l):i:l.type.spec.leafText?l.type.spec.leafText(l):"":"";l.isBlock&&(l.isLeaf&&d||l.isTextblock)&&s&&(o?o=!1:r+=s),r+=d},0),r}append(e){if(!e.size)return this;if(!this.size)return e;let t=this.lastChild,s=e.firstChild,i=this.content.slice(),r=0;for(t.isText&&t.sameMarkup(s)&&(i[i.length-1]=t.withText(t.text+s.text),r=1);re)for(let r=0,o=0;oe&&((ot)&&(l.isText?l=l.cut(Math.max(0,e-o),Math.min(l.text.length,t-o)):l=l.cut(Math.max(0,e-o-1),Math.min(l.content.size,t-o-1))),s.push(l),i+=l.nodeSize),o=c}return new $(s,i)}cutByIndex(e,t){return e==t?$.empty:e==0&&t==this.content.length?this:new $(this.content.slice(e,t))}replaceChild(e,t){let s=this.content[e];if(s==t)return this;let i=this.content.slice(),r=this.size+t.nodeSize-s.nodeSize;return i[e]=t,new $(i,r)}addToStart(e){return new $([e].concat(this.content),this.size+e.nodeSize)}addToEnd(e){return new $(this.content.concat(e),this.size+e.nodeSize)}eq(e){if(this.content.length!=e.content.length)return!1;for(let t=0;tthis.size||e<0)throw new RangeError(`Position ${e} outside of fragment (${this})`);for(let t=0,s=0;;t++){let i=this.child(t),r=s+i.nodeSize;if(r>=e)return r==e?Ss(t+1,r):Ss(t,s);s=r}}toString(){return"<"+this.toStringInner()+">"}toStringInner(){return this.content.join(", ")}toJSON(){return this.content.length?this.content.map(e=>e.toJSON()):null}static fromJSON(e,t){if(!t)return $.empty;if(!Array.isArray(t))throw new RangeError("Invalid input for Fragment.fromJSON");return $.fromArray(t.map(e.nodeFromJSON))}static fromArray(e){if(!e.length)return $.empty;let t,s=0;for(let i=0;ithis.type.rank&&(t||(t=e.slice(0,i)),t.push(this),s=!0),t&&t.push(r)}}return t||(t=e.slice()),s||t.push(this),t}removeFromSet(e){for(let t=0;ts.type.rank-i.type.rank),t}};ie.none=[];class ss extends Error{}class z{constructor(e,t,s){this.content=e,this.openStart=t,this.openEnd=s}get size(){return this.content.size-this.openStart-this.openEnd}insertAt(e,t){let s=ja(this.content,e+this.openStart,t,this.openStart+1,this.openEnd+1);return s&&new z(s,this.openStart,this.openEnd)}removeBetween(e,t){return new z(za(this.content,e+this.openStart,t+this.openStart),this.openStart,this.openEnd)}eq(e){return this.content.eq(e.content)&&this.openStart==e.openStart&&this.openEnd==e.openEnd}toString(){return this.content+"("+this.openStart+","+this.openEnd+")"}toJSON(){if(!this.content.size)return null;let e={content:this.content.toJSON()};return this.openStart>0&&(e.openStart=this.openStart),this.openEnd>0&&(e.openEnd=this.openEnd),e}static fromJSON(e,t){if(!t)return z.empty;let s=t.openStart||0,i=t.openEnd||0;if(typeof s!="number"||typeof i!="number")throw new RangeError("Invalid input for Slice.fromJSON");return new z($.fromJSON(e,t.content),s,i)}static maxOpen(e,t=!0){let s=0,i=0;for(let r=e.firstChild;r&&!r.isLeaf&&(t||!r.type.spec.isolating);r=r.firstChild)s++;for(let r=e.lastChild;r&&!r.isLeaf&&(t||!r.type.spec.isolating);r=r.lastChild)i++;return new z(e,s,i)}}z.empty=new z($.empty,0,0);function za(n,e,t){let{index:s,offset:i}=n.findIndex(e),r=n.maybeChild(s),{index:o,offset:l}=n.findIndex(t);if(i==e||r.isText){if(l!=t&&!n.child(o).isText)throw new RangeError("Removing non-flat range");return n.cut(0,e).append(n.cut(t))}if(s!=o)throw new RangeError("Removing non-flat range");return n.replaceChild(s,r.copy(za(r.content,e-i-1,t-i-1)))}function ja(n,e,t,s,i,r){let{index:o,offset:l}=n.findIndex(e),c=n.maybeChild(o);if(l==e||c.isText)return r&&s<=0&&i<=0&&!r.canReplace(o,o,t)?null:n.cut(0,e).append(t).append(n.cut(e));let d=ja(c.content,e-l-1,t,o==0?s-1:0,o==n.childCount-1?i-1:0,c);return d&&n.replaceChild(o,c.copy(d))}function ev(n,e,t){if(t.openStart>n.depth)throw new ss("Inserted content deeper than insertion position");if(n.depth-t.openStart!=e.depth-t.openEnd)throw new ss("Inconsistent open depths");return Fa(n,e,t,0)}function Fa(n,e,t,s){let i=n.index(s),r=n.node(s);if(i==e.index(s)&&s=0&&n.isText&&n.sameMarkup(e[t])?e[t]=n.withText(e[t].text+n.text):e.push(n)}function Hn(n,e,t,s){let i=(e||n).node(t),r=0,o=e?e.index(t):i.childCount;n&&(r=n.index(t),n.depth>t?r++:n.textOffset&&(Yt(n.nodeAfter,s),r++));for(let l=r;li&&kr(n,e,i+1),o=s.depth>i&&kr(t,s,i+1),l=[];return Hn(null,n,i,l),r&&o&&e.index(i)==t.index(i)?(Va(r,o),Yt(Xt(r,Ha(n,e,t,s,i+1)),l)):(r&&Yt(Xt(r,Ws(n,e,i+1)),l),Hn(e,t,i,l),o&&Yt(Xt(o,Ws(t,s,i+1)),l)),Hn(s,null,i,l),new $(l)}function Ws(n,e,t){let s=[];if(Hn(null,n,t,s),n.depth>t){let i=kr(n,e,t+1);Yt(Xt(i,Ws(n,e,t+1)),s)}return Hn(e,null,t,s),new $(s)}function tv(n,e){let t=e.depth-n.openStart,i=e.node(t).copy(n.content);for(let r=t-1;r>=0;r--)i=e.node(r).copy($.from(i));return{start:i.resolveNoCache(n.openStart+t),end:i.resolveNoCache(i.content.size-n.openEnd-t)}}class is{constructor(e,t,s){this.pos=e,this.path=t,this.parentOffset=s,this.depth=t.length/3-1}resolveDepth(e){return e==null?this.depth:e<0?this.depth+e:e}get parent(){return this.node(this.depth)}get doc(){return this.node(0)}node(e){return this.path[this.resolveDepth(e)*3]}index(e){return this.path[this.resolveDepth(e)*3+1]}indexAfter(e){return e=this.resolveDepth(e),this.index(e)+(e==this.depth&&!this.textOffset?0:1)}start(e){return e=this.resolveDepth(e),e==0?0:this.path[e*3-1]+1}end(e){return e=this.resolveDepth(e),this.start(e)+this.node(e).content.size}before(e){if(e=this.resolveDepth(e),!e)throw new RangeError("There is no position before the top-level node");return e==this.depth+1?this.pos:this.path[e*3-1]}after(e){if(e=this.resolveDepth(e),!e)throw new RangeError("There is no position after the top-level node");return e==this.depth+1?this.pos:this.path[e*3-1]+this.path[e*3].nodeSize}get textOffset(){return this.pos-this.path[this.path.length-1]}get nodeAfter(){let e=this.parent,t=this.index(this.depth);if(t==e.childCount)return null;let s=this.pos-this.path[this.path.length-1],i=e.child(t);return s?e.child(t).cut(s):i}get nodeBefore(){let e=this.index(this.depth),t=this.pos-this.path[this.path.length-1];return t?this.parent.child(e).cut(0,t):e==0?null:this.parent.child(e-1)}posAtIndex(e,t){t=this.resolveDepth(t);let s=this.path[t*3],i=t==0?0:this.path[t*3-1]+1;for(let r=0;r0;t--)if(this.start(t)<=e&&this.end(t)>=e)return t;return 0}blockRange(e=this,t){if(e.pos=0;s--)if(e.pos<=this.end(s)&&(!t||t(this.node(s))))return new Ks(this,e,s);return null}sameParent(e){return this.pos-this.parentOffset==e.pos-e.parentOffset}max(e){return e.pos>this.pos?e:this}min(e){return e.pos=0&&t<=e.content.size))throw new RangeError("Position "+t+" out of range");let s=[],i=0,r=t;for(let o=e;;){let{index:l,offset:c}=o.content.findIndex(r),d=r-c;if(s.push(o,l,i+c),!d||(o=o.child(l),o.isText))break;r=d-1,i+=c+1}return new is(t,s,r)}static resolveCached(e,t){let s=_o.get(e);if(s)for(let r=0;re&&this.nodesBetween(e,t,r=>(s.isInSet(r.marks)&&(i=!0),!i)),i}get isBlock(){return this.type.isBlock}get isTextblock(){return this.type.isTextblock}get inlineContent(){return this.type.inlineContent}get isInline(){return this.type.isInline}get isText(){return this.type.isText}get isLeaf(){return this.type.isLeaf}get isAtom(){return this.type.isAtom}toString(){if(this.type.spec.toDebugString)return this.type.spec.toDebugString(this);let e=this.type.name;return this.content.size&&(e+="("+this.content.toStringInner()+")"),qa(this.marks,e)}contentMatchAt(e){let t=this.type.contentMatch.matchFragment(this.content,0,e);if(!t)throw new Error("Called contentMatchAt on a node with invalid content");return t}canReplace(e,t,s=$.empty,i=0,r=s.childCount){let o=this.contentMatchAt(e).matchFragment(s,i,r),l=o&&o.matchFragment(this.content,t);if(!l||!l.validEnd)return!1;for(let c=i;ct.type.name)}`);this.content.forEach(t=>t.check())}toJSON(){let e={type:this.type.name};for(let t in this.attrs){e.attrs=this.attrs;break}return this.content.size&&(e.content=this.content.toJSON()),this.marks.length&&(e.marks=this.marks.map(t=>t.toJSON())),e}static fromJSON(e,t){if(!t)throw new RangeError("Invalid input for Node.fromJSON");let s;if(t.marks){if(!Array.isArray(t.marks))throw new RangeError("Invalid mark data for Node.fromJSON");s=t.marks.map(e.markFromJSON)}if(t.type=="text"){if(typeof t.text!="string")throw new RangeError("Invalid text node in JSON");return e.text(t.text,s)}let i=$.fromJSON(e,t.content);return e.nodeType(t.type).create(t.attrs,i,s)}};Zt.prototype.text=void 0;class Js extends Zt{constructor(e,t,s,i){if(super(e,t,null,i),!s)throw new RangeError("Empty text nodes are not allowed");this.text=s}toString(){return this.type.spec.toDebugString?this.type.spec.toDebugString(this):qa(this.marks,JSON.stringify(this.text))}get textContent(){return this.text}textBetween(e,t){return this.text.slice(e,t)}get nodeSize(){return this.text.length}mark(e){return e==this.marks?this:new Js(this.type,this.attrs,this.text,e)}withText(e){return e==this.text?this:new Js(this.type,this.attrs,e,this.marks)}cut(e=0,t=this.text.length){return e==0&&t==this.text.length?this:this.withText(this.text.slice(e,t))}eq(e){return this.sameMarkup(e)&&this.text==e.text}toJSON(){let e=super.toJSON();return e.text=this.text,e}}function qa(n,e){for(let t=n.length-1;t>=0;t--)e=n[t].type.name+"("+e+")";return e}function zo(n,e,t,s){for(let i in e)if(!(i in n))throw new RangeError(`Unsupported attribute ${i} for ${t} of type ${s}`);for(let i in n)n[i].validate&&n[i].validate(e[i])}class tn{constructor(e){this.validEnd=e,this.next=[],this.wrapCache=[]}static parse(e,t){let s=new rv(e,t);if(s.next==null)return tn.empty;let i=Ua(s);s.next&&s.err("Unexpected trailing text");let r=pv(uv(i));return fv(r,s),r}matchType(e){for(let t=0;td.createAndFill()));for(let d=0;d=this.next.length)throw new RangeError(`There's no ${e}th edge in this content match`);return this.next[e]}toString(){let e=[];function t(s){e.push(s);for(let i=0;i{let r=i+(s.validEnd?"*":" ")+" ";for(let o=0;o"+e.indexOf(s.next[o].next);return r}).join(` -`)}}tn.empty=new tn(!0);class rv{constructor(e,t){this.string=e,this.nodeTypes=t,this.inline=null,this.pos=0,this.tokens=e.split(/\s*(?=\b|\W|$)/),this.tokens[this.tokens.length-1]==""&&this.tokens.pop(),this.tokens[0]==""&&this.tokens.shift()}get next(){return this.tokens[this.pos]}eat(e){return this.next==e&&(this.pos++||!0)}err(e){throw new SyntaxError(e+" (in content expression '"+this.string+"')")}}function Ua(n){let e=[];do e.push(ov(n));while(n.eat("|"));return e.length==1?e[0]:{type:"choice",exprs:e}}function ov(n){let e=[];do e.push(lv(n));while(n.next&&n.next!=")"&&n.next!="|");return e.length==1?e[0]:{type:"seq",exprs:e}}function lv(n){let e=dv(n);for(;;)if(n.eat("+"))e={type:"plus",expr:e};else if(n.eat("*"))e={type:"star",expr:e};else if(n.eat("?"))e={type:"opt",expr:e};else if(n.eat("{"))e=av(n,e);else break;return e}function jo(n){/\D/.test(n.next)&&n.err("Expected number, got '"+n.next+"'");let e=Number(n.next);return n.pos++,e}function av(n,e){let t=jo(n),s=t;return n.eat(",")&&(n.next!="}"?s=jo(n):s=-1),n.eat("}")||n.err("Unclosed braced range"),{type:"range",min:t,max:s,expr:e}}function cv(n,e){let t=n.nodeTypes,s=t[e];if(s)return[s];let i=[];for(let r in t){let o=t[r];o.isInGroup(e)&&i.push(o)}return i.length==0&&n.err("No node type or group '"+e+"' found"),i}function dv(n){if(n.eat("(")){let e=Ua(n);return n.eat(")")||n.err("Missing closing paren"),e}else if(/\W/.test(n.next))n.err("Unexpected token '"+n.next+"'");else{let e=cv(n,n.next).map(t=>(n.inline==null?n.inline=t.isInline:n.inline!=t.isInline&&n.err("Mixing inline and block content"),{type:"name",value:t}));return n.pos++,e.length==1?e[0]:{type:"choice",exprs:e}}}function uv(n){let e=[[]];return i(r(n,0),t()),e;function t(){return e.push([])-1}function s(o,l,c){let d={term:c,to:l};return e[o].push(d),d}function i(o,l){o.forEach(c=>c.to=l)}function r(o,l){if(o.type=="choice")return o.exprs.reduce((c,d)=>c.concat(r(d,l)),[]);if(o.type=="seq")for(let c=0;;c++){let d=r(o.exprs[c],l);if(c==o.exprs.length-1)return d;i(d,l=t())}else if(o.type=="star"){let c=t();return s(l,c),i(r(o.expr,c),c),[s(c)]}else if(o.type=="plus"){let c=t();return i(r(o.expr,l),c),i(r(o.expr,c),c),[s(c)]}else{if(o.type=="opt")return[s(l)].concat(r(o.expr,l));if(o.type=="range"){let c=l;for(let d=0;d{n[o].forEach(({term:l,to:c})=>{if(!l)return;let d;for(let u=0;u{d||i.push([l,d=[]]),d.indexOf(u)==-1&&d.push(u)})})});let r=e[s.join(",")]=new tn(s.indexOf(n.length-1)>-1);for(let o=0;o-1}get whitespace(){return this.spec.whitespace||(this.spec.code?"pre":"normal")}hasRequiredAttrs(){for(let e in this.attrs)if(this.attrs[e].isRequired)return!0;return!1}compatibleContent(e){return this==e||this.contentMatch.compatible(e.contentMatch)}computeAttrs(e){return!e&&this.defaultAttrs?this.defaultAttrs:Ja(this.attrs,e)}create(e=null,t,s){if(this.isText)throw new Error("NodeType.create can't construct text nodes");return new Zt(this,this.computeAttrs(e),$.from(t),ie.setFrom(s))}createChecked(e=null,t,s){return t=$.from(t),this.checkContent(t),new Zt(this,this.computeAttrs(e),t,ie.setFrom(s))}createAndFill(e=null,t,s){if(e=this.computeAttrs(e),t=$.from(t),t.size){let o=this.contentMatch.fillBefore(t);if(!o)return null;t=o.append(t)}let i=this.contentMatch.matchFragment(t),r=i&&i.fillBefore($.empty,!0);return r?new Zt(this,e,t.append(r),ie.setFrom(s)):null}validContent(e){let t=this.contentMatch.matchFragment(e);if(!t||!t.validEnd)return!1;for(let s=0;s-1}allowsMarks(e){if(this.markSet==null)return!0;for(let t=0;ts[r]=new Ya(r,t,o));let i=t.spec.topNode||"doc";if(!s[i])throw new RangeError("Schema is missing its top node type ('"+i+"')");if(!s.text)throw new RangeError("Every schema needs a 'text' type");for(let r in s.text.attrs)throw new RangeError("The text node type should not have attributes");return s}};function hv(n,e,t){let s=t.split("|");return i=>{let r=i===null?"null":typeof i;if(s.indexOf(r)<0)throw new RangeError(`Expected value of type ${s} for attribute ${e} on type ${n}, got ${r}`)}}class mv{constructor(e,t,s){this.hasDefault=Object.prototype.hasOwnProperty.call(s,"default"),this.default=s.default,this.validate=typeof s.validate=="string"?hv(e,t,s.validate):s.validate}get isRequired(){return!this.hasDefault}}class Ri{constructor(e,t,s,i){this.name=e,this.rank=t,this.schema=s,this.spec=i,this.attrs=Ga(e,i.attrs),this.excluded=null;let r=Ka(this.attrs);this.instance=r?new ie(this,r):null}create(e=null){return!e&&this.instance?this.instance:new ie(this,Ja(this.attrs,e))}static compile(e,t){let s=Object.create(null),i=0;return e.forEach((r,o)=>s[r]=new Ri(r,i++,t,o)),s}removeFromSet(e){for(var t=0;t-1}}class _s{constructor(e){this.linebreakReplacement=null,this.cached=Object.create(null);let t=this.spec={};for(let i in e)t[i]=e[i];t.nodes=Se.from(e.nodes),t.marks=Se.from(e.marks||{}),this.nodes=Vo.compile(this.spec.nodes,this),this.marks=Ri.compile(this.spec.marks,this);let s=Object.create(null);for(let i in this.nodes){if(i in this.marks)throw new RangeError(i+" can not be both a node and a mark");let r=this.nodes[i],o=r.spec.content||"",l=r.spec.marks;if(r.contentMatch=s[o]||(s[o]=tn.parse(o,this.nodes)),r.inlineContent=r.contentMatch.inlineContent,r.spec.linebreakReplacement){if(this.linebreakReplacement)throw new RangeError("Multiple linebreak nodes defined");if(!r.isInline||!r.isLeaf)throw new RangeError("Linebreak replacement nodes must be inline leaf nodes");this.linebreakReplacement=r}r.markSet=l=="_"?null:l?Ho(this,l.split(" ")):l==""||!r.inlineContent?[]:null}for(let i in this.marks){let r=this.marks[i],o=r.spec.excludes;r.excluded=o==null?[r]:o==""?[]:Ho(this,o.split(" "))}this.nodeFromJSON=i=>Zt.fromJSON(this,i),this.markFromJSON=i=>ie.fromJSON(this,i),this.topNodeType=this.nodes[this.spec.topNode||"doc"],this.cached.wrappings=Object.create(null)}node(e,t=null,s,i){if(typeof e=="string")e=this.nodeType(e);else if(e instanceof Vo){if(e.schema!=this)throw new RangeError("Node type from different schema used ("+e.name+")")}else throw new RangeError("Invalid node type: "+e);return e.createChecked(t,s,i)}text(e,t){let s=this.nodes.text;return new Js(s,s.defaultAttrs,e,ie.setFrom(t))}mark(e,t){return typeof e=="string"&&(e=this.marks[e]),e.create(t)}nodeType(e){let t=this.nodes[e];if(!t)throw new RangeError("Unknown node type: "+e);return t}}function Ho(n,e){let t=[];for(let s=0;s-1)&&t.push(o=c)}if(!o)throw new SyntaxError("Unknown mark type: '"+e[s]+"'")}return t}function gv(n){return n.tag!=null}function bv(n){return n.style!=null}class Ot{constructor(e,t){this.schema=e,this.rules=t,this.tags=[],this.styles=[];let s=this.matchedStyles=[];t.forEach(i=>{if(gv(i))this.tags.push(i);else if(bv(i)){let r=/[^=]*/.exec(i.style)[0];s.indexOf(r)<0&&s.push(r),this.styles.push(i)}}),this.normalizeLists=!this.tags.some(i=>{if(!/^(ul|ol)\b/.test(i.tag)||!i.node)return!1;let r=e.nodes[i.node];return r.contentMatch.matchType(r)})}parse(e,t={}){let s=new Uo(this,t,!1);return s.addAll(e,ie.none,t.from,t.to),s.finish()}parseSlice(e,t={}){let s=new Uo(this,t,!0);return s.addAll(e,ie.none,t.from,t.to),z.maxOpen(s.finish())}matchTag(e,t,s){for(let i=s?this.tags.indexOf(s)+1:0;ie.length&&(l.charCodeAt(e.length)!=61||l.slice(e.length+1)!=t))){if(o.getAttrs){let c=o.getAttrs(t);if(c===!1)continue;o.attrs=c||void 0}return o}}}static schemaRules(e){let t=[];function s(i){let r=i.priority==null?50:i.priority,o=0;for(;o{s(o=Wo(o)),o.mark||o.ignore||o.clearMark||(o.mark=i)})}for(let i in e.nodes){let r=e.nodes[i].spec.parseDOM;r&&r.forEach(o=>{s(o=Wo(o)),o.node||o.ignore||o.mark||(o.node=i)})}return t}static fromSchema(e){return e.cached.domParser||(e.cached.domParser=new Ot(e,Ot.schemaRules(e)))}}const Xa={address:!0,article:!0,aside:!0,blockquote:!0,body:!0,canvas:!0,dd:!0,div:!0,dl:!0,fieldset:!0,figcaption:!0,figure:!0,footer:!0,form:!0,h1:!0,h2:!0,h3:!0,h4:!0,h5:!0,h6:!0,header:!0,hgroup:!0,hr:!0,li:!0,noscript:!0,ol:!0,output:!0,p:!0,pre:!0,section:!0,table:!0,tfoot:!0,ul:!0},vv={head:!0,noscript:!0,object:!0,script:!0,style:!0,title:!0},Za={ol:!0,ul:!0},rs=1,wr=2,qn=4;function qo(n,e,t){return e!=null?(e?rs:0)|(e==="full"?wr:0):n&&n.whitespace=="pre"?rs|wr:t&~qn}class Cs{constructor(e,t,s,i,r,o){this.type=e,this.attrs=t,this.marks=s,this.solid=i,this.options=o,this.content=[],this.activeMarks=ie.none,this.match=r||(o&qn?null:e.contentMatch)}findWrapping(e){if(!this.match){if(!this.type)return[];let t=this.type.contentMatch.fillBefore($.from(e));if(t)this.match=this.type.contentMatch.matchFragment(t);else{let s=this.type.contentMatch,i;return(i=s.findWrapping(e.type))?(this.match=s,i):null}}return this.match.findWrapping(e.type)}finish(e){if(!(this.options&rs)){let s=this.content[this.content.length-1],i;if(s&&s.isText&&(i=/[ \t\r\n\u000c]+$/.exec(s.text))){let r=s;s.text.length==i[0].length?this.content.pop():this.content[this.content.length-1]=r.withText(r.text.slice(0,r.text.length-i[0].length))}}let t=$.from(this.content);return!e&&this.match&&(t=t.append(this.match.fillBefore($.empty,!0))),this.type?this.type.create(this.attrs,t,this.marks):t}inlineContext(e){return this.type?this.type.inlineContent:this.content.length?this.content[0].isInline:e.parentNode&&!Xa.hasOwnProperty(e.parentNode.nodeName.toLowerCase())}}class Uo{constructor(e,t,s){this.parser=e,this.options=t,this.isOpen=s,this.open=0,this.localPreserveWS=!1;let i=t.topNode,r,o=qo(null,t.preserveWhitespace,0)|(s?qn:0);i?r=new Cs(i.type,i.attrs,ie.none,!0,t.topMatch||i.type.contentMatch,o):s?r=new Cs(null,null,ie.none,!0,null,o):r=new Cs(e.schema.topNodeType,null,ie.none,!0,null,o),this.nodes=[r],this.find=t.findPositions,this.needsBlock=!1}get top(){return this.nodes[this.open]}addDOM(e,t){e.nodeType==3?this.addTextNode(e,t):e.nodeType==1&&this.addElement(e,t)}addTextNode(e,t){let s=e.nodeValue,i=this.top,r=i.options&wr?"full":this.localPreserveWS||(i.options&rs)>0,{schema:o}=this.parser;if(r==="full"||i.inlineContext(e)||/[^ \t\r\n\u000c]/.test(s)){if(r)if(r==="full")s=s.replace(/\r\n?/g,` -`);else if(o.linebreakReplacement&&/[\r\n]/.test(s)&&this.top.findWrapping(o.linebreakReplacement.create())){let l=s.split(/\r?\n|\r/);for(let c=0;c!c.clearMark(d)):t=t.concat(this.parser.schema.marks[c.mark].create(c.attrs)),c.consuming===!1)l=c;else break}}return t}addElementByRule(e,t,s,i){let r,o;if(t.node)if(o=this.parser.schema.nodes[t.node],o.isLeaf)this.insertNode(o.create(t.attrs),s,e.nodeName=="BR")||this.leafFallback(e,s);else{let c=this.enter(o,t.attrs||null,s,t.preserveWhitespace);c&&(r=!0,s=c)}else{let c=this.parser.schema.marks[t.mark];s=s.concat(c.create(t.attrs))}let l=this.top;if(o&&o.isLeaf)this.findInside(e);else if(i)this.addElement(e,s,i);else if(t.getContent)this.findInside(e),t.getContent(e,this.parser.schema).forEach(c=>this.insertNode(c,s,!1));else{let c=e;typeof t.contentElement=="string"?c=e.querySelector(t.contentElement):typeof t.contentElement=="function"?c=t.contentElement(e):t.contentElement&&(c=t.contentElement),this.findAround(e,c,!0),this.addAll(c,s),this.findAround(e,c,!1)}r&&this.sync(l)&&this.open--}addAll(e,t,s,i){let r=s||0;for(let o=s?e.childNodes[s]:e.firstChild,l=i==null?null:e.childNodes[i];o!=l;o=o.nextSibling,++r)this.findAtPoint(e,r),this.addDOM(o,t);this.findAtPoint(e,r)}findPlace(e,t,s){let i,r;for(let o=this.open,l=0;o>=0;o--){let c=this.nodes[o],d=c.findWrapping(e);if(d&&(!i||i.length>d.length+l)&&(i=d,r=c,!d.length))break;if(c.solid){if(s)break;l+=2}}if(!i)return null;this.sync(r);for(let o=0;o(o.type?o.type.allowsMarkType(d.type):Ko(d.type,e))?(c=d.addToSet(c),!1):!0),this.nodes.push(new Cs(e,t,c,i,null,l)),this.open++,s}closeExtra(e=!1){let t=this.nodes.length-1;if(t>this.open){for(;t>this.open;t--)this.nodes[t-1].content.push(this.nodes[t].finish(e));this.nodes.length=this.open+1}}finish(){return this.open=0,this.closeExtra(this.isOpen),this.nodes[0].finish(!!(this.isOpen||this.options.topOpen))}sync(e){for(let t=this.open;t>=0;t--){if(this.nodes[t]==e)return this.open=t,!0;this.localPreserveWS&&(this.nodes[t].options|=rs)}return!1}get currentPos(){this.closeExtra();let e=0;for(let t=this.open;t>=0;t--){let s=this.nodes[t].content;for(let i=s.length-1;i>=0;i--)e+=s[i].nodeSize;t&&e++}return e}findAtPoint(e,t){if(this.find)for(let s=0;s-1)return e.split(/\s*\|\s*/).some(this.matchesContext,this);let t=e.split("/"),s=this.options.context,i=!this.isOpen&&(!s||s.parent.type==this.nodes[0].type),r=-(s?s.depth+1:0)+(i?0:1),o=(l,c)=>{for(;l>=0;l--){let d=t[l];if(d==""){if(l==t.length-1||l==0)continue;for(;c>=r;c--)if(o(l-1,c))return!0;return!1}else{let u=c>0||c==0&&i?this.nodes[c].type:s&&c>=r?s.node(c-r).type:null;if(!u||u.name!=d&&!u.isInGroup(d))return!1;c--}}return!0};return o(t.length-1,this.open)}textblockFromContext(){let e=this.options.context;if(e)for(let t=e.depth;t>=0;t--){let s=e.node(t).contentMatchAt(e.indexAfter(t)).defaultType;if(s&&s.isTextblock&&s.defaultAttrs)return s}for(let t in this.parser.schema.nodes){let s=this.parser.schema.nodes[t];if(s.isTextblock&&s.defaultAttrs)return s}}}function yv(n){for(let e=n.firstChild,t=null;e;e=e.nextSibling){let s=e.nodeType==1?e.nodeName.toLowerCase():null;s&&Za.hasOwnProperty(s)&&t?(t.appendChild(e),e=t):s=="li"?t=e:s&&(t=null)}}function kv(n,e){return(n.matches||n.msMatchesSelector||n.webkitMatchesSelector||n.mozMatchesSelector).call(n,e)}function Wo(n){let e={};for(let t in n)e[t]=n[t];return e}function Ko(n,e){let t=e.schema.nodes;for(let s in t){let i=t[s];if(!i.allowsMarkType(n))continue;let r=[],o=l=>{r.push(l);for(let c=0;c{if(r.length||o.marks.length){let l=0,c=0;for(;l=0;i--){let r=this.serializeMark(e.marks[i],e.isInline,t);r&&((r.contentDOM||r.dom).appendChild(s),s=r.dom)}return s}serializeMark(e,t,s={}){let i=this.marks[e.type.name];return i&&zs(Ms(s),i(e,t),null,e.attrs)}static renderSpec(e,t,s=null,i){return typeof t=="string"?{dom:e.createTextNode(t)}:zs(e,t,s,i)}static fromSchema(e){return e.cached.domSerializer||(e.cached.domSerializer=new ln(this.nodesFromSchema(e),this.marksFromSchema(e)))}static nodesFromSchema(e){let t=Jo(e.nodes);return t.text||(t.text=s=>s.text),t}static marksFromSchema(e){return Jo(e.marks)}}function Jo(n){let e={};for(let t in n){let s=n[t].spec.toDOM;s&&(e[t]=s)}return e}function Ms(n){return n.document||window.document}const Go=new WeakMap;function xv(n){let e=Go.get(n);return e===void 0&&Go.set(n,e=wv(n)),e}function wv(n){let e=null;function t(s){if(s&&typeof s=="object")if(Array.isArray(s))if(typeof s[0]=="string")e||(e=[]),e.push(s);else for(let i=0;i-1)throw new RangeError("Using an array from an attribute object as a DOM spec. This may be an attempted cross site scripting attack.");let o=i.indexOf(" ");o>0&&(t=i.slice(0,o),i=i.slice(o+1));let l,c=t?n.createElementNS(t,i):n.createElement(i),d=e[1],u=1;if(d&&typeof d=="object"&&d.nodeType==null&&!Array.isArray(d)){u=2;for(let p in d)if(d[p]!=null){let f=p.indexOf(" ");f>0?c.setAttributeNS(p.slice(0,f),p.slice(f+1),d[p]):p=="style"&&c.style?c.style.cssText=d[p]:c.setAttribute(p,d[p])}}for(let p=u;pu)throw new RangeError("Content hole must be the only child of its parent node");return{dom:c,contentDOM:c}}else if(typeof f=="string")c.appendChild(n.createTextNode(f));else{let{dom:h,contentDOM:g}=zs(n,f,t,s);if(c.appendChild(h),g){if(l)throw new RangeError("Multiple content holes");l=g}}}return{dom:c,contentDOM:l}}const Qa=65535,ec=Math.pow(2,16);function Sv(n,e){return n+e*ec}function Yo(n){return n&Qa}function Cv(n){return(n-(n&Qa))/ec}const tc=1,nc=2,js=4,sc=8;class Sr{constructor(e,t,s){this.pos=e,this.delInfo=t,this.recover=s}get deleted(){return(this.delInfo&sc)>0}get deletedBefore(){return(this.delInfo&(tc|js))>0}get deletedAfter(){return(this.delInfo&(nc|js))>0}get deletedAcross(){return(this.delInfo&js)>0}}class He{constructor(e,t=!1){if(this.ranges=e,this.inverted=t,!e.length&&He.empty)return He.empty}recover(e){let t=0,s=Yo(e);if(!this.inverted)for(let i=0;ie)break;let d=this.ranges[l+r],u=this.ranges[l+o],p=c+d;if(e<=p){let f=d?e==c?-1:e==p?1:t:t,h=c+i+(f<0?0:u);if(s)return h;let g=e==(t<0?c:p)?null:Sv(l/3,e-c),b=0;return d&&(b|=e==c?nc:e==p?tc:js,(t<0?e!=c:e!=p)&&(b|=sc)),new Sr(h,b,g)}i+=u-d}return s?e+i:new Sr(e+i,0,null)}touches(e,t){let s=0,i=Yo(t),r=this.inverted?2:1,o=this.inverted?1:2;for(let l=0;le)break;let d=this.ranges[l+r],u=c+d;if(e<=u&&l==i*3)return!0;s+=this.ranges[l+o]-d}return!1}forEach(e){let t=this.inverted?2:1,s=this.inverted?1:2;for(let i=0,r=0;i=0;t--){let i=e.getMirror(t);this.appendMap(e._maps[t].invert(),i!=null&&i>t?s-i-1:void 0)}}invert(){let e=new ls;return e.appendMappingInverted(this),e}map(e,t=1){if(this.mirror)return this._map(e,t,!0);for(let s=this.from;sr&&c!o.isAtom||!l.type.allowsMarkType(this.mark.type)?o:o.mark(this.mark.addToSet(o.marks)),i),t.openStart,t.openEnd);return he.fromReplace(e,this.from,this.to,r)}invert(){return new Xe(this.from,this.to,this.mark)}map(e){let t=e.mapResult(this.from,1),s=e.mapResult(this.to,-1);return t.deleted&&s.deleted||t.pos>=s.pos?null:new Tt(t.pos,s.pos,this.mark)}merge(e){return e instanceof Tt&&e.mark.eq(this.mark)&&this.from<=e.to&&this.to>=e.from?new Tt(Math.min(this.from,e.from),Math.max(this.to,e.to),this.mark):null}toJSON(){return{stepType:"addMark",mark:this.mark.toJSON(),from:this.from,to:this.to}}static fromJSON(e,t){if(typeof t.from!="number"||typeof t.to!="number")throw new RangeError("Invalid input for AddMarkStep.fromJSON");return new Tt(t.from,t.to,e.markFromJSON(t.mark))}}Re.jsonID("addMark",Tt);class Xe extends Re{constructor(e,t,s){super(),this.from=e,this.to=t,this.mark=s}apply(e){let t=e.slice(this.from,this.to),s=new z(eo(t.content,i=>i.mark(this.mark.removeFromSet(i.marks)),e),t.openStart,t.openEnd);return he.fromReplace(e,this.from,this.to,s)}invert(){return new Tt(this.from,this.to,this.mark)}map(e){let t=e.mapResult(this.from,1),s=e.mapResult(this.to,-1);return t.deleted&&s.deleted||t.pos>=s.pos?null:new Xe(t.pos,s.pos,this.mark)}merge(e){return e instanceof Xe&&e.mark.eq(this.mark)&&this.from<=e.to&&this.to>=e.from?new Xe(Math.min(this.from,e.from),Math.max(this.to,e.to),this.mark):null}toJSON(){return{stepType:"removeMark",mark:this.mark.toJSON(),from:this.from,to:this.to}}static fromJSON(e,t){if(typeof t.from!="number"||typeof t.to!="number")throw new RangeError("Invalid input for RemoveMarkStep.fromJSON");return new Xe(t.from,t.to,e.markFromJSON(t.mark))}}Re.jsonID("removeMark",Xe);class Et extends Re{constructor(e,t){super(),this.pos=e,this.mark=t}apply(e){let t=e.nodeAt(this.pos);if(!t)return he.fail("No node at mark step's position");let s=t.type.create(t.attrs,null,this.mark.addToSet(t.marks));return he.fromReplace(e,this.pos,this.pos+1,new z($.from(s),0,t.isLeaf?0:1))}invert(e){let t=e.nodeAt(this.pos);if(t){let s=this.mark.addToSet(t.marks);if(s.length==t.marks.length){for(let i=0;is.pos?null:new xe(t.pos,s.pos,i,r,this.slice,this.insert,this.structure)}toJSON(){let e={stepType:"replaceAround",from:this.from,to:this.to,gapFrom:this.gapFrom,gapTo:this.gapTo,insert:this.insert};return this.slice.size&&(e.slice=this.slice.toJSON()),this.structure&&(e.structure=!0),e}static fromJSON(e,t){if(typeof t.from!="number"||typeof t.to!="number"||typeof t.gapFrom!="number"||typeof t.gapTo!="number"||typeof t.insert!="number")throw new RangeError("Invalid input for ReplaceAroundStep.fromJSON");return new xe(t.from,t.to,t.gapFrom,t.gapTo,z.fromJSON(e,t.slice),t.insert,!!t.structure)}}Re.jsonID("replaceAround",xe);function Cr(n,e,t){let s=n.resolve(e),i=t-e,r=s.depth;for(;i>0&&r>0&&s.indexAfter(r)==s.node(r).childCount;)r--,i--;if(i>0){let o=s.node(r).maybeChild(s.indexAfter(r));for(;i>0;){if(!o||o.isLeaf)return!0;o=o.firstChild,i--}}return!1}function Mv(n,e,t,s){let i=[],r=[],o,l;n.doc.nodesBetween(e,t,(c,d,u)=>{if(!c.isInline)return;let p=c.marks;if(!s.isInSet(p)&&u.type.allowsMarkType(s.type)){let f=Math.max(d,e),h=Math.min(d+c.nodeSize,t),g=s.addToSet(p);for(let b=0;bn.step(c)),r.forEach(c=>n.step(c))}function Tv(n,e,t,s){let i=[],r=0;n.doc.nodesBetween(e,t,(o,l)=>{if(!o.isInline)return;r++;let c=null;if(s instanceof Ri){let d=o.marks,u;for(;u=s.isInSet(d);)(c||(c=[])).push(u),d=u.removeFromSet(d)}else s?s.isInSet(o.marks)&&(c=[s]):c=o.marks;if(c&&c.length){let d=Math.min(l+o.nodeSize,t);for(let u=0;un.step(new Xe(o.from,o.to,o.style)))}function to(n,e,t,s=t.contentMatch,i=!0){let r=n.doc.nodeAt(e),o=[],l=e+1;for(let c=0;c=0;c--)n.step(o[c])}function Ev(n,e,t){return(e==0||n.canReplace(e,n.childCount))&&(t==n.childCount||n.canReplace(0,t))}function Dn(n){let t=n.parent.content.cutByIndex(n.startIndex,n.endIndex);for(let s=n.depth,i=0,r=0;;--s){let o=n.$from.node(s),l=n.$from.index(s)+i,c=n.$to.indexAfter(s)-r;if(st;g--)b||s.index(g)>0?(b=!0,u=$.from(s.node(g).copy(u)),p++):c--;let f=$.empty,h=0;for(let g=r,b=!1;g>t;g--)b||i.after(g+1)=0;o--){if(s.size){let l=t[o].type.contentMatch.matchFragment(s);if(!l||!l.validEnd)throw new RangeError("Wrapper type given to Transform.wrap does not form valid content of its parent wrapper")}s=$.from(t[o].type.create(t[o].attrs,s))}let i=e.start,r=e.end;n.step(new xe(i,r,i,r,new z(s,0,0),t.length,!0))}function Dv(n,e,t,s,i){if(!s.isTextblock)throw new RangeError("Type given to setBlockType should be a textblock");let r=n.steps.length;n.doc.nodesBetween(e,t,(o,l)=>{let c=typeof i=="function"?i(o):i;if(o.isTextblock&&!o.hasMarkup(s,c)&&$v(n.doc,n.mapping.slice(r).map(l),s)){let d=null;if(s.schema.linebreakReplacement){let h=s.whitespace=="pre",g=!!s.contentMatch.matchType(s.schema.linebreakReplacement);h&&!g?d=!1:!h&&g&&(d=!0)}d===!1&&rc(n,o,l,r),to(n,n.mapping.slice(r).map(l,1),s,void 0,d===null);let u=n.mapping.slice(r),p=u.map(l,1),f=u.map(l+o.nodeSize,1);return n.step(new xe(p,f,p+1,f-1,new z($.from(s.create(c,null,o.marks)),0,0),1,!0)),d===!0&&ic(n,o,l,r),!1}})}function ic(n,e,t,s){e.forEach((i,r)=>{if(i.isText){let o,l=/\r?\n|\r/g;for(;o=l.exec(i.text);){let c=n.mapping.slice(s).map(t+1+r+o.index);n.replaceWith(c,c+1,e.type.schema.linebreakReplacement.create())}}})}function rc(n,e,t,s){e.forEach((i,r)=>{if(i.type==i.type.schema.linebreakReplacement){let o=n.mapping.slice(s).map(t+1+r);n.replaceWith(o,o+1,e.type.schema.text(` -`))}})}function $v(n,e,t){let s=n.resolve(e),i=s.index();return s.parent.canReplaceWith(i,i+1,t)}function Rv(n,e,t,s,i){let r=n.doc.nodeAt(e);if(!r)throw new RangeError("No node at given position");t||(t=r.type);let o=t.create(s,null,i||r.marks);if(r.isLeaf)return n.replaceWith(e,e+r.nodeSize,o);if(!t.validContent(r.content))throw new RangeError("Invalid content for node type "+t.name);n.step(new xe(e,e+r.nodeSize,e+1,e+r.nodeSize-1,new z($.from(o),0,0),1,!0))}function mt(n,e,t=1,s){let i=n.resolve(e),r=i.depth-t,o=s&&s[s.length-1]||i.parent;if(r<0||i.parent.type.spec.isolating||!i.parent.canReplace(i.index(),i.parent.childCount)||!o.type.validContent(i.parent.content.cutByIndex(i.index(),i.parent.childCount)))return!1;for(let d=i.depth-1,u=t-2;d>r;d--,u--){let p=i.node(d),f=i.index(d);if(p.type.spec.isolating)return!1;let h=p.content.cutByIndex(f,p.childCount),g=s&&s[u+1];g&&(h=h.replaceChild(0,g.type.create(g.attrs)));let b=s&&s[u]||p;if(!p.canReplace(f+1,p.childCount)||!b.type.validContent(h))return!1}let l=i.indexAfter(r),c=s&&s[0];return i.node(r).canReplaceWith(l,l,c?c.type:i.node(r+1).type)}function Lv(n,e,t=1,s){let i=n.doc.resolve(e),r=$.empty,o=$.empty;for(let l=i.depth,c=i.depth-t,d=t-1;l>c;l--,d--){r=$.from(i.node(l).copy(r));let u=s&&s[d];o=$.from(u?u.type.create(u.attrs,o):i.node(l).copy(o))}n.step(new de(e,e,new z(r.append(o),t,t),!0))}function _t(n,e){let t=n.resolve(e),s=t.index();return oc(t.nodeBefore,t.nodeAfter)&&t.parent.canReplace(s,s+1)}function Pv(n,e){e.content.size||n.type.compatibleContent(e.type);let t=n.contentMatchAt(n.childCount),{linebreakReplacement:s}=n.type.schema;for(let i=0;i0?(r=s.node(i+1),l++,o=s.node(i).maybeChild(l)):(r=s.node(i).maybeChild(l-1),o=s.node(i+1)),r&&!r.isTextblock&&oc(r,o)&&s.node(i).canReplace(l,l+1))return e;if(i==0)break;e=t<0?s.before(i):s.after(i)}}function Bv(n,e,t){let s=null,{linebreakReplacement:i}=n.doc.type.schema,r=n.doc.resolve(e-t),o=r.node().type;if(i&&o.inlineContent){let u=o.whitespace=="pre",p=!!o.contentMatch.matchType(i);u&&!p?s=!1:!u&&p&&(s=!0)}let l=n.steps.length;if(s===!1){let u=n.doc.resolve(e+t);rc(n,u.node(),u.before(),l)}o.inlineContent&&to(n,e+t-1,o,r.node().contentMatchAt(r.index()),s==null);let c=n.mapping.slice(l),d=c.map(e-t);if(n.step(new de(d,c.map(e+t,-1),z.empty,!0)),s===!0){let u=n.doc.resolve(d);ic(n,u.node(),u.before(),n.steps.length)}return n}function _v(n,e,t){let s=n.resolve(e);if(s.parent.canReplaceWith(s.index(),s.index(),t))return e;if(s.parentOffset==0)for(let i=s.depth-1;i>=0;i--){let r=s.index(i);if(s.node(i).canReplaceWith(r,r,t))return s.before(i+1);if(r>0)return null}if(s.parentOffset==s.parent.content.size)for(let i=s.depth-1;i>=0;i--){let r=s.indexAfter(i);if(s.node(i).canReplaceWith(r,r,t))return s.after(i+1);if(r=0;o--){let l=o==s.depth?0:s.pos<=(s.start(o+1)+s.end(o+1))/2?-1:1,c=s.index(o)+(l>0?1:0),d=s.node(o),u=!1;if(r==1)u=d.canReplace(c,c,i);else{let p=d.contentMatchAt(c).findWrapping(i.firstChild.type);u=p&&d.canReplaceWith(c,c,p[0])}if(u)return l==0?s.pos:l<0?s.before(o+1):s.after(o+1)}return null}function Pi(n,e,t=e,s=z.empty){if(e==t&&!s.size)return null;let i=n.resolve(e),r=n.resolve(t);return ac(i,r,s)?new de(e,t,s):new zv(i,r,s).fit()}function ac(n,e,t){return!t.openStart&&!t.openEnd&&n.start()==e.start()&&n.parent.canReplace(n.index(),e.index(),t.content)}class zv{constructor(e,t,s){this.$from=e,this.$to=t,this.unplaced=s,this.frontier=[],this.placed=$.empty;for(let i=0;i<=e.depth;i++){let r=e.node(i);this.frontier.push({type:r.type,match:r.contentMatchAt(e.indexAfter(i))})}for(let i=e.depth;i>0;i--)this.placed=$.from(e.node(i).copy(this.placed))}get depth(){return this.frontier.length-1}fit(){for(;this.unplaced.size;){let d=this.findFittable();d?this.placeNodes(d):this.openMore()||this.dropNode()}let e=this.mustMoveInline(),t=this.placed.size-this.depth-this.$from.depth,s=this.$from,i=this.close(e<0?this.$to:s.doc.resolve(e));if(!i)return null;let r=this.placed,o=s.depth,l=i.depth;for(;o&&l&&r.childCount==1;)r=r.firstChild.content,o--,l--;let c=new z(r,o,l);return e>-1?new xe(s.pos,e,this.$to.pos,this.$to.end(),c,t):c.size||s.pos!=this.$to.pos?new de(s.pos,i.pos,c):null}findFittable(){let e=this.unplaced.openStart;for(let t=this.unplaced.content,s=0,i=this.unplaced.openEnd;s1&&(i=0),r.type.spec.isolating&&i<=s){e=s;break}t=r.content}for(let t=1;t<=2;t++)for(let s=t==1?e:this.unplaced.openStart;s>=0;s--){let i,r=null;s?(r=Zo(this.unplaced.content,s-1).firstChild,i=r.content):i=this.unplaced.content;let o=i.firstChild;for(let l=this.depth;l>=0;l--){let{type:c,match:d}=this.frontier[l],u,p=null;if(t==1&&(o?d.matchType(o.type)||(p=d.fillBefore($.from(o),!1)):r&&c.compatibleContent(r.type)))return{sliceDepth:s,frontierDepth:l,parent:r,inject:p};if(t==2&&o&&(u=d.findWrapping(o.type)))return{sliceDepth:s,frontierDepth:l,parent:r,wrap:u};if(r&&d.matchType(r.type))break}}}openMore(){let{content:e,openStart:t,openEnd:s}=this.unplaced;return Qo(e,-1)<=t?!1:(this.unplaced.size>1&&Qo(e,1)>s&&s++,this.unplaced=new z(e,t+1,s),!0)}dropNode(){let{content:e,openStart:t,openEnd:s}=this.unplaced,i=Zo(e,t);if(i.childCount<=1&&t>0){let r=e.size-t<=t+i.size;this.unplaced=new z(_n(e,t-1,1),t-1,r?t-1:s)}else this.unplaced=new z(_n(e,t,1),t,s)}placeNodes({sliceDepth:e,frontierDepth:t,parent:s,inject:i,wrap:r}){for(;this.depth>t;)this.closeFrontierNode();if(r)for(let b=0;b1||c==0||b.content.size)&&(p=m,u.push(cc(b.mark(f.allowedMarks(b.marks)),d==1?c:0,d==l.childCount?h:-1)))}let g=d==l.childCount;g||(h=-1),this.placed=zn(this.placed,t,$.from(u)),this.frontier[t].match=p,g&&h<0&&s&&s.type==this.frontier[this.depth].type&&this.frontier.length>1&&this.closeFrontierNode();for(let b=0,m=l;b1&&i==this.$to.end(--s);)++i;return i}findCloseLevel(e){e:for(let t=Math.min(this.depth,e.depth);t>=0;t--){let{match:s,type:i}=this.frontier[t],r=t=0;l--){let{match:c,type:d}=this.frontier[l],u=Qi(e,l,d,c,!0);if(!u||u.childCount)continue e}return{depth:t,fit:o,move:r?e.doc.resolve(e.after(t+1)):e}}}}close(e){let t=this.findCloseLevel(e);if(!t)return null;for(;this.depth>t.depth;)this.closeFrontierNode();t.fit.childCount&&(this.placed=zn(this.placed,t.depth,t.fit)),e=t.move;for(let s=t.depth+1;s<=e.depth;s++){let i=e.node(s),r=i.type.contentMatch.fillBefore(i.content,!0,e.index(s));this.openFrontierNode(i.type,i.attrs,r)}return e}openFrontierNode(e,t=null,s){let i=this.frontier[this.depth];i.match=i.match.matchType(e),this.placed=zn(this.placed,this.depth,$.from(e.create(t,s))),this.frontier.push({type:e,match:e.contentMatch})}closeFrontierNode(){let t=this.frontier.pop().match.fillBefore($.empty,!0);t.childCount&&(this.placed=zn(this.placed,this.frontier.length,t))}}function _n(n,e,t){return e==0?n.cutByIndex(t,n.childCount):n.replaceChild(0,n.firstChild.copy(_n(n.firstChild.content,e-1,t)))}function zn(n,e,t){return e==0?n.append(t):n.replaceChild(n.childCount-1,n.lastChild.copy(zn(n.lastChild.content,e-1,t)))}function Zo(n,e){for(let t=0;t1&&(s=s.replaceChild(0,cc(s.firstChild,e-1,s.childCount==1?t-1:0))),e>0&&(s=n.type.contentMatch.fillBefore(s).append(s),t<=0&&(s=s.append(n.type.contentMatch.matchFragment(s).fillBefore($.empty,!0)))),n.copy(s)}function Qi(n,e,t,s,i){let r=n.node(e),o=i?n.indexAfter(e):n.index(e);if(o==r.childCount&&!t.compatibleContent(r.type))return null;let l=s.fillBefore(r.content,!0,o);return l&&!jv(t,r.content,o)?l:null}function jv(n,e,t){for(let s=t;s0;f--,h--){let g=i.node(f).type.spec;if(g.defining||g.definingAsContext||g.isolating)break;o.indexOf(f)>-1?l=f:i.before(f)==h&&o.splice(1,0,-f)}let c=o.indexOf(l),d=[],u=s.openStart;for(let f=s.content,h=0;;h++){let g=f.firstChild;if(d.push(g),h==s.openStart)break;f=g.content}for(let f=u-1;f>=0;f--){let h=d[f],g=Fv(h.type);if(g&&!h.sameMarkup(i.node(Math.abs(l)-1)))u=f;else if(g||!h.type.isTextblock)break}for(let f=s.openStart;f>=0;f--){let h=(f+u+1)%(s.openStart+1),g=d[h];if(g)for(let b=0;b=0&&(n.replace(e,t,s),!(n.steps.length>p));f--){let h=o[f];h<0||(e=i.before(h),t=r.after(h))}}function dc(n,e,t,s,i){if(es){let r=i.contentMatchAt(0),o=r.fillBefore(n).append(n);n=o.append(r.matchFragment(o).fillBefore($.empty,!0))}return n}function Hv(n,e,t,s){if(!s.isInline&&e==t&&n.doc.resolve(e).parent.content.size){let i=_v(n.doc,e,s.type);i!=null&&(e=t=i)}n.replaceRange(e,t,new z($.from(s),0,0))}function qv(n,e,t){let s=n.doc.resolve(e),i=n.doc.resolve(t);if(s.parent.isTextblock&&i.parent.isTextblock&&s.start()!=i.start()&&s.parentOffset==0&&i.parentOffset==0){let o=s.sharedDepth(t),l=!1;for(let c=s.depth;c>o;c--)s.node(c).type.spec.isolating&&(l=!0);for(let c=i.depth;c>o;c--)i.node(c).type.spec.isolating&&(l=!0);if(!l){for(let c=s.depth;c>0&&e==s.start(c);c--)e=s.before(c);for(let c=i.depth;c>0&&t==i.start(c);c--)t=i.before(c);s=n.doc.resolve(e),i=n.doc.resolve(t)}}let r=uc(s,i);for(let o=0;o0&&(c||s.node(l-1).canReplace(s.index(l-1),i.indexAfter(l-1))))return n.delete(s.before(l),i.after(l))}for(let o=1;o<=s.depth&&o<=i.depth;o++)if(e-s.start(o)==s.depth-o&&t>s.end(o)&&i.end(o)-t!=i.depth-o&&s.start(o-1)==i.start(o-1)&&s.node(o-1).canReplace(s.index(o-1),i.index(o-1)))return n.delete(s.before(o),t);n.delete(e,t)}function uc(n,e){let t=[],s=Math.min(n.depth,e.depth);for(let i=s;i>=0;i--){let r=n.start(i);if(re.pos+(e.depth-i)||n.node(i).type.spec.isolating||e.node(i).type.spec.isolating)break;(r==e.start(i)||i==n.depth&&i==e.depth&&n.parent.inlineContent&&e.parent.inlineContent&&i&&e.start(i-1)==r-1)&&t.push(i)}return t}class kn extends Re{constructor(e,t,s){super(),this.pos=e,this.attr=t,this.value=s}apply(e){let t=e.nodeAt(this.pos);if(!t)return he.fail("No node at attribute step's position");let s=Object.create(null);for(let r in t.attrs)s[r]=t.attrs[r];s[this.attr]=this.value;let i=t.type.create(s,null,t.marks);return he.fromReplace(e,this.pos,this.pos+1,new z($.from(i),0,t.isLeaf?0:1))}getMap(){return He.empty}invert(e){return new kn(this.pos,this.attr,e.nodeAt(this.pos).attrs[this.attr])}map(e){let t=e.mapResult(this.pos,1);return t.deletedAfter?null:new kn(t.pos,this.attr,this.value)}toJSON(){return{stepType:"attr",pos:this.pos,attr:this.attr,value:this.value}}static fromJSON(e,t){if(typeof t.pos!="number"||typeof t.attr!="string")throw new RangeError("Invalid input for AttrStep.fromJSON");return new kn(t.pos,t.attr,t.value)}}Re.jsonID("attr",kn);class as extends Re{constructor(e,t){super(),this.attr=e,this.value=t}apply(e){let t=Object.create(null);for(let i in e.attrs)t[i]=e.attrs[i];t[this.attr]=this.value;let s=e.type.create(t,e.content,e.marks);return he.ok(s)}getMap(){return He.empty}invert(e){return new as(this.attr,e.attrs[this.attr])}map(e){return this}toJSON(){return{stepType:"docAttr",attr:this.attr,value:this.value}}static fromJSON(e,t){if(typeof t.attr!="string")throw new RangeError("Invalid input for DocAttrStep.fromJSON");return new as(t.attr,t.value)}}Re.jsonID("docAttr",as);let Sn=class extends Error{};Sn=function n(e){let t=Error.call(this,e);return t.__proto__=n.prototype,t};Sn.prototype=Object.create(Error.prototype);Sn.prototype.constructor=Sn;Sn.prototype.name="TransformError";class pc{constructor(e){this.doc=e,this.steps=[],this.docs=[],this.mapping=new ls}get before(){return this.docs.length?this.docs[0]:this.doc}step(e){let t=this.maybeStep(e);if(t.failed)throw new Sn(t.failed);return this}maybeStep(e){let t=e.apply(this.doc);return t.failed||this.addStep(e,t.doc),t}get docChanged(){return this.steps.length>0}changedRange(){let e=1e9,t=-1e9;for(let s=0;s{e=Math.min(e,l),t=Math.max(t,c)})}return e==1e9?null:{from:e,to:t}}addStep(e,t){this.docs.push(this.doc),this.steps.push(e),this.mapping.appendMap(e.getMap()),this.doc=t}replace(e,t=e,s=z.empty){let i=Pi(this.doc,e,t,s);return i&&this.step(i),this}replaceWith(e,t,s){return this.replace(e,t,new z($.from(s),0,0))}delete(e,t){return this.replace(e,t,z.empty)}insert(e,t){return this.replaceWith(e,e,t)}replaceRange(e,t,s){return Vv(this,e,t,s),this}replaceRangeWith(e,t,s){return Hv(this,e,t,s),this}deleteRange(e,t){return qv(this,e,t),this}lift(e,t){return Av(this,e,t),this}join(e,t=1){return Bv(this,e,t),this}wrap(e,t){return Iv(this,e,t),this}setBlockType(e,t=e,s,i=null){return Dv(this,e,t,s,i),this}setNodeMarkup(e,t,s=null,i){return Rv(this,e,t,s,i),this}setNodeAttribute(e,t,s){return this.step(new kn(e,t,s)),this}setDocAttribute(e,t){return this.step(new as(e,t)),this}addNodeMark(e,t){return this.step(new Et(e,t)),this}removeNodeMark(e,t){let s=this.doc.nodeAt(e);if(!s)throw new RangeError("No node at position "+e);if(t instanceof ie)t.isInSet(s.marks)&&this.step(new nn(e,t));else{let i=s.marks,r,o=[];for(;r=t.isInSet(i);)o.push(new nn(e,r)),i=r.removeFromSet(i);for(let l=o.length-1;l>=0;l--)this.step(o[l])}return this}split(e,t=1,s){return Lv(this,e,t,s),this}addMark(e,t,s){return Mv(this,e,t,s),this}removeMark(e,t,s){return Tv(this,e,t,s),this}clearIncompatible(e,t,s){return to(this,e,t,s),this}}const er=Object.create(null);class X{constructor(e,t,s){this.$anchor=e,this.$head=t,this.ranges=s||[new Uv(e.min(t),e.max(t))]}get anchor(){return this.$anchor.pos}get head(){return this.$head.pos}get from(){return this.$from.pos}get to(){return this.$to.pos}get $from(){return this.ranges[0].$from}get $to(){return this.ranges[0].$to}get empty(){let e=this.ranges;for(let t=0;t=0;r--){let o=t<0?mn(e.node(0),e.node(r),e.before(r+1),e.index(r),t,s):mn(e.node(0),e.node(r),e.after(r+1),e.index(r)+1,t,s);if(o)return o}return null}static near(e,t=1){return this.findFrom(e,t)||this.findFrom(e,-t)||new qe(e.node(0))}static atStart(e){return mn(e,e,0,0,1)||new qe(e)}static atEnd(e){return mn(e,e,e.content.size,e.childCount,-1)||new qe(e)}static fromJSON(e,t){if(!t||!t.type)throw new RangeError("Invalid input for Selection.fromJSON");let s=er[t.type];if(!s)throw new RangeError(`No selection type ${t.type} defined`);return s.fromJSON(e,t)}static jsonID(e,t){if(e in er)throw new RangeError("Duplicate use of selection JSON ID "+e);return er[e]=t,t.prototype.jsonID=e,t}getBookmark(){return U.between(this.$anchor,this.$head).getBookmark()}}X.prototype.visible=!0;class Uv{constructor(e,t){this.$from=e,this.$to=t}}let el=!1;function tl(n){!el&&!n.parent.inlineContent&&(el=!0,console.warn("TextSelection endpoint not pointing into a node with inline content ("+n.parent.type.name+")"))}class U extends X{constructor(e,t=e){tl(e),tl(t),super(e,t)}get $cursor(){return this.$anchor.pos==this.$head.pos?this.$head:null}map(e,t){let s=e.resolve(t.map(this.head));if(!s.parent.inlineContent)return X.near(s);let i=e.resolve(t.map(this.anchor));return new U(i.parent.inlineContent?i:s,s)}replace(e,t=z.empty){if(super.replace(e,t),t==z.empty){let s=this.$from.marksAcross(this.$to);s&&e.ensureMarks(s)}}eq(e){return e instanceof U&&e.anchor==this.anchor&&e.head==this.head}getBookmark(){return new Bi(this.anchor,this.head)}toJSON(){return{type:"text",anchor:this.anchor,head:this.head}}static fromJSON(e,t){if(typeof t.anchor!="number"||typeof t.head!="number")throw new RangeError("Invalid input for TextSelection.fromJSON");return new U(e.resolve(t.anchor),e.resolve(t.head))}static create(e,t,s=t){let i=e.resolve(t);return new this(i,s==t?i:e.resolve(s))}static between(e,t,s){let i=e.pos-t.pos;if((!s||i)&&(s=i>=0?1:-1),!t.parent.inlineContent){let r=X.findFrom(t,s,!0)||X.findFrom(t,-s,!0);if(r)t=r.$head;else return X.near(t,s)}return e.parent.inlineContent||(i==0?e=t:(e=(X.findFrom(e,-s,!0)||X.findFrom(e,s,!0)).$anchor,e.pos0?0:1);i>0?o=0;o+=i){let l=e.child(o);if(l.isAtom){if(!r&&W.isSelectable(l))return W.create(n,t-(i<0?l.nodeSize:0))}else{let c=mn(n,l,t+i,i<0?l.childCount:0,i,r);if(c)return c}t+=l.nodeSize*i}return null}function nl(n,e,t){let s=n.steps.length-1;if(s{o==null&&(o=u)}),n.setSelection(X.near(n.doc.resolve(o),t))}const sl=1,Ts=2,il=4;class Kv extends pc{constructor(e){super(e.doc),this.curSelectionFor=0,this.updated=0,this.meta=Object.create(null),this.time=Date.now(),this.curSelection=e.selection,this.storedMarks=e.storedMarks}get selection(){return this.curSelectionFor0}setStoredMarks(e){return this.storedMarks=e,this.updated|=Ts,this}ensureMarks(e){return ie.sameSet(this.storedMarks||this.selection.$from.marks(),e)||this.setStoredMarks(e),this}addStoredMark(e){return this.ensureMarks(e.addToSet(this.storedMarks||this.selection.$head.marks()))}removeStoredMark(e){return this.ensureMarks(e.removeFromSet(this.storedMarks||this.selection.$head.marks()))}get storedMarksSet(){return(this.updated&Ts)>0}addStep(e,t){super.addStep(e,t),this.updated=this.updated&~Ts,this.storedMarks=null}setTime(e){return this.time=e,this}replaceSelection(e){return this.selection.replace(this,e),this}replaceSelectionWith(e,t=!0){let s=this.selection;return t&&(e=e.mark(this.storedMarks||(s.empty?s.$from.marks():s.$from.marksAcross(s.$to)||ie.none))),s.replaceWith(this,e),this}deleteSelection(){return this.selection.replace(this),this}insertText(e,t,s){let i=this.doc.type.schema;if(t==null)return e?this.replaceSelectionWith(i.text(e),!0):this.deleteSelection();{if(s==null&&(s=t),!e)return this.deleteRange(t,s);let r=this.storedMarks;if(!r){let o=this.doc.resolve(t);r=s==t?o.marks():o.marksAcross(this.doc.resolve(s))}return this.replaceRangeWith(t,s,i.text(e,r)),!this.selection.empty&&this.selection.to==t+e.length&&this.setSelection(X.near(this.selection.$to)),this}}setMeta(e,t){return this.meta[typeof e=="string"?e:e.key]=t,this}getMeta(e){return this.meta[typeof e=="string"?e:e.key]}get isGeneric(){for(let e in this.meta)return!1;return!0}scrollIntoView(){return this.updated|=il,this}get scrolledIntoView(){return(this.updated&il)>0}}function rl(n,e){return!e||!n?n:n.bind(e)}class jn{constructor(e,t,s){this.name=e,this.init=rl(t.init,s),this.apply=rl(t.apply,s)}}const Jv=[new jn("doc",{init(n){return n.doc||n.schema.topNodeType.createAndFill()},apply(n){return n.doc}}),new jn("selection",{init(n,e){return n.selection||X.atStart(e.doc)},apply(n){return n.selection}}),new jn("storedMarks",{init(n){return n.storedMarks||null},apply(n,e,t,s){return s.selection.$cursor?n.storedMarks:null}}),new jn("scrollToSelection",{init(){return 0},apply(n,e){return n.scrolledIntoView?e+1:e}})];class tr{constructor(e,t){this.schema=e,this.plugins=[],this.pluginsByKey=Object.create(null),this.fields=Jv.slice(),t&&t.forEach(s=>{if(this.pluginsByKey[s.key])throw new RangeError("Adding different instances of a keyed plugin ("+s.key+")");this.plugins.push(s),this.pluginsByKey[s.key]=s,s.spec.state&&this.fields.push(new jn(s.key,s.spec.state,s))})}}class pt{constructor(e){this.config=e}get schema(){return this.config.schema}get plugins(){return this.config.plugins}apply(e){return this.applyTransaction(e).state}filterTransaction(e,t=-1){for(let s=0;ss.toJSON())),e&&typeof e=="object")for(let s in e){if(s=="doc"||s=="selection")throw new RangeError("The JSON fields `doc` and `selection` are reserved");let i=e[s],r=i.spec.state;r&&r.toJSON&&(t[s]=r.toJSON.call(i,this[i.key]))}return t}static fromJSON(e,t,s){if(!t)throw new RangeError("Invalid input for EditorState.fromJSON");if(!e.schema)throw new RangeError("Required config field 'schema' missing");let i=new tr(e.schema,e.plugins),r=new pt(i);return i.fields.forEach(o=>{if(o.name=="doc")r.doc=Zt.fromJSON(e.schema,t.doc);else if(o.name=="selection")r.selection=X.fromJSON(r.doc,t.selection);else if(o.name=="storedMarks")t.storedMarks&&(r.storedMarks=t.storedMarks.map(e.schema.markFromJSON));else{if(s)for(let l in s){let c=s[l],d=c.spec.state;if(c.key==o.name&&d&&d.fromJSON&&Object.prototype.hasOwnProperty.call(t,l)){r[o.name]=d.fromJSON.call(c,e,t[l],r);return}}r[o.name]=o.init(e,r)}}),r}}function fc(n,e,t){for(let s in n){let i=n[s];i instanceof Function?i=i.bind(e):s=="handleDOMEvents"&&(i=fc(i,e,{})),t[s]=i}return t}class oe{constructor(e){this.spec=e,this.props={},e.props&&fc(e.props,this,this.props),this.key=e.key?e.key.key:hc("plugin")}getState(e){return e[this.key]}}const nr=Object.create(null);function hc(n){return n in nr?n+"$"+ ++nr[n]:(nr[n]=0,n+"$")}class me{constructor(e="key"){this.key=hc(e)}get(e){return e.config.pluginsByKey[this.key]}getState(e){return e[this.key]}}const mc=(n,e)=>n.selection.empty?!1:(e&&e(n.tr.deleteSelection().scrollIntoView()),!0);function gc(n,e){let{$cursor:t}=n.selection;return!t||(e?!e.endOfTextblock("backward",n):t.parentOffset>0)?null:t}const bc=(n,e,t)=>{let s=gc(n,t);if(!s)return!1;let i=io(s);if(!i){let o=s.blockRange(),l=o&&Dn(o);return l==null?!1:(e&&e(n.tr.lift(o,l).scrollIntoView()),!0)}let r=i.nodeBefore;if(Tc(n,i,e,-1))return!0;if(s.parent.content.size==0&&(Cn(r,"end")||W.isSelectable(r)))for(let o=s.depth;;o--){let l=Pi(n.doc,s.before(o),s.after(o),z.empty);if(l&&l.slice.size1)break}return r.isAtom&&i.depth==s.depth-1?(e&&e(n.tr.delete(i.pos-r.nodeSize,i.pos).scrollIntoView()),!0):!1},Gv=(n,e,t)=>{let s=gc(n,t);if(!s)return!1;let i=io(s);return i?vc(n,i,e):!1},Yv=(n,e,t)=>{let s=kc(n,t);if(!s)return!1;let i=ro(s);return i?vc(n,i,e):!1};function vc(n,e,t){let s=e.nodeBefore,i=s,r=e.pos-1;for(;!i.isTextblock;r--){if(i.type.spec.isolating)return!1;let u=i.lastChild;if(!u)return!1;i=u}let o=e.nodeAfter,l=o,c=e.pos+1;for(;!l.isTextblock;c++){if(l.type.spec.isolating)return!1;let u=l.firstChild;if(!u)return!1;l=u}let d=Pi(n.doc,r,c,z.empty);if(!d||d.from!=r||d instanceof de&&d.slice.size>=c-r)return!1;if(t){let u=n.tr.step(d);u.setSelection(U.create(u.doc,r)),t(u.scrollIntoView())}return!0}function Cn(n,e,t=!1){for(let s=n;s;s=e=="start"?s.firstChild:s.lastChild){if(s.isTextblock)return!0;if(t&&s.childCount!=1)return!1}return!1}const yc=(n,e,t)=>{let{$head:s,empty:i}=n.selection,r=s;if(!i)return!1;if(s.parent.isTextblock){if(t?!t.endOfTextblock("backward",n):s.parentOffset>0)return!1;r=io(s)}let o=r&&r.nodeBefore;return!o||!W.isSelectable(o)?!1:(e&&e(n.tr.setSelection(W.create(n.doc,r.pos-o.nodeSize)).scrollIntoView()),!0)};function io(n){if(!n.parent.type.spec.isolating)for(let e=n.depth-1;e>=0;e--){if(n.index(e)>0)return n.doc.resolve(n.before(e+1));if(n.node(e).type.spec.isolating)break}return null}function kc(n,e){let{$cursor:t}=n.selection;return!t||(e?!e.endOfTextblock("forward",n):t.parentOffset{let s=kc(n,t);if(!s)return!1;let i=ro(s);if(!i)return!1;let r=i.nodeAfter;if(Tc(n,i,e,1))return!0;if(s.parent.content.size==0&&(Cn(r,"start")||W.isSelectable(r))){let o=Pi(n.doc,s.before(),s.after(),z.empty);if(o&&o.slice.size{let{$head:s,empty:i}=n.selection,r=s;if(!i)return!1;if(s.parent.isTextblock){if(t?!t.endOfTextblock("forward",n):s.parentOffset=0;e--){let t=n.node(e);if(n.index(e)+1{let t=n.selection,s=t instanceof W,i;if(s){if(t.node.isTextblock||!_t(n.doc,t.from))return!1;i=t.from}else if(i=Li(n.doc,t.from,-1),i==null)return!1;if(e){let r=n.tr.join(i);s&&r.setSelection(W.create(r.doc,i-n.doc.resolve(i).nodeBefore.nodeSize)),e(r.scrollIntoView())}return!0},Zv=(n,e)=>{let t=n.selection,s;if(t instanceof W){if(t.node.isTextblock||!_t(n.doc,t.to))return!1;s=t.to}else if(s=Li(n.doc,t.to,1),s==null)return!1;return e&&e(n.tr.join(s).scrollIntoView()),!0},Qv=(n,e)=>{let{$from:t,$to:s}=n.selection,i=t.blockRange(s),r=i&&Dn(i);return r==null?!1:(e&&e(n.tr.lift(i,r).scrollIntoView()),!0)},Sc=(n,e)=>{let{$head:t,$anchor:s}=n.selection;return!t.parent.type.spec.code||!t.sameParent(s)?!1:(e&&e(n.tr.insertText(` -`).scrollIntoView()),!0)};function oo(n){for(let e=0;e{let{$head:t,$anchor:s}=n.selection;if(!t.parent.type.spec.code||!t.sameParent(s))return!1;let i=t.node(-1),r=t.indexAfter(-1),o=oo(i.contentMatchAt(r));if(!o||!i.canReplaceWith(r,r,o))return!1;if(e){let l=t.after(),c=n.tr.replaceWith(l,l,o.createAndFill());c.setSelection(X.near(c.doc.resolve(l),1)),e(c.scrollIntoView())}return!0},Cc=(n,e)=>{let t=n.selection,{$from:s,$to:i}=t;if(t instanceof qe||s.parent.inlineContent||i.parent.inlineContent)return!1;let r=oo(i.parent.contentMatchAt(i.indexAfter()));if(!r||!r.isTextblock)return!1;if(e){let o=(!s.parentOffset&&i.index(){let{$cursor:t}=n.selection;if(!t||t.parent.content.size)return!1;if(t.depth>1&&t.after()!=t.end(-1)){let r=t.before();if(mt(n.doc,r))return e&&e(n.tr.split(r).scrollIntoView()),!0}let s=t.blockRange(),i=s&&Dn(s);return i==null?!1:(e&&e(n.tr.lift(s,i).scrollIntoView()),!0)};function ty(n){return(e,t)=>{if(e.selection instanceof W&&e.selection.node.isBlock){let{$from:h}=e.selection;return!h.parentOffset||!mt(e.doc,h.pos)?!1:(t&&t(e.tr.split(h.pos).scrollIntoView()),!0)}if(!e.selection.$from.depth)return!1;let s=e.tr;!e.selection.empty&&(e.selection instanceof U||e.selection instanceof qe)&&s.deleteSelection();let{$from:i}=s.selection,r=s.steps.length,o=[],l,c,d=!1,u=!1;for(let h=i.depth;;h--)if(i.node(h).isBlock){d=i.end(h)==i.pos+(i.depth-h),u=i.start(h)==i.pos-(i.depth-h),c=oo(i.node(h-1).contentMatchAt(i.indexAfter(h-1))),o.unshift(d&&c?{type:c}:null),l=h;break}else{if(h==1)return!1;o.unshift(null)}let p=i.pos,f=mt(s.doc,p,o.length,o);if(f||(o[0]=c?{type:c}:null,f=mt(s.doc,p,o.length,o)),!f)return!1;if(s.split(p,o.length,o),!d&&u&&i.node(l).type!=c){let h=s.mapping.slice(r),g=h.map(i.before(l)),b=s.doc.resolve(g);c&&i.node(l-1).canReplaceWith(b.index(),b.index()+1,c)&&s.setNodeMarkup(h.map(i.before(l)),c)}return t&&t(s.scrollIntoView()),!0}}const ny=ty(),sy=(n,e)=>{let{$from:t,to:s}=n.selection,i,r=t.sharedDepth(s);return r==0?!1:(i=t.before(r),e&&e(n.tr.setSelection(W.create(n.doc,i))),!0)};function iy(n,e,t){let s=e.nodeBefore,i=e.nodeAfter,r=e.index();return!s||!i||!s.type.compatibleContent(i.type)?!1:!s.content.size&&e.parent.canReplace(r-1,r)?(t&&t(n.tr.delete(e.pos-s.nodeSize,e.pos).scrollIntoView()),!0):!e.parent.canReplace(r,r+1)||!(i.isTextblock||_t(n.doc,e.pos))?!1:(t&&t(n.tr.join(e.pos).scrollIntoView()),!0)}function Tc(n,e,t,s){let i=e.nodeBefore,r=e.nodeAfter,o,l,c=i.type.spec.isolating||r.type.spec.isolating;if(!c&&iy(n,e,t))return!0;let d=!c&&e.parent.canReplace(e.index(),e.index()+1);if(d&&(o=(l=i.contentMatchAt(i.childCount)).findWrapping(r.type))&&l.matchType(o[0]||r.type).validEnd){if(t){let h=e.pos+r.nodeSize,g=$.empty;for(let v=o.length-1;v>=0;v--)g=$.from(o[v].create(null,g));g=$.from(i.copy(g));let b=n.tr.step(new xe(e.pos-1,h,e.pos,h,new z(g,1,0),o.length,!0)),m=b.doc.resolve(h+2*o.length);m.nodeAfter&&m.nodeAfter.type==i.type&&_t(b.doc,m.pos)&&b.join(m.pos),t(b.scrollIntoView())}return!0}let u=r.type.spec.isolating||s>0&&c?null:X.findFrom(e,1),p=u&&u.$from.blockRange(u.$to),f=p&&Dn(p);if(f!=null&&f>=e.depth)return t&&t(n.tr.lift(p,f).scrollIntoView()),!0;if(d&&Cn(r,"start",!0)&&Cn(i,"end")){let h=i,g=[];for(;g.push(h),!h.isTextblock;)h=h.lastChild;let b=r,m=1;for(;!b.isTextblock;b=b.firstChild)m++;if(h.canReplace(h.childCount,h.childCount,b.content)){if(t){let v=$.empty;for(let A=g.length-1;A>=0;A--)v=$.from(g[A].copy(v));let S=n.tr.step(new xe(e.pos-g.length,e.pos+r.nodeSize,e.pos+m,e.pos+r.nodeSize-m,new z(v,g.length,0),0,!0));t(S.scrollIntoView())}return!0}}return!1}function Ec(n){return function(e,t){let s=e.selection,i=n<0?s.$from:s.$to,r=i.depth;for(;i.node(r).isInline;){if(!r)return!1;r--}return i.node(r).isTextblock?(t&&t(e.tr.setSelection(U.create(e.doc,n<0?i.start(r):i.end(r)))),!0):!1}}const ry=Ec(-1),oy=Ec(1);function ly(n,e=null){return function(t,s){let{$from:i,$to:r}=t.selection,o=i.blockRange(r),l=o&&no(o,n,e);return l?(s&&s(t.tr.wrap(o,l).scrollIntoView()),!0):!1}}function ol(n,e=null){return function(t,s){let i=!1;for(let r=0;r{if(i)return!1;if(!(!c.isTextblock||c.hasMarkup(n,e)))if(c.type==n)i=!0;else{let u=t.doc.resolve(d),p=u.index();i=u.parent.canReplaceWith(p,p+1,n)}})}if(!i)return!1;if(s){let r=t.tr;for(let o=0;o=2&&e.$from.node(e.depth-1).type.compatibleContent(t)&&e.startIndex==0){if(e.$from.index(e.depth-1)==0)return!1;let c=o.resolve(e.start-2);r=new Ks(c,c,e.depth),e.endIndex=0;u--)r=$.from(t[u].type.create(t[u].attrs,r));n.step(new xe(e.start-(s?2:0),e.end,e.start,e.end,new z(r,0,0),t.length,!0));let o=0;for(let u=0;uo.childCount>0&&o.firstChild.type==n);return r?t?s.node(r.depth-1).type==n?py(e,t,n,r):fy(e,t,r):!0:!1}}function py(n,e,t,s){let i=n.tr,r=s.end,o=s.$to.end(s.depth);rb;g--)h-=i.child(g).nodeSize,s.delete(h-1,h+1);let r=s.doc.resolve(t.start),o=r.nodeAfter;if(s.mapping.map(t.end)!=t.start+r.nodeAfter.nodeSize)return!1;let l=t.startIndex==0,c=t.endIndex==i.childCount,d=r.node(-1),u=r.index(-1);if(!d.canReplace(u+(l?0:1),u+1,o.content.append(c?$.empty:$.from(i))))return!1;let p=r.pos,f=p+o.nodeSize;return s.step(new xe(p-(l?1:0),f+(c?1:0),p+1,f-1,new z((l?$.empty:$.from(i.copy($.empty))).append(c?$.empty:$.from(i.copy($.empty))),l?0:1,c?0:1),l?0:1)),e(s.scrollIntoView()),!0}function hy(n){return function(e,t){let{$from:s,$to:i}=e.selection,r=s.blockRange(i,d=>d.childCount>0&&d.firstChild.type==n);if(!r)return!1;let o=r.startIndex;if(o==0)return!1;let l=r.parent,c=l.child(o-1);if(c.type!=n)return!1;if(t){let d=c.lastChild&&c.lastChild.type==l.type,u=$.from(d?n.create():null),p=new z($.from(n.create(null,$.from(l.type.create(null,u)))),d?3:1,0),f=r.start,h=r.end;t(e.tr.step(new xe(f-(d?3:1),h,f,h,p,1,!0)).scrollIntoView())}return!0}}const Ce=function(n){for(var e=0;;e++)if(n=n.previousSibling,!n)return e},Mn=function(n){let e=n.assignedSlot||n.parentNode;return e&&e.nodeType==11?e.host:e};let Mr=null;const ut=function(n,e,t){let s=Mr||(Mr=document.createRange());return s.setEnd(n,t==null?n.nodeValue.length:t),s.setStart(n,e||0),s},my=function(){Mr=null},sn=function(n,e,t,s){return t&&(ll(n,e,t,s,-1)||ll(n,e,t,s,1))},gy=/^(img|br|input|textarea|hr)$/i;function ll(n,e,t,s,i){for(var r;;){if(n==t&&e==s)return!0;if(e==(i<0?0:Ie(n))){let o=n.parentNode;if(!o||!q(o)||ms(n)||gy.test(n.nodeName)||n.contentEditable=="false")return!1;e=Ce(n)+(i<0?0:1),n=o}else if(q(n)){let o=n.childNodes[e+(i<0?-1:0)];if(q(o)&&o.contentEditable=="false")if(!((r=o.pmViewDesc)===null||r===void 0)&&r.ignoreForSelection)e+=i;else return!1;else n=o,e=i<0?Ie(n):0}else return!1}}function Ie(n){return n.nodeType==3?n.nodeValue.length:n.childNodes.length}function q(n){return n.nodeType==1}function ve(n){return n.nodeType==3}function rn(n,e){return e?n.contains(q(e)?e:e.parentNode):!1}function by(n,e){for(;;){if(ve(n)&&e)return n;if(q(n)&&e>0){if(n.contentEditable=="false")return null;n=n.childNodes[e-1],e=Ie(n)}else if(n.parentNode&&!ms(n))e=Ce(n),n=n.parentNode;else return null}}function vy(n,e){for(;;){if(ve(n)&&e2),Je=Tn||(it?/Mac/.test(it.platform):!1),Nc=it?/Win/.test(it.platform):!1,ft=/Android \d/.test(zt),zi=!!al&&"webkitFontSmoothing"in al.documentElement.style,wy=zi?+(/\bAppleWebKit\/(\d+)/.exec(navigator.userAgent)||[0,0])[1]:0;function Sy(n){let e=n.defaultView&&n.defaultView.visualViewport;return e?{left:0,right:e.width,top:0,bottom:e.height}:{left:0,right:n.documentElement.clientWidth,top:0,bottom:n.documentElement.clientHeight}}function ot(n,e){return typeof n=="number"?n:n[e]}function Cy(n){let e=n.getBoundingClientRect(),t=e.width/n.offsetWidth||1,s=e.height/n.offsetHeight||1;return{left:e.left,right:e.left+n.clientWidth*t,top:e.top,bottom:e.top+n.clientHeight*s}}function cl(n,e,t){if(!Or(e)&&e.left==0)return;let s=n.someProp("scrollThreshold")||0,i=n.someProp("scrollMargin")||5,r=n.dom.ownerDocument;for(let o=t||n.dom;o;){if(!q(o)){o=Mn(o);continue}let l=o==r.body,c=l?Sy(r):Cy(o),d=0,u=0;if(e.topc.bottom-ot(s,"bottom")&&(u=e.bottom-e.top>c.bottom-c.top?e.top+ot(i,"top")-c.top:e.bottom-c.bottom+ot(i,"bottom")),e.leftc.right-ot(s,"right")&&(d=e.right-c.right+ot(i,"right")),d||u)if(l)r.defaultView.scrollBy(d,u);else{let f=o.scrollLeft,h=o.scrollTop;u&&(o.scrollTop+=u),d&&(o.scrollLeft+=d);let g=o.scrollLeft-f,b=o.scrollTop-h;e={left:e.left-g,top:e.top-b,right:e.right-g,bottom:e.bottom-b}}let p=l?"fixed":getComputedStyle(o).position;if(/^(fixed|sticky)$/.test(p))break;o=p=="absolute"?o.offsetParent:Mn(o)}}function My(n){let e=n.dom.getBoundingClientRect(),t=Math.max(0,e.top),s,i;for(let r=(e.left+e.right)/2,o=t+1;o=t-20){s=l,i=c.top;break}}return{refDOM:s,refTop:i,stack:Ic(n.dom)}}function Ic(n){let e=[],t=n.ownerDocument;for(let s=n;s&&(e.push({dom:s,top:s.scrollTop,left:s.scrollLeft}),n!=t);s=Mn(s));return e}function Ty({refDOM:n,refTop:e,stack:t}){let s=n?n.getBoundingClientRect().top:0;Dc(t,s==0?0:s-e)}function Dc(n,e){for(let t=0;t=l){o=Math.max(g.bottom,o),l=Math.min(g.top,l);let b=g.left>e.left?g.left-e.left:g.right=(g.left+g.right)/2?1:0));continue}}else g.top>e.top&&!c&&g.left<=e.left&&g.right>=e.left&&(c=u,d={left:Math.max(g.left,Math.min(g.right,e.left)),top:g.top});!t&&(e.left>=g.right&&e.top>=g.top||e.left>=g.left&&e.top>=g.bottom)&&(r=p+1)}}return!t&&c&&(t=c,i=d,s=0),t&&ve(t)?Ay(t,i):!t||s?{node:n,offset:r}:$c(t,i)}function Ay(n,e){let t=n.nodeValue.length,s=document.createRange(),i;for(let r=0;r=(o.left+o.right)/2?1:0)};break}}return s.detach(),i||{node:n,offset:0}}function ao(n,e){return n.left>=e.left-1&&n.left<=e.right+1&&n.top>=e.top-1&&n.top<=e.bottom+1}function Oy(n,e){let t=n.parentNode;return t&&/^li$/i.test(t.nodeName)&&e.left(o.left+o.right)/2?1:-1}return n.docView.posFromDOM(s,i,r)}function Iy(n,e,t,s){let i=-1;for(let r=e,o=!1;r!=n.dom;){let l=n.docView.nearestDesc(r,!0),c;if(!l)return null;if(q(l.dom)&&(l.node.isBlock&&l.parent||!l.contentDOM)&&((c=l.dom.getBoundingClientRect()).width||c.height)&&(l.node.isBlock&&l.parent&&!/^T(R|BODY|HEAD|FOOT)$/.test(l.dom.nodeName)&&(!o&&c.left>s.left||c.top>s.top?i=l.posBefore:(!o&&c.right-1?i:n.docView.posFromDOM(e,t,-1)}function Rc(n,e,t){let s=n.childNodes.length;if(s&&t.tope.top&&i++}let d;zi&&i&&q(s)&&q(d=s.childNodes[i-1])&&d.contentEditable=="false"&&d.getBoundingClientRect().top>=e.top&&i--,s==n.dom&&i==s.childNodes.length-1&&q(s.lastChild)&&e.top>s.lastChild.getBoundingClientRect().bottom?l=n.state.doc.content.size:(i==0||!q(s)||s.childNodes[i-1].nodeName!="BR")&&(l=Iy(n,s,i,e))}l==null&&(l=Ny(n,o,e));let c=n.docView.nearestDesc(o,!0);return{pos:l,inside:c?c.posAtStart-c.border:-1}}function Or(n){return n.top=0&&i==s.nodeValue.length?(c--,u=1):t<0?c--:d++,$n(xt(ut(s,c,d),u),u<0)}if(!n.state.doc.resolve(e-(r||0)).parent.inlineContent){if(r==null&&i&&(t<0||i==Ie(s))){let c=s.childNodes[i-1];if(q(c))return sr(c.getBoundingClientRect(),!1)}if(r==null&&i=0)}if(r==null&&i&&(t<0||i==Ie(s))){let c=s.childNodes[i-1],d=ve(c)?ut(c,Ie(c)-(o?0:1)):q(c)&&(c.nodeName!="BR"||!c.nextSibling)?c:null;if(d)return $n(xt(d,1),!1)}if(r==null&&i=0)}function $n(n,e){if(n.width==0)return n;let t=e?n.left:n.right;return{top:n.top,bottom:n.bottom,left:t,right:t}}function sr(n,e){if(n.height==0)return n;let t=e?n.top:n.bottom;return{top:t,bottom:t,left:n.left,right:n.right}}function Pc(n,e,t){let s=n.state,i=n.root.activeElement;s!=e&&n.updateState(e),i!=n.dom&&n.focus();try{return t()}finally{s!=e&&n.updateState(s),i!=n.dom&&i&&i.focus()}}function Ry(n,e,t){let s=e.selection,i=t=="up"?s.$from:s.$to;return Pc(n,e,()=>{let{node:r}=n.docView.domFromPos(i.pos,t=="up"?-1:1);for(;;){let l=n.docView.nearestDesc(r,!0);if(!l)break;if(l.node.isBlock){r=l.contentDOM||l.dom;break}r=l.dom.parentNode}let o=Lc(n,i.pos,1);for(let l=r.firstChild;l;l=l.nextSibling){let c;if(q(l))c=l.getClientRects();else if(ve(l))c=ut(l,0,l.nodeValue.length).getClientRects();else continue;for(let d=0;du.top+1&&(t=="up"?o.top-u.top>(u.bottom-o.top)*2:u.bottom-o.bottom>(o.bottom-u.top)*2))return!1}}return!0})}const Ly=/[\u0590-\u08ac]/;function Py(n,e,t){let{$head:s}=e.selection;if(!s.parent.isTextblock)return!1;let i=s.parentOffset,r=!i,o=i==s.parent.content.size,l=n.domSelection();return l?!Ly.test(s.parent.textContent)||!l.modify?t=="left"||t=="backward"?r:o:Pc(n,e,()=>{let{focusNode:c,focusOffset:d,anchorNode:u,anchorOffset:p}=n.domSelectionRange(),f=l.caretBidiLevel;l.modify("move",t,"character");let h=s.depth?n.docView.domAfterPos(s.before()):n.dom,{focusNode:g,focusOffset:b}=n.domSelectionRange(),m=g&&!rn(h,g)||c==g&&d==b;try{l.collapse(u,p),c&&(c!=u||d!=p)&&l.extend&&l.extend(c,d)}catch(v){}return f!=null&&(l.caretBidiLevel=f),m}):s.pos==s.start()||s.pos==s.end()}let dl=null,ul=null,pl=!1;function By(n,e,t){return dl==e&&ul==t?pl:(dl=e,ul=t,pl=t=="up"||t=="down"?Ry(n,e,t):Py(n,e,t))}const Ge=0,fl=1,Ut=2,Ze=3;class gs{constructor(e,t,s,i){this.parent=e,this.children=t,this.dom=s,this.contentDOM=i,this.dirty=Ge,s.pmViewDesc=this}matchesWidget(e){return!1}matchesMark(e){return!1}matchesNode(e,t,s){return!1}matchesHack(e){return!1}parseRule(e){return null}stopEvent(e){return!1}get size(){let e=0;for(let t=0;tCe(this.contentDOM);else if(this.contentDOM&&this.contentDOM!=this.dom&&this.dom.contains(this.contentDOM))i=!!(e.compareDocumentPosition(this.contentDOM)&4);else if(this.dom.firstChild){if(t==0)for(let r=e;;r=r.parentNode){if(r==this.dom){i=!1;break}if(r.previousSibling)break}if(i==null&&t==e.childNodes.length)for(let r=e;;r=r.parentNode){if(r==this.dom){i=!0;break}if(r.nextSibling)break}}return(i==null?s>0:i)?this.posAtEnd:this.posAtStart}nearestDesc(e,t=!1){for(let s=!0,i=e;i;i=i.parentNode){let r=this.getDesc(i),o;if(r&&(!t||r.node))if(s&&(o=r.nodeDOM)&&!(q(o)?rn(o,e):o==e))s=!1;else return r}}getDesc(e){let t=e.pmViewDesc;for(let s=t;s;s=s.parent)if(s==this)return t}posFromDOM(e,t,s){for(let i=e;i;i=i.parentNode){let r=this.getDesc(i);if(r)return r.localPosFromDOM(e,t,s)}return-1}descAt(e){for(let t=0,s=0;te){i=e-r;break}r=l}if(i)return this.children[s].domFromPos(i-this.children[s].border,t);for(;s>0;s--){let r=this.children[s-1];if(r.size||!(r instanceof _c||r instanceof Bc&&r.side>=0))break}if(t<=0){let r,o=!0;for(;r=s?this.children[s-1]:null,!(!r||r.dom.parentNode==this.contentDOM);s--,o=!1);return r&&t&&o&&!r.border&&!r.domAtom?r.domFromPos(r.size,t):{node:this.contentDOM,offset:r?Ce(r.dom)+1:0}}else{let r,o=!0;for(;r=s=u&&t<=d-c.border&&c.node&&c.contentDOM&&this.contentDOM.contains(c.contentDOM))return c.parseRange(e,t,u);e=o;for(let p=l;p>0;p--){let f=this.children[p-1];if(f.size&&f.dom.parentNode==this.contentDOM&&!f.emptyChildAt(1)){i=Ce(f.dom)+1;break}e-=f.size}i==-1&&(i=0)}if(i>-1&&(d>t||l==this.children.length-1)){t=d;for(let u=l+1;ug&&ot){let g=l;l=c,c=g}let h=document.createRange();h.setEnd(c.node,c.offset),h.setStart(l.node,l.offset),d.removeAllRanges(),d.addRange(h)}}ignoreMutation(e){return!this.contentDOM&&e.type!="selection"}get contentLost(){return this.contentDOM&&this.contentDOM!=this.dom&&!this.dom.contains(this.contentDOM)}markDirty(e,t){for(let s=0,i=0;i=s:es){let l=s+r.border,c=o-r.border;if(e>=l&&t<=c){this.dirty=e==s||t==o?Ut:fl,e==l&&t==c&&(r.contentLost||r.dom.parentNode!=this.contentDOM)?r.dirty=Ze:r.markDirty(e-l,t-l);return}else r.dirty=r.dom==r.contentDOM&&r.dom.parentNode==this.contentDOM&&!r.children.length?Ut:Ze}s=o}this.dirty=Ut}markParentsDirty(){let e=1;for(let t=this.parent;t;t=t.parent,e++){let s=e==1?Ut:fl;t.dirty{if(!r)return i;if(r.parent)return r.parent.posBeforeChild(r)})),!t.type.spec.raw){let l=q(o)?o:document.createElement("span");l!=o&&l.appendChild(o),l.hasAttribute("contenteditable")||(l.contentEditable="false"),l.classList.add("ProseMirror-widget")}super(e,[],o,null),this.widget=t,this.widget=t,r=this}matchesWidget(e){return this.dirty==Ge&&e.type.eq(this.widget.type)}parseRule(){return{ignore:!0}}stopEvent(e){let t=this.widget.spec.stopEvent;return t?t(e):!1}ignoreMutation(e){return e.type!="selection"||this.widget.spec.ignoreSelection}destroy(){this.widget.type.destroy(this.dom),super.destroy()}get domAtom(){return!0}get ignoreForSelection(){return!!this.widget.type.spec.relaxedSide}get side(){return this.widget.type.side}}class _y extends gs{constructor(e,t,s,i){super(e,[],t,null),this.textDOM=s,this.text=i}get size(){return this.text.length}localPosFromDOM(e,t){return e!=this.textDOM?this.posAtStart+(t?this.size:0):this.posAtStart+t}domFromPos(e){return{node:this.textDOM,offset:e}}ignoreMutation(e){return e.type==="characterData"&&e.target.nodeValue==e.oldValue}}class It extends gs{constructor(e,t,s,i,r){super(e,[],s,i),this.mark=t,this.spec=r}static create(e,t,s,i){let r=i.nodeViews[t.type.name],o=r&&r(t,i,s);return(!o||!o.dom)&&(o=ln.renderSpec(document,t.type.spec.toDOM(t,s),null,t.attrs)),new It(e,t,o.dom,o.contentDOM||o.dom,o)}parseRule(){return this.dirty&Ze||this.mark.type.spec.reparseInView?null:{mark:this.mark.type.name,attrs:this.mark.attrs,contentElement:this.contentDOM}}matchesMark(e){return this.dirty!=Ze&&this.mark.eq(e)}markDirty(e,t){if(super.markDirty(e,t),this.dirty!=Ge){let s=this.parent;for(;!s.node;)s=s.parent;s.dirty0&&(r=Ir(r,0,e,s));for(let l=0;l{if(!c)return o;if(c.parent)return c.parent.posBeforeChild(c)},s,i),u=d&&d.dom,p=d&&d.contentDOM;if(t.isText){if(!u)u=document.createTextNode(t.text);else if(!ve(u))throw new RangeError("Text must be rendered as a DOM text node")}else u||({dom:u,contentDOM:p}=ln.renderSpec(document,t.type.spec.toDOM(t),null,t.attrs));!p&&!t.isText&&u.nodeName!="BR"&&(u.hasAttribute("contenteditable")||(u.contentEditable="false"),t.type.spec.draggable&&(u.draggable=!0));let f=u;return u=Fc(u,s,t),d?c=new zy(e,t,s,i,u,p||null,f,d):t.isText?new ji(e,t,s,i,u,f):new Dt(e,t,s,i,u,p||null,f)}parseRule(e){if(this.node.type.spec.reparseInView)return null;let t={node:this.node.type.name,attrs:this.node.attrs};if(this.node.type.whitespace=="pre"&&(t.preserveWhitespace="full"),!this.contentDOM)t.getContent=()=>this.node.content;else if(!this.contentLost)t.contentElement=this.contentDOM;else{for(let s=this.children.length-1;s>=0;s--){let i=this.children[s];if(this.dom.contains(i.dom.parentNode)){t.contentElement=i.dom.parentNode;break}}if(!t.contentElement){let s=e&&e.find(i=>q(i)&&e.indexOf(i.parentNode)<0&&this.dom.contains(i));s?t.contentElement=s:t.getContent=()=>$.empty}}return t}matchesNode(e,t,s){return this.dirty==Ge&&e.eq(this.node)&&Gs(t,this.outerDeco)&&s.eq(this.innerDeco)}get size(){return this.node.nodeSize}get border(){return this.node.isLeaf?0:1}updateChildren(e,t){let s=this.node.inlineContent,i=t,r=e.composing?this.localCompositionInfo(e,t):null,o=r&&r.pos>-1?r:null,l=r&&r.pos<0,c=new Fy(this,o&&o.node,e),d=this.node.inlineContent,u=d&&this.node.isBlock;qy(this.node,this.innerDeco,(p,f,h)=>{p.spec.marks?c.syncToMarks(p.spec.marks,s,e,f):p.type.side>=0&&!h&&c.syncToMarks(f==this.node.childCount?ie.none:this.node.child(f).marks,s,e,f),c.placeWidget(p,e,i)},(p,f,h,g)=>{c.syncToMarks(p.marks,s,e,g),u&&p.isAtom&&!p.isText&&c.addHackNode("IMG",c.top);let b;c.findNodeMatch(p,f,h,g)||l&&e.state.selection.from>i&&e.state.selection.to-1&&c.updateNodeAt(p,f,h,b,e)||c.updateNextNode(p,f,h,e,g,i)||c.addNode(p,f,h,e,i),i+=p.nodeSize,d&&(u=p.isAtom&&!p.isText)}),c.syncToMarks([],s,e,0),this.node.isTextblock&&c.addTextblockHacks(),c.destroyRest(),(c.changed||this.dirty==Ut)&&(o&&this.protectLocalComposition(e,o),zc(this.contentDOM,this.children,e),Tn&&Uy(this.dom))}localCompositionInfo(e,t){let{from:s,to:i}=e.state.selection;if(!(e.state.selection instanceof U)||st+this.node.content.size)return null;let r=e.input.compositionNode;if(!r||!this.dom.contains(r.parentNode))return null;if(this.node.inlineContent){let o=r.nodeValue,l=Wy(this.node.content,o,s-t,i-t);return l<0?null:{node:r,pos:l,text:o}}else return{node:r,pos:-1,text:""}}protectLocalComposition(e,{node:t,pos:s,text:i}){if(this.getDesc(t))return;let r=t;for(;r.parentNode!=this.contentDOM;r=r.parentNode){for(;r.previousSibling;)r.parentNode.removeChild(r.previousSibling);for(;r.nextSibling;)r.parentNode.removeChild(r.nextSibling);r.pmViewDesc&&(r.pmViewDesc=void 0)}let o=new _y(this,r,t,i);e.input.compositionNodes.push(o),this.children=Ir(this.children,s,s+i.length,e,o)}update(e,t,s,i){return this.dirty==Ze||!e.sameMarkup(this.node)?!1:(this.updateInner(e,t,s,i),!0)}updateInner(e,t,s,i){this.updateOuterDeco(t),this.node=e,this.innerDeco=s,this.contentDOM&&this.updateChildren(i,this.posAtStart),this.dirty=Ge}updateOuterDeco(e){if(Gs(e,this.outerDeco))return;let t=!q(this.nodeDOM),s=this.dom;this.dom=jc(this.dom,this.nodeDOM,Nr(this.outerDeco,this.node,t),Nr(e,this.node,t)),this.dom!=s&&(s.pmViewDesc=void 0,this.dom.pmViewDesc=this),this.outerDeco=e}selectNode(){q(this.nodeDOM)&&(this.nodeDOM.classList.add("ProseMirror-selectednode"),(this.contentDOM||!this.node.type.spec.draggable)&&(this.nodeDOM.draggable=!0))}deselectNode(){q(this.nodeDOM)&&(this.nodeDOM.classList.remove("ProseMirror-selectednode"),(this.contentDOM||!this.node.type.spec.draggable)&&this.nodeDOM.removeAttribute("draggable"))}get domAtom(){return this.node.isAtom}}function hl(n,e,t,s,i){Fc(s,e,n);let r=new Dt(void 0,n,e,t,s,s,s);return r.contentDOM&&r.updateChildren(i,0),r}class ji extends Dt{constructor(e,t,s,i,r,o){super(e,t,s,i,r,null,o)}parseRule(){let e=this.nodeDOM.parentNode;for(;e&&e!=this.dom&&!e.pmIsDeco;)e=e.parentNode;return{skip:e||!0}}update(e,t,s,i){return this.dirty==Ze||this.dirty!=Ge&&!this.inParent()||!e.sameMarkup(this.node)?!1:(this.updateOuterDeco(t),(this.dirty!=Ge||e.text!=this.node.text)&&e.text!=this.nodeDOM.nodeValue&&(this.nodeDOM.nodeValue=e.text,i.trackWrites==this.nodeDOM&&(i.trackWrites=null)),this.node=e,this.dirty=Ge,!0)}inParent(){let e=this.parent.contentDOM;for(let t=this.nodeDOM;t;t=t.parentNode)if(t==e)return!0;return!1}domFromPos(e){return{node:this.nodeDOM,offset:e}}localPosFromDOM(e,t,s){return e==this.nodeDOM?this.posAtStart+Math.min(t,this.node.text.length):super.localPosFromDOM(e,t,s)}ignoreMutation(e){return e.type!="characterData"&&e.type!="selection"}slice(e,t,s){let i=this.node.cut(e,t),r=document.createTextNode(i.text);return new ji(this.parent,i,this.outerDeco,this.innerDeco,r,r)}markDirty(e,t){super.markDirty(e,t),this.dom!=this.nodeDOM&&(e==0||t==this.nodeDOM.nodeValue.length)&&(this.dirty=Ze)}get domAtom(){return!1}isText(e){return this.node.text==e}}class _c extends gs{parseRule(){return{ignore:!0}}matchesHack(e){return this.dirty==Ge&&this.dom.nodeName==e}get domAtom(){return!0}get ignoreForCoords(){return this.dom.nodeName=="IMG"}}class zy extends Dt{constructor(e,t,s,i,r,o,l,c){super(e,t,s,i,r,o,l),this.spec=c}update(e,t,s,i){if(this.dirty==Ze)return!1;if(this.spec.update&&(this.node.type==e.type||this.spec.multiType)){let r=this.spec.update(e,t,s);return r&&this.updateInner(e,t,s,i),r}else return!this.contentDOM&&!e.isLeaf?!1:super.update(e,t,s,i)}selectNode(){this.spec.selectNode?this.spec.selectNode():super.selectNode()}deselectNode(){this.spec.deselectNode?this.spec.deselectNode():super.deselectNode()}setSelection(e,t,s,i){this.spec.setSelection?this.spec.setSelection(e,t,s.root):super.setSelection(e,t,s,i)}destroy(){this.spec.destroy&&this.spec.destroy(),super.destroy()}stopEvent(e){return this.spec.stopEvent?this.spec.stopEvent(e):!1}ignoreMutation(e){return this.spec.ignoreMutation?this.spec.ignoreMutation(e):super.ignoreMutation(e)}}function zc(n,e,t){let s=n.firstChild,i=!1;for(let r=0;r>1,l=Math.min(o,e.length);for(;r-1)c>this.index&&(this.changed=!0,this.destroyBetween(this.index,c)),this.top=this.top.children[this.index];else{let u=It.create(this.top,e[o],t,s);this.top.children.splice(this.index,0,u),this.top=u,this.changed=!0}this.index=0,o++}}findNodeMatch(e,t,s,i){let r=-1,o;if(i>=this.preMatch.index&&(o=this.preMatch.matches[i-this.preMatch.index]).parent==this.top&&o.matchesNode(e,t,s))r=this.top.children.indexOf(o,this.index);else for(let l=this.index,c=Math.min(this.top.children.length,l+5);l0;){let l;for(;;)if(s){let d=t.children[s-1];if(d instanceof It)t=d,s=d.children.length;else{l=d,s--;break}}else{if(t==e)break e;s=t.parent.children.indexOf(t),t=t.parent}let c=l.node;if(c){if(c!=n.child(i-1))break;--i,r.set(l,i),o.push(l)}}return{index:i,matched:r,matches:o.reverse()}}function Hy(n,e){return n.type.side-e.type.side}function qy(n,e,t,s){let i=e.locals(n),r=0;if(i.length==0){for(let d=0;dr;)l.push(i[o++]);let g=r+f.nodeSize;if(f.isText){let m=g;o!m.inline):l.slice();s(f,b,e.forChild(r,f),h),r=g}}function Uy(n){if(n.nodeName=="UL"||n.nodeName=="OL"){let e=n.style.cssText;n.style.cssText=e+"; list-style: square !important",window.getComputedStyle(n).listStyle,n.style.cssText=e}}function Wy(n,e,t,s){for(let i=0,r=0;i=t){if(r>=s&&c.slice(s-e.length-l,s-l)==e)return s-e.length;let d=l=0&&d+e.length+l>=t)return l+d;if(t==s&&c.length>=s+e.length-l&&c.slice(s-l,s-l+e.length)==e)return s}}return-1}function Ir(n,e,t,s,i){let r=[];for(let o=0,l=0;o=t||u<=e?r.push(c):(dt&&r.push(c.slice(t-d,c.size,s)))}return r}function co(n,e=null){let t=n.domSelectionRange(),s=n.state.doc;if(!t.focusNode)return null;let i=n.docView.nearestDesc(t.focusNode),r=i&&i.size==0,o=n.docView.posFromDOM(t.focusNode,t.focusOffset,1);if(o<0)return null;let l=s.resolve(o),c,d;if(_i(t)){for(c=o;i&&!i.node;)i=i.parent;if(i&&i.node.isAtom&&W.isSelectable(i.node)&&i.parent&&!(i.node.isInline&&yy(t.focusNode,t.focusOffset,i.dom))){let p=i.posBefore;d=new W(o==p?l:s.resolve(p))}else if(Ue&&e=="key"&&o>n.state.selection.to&&q(t.focusNode)&&t.focusOffset==t.focusNode.childNodes.length&&i&&i.posAtStart>n.state.selection.to)for(let p=t.focusNode;;p=p.parentNode){if(getComputedStyle(p).overflow!="visible"){d=X.findFrom(s.resolve(i.posAtStart),1);break}if(p==i.dom||p.nextSibling||!p.parentNode||!q(p.parentNode))break}}else{if(t instanceof n.dom.ownerDocument.defaultView.Selection&&t.rangeCount>1){let p=o,f=o;for(let h=0;h{(t.anchorNode!=s||t.anchorOffset!=i)&&(e.removeEventListener("selectionchange",n.input.hideSelectionGuard),setTimeout(()=>{(!Vc(n)||n.state.selection.visible)&&n.dom.classList.remove("ProseMirror-hideselection")},20))})}function Jy(n){let e=n.domSelection();if(!e)return;let t=n.cursorWrapper.dom,s=t.nodeName=="IMG";s?e.collapse(t.parentNode,Ce(t)+1):e.collapse(t,0),!s&&!n.state.selection.visible&&je&&Nt<=11&&(t.disabled=!0,t.disabled=!1)}function Hc(n,e){if(e instanceof W){let t=n.docView.descAt(e.from);t!=n.lastSelectedViewDesc&&(yl(n),t&&t.selectNode(),n.lastSelectedViewDesc=t)}else yl(n)}function yl(n){n.lastSelectedViewDesc&&(n.lastSelectedViewDesc.parent&&n.lastSelectedViewDesc.deselectNode(),n.lastSelectedViewDesc=void 0)}function uo(n,e,t,s){return n.someProp("createSelectionBetween",i=>i(n,e,t))||U.between(e,t,s)}function kl(n){return n.editable&&!n.hasFocus()?!1:qc(n)}function qc(n){let e=n.domSelectionRange();if(!e.anchorNode)return!1;try{return rn(n.dom,e.anchorNode)&&(n.editable||rn(n.dom,e.focusNode))}catch(t){return!1}}function Gy(n){let e=n.docView.domFromPos(n.state.selection.anchor,0),t=n.domSelectionRange();return sn(e.node,e.offset,t.anchorNode,t.anchorOffset)}function Dr(n,e){let{$anchor:t,$head:s}=n.selection,i=e>0?t.max(s):t.min(s),r=i.parent.inlineContent?i.depth?n.doc.resolve(e>0?i.after():i.before()):null:i;return r&&X.findFrom(r,e)}function wt(n,e){return n.dispatch(n.state.tr.setSelection(e).scrollIntoView()),!0}function xl(n,e,t){let s=n.state.selection;if(s instanceof U)if(t.indexOf("s")>-1){let{$head:i}=s,r=i.textOffset?null:e<0?i.nodeBefore:i.nodeAfter;if(!r||r.isText||!r.isLeaf)return!1;let o=n.state.doc.resolve(i.pos+r.nodeSize*(e<0?-1:1));return wt(n,new U(s.$anchor,o))}else if(s.empty){if(n.endOfTextblock(e>0?"forward":"backward")){let i=Dr(n.state,e);return i&&i instanceof W?wt(n,i):!1}else if(!(Je&&t.indexOf("m")>-1)){let i=s.$head,r=i.textOffset?null:e<0?i.nodeBefore:i.nodeAfter,o;if(!r||r.isText)return!1;let l=e<0?i.pos-r.nodeSize:i.pos;return r.isAtom||(o=n.docView.descAt(l))&&!o.contentDOM?W.isSelectable(r)?wt(n,new W(e<0?n.state.doc.resolve(i.pos-r.nodeSize):i)):wt(n,new U(n.state.doc.resolve(e<0?l:l+r.nodeSize))):!1}}else return!1;else{if(s instanceof W&&s.node.isInline)return wt(n,new U(e>0?s.$to:s.$from));{let i=Dr(n.state,e);return i?wt(n,i):!1}}}function Wn(n,e){let t=n.pmViewDesc;return t?t.size==0&&(e<0||n.nextSibling||n.nodeName!="BR"):q(n)&&n.contentEditable=="false"}function pn(n,e){return e<0?Yy(n):Xy(n)}function Yy(n){let e=n.domSelectionRange(),t=e.focusNode,s=e.focusOffset;if(!t)return;let i,r,o=!1;for(Ue&&q(t)&&s0){if(!q(t))break;let l=t.childNodes[s-1];if(Wn(l,-1))i=t,r=--s;else if(ve(l))t=l,s=t.nodeValue.length;else break}else{if(Uc(t))break;{let l=t.previousSibling;for(;l&&Wn(l,-1);)i=t.parentNode,r=Ce(l),l=l.previousSibling;if(l)t=l,s=Ie(t);else{if(t=t.parentNode,t==n.dom)break;s=0}}}o?$r(n,t,s):i&&$r(n,i,r)}function Xy(n){let e=n.domSelectionRange(),t=e.focusNode,s=e.focusOffset;if(!t)return;let i=Ie(t),r,o;for(;;)if(s{n.state==i&>(n)},50)}function wl(n,e){let t=n.state.doc.resolve(e);if(!(Ee||Nc)&&t.parent.inlineContent){let i=n.coordsAtPos(e);if(e>t.start()){let r=n.coordsAtPos(e-1),o=(r.top+r.bottom)/2;if(o>i.top&&o1)return r.lefti.top&&o1)return r.left>i.left?"ltr":"rtl"}}return getComputedStyle(n.dom).direction=="rtl"?"rtl":"ltr"}function Sl(n,e,t){let s=n.state.selection;if(s instanceof U&&!s.empty||t.indexOf("s")>-1||Je&&t.indexOf("m")>-1)return!1;let{$from:i,$to:r}=s;if(!i.parent.inlineContent||n.endOfTextblock(e<0?"up":"down")){let o=Dr(n.state,e);if(o&&o instanceof W)return wt(n,o)}if(!i.parent.inlineContent){let o=e<0?i:r,l=s instanceof qe?X.near(o,e):X.findFrom(o,e);return l?wt(n,l):!1}return!1}function Cl(n,e){if(!(n.state.selection instanceof U))return!0;let{$head:t,$anchor:s,empty:i}=n.state.selection;if(!t.sameParent(s))return!0;if(!i)return!1;if(n.endOfTextblock(e>0?"forward":"backward"))return!0;let r=!t.textOffset&&(e<0?t.nodeBefore:t.nodeAfter);if(r&&!r.isText){let o=n.state.tr;return e<0?o.delete(t.pos-r.nodeSize,t.pos):o.delete(t.pos,t.pos+r.nodeSize),n.dispatch(o),!0}return!1}function Ml(n,e,t){n.domObserver.stop(),e.contentEditable=t,n.domObserver.start()}function e0(n){if(!$e||n.state.selection.$head.parentOffset>0)return!1;let{focusNode:e,focusOffset:t}=n.domSelectionRange();if(e&&q(e)&&t==0&&e.firstChild&&q(e.firstChild)&&e.firstChild.contentEditable=="false"){let s=e.firstChild;Ml(n,s,"true"),setTimeout(()=>Ml(n,s,"false"),20)}return!1}function t0(n){let e="";return n.ctrlKey&&(e+="c"),n.metaKey&&(e+="m"),n.altKey&&(e+="a"),n.shiftKey&&(e+="s"),e}function n0(n,e){let t=e.keyCode,s=t0(e);if(t==8||Je&&t==72&&s=="c")return Cl(n,-1)||pn(n,-1);if(t==46&&!e.shiftKey||Je&&t==68&&s=="c")return Cl(n,1)||pn(n,1);if(t==13||t==27)return!0;if(t==37||Je&&t==66&&s=="c"){let i=t==37?wl(n,n.state.selection.from)=="ltr"?-1:1:-1;return xl(n,i,s)||pn(n,i)}else if(t==39||Je&&t==70&&s=="c"){let i=t==39?wl(n,n.state.selection.from)=="ltr"?1:-1:1;return xl(n,i,s)||pn(n,i)}else{if(t==38||Je&&t==80&&s=="c")return Sl(n,-1,s)||pn(n,-1);if(t==40||Je&&t==78&&s=="c")return e0(n)||Sl(n,1,s)||pn(n,1);if(s==(Je?"m":"c")&&(t==66||t==73||t==89||t==90))return!0}return!1}function po(n,e){n.someProp("transformCopied",h=>{e=h(e,n)});let t=[],{content:s,openStart:i,openEnd:r}=e;for(;i>1&&r>1&&s.childCount==1&&s.firstChild.childCount==1;){i--,r--;let h=s.firstChild;t.push(h.type.name,h.attrs!=h.type.defaultAttrs?h.attrs:null),s=h.content}let o=n.someProp("clipboardSerializer")||ln.fromSchema(n.state.schema),l=Xc(),c=l.createElement("div");c.appendChild(o.serializeFragment(s,{document:l}));let d=c.firstChild,u,p=0;for(;d&&q(d)&&(u=Yc[d.nodeName.toLowerCase()]);){for(let h=u.length-1;h>=0;h--){let g=l.createElement(u[h]);for(;c.firstChild;)g.appendChild(c.firstChild);c.appendChild(g),p++}d=c.firstChild}d&&q(d)&&d.setAttribute("data-pm-slice",`${i} ${r}${p?` -${p}`:""} ${JSON.stringify(t)}`);let f=n.someProp("clipboardTextSerializer",h=>h(e,n))||e.content.textBetween(0,e.content.size,` +`),x:300,y:(s-(n.length-1)/2)*120,itemStyle:{color:"#e3efe8",borderColor:"#8ebaa6",borderWidth:1},label:{color:"#213f48"}}))],n.map(t=>({source:"platform",target:"home:"+t.id})))}const ap={class:"local-chart-wrap"},cp=["aria-label"],dp={key:0,class:"small text-secondary px-3",role:"status"},wn={__name:"LocalChart",props:{option:{type:Object,required:!0},label:String,active:{type:Boolean,default:!0},height:{type:Number,default:260}},emits:["select"],setup(n,{emit:e}){const t=n,s=e,i=P(null),r=P(!1);let o,l,c,d,u=!0,p=!1,f="",h="";function g(){o==null||o.dispose(),o=null,f="",h=""}function b(){!d&&u&&(d=requestAnimationFrame(()=>{d=null,m()}))}async function m(){if(!u||!i.value||!t.active){g();return}const v=Math.floor(i.value.clientWidth),S=Math.floor(i.value.clientHeight);if(!v||!S)return;if(!o){if(p)return;p=!0;try{const T=await Nu(()=>import("./charts-runtime-DBCaHPDW.js"),[]);if(!u||!t.active||!i.value)return;o=T.init(i.value,null,{renderer:"canvas",devicePixelRatio:Math.min(window.devicePixelRatio||1,2)}),o.on("click",O=>{var I;(I=O.data)!=null&&I.targetId&&s("select",O.data.targetId)}),r.value=!1}catch(T){r.value=!0,console.error("Local chart unavailable",T);return}finally{p=!1}}const A=getComputedStyle(document.documentElement),N=A.getPropertyValue("--ink").trim()||"#253b46",B=A.getPropertyValue("--ui-muted").trim()||"#627485",E=A.getPropertyValue("--ui-line").trim()||"#e3e9ef",M=JSON.stringify(t.option)+N+B+E;if(M!==f){const T={...t.option,animation:!1,backgroundColor:"transparent",textStyle:{color:N,fontFamily:"system-ui, Microsoft YaHei, sans-serif"},aria:{enabled:!0,description:t.label},tooltip:{trigger:"item",renderMode:"richText",confine:!0,...t.option.tooltip}};for(const O of["xAxis","yAxis"])T[O]&&(T[O]={...T[O],axisLabel:{color:B,...T[O].axisLabel},splitLine:{lineStyle:{color:E}}});T.series=(T.series||[]).map(O=>({...O,label:{color:N,...O.label}})),o.setOption(T,{notMerge:!0,lazyUpdate:!1}),f=M}const w=v+":"+S;w!==h&&(o.resize({width:v,height:S}),h=w)}return Ae(()=>[t.option,t.active],b,{deep:!0,flush:"post"}),$i(()=>{l=new ResizeObserver(b),l.observe(i.value),c=new MutationObserver(b),c.observe(document.documentElement,{attributes:!0,attributeFilter:["data-theme","data-density"]}),b()}),Bt(()=>{u=!1,cancelAnimationFrame(d),l==null||l.disconnect(),c==null||c.disconnect(),g()}),(v,S)=>(y(),x("div",ap,[a("div",{ref_key:"host",ref:i,class:"local-chart",role:"img","aria-label":n.label,style:Nn({height:n.height+"px"})},null,12,cp),r.value?(y(),x("p",dp,"图表暂未加载,可查看下方数据。")):D("",!0)]))}},up={class:"col-12 col-xl-4"},pp={class:"dashboard-welcome h-100"},fp={class:"dashboard-totals"},hp={class:"insight-scope"},mp={class:"col-12 d-md-none"},gp=["aria-expanded"],bp={class:"col-12 col-md-5 col-xl-3 dashboard-chart-column"},vp={class:"chart-card h-100"},yp={class:"chart-heading"},kp={class:"badge"},xp={key:1,class:"chart-empty"},wp={class:"chart-legend"},Sp={class:"col-12 col-md-7 col-xl-5 dashboard-chart-column"},Cp={class:"chart-card h-100"},Mp={key:1,class:"chart-empty"},Tp={key:2,class:"chart-data"},Ep={__name:"HomeInsights",setup(n){const e=ee(()=>ip(R.value.state.households)),t=P(!1),s=ee(()=>R.value.loggedIn&&R.value.page==="households"),i=ee(()=>(R.value.state.households||[]).map(r=>({label:r.name,count:r.deviceCount||0})).sort((r,o)=>o.count-r.count).slice(0,8));return(r,o)=>(y(),x("section",{class:De(["dashboard-grid row g-3 mb-4",{"charts-expanded":t.value}]),"aria-label":"已授权场所概览"},[a("div",up,[a("article",pp,[o[5]||(o[5]=a("span",{class:"insight-kicker"},"一处相连 · 各有归属",-1)),o[6]||(o[6]=a("h2",null,"家与日常,尽在掌握",-1)),o[7]||(o[7]=a("p",null,"从一处灯火,连接生活的每个空间。",-1)),a("div",fp,[a("div",null,[a("strong",null,k(e.value.total),1),o[1]||(o[1]=a("span",null,"家庭与场所",-1))]),a("div",null,[a("strong",null,k(e.value.devices),1),o[2]||(o[2]=a("span",null,"已登记设备",-1))]),a("div",null,[a("strong",null,k(e.value.areas),1),o[3]||(o[3]=a("span",null,"区域空间",-1))])]),a("div",hp,[G(be,{name:"shield"}),o[4]||(o[4]=C(" 仅汇总你有权访问的家庭与场所",-1))])])]),a("div",mp,[a("button",{class:"btn btn-outline-secondary w-100","aria-expanded":t.value,onClick:o[0]||(o[0]=l=>t.value=!t.value)},k(t.value?"收起图表统计":"展开图表统计"),9,gp)]),a("div",bp,[a("article",vp,[a("div",yp,[o[8]||(o[8]=a("h3",null,"空间分布",-1)),a("span",kp,k(e.value.total)+" 处",1)]),e.value.total?(y(),Qe(wn,{key:0,option:j(Na)(e.value.kinds),active:s.value,height:160,label:"场所分布:"+e.value.kinds.map(l=>l.label+l.count+"个").join(",")},null,8,["option","active","label"])):(y(),x("p",xp,"添加家庭或场所后显示分布")),a("div",wp,[(y(!0),x(H,null,J(e.value.kinds,l=>(y(),x("span",{key:l.key},[a("i",{style:Nn({background:l.color})},null,4),C(k(l.label)+" ",1),a("b",null,k(l.count),1)]))),128))])])]),a("div",Sp,[a("article",Cp,[o[10]||(o[10]=a("div",{class:"chart-heading"},[a("h3",null,"设备分布"),a("span",{class:"small text-secondary"},"按场所 · 最多显示 8 处")],-1)),i.value.length?(y(),Qe(wn,{key:0,option:j(Ia)(i.value),active:s.value,height:190,label:"各场所已登记设备:"+i.value.map(l=>l.label+l.count+"台").join(",")},null,8,["option","active","label"])):(y(),x("p",Mp,"暂无已授权场所")),i.value.length?(y(),x("details",Tp,[o[9]||(o[9]=a("summary",null,"查看统计数字",-1)),a("ul",null,[(y(!0),x(H,null,J(i.value,l=>(y(),x("li",{key:l.label},k(l.label)+":"+k(l.count)+" 台",1))),128))])])):D("",!0)])])],2))}},Ap={key:0,class:"panel","aria-label":"按世代浏览家庭"},Op={class:"d-flex justify-content-between align-items-start flex-wrap gap-3"},Np={key:0,class:"count-pill"},Ip={class:"mb-3"},Dp=["disabled"],$p={key:0,class:"alert alert-danger",role:"alert"},Rp={key:1,role:"status",class:"text-secondary"},Lp={class:"fw-semibold"},Pp={key:0,class:"mt-3 text-secondary"},Bp={key:0,class:"fs-6"},_p={class:"fw-semibold text-primary"},zp={class:"fw-normal text-secondary ms-2"},jp={class:"row g-3 mt-1"},Fp={class:"card-body"},Vp=["disabled","onClick"],Hp={key:0,class:"badge text-bg-primary ms-2"},qp={key:1,class:"text-secondary ms-2"},Up={class:"small text-secondary mt-2 mb-0"},Wp={class:"d-flex flex-wrap gap-2 mt-3"},Kp=["onClick"],Jp={key:0,class:"small text-secondary"},Gp={class:"d-flex flex-wrap gap-2 mt-3"},Yp=["disabled","onClick"],Xp={key:2,class:"mt-3"},Zp={class:"d-flex flex-wrap gap-2 mt-2"},Qp=["disabled","onClick"],ef={key:2,class:"text-secondary",role:"status"},tf={key:3,class:"alert alert-info"},nf={key:4,class:"border rounded p-3",open:""},sf={class:"d-flex flex-wrap gap-2 mt-3"},rf=["onClick"],of={key:5,class:"small text-secondary mt-3 mb-0"},lf={__name:"GenerationDirectory",props:{active:Boolean},setup(n){const e=n,t=P(null),s=P(""),i=P(""),r=P(!1);let o=0;async function l(){const h=++o;if(t.value=null,s.value="",i.value="",r.value=!1,!(!e.active||!R.value.loggedIn))try{const g=await K().api("/api/family-directory");h===o&&(t.value=g)}catch(g){h===o&&(s.value=g.message)}}Ae(()=>[e.active,R.value.loggedIn,R.value.session],l,{immediate:!0});const c=h=>h?(h<=10?["","一","二","三","四","五","六","七","八","九","十"][h]:"第"+h)+"世":"世次待考",d=h=>[...new Set(h.map(g=>g.generation))],u=ee(()=>{var g;const h=i.value.trim().toLocaleLowerCase();return(((g=t.value)==null?void 0:g.trees)||[]).map(b=>({...b,branches:b.branches.map(m=>({...m,people:m.people.filter(v=>!h||[v.name,...v.homes.map(S=>S.name)].join(" ").toLocaleLowerCase().includes(h))})).filter(m=>m.people.length)})).filter(b=>!h||b.branches.length)}),p=ee(()=>{var h;return new Set((((h=t.value)==null?void 0:h.trees)||[]).flatMap(g=>g.branches.flatMap(b=>b.people.map(m=>m.id)))).size});async function f(h,g,b=!1){if(r.value)return;const m=o;r.value=!0,s.value="";try{b?await K().viewMemberHistory(h.id,h.name,g):await K().viewPerson(h.id,g)}catch(v){m===o&&!v.stale&&(s.value=v.message)}finally{m===o&&(r.value=!1)}}return(h,g)=>{var b,m;return n.active?(y(),x("section",Ap,[a("div",Op,[a("div",null,[a("h2",null,[g[1]||(g[1]=C("家族世代 ",-1)),t.value?(y(),x("span",Np,k(p.value)+" 位家人",1)):D("",!0)]),g[2]||(g[2]=a("p",{class:"text-secondary"},"从长辈到晚辈,查看每个人的亲属、故事与家庭。一个家庭可以包含多代人。",-1))]),a("label",Ip,[g[3]||(g[3]=C("找家人",-1)),Y(a("input",{"onUpdate:modelValue":g[0]||(g[0]=v=>i.value=v),type:"search",class:"form-control",placeholder:"姓名或家庭名称",disabled:!t.value},null,8,Dp),[[At,i.value]])])]),g[7]||(g[7]=a("p",{class:"small text-secondary"},"一世从本支已知最早一代相对起算,不代表历史族谱中的绝对世次。未连接的分支分别展示,关系不足时标为“世次待考”。",-1)),s.value?(y(),x("div",$p,[C(k(s.value)+" ",1),a("button",{class:"btn btn-sm btn-outline-danger ms-2",onClick:l},"重新加载")])):t.value?D("",!0):(y(),x("p",Rp,"正在整理世代关系…")),(y(!0),x(H,null,J(u.value,v=>(y(),x("details",{key:v.id,class:"border rounded p-3 mb-3",open:""},[a("summary",Lp,"共用族谱 · "+k(v.homes.map(S=>S.name).join("、")),1),v.branches.length?D("",!0):(y(),x("p",Pp,"请先登记家庭成员,再连接亲属关系。")),(y(!0),x(H,null,J(v.branches,(S,A)=>{var N;return y(),x("section",{key:S.id,class:"mt-4"},[v.branches.length>1?(y(),x("h3",Bp,"分支 "+k(A+1)+" · "+k((N=S.people[0])==null?void 0:N.name),1)):D("",!0),(y(!0),x(H,null,J(d(S.people),B=>(y(),x("details",{key:B||"unknown",class:"border-start ps-3 mb-4",open:""},[a("summary",_p,[C(k(c(B))+" ",1),a("small",zp,k(S.people.filter(E=>E.generation===B).length)+" 人",1)]),a("div",jp,[(y(!0),x(H,null,J(S.people.filter(E=>E.generation===B),E=>{var M;return y(),x("article",{key:E.id,class:"col-12 col-md-6 col-xl-4"},[a("div",{class:De(["card h-100",{"border-primary bg-primary-subtle":E.self}])},[a("div",Fp,[a("button",{class:"btn btn-link p-0 fw-semibold fs-5 text-start",disabled:r.value,onClick:w=>f(E,v.familyId)},k(E.name),9,Vp),E.self?(y(),x("span",Hp,"本人")):D("",!0),E.lifeStatus==="deceased"?(y(),x("small",qp,"已故")):D("",!0),a("p",Up,k(E.self?"当前账号关联的家人":"人物档案 · 亲属关系 · 生平"),1),a("div",Wp,[(y(!0),x(H,null,J(E.homes,w=>(y(),x("button",{key:w.id,class:"btn btn-sm btn-outline-primary",onClick:T=>j(K)().enterHome(w.id)},k(w.name)+" →",9,Kp))),128)),E.homes.length?D("",!0):(y(),x("span",Jp,"暂无可访问的当前家庭关联"))]),a("div",Gp,[a("button",{class:"btn btn-sm btn-outline-primary",disabled:r.value,onClick:w=>f(E,v.familyId)},"查看人物与亲属",8,Yp)]),(M=E.journalHomes)!=null&&M.length?(y(),x("details",Xp,[g[4]||(g[4]=a("summary",{class:"small"},"个人阅历",-1)),a("div",Zp,[(y(!0),x(H,null,J(E.journalHomes,w=>(y(),x("button",{key:w.id,class:"btn btn-sm btn-outline-secondary",disabled:r.value,onClick:T=>f(E,w.id,!0)},k(w.name)+"的记事",9,Qp))),128))]),g[5]||(g[5]=a("p",{class:"small text-secondary mt-2 mb-0"},"按记事所属家庭查看,仅展示已授权的内容。",-1))])):D("",!0)])],2)])}),128))])]))),128))])}),128))]))),128)),t.value&&i.value.trim()&&!u.value.length?(y(),x("p",ef,"没有找到这位家人,可尝试其他姓名或清空搜索。")):D("",!0),t.value&&!t.value.trees.length?(y(),x("p",tf,"暂无可查看的家族资料。进入下方已授权家庭登记成员,或请家庭管理员授予族谱查看权限。")):D("",!0),(m=(b=t.value)==null?void 0:b.unplaced)!=null&&m.length?(y(),x("details",nf,[g[6]||(g[6]=a("summary",null,"我的家庭与其他场所",-1)),a("div",sf,[(y(!0),x(H,null,J(t.value.unplaced,v=>(y(),x("button",{key:v.id,class:"btn btn-outline-secondary",onClick:S=>j(K)().enterHome(v.id)},k(v.name)+" →",9,rf))),128))])])):D("",!0),t.value?(y(),x("p",of,"家人无需注册账号。人物档案沿用同一份,居住地址不决定亲属关系;这里仅展示你有权查看的资料。")):D("",!0)])):D("",!0)}}},af={id:"page-households",class:"page"},cf={class:"section-head"},df=["hidden"],uf={class:"btn-group",role:"group","aria-label":"浏览方式"},pf=["aria-pressed"],ff=["aria-pressed"],hf=["aria-pressed"],mf=["aria-expanded"],gf={id:"home-layout-options",class:"home-layout-controls"},bf=["disabled"],vf=["value"],yf=["disabled"],kf=["value"],xf={class:"inline-check"},wf=["disabled"],Sf={class:"inline-check"},Cf=["disabled"],Mf=["disabled"],Tf=["disabled"],Ef={key:0,class:"group-title"},Af={class:"home-card-grid"},Of=["draggable","onDragstart","onDrop"],Nf={class:"home-cover"},If=["src","alt"],Df={class:"home-cover-content"},$f={class:"site-heading"},Rf={class:"badge"},Lf=["data-edit-household"],Pf={class:"home-location"},Bf={class:"card-body"},_f={key:0,class:"home-order-actions"},zf=["disabled","aria-label","onClick"],jf=["disabled","aria-label","onClick"],Ff={class:"home-summary"},Vf={class:"home-numbers"},Hf={class:"compact-details"},qf={class:"home-card-actions"},Uf=["onClick"],Wf=["data-leadership"],Kf={key:0,class:"empty"},Jf={id:"home-global-topology",class:"network-overview"},Gf={class:"network-platform"},Yf={key:0,class:"chart-network-surface mb-3"},Xf={class:"platform-place-grid"},Zf=["onClick"],Qf={class:"badge"},eh={class:"home-pagination"},th={id:"home-page-info"},nh=["disabled"],sh=["disabled"],ih={__name:"HomeExplorer",setup(n){const e=P({revision:0,columns:2,rows:2,groupCity:!1,order:[]}),t=P(!1),s=P(!1),i=P(0),r=P(!1),o=P("generations"),l=P(!1),c=P(""),d=P("");let u="";Ae(R,E=>{var w;const M=((w=E.user)==null?void 0:w.id)+":"+E.session;u!==M&&(u=M,t.value=!1,s.value=!1,i.value=0,r.value=!1,o.value="generations",l.value=!1,c.value="",d.value=""),!t.value&&!s.value&&(e.value={revision:0,columns:2,rows:2,groupCity:!1,order:[],...E.state.householdLayout})},{immediate:!0});const p=ee(()=>{const E=R.value.state.households||[],M=new Map(E.map(w=>[w.id,w]));return[...new Set([...e.value.order,...E.map(w=>w.id)])].filter(w=>M.has(w)).map(w=>M.get(w))}),f=ee(()=>e.value.columns*e.value.rows),h=ee(()=>Math.max(1,Math.ceil(p.value.length/f.value)));Ae(h,E=>i.value=Math.min(i.value,E-1));const g=ee(()=>{var w;const E=p.value.slice(i.value*f.value,(i.value+1)*f.value);if(!e.value.groupCity)return[{name:"",items:E}];const M=new Map;for(const T of E){const O=[((w=T.geography)==null?void 0:w.country)||T.country,T.province,T.city||"地区待填写"].filter(Boolean).join(" / ");M.has(O)||M.set(O,[]),M.get(O).push(T)}return[...M].map(([T,O])=>({name:T,items:O}))}),b=E=>({home:"家庭",office:"办公场所",factory:"工厂"})[E.kind||"home"]||"场所",m=E=>{var M,w;return((w=(M=K()).address)==null?void 0:w.call(M,E))||[E.province,E.city,E.district].filter(Boolean).join(" · ")||"地区待填写"};function v(){t.value=!0,i.value=0,e.value.groupCity&&(r.value=!1),d.value="布局已调整,保存后下次登录会沿用。"}function S(E,M,w){if(s.value)return;const T=p.value.map(Z=>Z.id),O=T.indexOf(E),I=w?T.indexOf(w):O+M;O<0||I<0||I>=T.length||O===I||(T.splice(O,1),T.splice(I,0,E),e.value.order=T,t.value=!0,i.value=Math.floor(I/f.value))}function A(){t.value=!1,e.value={...R.value.state.householdLayout},i.value=0,d.value=""}async function N(){const E=u;s.value=!0;try{const M=await K().saveLayout({...e.value});if(E!==u)return;e.value=M,t.value=!1,d.value="布局与卡片顺序已保存"}catch(M){!M.stale&&E===u&&(d.value=M.message)}finally{E===u&&(s.value=!1)}}async function B(E,M=!1){await K().enterHome(E.id,M)}return(E,M)=>(y(),x("section",af,[a("div",cf,[M[13]||(M[13]=a("div",null,[a("h2",null," 家人与家庭 "),a("p",{class:"description mb-0"}," 以家人为起点,串起亲属关系、共同记忆与日常生活。 ")],-1)),a("button",{id:"new-household",class:"btn btn-primary",hidden:!j(R).platformAdmin}," + 新建家庭或场所 ",8,df)]),a("div",{class:De(["home-toolbar",{"home-options-open":l.value}])},[a("div",uf,[a("button",{class:De(["btn btn-outline-secondary",{active:o.value==="generations"}]),"aria-pressed":o.value==="generations",onClick:M[0]||(M[0]=w=>o.value="generations")},[G(be,{name:"tree"}),M[14]||(M[14]=C(" 家族世代",-1))],10,pf),a("button",{id:"home-card-view",class:De(["btn btn-outline-secondary",{active:o.value==="cards"}]),"aria-pressed":o.value==="cards",onClick:M[1]||(M[1]=w=>o.value="cards")},[G(be,{name:"grid"}),M[15]||(M[15]=C(" 家庭卡片",-1))],10,ff),a("button",{id:"home-topology-view",class:De(["btn btn-outline-secondary",{active:o.value==="topology"}]),"aria-pressed":o.value==="topology",onClick:M[2]||(M[2]=w=>o.value="topology")},[G(be,{name:"network"}),M[16]||(M[16]=C(" 场所网络 ",-1))],10,hf)]),Y(a("button",{class:"btn btn-outline-secondary home-layout-toggle","aria-expanded":l.value,"aria-controls":"home-layout-options",onClick:M[3]||(M[3]=w=>l.value=!l.value)},k(l.value?"收起设置":"布局设置"),9,mf),[[dn,o.value==="cards"]]),Y(a("div",gf,[a("label",null,[M[17]||(M[17]=C("每页 ",-1)),Y(a("select",{id:"home-columns","onUpdate:modelValue":M[4]||(M[4]=w=>e.value.columns=w),class:"form-select",disabled:s.value,onChange:v},[(y(),x(H,null,J(4,w=>a("option",{key:w,value:w},k(w)+" 列",9,vf)),64))],40,bf),[[Te,e.value.columns,void 0,{number:!0}]])]),M[20]||(M[20]=a("span",null,"×",-1)),Y(a("select",{id:"home-rows","onUpdate:modelValue":M[5]||(M[5]=w=>e.value.rows=w),"aria-label":"每页行数",class:"form-select",disabled:s.value,onChange:v},[(y(),x(H,null,J(4,w=>a("option",{key:w,value:w},k(w)+" 行",9,kf)),64))],40,yf),[[Te,e.value.rows,void 0,{number:!0}]]),a("label",xf,[Y(a("input",{id:"home-group-city","onUpdate:modelValue":M[6]||(M[6]=w=>e.value.groupCity=w),type:"checkbox",class:"form-check-input",disabled:s.value,onChange:v},null,40,wf),[[st,e.value.groupCity]]),M[18]||(M[18]=C("按城市分组",-1))]),a("label",Sf,[Y(a("input",{id:"home-arrange","onUpdate:modelValue":M[7]||(M[7]=w=>r.value=w),type:"checkbox",class:"form-check-input",disabled:e.value.groupCity||s.value},null,8,Cf),[[st,r.value]]),M[19]||(M[19]=C("调整顺序",-1))]),a("button",{id:"home-layout-save",class:"btn btn-primary",disabled:!t.value||s.value,onClick:N},k(s.value?"保存中…":"保存布局"),9,Mf),a("button",{id:"home-layout-reset",class:"btn btn-outline-secondary",disabled:!t.value||s.value,onClick:A}," 撤销 ",8,Tf)],512),[[dn,o.value==="cards"]])],2),Y(a("p",{id:"home-layout-status",role:"status",class:"small text-secondary"},k(d.value||"布局仅影响你的账号;手机端自动适配为单列。"),513),[[dn,o.value==="cards"]]),G(lf,{active:o.value==="generations"&&j(R).loggedIn&&j(R).page==="households"},null,8,["active"]),o.value==="topology"&&j(R).page==="households"&&j(R).loggedIn?(y(),Qe(Ep,{key:0})):D("",!0),Y(a("div",{id:"household-list",style:Nn({"--home-columns":e.value.columns})},[(y(!0),x(H,null,J(g.value,w=>(y(),x("section",{key:w.name,class:"home-city-group"},[w.name?(y(),x("h3",Ef,k(w.name),1)):D("",!0),a("div",Af,[(y(!0),x(H,null,J(w.items,T=>{var O,I;return y(),x("article",{key:T.id,class:"card home-card",draggable:r.value&&!s.value,onDragstart:Z=>{c.value=T.id,Z.dataTransfer.setData("text/plain",T.id)},onDragend:M[8]||(M[8]=Z=>c.value=""),onDragover:M[9]||(M[9]=Z=>r.value&&c.value&&Z.preventDefault()),onDrop:Ve(Z=>{r.value&&c.value&&S(c.value,0,T.id),c.value=""},["prevent"])},[a("div",Nf,[T.coverUrl?(y(),x("img",{key:0,src:T.coverUrl,alt:T.name+"封面",loading:"lazy"},null,8,If)):D("",!0),M[21]||(M[21]=a("div",{class:"cover-shade"},null,-1)),a("div",Df,[a("div",$f,[a("span",Rf,[C(k(b(T)),1),T.id===j(R).state.familyId?(y(),x(H,{key:0},[C(" · 当前")],64)):D("",!0)]),j(R).admin?(y(),x("button",{key:0,class:"btn btn-sm cover-edit","data-edit-household":T.id}," 编辑 ",8,Lf)):D("",!0)]),a("div",null,[a("h3",null,k(T.name),1),a("p",Pf,k(m(T)),1)])])]),a("div",Bf,[r.value?(y(),x("div",_f,[M[22]||(M[22]=a("span",null,"拖动排序",-1)),a("button",{class:"btn btn-sm btn-outline-secondary",disabled:((O=p.value[0])==null?void 0:O.id)===T.id||s.value,"aria-label":T.name+"前移",onClick:Z=>S(T.id,-1)}," ←",8,zf),a("button",{class:"btn btn-sm btn-outline-secondary",disabled:((I=p.value.at(-1))==null?void 0:I.id)===T.id||s.value,"aria-label":T.name+"后移",onClick:Z=>S(T.id,1)}," → ",8,jf)])):D("",!0),a("p",Ff,k(T.note||"记录家人、共同经历与日常生活。"),1),a("div",Vf,[a("span",null,[a("b",null,k(T.members||0),1),M[23]||(M[23]=C("成员",-1))]),a("span",null,[a("b",null,k(T.accounts||0),1),M[24]||(M[24]=C("授权账号",-1))]),a("span",null,k(b(T)),1)]),a("dl",Hf,[a("div",null,[a("dt",null,k(T.kind==="office"||T.kind==="factory"?"主要负责人":"家庭管理账号"),1),a("dd",null,k(T.ownerName||"待指定"),1)]),a("div",null,[M[25]||(M[25]=a("dt",null,"备用负责人",-1)),a("dd",null,k(T.successorName||"待指定"),1)])]),a("div",qf,[a("button",{class:"btn btn-primary",onClick:Z=>B(T)},[C(" 进入"+k(b(T))+" ",1),G(be,{name:"arrow"})],8,Uf),T.canAssignOwner?(y(),x("button",{key:0,class:"btn btn-link","data-leadership":T.id}," 负责人安排 ",8,Wf)):D("",!0)])])],40,Of)}),128))])]))),128)),p.value.length?D("",!0):(y(),x("div",Kf," 登录后查看已授权的家庭与场所。 "))],4),[[dn,o.value==="cards"]]),Y(a("div",Jf,[a("div",Gf,[G(be,{name:"network"}),a("div",null,[a("h3",null,k(j(R).brandName||"赵府")+" · 数字管家",1),a("p",null,k(p.value.length)+" 个已授权空间",1)])]),M[27]||(M[27]=a("p",{class:"description"}," 平台与场所的管理关系;进入场所查看内部设备及网络。 ",-1)),p.value.length?(y(),x("div",Yf,[G(wn,{option:j(lp)(p.value,j(R).brandName||"赵府"),active:j(R).loggedIn&&j(R).page==="households"&&o.value==="topology",height:340,label:"平台及已授权场所关系图;点击场所进入内部网络,下面也可通过卡片进入。",onSelect:M[10]||(M[10]=w=>B({id:w},!0))},null,8,["option","active"])])):D("",!0),a("div",Xf,[(y(!0),x(H,null,J(p.value,w=>(y(),x("button",{key:w.id,class:"card platform-place-node",onClick:T=>B(w,!0)},[a("span",Qf,k(b(w)),1),a("h3",null,k(w.name),1),a("p",null,k(m(w)),1),a("span",null,k(w.deviceCount||0)+" 台设备",1),a("small",null,k((w.networkAccesses||[]).map(j(Zr)).join(" · ")||"网络待登记"),1),M[26]||(M[26]=a("span",{class:"network-open"},"查看网络拓扑 →",-1))],8,Zf))),128))])],512),[[dn,o.value==="topology"]]),Y(a("div",eh,[a("span",th,"第 "+k(i.value+1)+" / "+k(h.value)+" 页 · 每页最多 "+k(f.value)+" 张",1),a("button",{id:"home-prev",class:"btn btn-outline-secondary",disabled:!i.value,onClick:M[11]||(M[11]=w=>i.value--)}," 上一页",8,nh),a("button",{id:"home-next",class:"btn btn-outline-secondary",disabled:i.value>=h.value-1,onClick:M[12]||(M[12]=w=>i.value++)}," 下一页 ",8,sh)],512),[[dn,o.value==="cards"]])]))}},rh={key:0,class:"network-status-block"},oh={class:"network-status-title"},lh=["disabled"],ah={key:0,class:"text-danger small",role:"status"},ch={key:0,class:"small text-secondary"},dh={key:1,class:"small text-secondary"},uh={key:2,class:"small text-secondary"},ph={class:"management-links"},fh=["href"],hh={key:0},mh={class:"network-check-time"},Qr={__name:"NetworkStatus",props:{device:{type:Object,required:!0},active:{type:Boolean,default:!0}},setup(n){const e=n,t=P(null),s=P(!1),i=P("");let r=0,o;const l=ee(()=>[e.device.id,e.device.source,e.device.managementHost,e.device.tailscaleHost,e.device.networkCidr,R.value.state.familyId,R.value.session,R.value.admin,e.active].join("|"));async function c(){const p=r;if(!(s.value||!R.value.admin||!e.active)){s.value=!0,i.value="";try{const f=await K().api("/api/devices/network?source="+encodeURIComponent(e.device.source)+"&id="+encodeURIComponent(e.device.id));p===r&&(t.value=f)}catch(f){p===r&&!f.stale&&(i.value=f.message)}finally{p===r&&(s.value=!1,o=setTimeout(c,35e3))}}}Ae(l,()=>{r++,clearTimeout(o),s.value=!1,t.value=null,i.value="",R.value.admin&&e.active&&c()},{immediate:!0}),Aa(()=>{r++,clearTimeout(o)});const d=ee(()=>t.value?t.value.targets.some(p=>p.reachable)?"网络可达":"未连通":"等待检查");function u(){clearTimeout(o),c()}return(p,f)=>{var h,g;return j(R).admin?(y(),x("div",rh,[a("div",oh,[a("span",null,[a("i",{class:De(["status-dot",{online:(h=t.value)==null?void 0:h.targets.some(b=>b.reachable)}])},null,2),C(k(s.value?"正在检查…":d.value),1)]),a("button",{class:"btn btn-sm btn-link",disabled:s.value,onClick:u},"检查网络",8,lh)]),i.value?(y(),x("p",ah,k(i.value),1)):D("",!0),t.value?(y(),x(H,{key:1},[(y(!0),x(H,null,J(t.value.targets,b=>(y(),x("div",{key:b.kind,class:"network-target"},[a("span",null,k(b.kind==="tailscale"?"Tailscale":"设备地址"),1),a("code",null,k(b.host),1),a("span",{class:De(b.reachable?"text-success":"text-secondary")},k(b.reachable?"服务可达":"未响应"),3)]))),128)),t.value.targets.length?D("",!0):(y(),x("p",ch,"请编辑设备档案,填写 IP 或域名。")),(g=t.value.tailscale)!=null&&g.available?(y(),x("p",dh,[C("Tailscale 节点"+k(t.value.tailscale.online?"在线":"离线"),1),t.value.tailscale.subnet?(y(),x(H,{key:0},[C(" · "+k(t.value.tailscale.subnetAvailable?"已发布":"未检测到")+" "+k(t.value.tailscale.subnet)+" 路由",1)],64)):D("",!0)])):t.value.tailscale?(y(),x("p",uh,k(t.value.tailscale.note),1)):D("",!0),a("div",ph,[(y(!0),x(H,null,J(t.value.links,b=>(y(),x("a",{key:b.kind,href:b.url,target:"_blank",rel:"noopener noreferrer",class:"btn btn-sm btn-outline-secondary"},[C("打开管理后台 · "+k(b.kind==="tailscale"?"Tailscale":"局域网")+" ↗",1),b.verified?D("",!0):(y(),x("span",hh,"(待连通)"))],8,fh))),128))]),a("small",mh,"检查于 "+k(new Date(t.value.checkedAt*1e3).toLocaleTimeString("zh-CN"))+" · 从服务器探测,打开后台需当前浏览器也能到达。",1)],64)):D("",!0)])):D("",!0)}}},gh={class:"mt-3"},bh=["disabled"],vh={class:"form-check"},yh={class:"d-flex flex-column gap-2 my-3"},kh=["value"],xh={key:0,class:"small text-secondary"},wh={key:0,class:"text-danger small",role:"alert"},Sh={key:1,class:"text-success small",role:"status"},Ch={__name:"VoicePermissions",props:{deviceId:String},setup(n){const e=n,t=P(!1),s=P([]),i=P([]),r=P(!0),o=P(""),l=P("");let c=!0;async function d(){try{const p=await K().api("/api/display-voice",{deviceId:e.deviceId,action:"settings"});c&&(t.value=p.enabled,s.value=p.allowed,i.value=p.candidates)}catch(p){c&&(o.value=p.message)}finally{c&&(r.value=!1)}}async function u(){if(!r.value){r.value=!0,o.value="",l.value="";try{await K().api("/api/display-voice",{deviceId:e.deviceId,action:"configure",enabled:t.value,allowed:s.value,consent:!0}),c&&(l.value="喊话接收权限已保存")}catch(p){c&&(o.value=p.message)}finally{c&&(r.value=!1)}}}return $i(d),Bt(()=>c=!1),(p,f)=>(y(),x("details",gh,[f[3]||(f[3]=a("summary",null,"家人喊话 · 接收权限",-1)),f[4]||(f[4]=a("p",{class:"small text-secondary mt-2"},"选择可以向此终端喊话的家人手机。对方按住说话、松开发送;终端 App 打开时播放,屏幕上可以停止播放。重新配对后需要重新授权。",-1)),a("fieldset",{disabled:r.value},[a("label",vh,[Y(a("input",{"onUpdate:modelValue":f[0]||(f[0]=h=>t.value=h),type:"checkbox",class:"form-check-input"},null,512),[[st,t.value]]),f[2]||(f[2]=C("允许接收所选家人的喊话",-1))]),a("div",yh,[(y(!0),x(H,null,J(i.value,h=>(y(),x("label",{key:h.id,class:"form-check"},[Y(a("input",{"onUpdate:modelValue":f[1]||(f[1]=g=>s.value=g),type:"checkbox",class:"form-check-input",value:h.id},null,8,kh),[[st,s.value]]),C(k(h.name),1)]))),128)),i.value.length?D("",!0):(y(),x("span",xh,"先让家人的手机完成配对,再选择喊话人。"))]),a("button",{class:"btn btn-outline-primary btn-sm",onClick:u},"保存接收权限")],8,bh),o.value?(y(),x("p",wh,k(o.value),1)):D("",!0),l.value?(y(),x("p",Sh,k(l.value),1)):D("",!0)]))}},Mh={key:0,class:"display-manager mt-3"},Th={key:0,class:"border rounded-3 p-3 mt-3"},Eh={class:"d-flex justify-content-between align-items-center gap-2 mb-3"},Ah={class:"small text-secondary"},Oh={class:"row g-2 hardware-grid"},Nh={class:"col-6"},Ih={class:"col-6"},Dh={class:"col-6"},$h={class:"col-6"},Rh={class:"small text-secondary mt-3"},Lh={key:0},Ph={key:0,class:"small text-secondary"},Bh={class:"small mb-3"},_h=["disabled"],zh={key:1,class:"tv-remote-preview"},jh=["src"],Fh={class:"small text-secondary"},Vh={class:"mt-3"},Hh={class:"row g-2 my-2"},qh={class:"col-12"},Uh={class:"col-6"},Wh={class:"col-6"},Kh=["disabled"],Jh={key:0,class:"my-3"},Gh=["value"],Yh=["href"],Xh=["disabled","onClick"],Zh={key:2,class:"alert alert-success mt-3"},Qh={class:"fs-3 font-monospace"},em={key:4,class:"text-danger mt-2",role:"alert"},tm={__name:"DisplayManager",props:{device:Object},setup(n){const e=n,t=P(!1),s=P(null),i=P([]),r=P(""),o=P(!1),l=P(""),c=P(""),d=P(0);let u,p=0,f="";const h=ee(()=>{var w;return(w=R.value.state.households)==null?void 0:w.find(T=>T.id===R.value.state.familyId)}),g=P(""),b=P(""),m=P(""),v=P(""),S=w=>w+"?deviceId="+encodeURIComponent(e.device.id),A=ee(()=>{var w;return((w=s.value)==null?void 0:w.hardware)||{}}),N=(w,T=1)=>typeof w=="number"?w.toFixed(T):"未提供",B=w=>w?new Date(w*1e3).toLocaleString("zh-CN"):"尚未上报";async function E(){const w=p;if(t.value)try{const T=await K().api(S("/api/displays/hardware"));if(w!==p)return;if(s.value=T,Date.now(){var T;if(p++,clearTimeout(u),l.value="",v.value="",r.value="",c.value="",d.value=0,f&&(URL.revokeObjectURL(f),f=""),w){const O=p;g.value=((T=h.value)==null?void 0:T.city)||"",b.value=g.value==="济南市"?"36.67":"",m.value=g.value==="济南市"?"116.99":"",E();try{const I=await K().api(S("/api/displays"));O===p&&(i.value=I.items)}catch(I){O===p&&(r.value=I.message)}}}),Ae(()=>[R.value.state.familyId,R.value.session,R.value.page,e.device.id].join("|"),()=>t.value=!1),Aa(()=>{p++,clearTimeout(u),f&&URL.revokeObjectURL(f)}),(w,T)=>{var O,I,Z,Oe,le,ae,_,fe,rt,yt,F,jt,xs,Ft,cn;return j(R).admin?(y(),x("div",Mh,[a("button",{class:"btn btn-outline-primary btn-sm",onClick:T[0]||(T[0]=te=>t.value=!t.value)},k(t.value?"收起显示终端管理":"显示终端管理 · 状态与模拟屏"),1),t.value?(y(),x("section",Th,[a("div",Eh,[a("strong",null,k(n.device.name),1),a("span",{class:De(["badge",(O=s.value)!=null&&O.online?"text-bg-success":"text-bg-secondary"])},k((I=s.value)!=null&&I.online?"在线 · 心跳正常":(Z=s.value)!=null&&Z.paired?"未收到心跳":"尚未绑定"),3)]),a("p",Ah,"所属:"+k((Oe=h.value)==null?void 0:Oe.name)+" · 最后心跳 "+k(B((le=s.value)==null?void 0:le.lastSeen)),1),a("div",Oh,[a("div",Nh,[T[7]||(T[7]=a("span",null,"处理器温度",-1)),a("strong",null,k(N(A.value.temperatureC))+k(A.value.temperatureC!=null?" °C":""),1),a("small",null,k(A.value.temperatureSource||"等待传感器上报"),1)]),a("div",Ih,[T[8]||(T[8]=a("span",null,"整机功率",-1)),a("strong",null,k(N(A.value.powerW))+k(A.value.powerW!=null?" W":""),1),a("small",null,k(A.value.powerSource||"需设备传感器或计量插座"),1)]),a("div",Dh,[T[9]||(T[9]=a("span",null,"可用内存",-1)),a("strong",null,k(N(A.value.memoryAvailableMB,0))+" / "+k(N(A.value.memoryTotalMB,0))+" MB",1)]),a("div",$h,[T[10]||(T[10]=a("span",null,"可用存储",-1)),a("strong",null,k(N(A.value.storageAvailableGB))+" / "+k(N(A.value.storageTotalGB))+" GB",1)])]),a("p",Rh,[C(k(A.value.model||n.device.model)+" · Android "+k(A.value.osVersion||"—")+" · IP "+k(A.value.ip||n.device.managementHost||"—"),1),T[11]||(T[11]=a("br",null,null,-1)),C(k(A.value.screenWidth||"—")+" × "+k(A.value.screenHeight||"—")+" · "+k(A.value.foreground?"看板在前台":"看板未在前台")+" · "+k(A.value.screenOn?"屏幕亮":"屏幕状态待确认"),1),(ae=s.value)!=null&&ae.online?D("",!0):(y(),x("span",Lh," · 当前数值为最后一次上报"))]),T[22]||(T[22]=a("h4",{class:"fs-6"},"异常与报警",-1)),(fe=(_=s.value)==null?void 0:_.alerts)!=null&&fe.some(te=>!te.cleared)?D("",!0):(y(),x("p",Ph,k((rt=s.value)!=null&&rt.online?"当前无活动报警":"连接恢复后继续检查硬件状态"),1)),(y(!0),x(H,null,J((F=(yt=s.value)==null?void 0:yt.alerts)==null?void 0:F.filter(te=>!te.cleared),te=>(y(),x("div",{key:te.code,class:De(["alert py-2 small",te.severity==="critical"?"alert-danger":"alert-warning"])},k(te.message)+" · "+k(B(te.opened)),3))),128)),a("details",Bh,[T[12]||(T[12]=a("summary",null,"报警记录与规则",-1)),T[13]||(T[13]=a("p",null,"心跳中断超过 100 秒;处理器 ≥75°C 提醒、≥85°C 严重;可用内存低于 5%;可用存储低于 0.5 GB;看板退出前台。数值来自显示终端上报。",-1)),(y(!0),x(H,null,J((jt=s.value)==null?void 0:jt.alerts,(te,ws)=>(y(),x("div",{key:ws},k(te.cleared?"已恢复":"处理中")+" · "+k(te.message)+" · "+k(B(te.opened)),1))),128))]),a("button",{class:"btn btn-primary btn-sm",disabled:o.value||!((xs=s.value)!=null&&xs.online),onClick:T[1]||(T[1]=te=>M("preview"))},"查看模拟屏 · 60 秒",8,_h),T[23]||(T[23]=a("p",{class:"small text-secondary mt-2"},"显示显示终端当前家庭看板的应用画面,约 20 秒更新一次;退出看板后不显示其他应用。预览仅短时保存在内存。",-1)),c.value?(y(),x("figure",zh,[a("img",{src:c.value,alt:"显示终端家庭看板的真实应用画面"},null,8,jh),a("figcaption",Fh,"画面时间:"+k(B((Ft=s.value)==null?void 0:Ft.previewAt)),1)])):D("",!0),a("details",Vh,[T[18]||(T[18]=a("summary",null,"展示授权与天气设置",-1)),a("div",Hh,[a("label",qh,[T[14]||(T[14]=C("天气城市",-1)),Y(a("input",{"onUpdate:modelValue":T[2]||(T[2]=te=>g.value=te),class:"form-control",maxlength:"60"},null,512),[[At,g.value]])]),a("label",Uh,[T[15]||(T[15]=C("纬度",-1)),Y(a("input",{"onUpdate:modelValue":T[3]||(T[3]=te=>b.value=te),class:"form-control",type:"number",step:"0.0001",min:"-90",max:"90"},null,512),[[At,b.value]])]),a("label",Wh,[T[16]||(T[16]=C("经度",-1)),Y(a("input",{"onUpdate:modelValue":T[4]||(T[4]=te=>m.value=te),class:"form-control",type:"number",step:"0.0001",min:"-180",max:"180"},null,512),[[At,m.value]])])]),T[19]||(T[19]=a("p",{class:"small text-secondary"},"链接有效期一年,仅可展示本家庭概况、设备状态与本人同意共享的家人位置。重新生成会停用旧链接。",-1)),a("button",{class:"btn btn-outline-primary btn-sm",disabled:o.value,onClick:T[5]||(T[5]=te=>M("create"))},"生成 App 配对码",8,Kh),l.value?(y(),x("div",Jh,[a("label",null,[T[17]||(T[17]=C("本次展示链接(请仅交给这台显示终端)",-1)),a("input",{class:"form-control",value:l.value,readonly:"",onFocus:T[6]||(T[6]=te=>te.target.select())},null,40,Gh)]),a("a",{class:"btn btn-sm btn-outline-secondary mt-2",href:l.value,target:"_blank",rel:"noreferrer"},"打开看板",8,Yh)])):D("",!0),(y(!0),x(H,null,J(i.value.filter(te=>!te.revoked),te=>(y(),x("div",{key:te.id,class:"d-flex gap-2 align-items-center small mt-2"},[a("span",null,"授权至 "+k(B(te.expires_at)),1),a("button",{class:"btn btn-sm btn-outline-danger",disabled:o.value,onClick:ws=>M("revoke",te.id)},"停用展示权限",8,Xh)]))),128))]),v.value&&l.value?(y(),x("div",Zh,[T[20]||(T[20]=C("App 配对码:",-1)),a("strong",Qh,k(v.value),1),T[21]||(T[21]=a("div",{class:"small"},"在“赵府家庭屏”App 输入,10 分钟内有效,使用一次即失效。App 摄像头画面在本地网络直接播放。",-1))])):D("",!0),(cn=s.value)!=null&&cn.paired?(y(),Qe(Ch,{key:n.device.id,"device-id":n.device.id},null,8,["device-id"])):D("",!0),r.value?(y(),x("p",em,k(r.value),1)):D("",!0)])):D("",!0)])):D("",!0)}}},$a=In(tm,[["__scopeId","data-v-2d075cdb"]]),nm={key:0,class:"mt-3"},sm={key:0,class:"border rounded p-3 mt-2"},im={class:"w-100"},rm=["value"],om={class:"d-flex gap-2 small mb-2"},lm=["disabled"],am={key:1,class:"small mt-2",role:"status"},Ra={__name:"DeviceTransfer",props:{device:Object},setup(n){const e=n,t=P(!1),s=P(""),i=P(!1),r=P(!1),o=P(""),l=ee(()=>(R.value.state.households||[]).filter(d=>d.id!==R.value.state.familyId));Ae(()=>R.value.state.familyId,()=>{t.value=!1,s.value="",i.value=!1,o.value=""});async function c(){if(!(!i.value||!s.value)){r.value=!0,o.value="";try{await K().api("/api/devices/transfer",{source:e.device.source,id:e.device.id,targetFamilyId:s.value}),K().notify("设备已转移,电视需在新家庭重新授权。"),t.value=!1,await K().refresh()}catch(d){o.value=d.message}finally{r.value=!1}}}return(d,u)=>{var p;return((p=j(R).user)==null?void 0:p.role)==="admin"?(y(),x("div",nm,[a("button",{class:"btn btn-sm btn-outline-secondary",onClick:u[0]||(u[0]=f=>t.value=!t.value)},"转移到其他家庭"),t.value?(y(),x("div",sm,[a("label",im,[u[4]||(u[4]=C("目标家庭 / 公司 / 工厂",-1)),Y(a("select",{"onUpdate:modelValue":u[1]||(u[1]=f=>s.value=f),class:"form-select mt-2"},[u[3]||(u[3]=a("option",{value:""},"请选择",-1)),(y(!0),x(H,null,J(l.value,f=>(y(),x("option",{key:f.id,value:f.id},k(f.name),9,rm))),128))],512),[[Te,s.value]])]),u[6]||(u[6]=a("p",{class:"small text-secondary mt-2"},"保留设备编号与基本档案。所属区域、负责人和上级设备需重新设置;电视旧展示授权会停用。关联录像机的摄像头需先解除关联。",-1)),a("label",om,[Y(a("input",{"onUpdate:modelValue":u[2]||(u[2]=f=>i.value=f),type:"checkbox"},null,512),[[st,i.value]]),u[5]||(u[5]=C("确认将这台设备转移给目标家庭管理",-1))]),a("button",{class:"btn btn-primary btn-sm",disabled:r.value||!i.value||!s.value,onClick:c},"确认转移",8,lm)])):D("",!0),o.value?(y(),x("p",am,k(o.value),1)):D("",!0)])):D("",!0)}}},cm={id:"asset-list"},dm={class:"group-title"},um={class:"count-pill"},pm={class:"device-card-grid"},fm={class:"card-body"},hm={class:"device-card-heading"},mm={class:"device-symbol"},gm={class:"flex-grow-1"},bm={class:"small text-secondary"},vm=["onClick"],ym={class:"device-location"},km={class:"compact-details"},xm={class:"font-monospace"},wm={key:0},Sm={key:0,class:"device-tags"},Cm={class:"card-footer device-card-actions"},Mm=["onClick"],Tm=["onClick"],Em=["onClick"],Am={key:0,class:"empty"},Om={__name:"DeviceCollection",setup(n){const e=i=>(R.value.state.cameras||[]).filter(r=>i.source==="camera"?r.assetId===i.id:r.recorderId===i.id||r.archiveRecorderId===i.id),t=i=>({["data-"+(i.source==="camera"?"edit-asset":i.source==="recorder"?"edit-recorder":"edit-device")]:i.id}),s=i=>/路由|网关|服务器/.test(i.deviceType)||/gl\.inet/i.test(i.brand||"");return(i,r)=>(y(),x("div",cm,[(y(!0),x(H,null,J(j(ze).groups,o=>(y(),x("section",{key:o.key,class:"device-group"},[a("h3",dm,[C(k(o.labels.join(" / ")||"全部设备")+" ",1),a("span",um,k(o.items.length),1)]),a("div",pm,[(y(!0),x(H,null,J(o.items,l=>{var c,d,u;return y(),x("article",{key:l.source+l.id,class:"card device-card"},[a("div",fm,[a("div",hm,[a("div",mm,[G(be,{name:l.source==="camera"?"camera":s(l)?"router":"devices"},null,8,["name"])]),a("div",gm,[a("span",bm,k(l.deviceType),1),a("h3",null,[a("button",{class:"device-title",onClick:p=>j(K)().enterDevice(l.source,l.id)},k(l.name),9,vm)])]),j(R).admin?(y(),x("button",Iu({key:0,class:"btn btn-sm btn-outline-secondary"},{ref_for:!0},t(l))," 编辑 ",16)):D("",!0)]),a("p",ym,[C(k(((d=(c=j(K)()).location)==null?void 0:d.call(c,l.siteId))||"区域待填写"),1),l.point?(y(),x(H,{key:0},[C(" · "+k(l.point),1)],64)):D("",!0)]),a("dl",km,[a("div",null,[r[0]||(r[0]=a("dt",null,"品牌型号",-1)),a("dd",null,k([l.brand,l.model].filter(Boolean).join(" / ")||"未填写"),1)]),a("div",null,[r[1]||(r[1]=a("dt",null,"设备地址",-1)),a("dd",xm,k(l.networkHosts.join(" / ")||"未填写"),1)]),a("div",null,[r[2]||(r[2]=a("dt",null,"网络",-1)),a("dd",null,k(j(Zr)(l.networkAccess)),1)]),a("div",null,[r[3]||(r[3]=a("dt",null,"所有人 / 负责人",-1)),a("dd",null,k(l.ownerName||"待指定")+" / "+k(l.managerName||"待指定"),1)]),l.source!=="device"?(y(),x("div",wm,[r[4]||(r[4]=a("dt",null,"镜头通道",-1)),a("dd",null,k(e(l).length)+" 个已配置",1)])):D("",!0)]),(u=l.tags)!=null&&u.length?(y(),x("div",Sm,[(y(!0),x(H,null,J(l.tags,p=>(y(),x("span",{key:p},k(p),1))),128))])):D("",!0),s(l)?(y(),Qe(Qr,{key:1,device:l,active:j(R).page==="objects"&&j(ze).mode==="cards"},null,8,["device","active"])):D("",!0),l.source==="device"&&/电视|显示|大屏/.test(l.deviceType)?(y(),Qe($a,{key:2,device:l},null,8,["device"])):D("",!0),G(Ra,{device:l},null,8,["device"])]),a("div",Cm,[a("button",{class:"btn btn-sm btn-outline-secondary",onClick:p=>j(K)().enterDevice(l.source,l.id,"device")}," 设备详情",8,Mm),l.source!=="device"?(y(),x(H,{key:0},[j(R).admin?(y(),x("button",{key:0,class:"btn btn-sm btn-outline-secondary",onClick:p=>j(K)().enterDevice(l.source,l.id,"cameras")}," 配置镜头",8,Tm)):D("",!0),e(l).length?(y(),x("button",{key:1,class:"btn btn-sm btn-primary",onClick:p=>j(K)().enterDevice(l.source,l.id,"live")}," 实时画面 ",8,Em)):D("",!0)],64)):D("",!0)])])}),128))])]))),128)),j(ze).devices.length?D("",!0):(y(),x("div",Am,[G(be,{name:"devices"}),r[5]||(r[5]=a("h3",null,"当前范围没有设备",-1)),r[6]||(r[6]=a("p",null,"调整筛选条件,或添加摄像机、路由器、灯等设备。",-1))]))]))}},Nm={key:0,class:"network-diagram"},Im={class:"diagram-toolbar"},Dm={class:"small text-secondary"},$m={class:"chart-network-surface"},Rm={__name:"NetworkDiagram",setup(n){const e=P(0),t=ee(()=>op(ze.value.rows,K().location)),s=ee(()=>R.value.loggedIn&&R.value.page==="objects"&&ze.value.mode==="topology");Ae(()=>R.value.session+":"+R.value.state.familyId,()=>e.value++);function i(r){const o=ze.value.rows.find(l=>l.device.id===r);o&&K().enterDevice(o.device.source,r,"device")}return(r,o)=>j(ze).rows.length?(y(),x("div",Nm,[a("div",Im,[a("div",null,[o[1]||(o[1]=a("span",{class:"diagram-dot"},null,-1)),o[2]||(o[2]=a("strong",null,"设备连接图",-1)),a("span",Dm,k(j(ze).rows.length)+" 台设备 · "+k(t.value.series[0].links.length)+" 条已登记连接",1)]),a("button",{class:"btn btn-sm btn-outline-secondary",onClick:o[0]||(o[0]=l=>e.value++)},"重置视图")]),a("div",$m,[(y(),Qe(wn,{key:e.value,option:t.value,active:s.value,height:400,label:"已登记设备连接图,可拖动缩放;下方设备详情提供相同信息及操作。",onSelect:i},null,8,["option","active"]))]),o[3]||(o[3]=a("p",{class:"diagram-note"},"拖动平移、滚轮或双指缩放;点击节点打开档案。未登记上级的设备独立显示;接入方式不代表在线状态。",-1))])):D("",!0)}},Lm={id:"device-topology",hidden:""},Pm={class:"panel network-map"},Bm={class:"network-platform"},_m={class:"topology-nodes"},zm={class:"card-body"},jm={class:"device-card-heading"},Fm={class:"flex-grow-1"},Vm={class:"small text-secondary"},Hm=["onClick"],qm=["onClick"],Um={class:"device-location"},Wm={class:"network-facts"},Km={key:0},Jm={key:1},Gm={key:2},Ym={key:3},Xm={key:0,class:"empty"},Zm={__name:"NetworkMap",setup(n){const e=ee(()=>(R.value.state.households||[]).find(t=>t.id===R.value.state.familyId));return(t,s)=>{var i;return y(),x("div",Lm,[a("section",Pm,[a("div",Bm,[G(be,{name:"network"}),a("div",null,[a("h3",null,k(((i=e.value)==null?void 0:i.name)||"当前场所"),1),a("p",null,k(j(ze).devices.length)+" 台设备 · 随设备档案自动更新",1)])]),s[7]||(s[7]=a("p",{class:"description"}," 连线来自已确认的上级设备关系。上级未填写时单独列出;不代表已自动发现所有交换机或布线。 ",-1)),G(Rm),s[8]||(s[8]=a("h3",{class:"network-details-heading"},"设备与连接详情",-1)),a("div",_m,[(y(!0),x(H,null,J(j(ze).rows,r=>{var o,l;return y(),x("article",{key:r.device.id,class:De(["network-node card",{nested:r.depth>0}]),style:Nn({"--depth":Math.min(r.depth,5)})},[a("div",zm,[a("div",jm,[G(be,{name:r.device.source==="camera"?"camera":"router"},null,8,["name"]),a("div",Fm,[a("span",Vm,k(r.device.deviceType)+" · "+k(j(Zr)(r.device.networkAccess)),1),a("h3",null,[a("button",{class:"device-title",onClick:c=>j(K)().enterDevice(r.device.source,r.device.id)},k(r.device.name),9,Hm)])]),a("button",{class:"btn btn-sm btn-outline-secondary",onClick:c=>j(K)().enterDevice(r.device.source,r.device.id,"device")}," 详情 → ",8,qm)]),a("p",Um,[C(k(((l=(o=j(K)()).location)==null?void 0:l.call(o,r.device.siteId))||"未指定区域")+" ",1),r.device.point?(y(),x(H,{key:0},[C(" · "+k(r.device.point),1)],64)):D("",!0)]),a("div",Wm,[a("span",null,[s[0]||(s[0]=C("IP ",-1)),a("b",null,k(r.device.networkHosts.join(" / ")||"待填写"),1)]),r.device.tailscaleHost?(y(),x("span",Km,[s[1]||(s[1]=C("Tailscale ",-1)),a("b",null,k(r.device.tailscaleHost),1)])):D("",!0),r.device.networkCidr?(y(),x("span",Jm,[s[2]||(s[2]=C("网段 ",-1)),a("b",null,k(r.device.networkCidr),1)])):D("",!0),a("span",null,[s[3]||(s[3]=C("上级 ",-1)),a("b",null,k(r.parentName||"待确认 / 直接接入"),1)]),a("span",null,[s[4]||(s[4]=C("连接 ",-1)),a("b",null,k({wired:"网线",wifi:"Wi-Fi"}[r.device.connectionType]||"待确认"),1)]),r.via.length?(y(),x("span",Gm,[s[5]||(s[5]=C("取流经录像机 ",-1)),a("b",null,k(r.via.join("、")),1)])):D("",!0),r.archiveVia.length?(y(),x("span",Ym,[s[6]||(s[6]=C("录像归档 ",-1)),a("b",null,k(r.archiveVia.join("、")),1)])):D("",!0)]),/路由|网关|服务器/.test(r.device.deviceType)?(y(),Qe(Qr,{key:0,device:r.device,active:j(R).page==="objects"&&j(ze).mode==="topology"},null,8,["device","active"])):D("",!0)])],6)}),128)),j(ze).rows.length?D("",!0):(y(),x("p",Xm," 当前范围尚未登记设备。 "))])])])}}},Qm={key:0,class:"panel"},eg={__name:"DeviceNetworkPanel",setup(n){return(e,t)=>j(R).admin&&j(R).device&&j(R).page==="device"?(y(),x("section",Qm,[t[0]||(t[0]=a("h3",null,"网络状态与管理入口",-1)),j(R).device.source==="device"&&/电视|显示|大屏/.test(j(R).device.deviceType)?(y(),Qe($a,{key:0,device:j(R).device},null,8,["device"])):(y(),Qe(Qr,{key:1,device:j(R).device},null,8,["device"])),G(Ra,{device:j(R).device},null,8,["device"])])):D("",!0)}},tg={key:0,class:"row g-3 mb-4","aria-label":"当前场所设备统计"},ng={class:"col-12 col-lg-7"},sg={class:"chart-card h-100"},ig={class:"chart-heading"},rg={class:"small text-secondary"},og={class:"chart-data"},lg={class:"col-12 col-lg-5"},ag={class:"chart-card h-100"},cg={class:"chart-legend"},dg={__name:"ScopeInsights",setup(n){const e=ee(()=>rp(R.value.state)),t=ee(()=>R.value.loggedIn&&R.value.page==="objects");return(s,i)=>t.value&&e.value.total?(y(),x("section",tg,[a("div",ng,[a("article",sg,[a("div",ig,[i[0]||(i[0]=a("h3",null,"设备类型",-1)),a("span",rg,k(e.value.total)+" 台已授权设备",1)]),G(wn,{option:j(Ia)(e.value.types.slice(0,8)),height:220,label:"设备类型:"+e.value.types.map(r=>r.label+r.count+"台").join(",")},null,8,["option","label"]),a("details",og,[i[1]||(i[1]=a("summary",null,"查看全部类型",-1)),a("ul",null,[(y(!0),x(H,null,J(e.value.types,r=>(y(),x("li",{key:r.label},k(r.label)+":"+k(r.count)+" 台",1))),128))])])])]),a("div",lg,[a("article",ag,[i[2]||(i[2]=a("div",{class:"chart-heading"},[a("h3",null,"网络接入"),a("span",{class:"small text-secondary"},"来自设备档案")],-1)),G(wn,{option:j(Na)(e.value.networks),height:190,label:"登记的网络接入方式:"+e.value.networks.map(r=>r.label+r.count+"台").join(",")},null,8,["option","label"]),a("div",cg,[(y(!0),x(H,null,J(e.value.networks,(r,o)=>(y(),x("span",{key:r.label},[a("i",{style:Nn({background:j(ns)[o]})},null,4),C(k(r.label)+" ",1),a("b",null,k(r.count),1)]))),128))]),i[3]||(i[3]=a("p",{class:"small text-secondary mt-2 mb-0"},"接入方式不代表设备在线状态。",-1))])])])):D("",!0)}},ug={class:"border-top mt-3 pt-3"},pg={class:"col-sm-3"},fg=["value"],hg={class:"col-sm-2"},mg={key:0,class:"col-sm-3"},gg={key:1,class:"col-sm-3"},bg={class:"col-sm-3 align-self-end"},vg=["disabled"],yg={role:"status"},kg=["disabled"],xg={__name:"LocationHistory",props:{members:{type:Array,default:()=>[]}},setup(n){const e=P(""),t=P(new Intl.DateTimeFormat("sv-SE",{timeZone:"Asia/Shanghai"}).format(new Date)),s=P(t.value),i=P("day"),r=P([]),o=P(""),l=P(!1),c=P(null);let d=0,u;function p(){d++,r.value=[],o.value="",l.value=!1,c.value=null,clearTimeout(u)}Ae([e,t,s,i,()=>R.value.state.familyId,()=>R.value.page,()=>R.value.session],p);async function f(g=!1){const b=g?c.value:0;g||p();const m=d;l.value=!0,o.value="正在从网盘读取…";try{const v=await K().api("/api/location-history?"+new URLSearchParams({memberId:e.value,date:t.value,until:s.value,period:i.value,cursor:b}));if(m===d){const S=[...r.value,...v.points];let N=[...new Map(S.map(B=>[B.at,B])).values()].sort((B,E)=>B.at-E.at);N.length>1e4&&(N=Array.from({length:1e4},(B,E)=>N[Math.round(E*(N.length-1)/9999)])),r.value=N,c.value=v.nextCursor,o.value=`已读取 ${v.loadedFiles} / ${v.totalFiles} 段归档 · 显示 ${N.length} 个采样点${v.nextCursor!==null?",点击继续加载读取其余记录":",本时段已读取完毕"}`,clearTimeout(u),u=setTimeout(p,6e4)}}catch(v){m===d&&(r.value=[],c.value=null,o.value=v.message)}finally{m===d&&(l.value=!1)}}function h(){document.hidden&&p()}return document.addEventListener("visibilitychange",h),Bt(()=>{p(),document.removeEventListener("visibilitychange",h)}),(g,b)=>(y(),x("details",ug,[b[11]||(b[11]=a("summary",null,"历史轨迹 · 每天到一生",-1)),b[12]||(b[12]=a("p",{class:"small text-secondary mt-2"},"仅记录本人同意保存的轨迹,长期保留至本人删除。关闭共享后他人不能读取;新查看人不自动获得过去记录。长时段分批从网盘读取,概览抽样展示,原始定位点仍保留。连线不是实际道路路线。画面 1 分钟后清除,需要时重新读取。",-1)),a("form",{class:"row g-2 my-2",onSubmit:b[4]||(b[4]=Ve(m=>f(!1),["prevent"]))},[a("label",pg,[b[7]||(b[7]=C("家人",-1)),Y(a("select",{"onUpdate:modelValue":b[0]||(b[0]=m=>e.value=m),required:"",class:"form-select"},[b[6]||(b[6]=a("option",{value:""},"请选择",-1)),(y(!0),x(H,null,J(n.members,m=>(y(),x("option",{key:m.id,value:m.id},k(m.name),9,fg))),128))],512),[[Te,e.value]])]),a("label",hg,[b[9]||(b[9]=C("时段",-1)),Y(a("select",{"onUpdate:modelValue":b[1]||(b[1]=m=>i.value=m),class:"form-select"},[...b[8]||(b[8]=[ge('',6)])],512),[[Te,i.value]])]),i.value!=="life"?(y(),x("label",mg,[C(k(i.value==="custom"?"开始日期":"选择该时段内的日期"),1),Y(a("input",{type:"date","onUpdate:modelValue":b[2]||(b[2]=m=>t.value=m),required:"",class:"form-control"},null,512),[[At,t.value]])])):D("",!0),i.value==="custom"?(y(),x("label",gg,[b[10]||(b[10]=C("结束日期",-1)),Y(a("input",{type:"date","onUpdate:modelValue":b[3]||(b[3]=m=>s.value=m),required:"",class:"form-control"},null,512),[[At,s.value]])])):D("",!0),a("div",bg,[a("button",{class:"btn btn-primary",disabled:l.value},k(l.value?"读取中":"查看轨迹"),9,vg)])],32),r.value.length?(y(),Qe(Oa,{key:0,track:r.value,height:420},null,8,["track"])):D("",!0),a("p",yg,k(o.value),1),c.value!==null?(y(),x("button",{key:1,class:"btn btn-outline-primary",disabled:l.value,onClick:b[5]||(b[5]=m=>f(!0))},"继续加载",8,kg)):D("",!0)]))}},wg=In(xg,[["__scopeId","data-v-3234de1e"]]),Sg={key:0,class:"panel family-locations mb-4","aria-label":"家庭位置共享"},Cg={class:"d-flex flex-wrap justify-content-between gap-2"},Mg={class:"text-secondary small"},Tg={key:0,class:"alert alert-warning",role:"status"},Eg={class:"row g-3"},Ag={class:"col-12 col-lg-8"},Og={class:"col-12 col-lg-4"},Ng={key:0,class:"location-empty"},Ig=["onClick"],Dg={key:0},$g={key:1},Rg={class:"mt-3 border-top pt-3"},Lg={key:0,class:"alert alert-info"},Pg={class:"row g-3"},Bg={class:"col-sm-8"},_g=["disabled"],zg=["value","disabled"],jg={class:"col-sm-4"},Fg=["disabled"],Vg={class:"d-flex gap-2 mt-3"},Hg=["disabled"],qg={key:0,class:"mt-3"},Ug=["value","disabled"],Wg={key:1,class:"mt-3"},Kg=["value","disabled"],Jg={key:2,class:"mt-3"},Gg={key:0,class:"small text-secondary"},Yg=["value","disabled"],Xg={key:3},Zg={class:"d-flex flex-wrap gap-2 mt-3"},Qg=["disabled"],eb=["disabled"],tb={key:4,class:"alert alert-success mt-3",role:"status"},nb={class:"font-monospace fs-3"},sb={key:1,class:"text-danger mt-2",role:"alert"},ib={__name:"FamilyLocations",setup(n){const e=P(null),t=P(""),s=P(!1),i=P(7),r=P(""),o=P(0),l=P(!1),c=P(""),d=P(""),u=P([]),p=P([]),f=P([]),h=P(!0),g=ee(()=>{var O,I;return(I=(O=e.value)==null?void 0:O.bindings)==null?void 0:I.find(Z=>Z.memberId===d.value)}),b=ee(()=>R.value.loggedIn&&R.value.page==="overview"),m=ee(()=>{var O;return(O=R.value.state.households)==null?void 0:O.find(I=>I.id===R.value.state.familyId)});let v,S=0,A=0;const N=ee(()=>{var O;return((O=e.value)==null?void 0:O.items)||[]}),B=O=>O?new Date(O*1e3).toLocaleString("zh-CN"):"尚未收到",E=O=>O.status==="scheduled"?"等待下次定时上传":O.status==="stale"?"位置更新中断":O.status==="live"?"位置已更新":"等待手机定位",M=O=>O.position?`${O.position.latitude.toFixed(4)}°, ${O.position.longitude.toFixed(4)}° · 精度约 ${Math.round(O.position.accuracy)} 米`:"尚无有效位置";async function w(){const O=S,I=++A;if(b.value)try{const Z=await K().api("/api/locations");O===S&&I===A&&(e.value=Z,t.value="")}catch(Z){O===S&&I===A&&(e.value=null,t.value=Z.message)}finally{O===S&&I===A&&b.value&&(v=setTimeout(w,3e4))}}async function T(O){if(l.value)return;l.value=!0,t.value="";const I=S;A++,clearTimeout(v);try{const Z=await K().api("/api/locations",{action:O,memberId:d.value,viewerIds:u.value,displayIds:p.value,phoneIds:f.value,viewOnly:h.value,days:i.value});if(I!==S)return;r.value=Z.code||"",o.value=Z.expires||0,O==="stop"&&(s.value=!1),clearTimeout(v),await w()}catch(Z){I===S&&(t.value=Z.message)}finally{I===S&&(l.value=!1,clearTimeout(v),b.value&&(v=setTimeout(w,3e4)))}}return Ae([b,()=>R.value.state.familyId,()=>R.value.session],()=>{S++,clearTimeout(v),e.value=null,r.value="",d.value="",u.value=[],p.value=[],f.value=[],h.value=!0,c.value="",s.value=!1,l.value=!1,b.value&&w()},{immediate:!0}),Ae([d,u,p,f,h,i],()=>{r.value=""},{deep:!0}),Bt(()=>{S++,clearTimeout(v)}),(O,I)=>{var Z,Oe,le,ae;return b.value?(y(),x("section",Sg,[a("div",Cg,[a("div",null,[I[10]||(I[10]=a("h2",null,"家人位置",-1)),a("p",Mg,k((Z=m.value)==null?void 0:Z.name)+" · "+k(N.value.length)+" 位家人正在共享 · 只显示本人同意分享的最新位置",1)]),a("button",{class:"btn btn-sm btn-outline-secondary align-self-start",onClick:I[0]||(I[0]=_=>c.value="")},"查看全部位置")]),N.value.some(_=>_.status==="stale")?(y(),x("div",Tg,k(N.value.filter(_=>_.status==="stale").map(_=>_.name).join("、"))+"的位置超过约定上传周期仍未更新。请检查手机网络、定位权限或省电设置;这不代表人员失联。",1)):D("",!0),a("div",Eg,[a("div",Ag,[G(Oa,{items:N.value,selected:c.value,height:420,onSelect:I[1]||(I[1]=_=>c.value=_)},null,8,["items","selected"]),I[11]||(I[11]=a("p",{class:"small text-secondary mb-0"},"点击家人卡片定位,圆圈表示定位精度范围。底图由智家提供,位置仅对获授权的人显示。",-1))]),a("div",Og,[N.value.length?D("",!0):(y(),x("div",Ng,[...I[12]||(I[12]=[a("span",null,"⌖",-1),a("h3",{class:"fs-5"},"等待家人主动分享",-1),a("p",null,"家人无需注册账号。手机配对、本人同意并开启共享后,获准的查看人才能看到位置。",-1)])])),(y(!0),x(H,null,J(N.value,_=>{var fe;return y(),x("button",{key:_.id,class:De(["location-person w-100 text-start",{"location-selected":c.value===_.id}]),onClick:rt=>c.value=_.id},[a("strong",null,k(_.name),1),a("span",{class:De(_.status==="stale"?"text-warning-emphasis":"text-success")},k(E(_)),3),a("small",null,k(M(_)),1),a("small",null,"定位时间:"+k(B((fe=_.position)==null?void 0:fe.at)),1),_.status==="scheduled"?(y(),x("small",Dg,"下次预计上传:"+k(B(_.nextUploadAt))+" · 期间轨迹保留在手机",1)):D("",!0),_.signal==="permission_denied"||_.signal==="location_disabled"?(y(),x("small",$g,"手机定位或权限未开启")):D("",!0)],10,Ig)}),128))])]),G(wg,{members:[...N.value,...(((Oe=e.value)==null?void 0:Oe.members)||[]).filter(_=>!N.value.some(fe=>fe.id===_.id))]},null,8,["members"]),a("details",Rg,[I[25]||(I[25]=a("summary",null,"为家庭成员配对手机",-1)),I[26]||(I[26]=a("p",{class:"small text-secondary mt-2"},"老人和孩子无需登录。先选择真实成员及具体查看人,再将配对码输入本人的手机。本人核对授权内容、允许定位并打开共享后才上传;管理员生成配对码不能代替本人同意。家庭屏需单独勾选。",-1)),(ae=(le=e.value)==null?void 0:le.members)!=null&&ae.length?(y(),x("form",{key:1,onSubmit:I[9]||(I[9]=Ve(_=>T("pair"),["prevent"]))},[a("div",Pg,[a("label",Bg,[I[14]||(I[14]=C("绑定的家庭成员",-1)),Y(a("select",{"onUpdate:modelValue":I[2]||(I[2]=_=>d.value=_),required:"",class:"form-select",disabled:l.value},[I[13]||(I[13]=a("option",{value:""},"请选择成员",-1)),(y(!0),x(H,null,J(e.value.members,_=>(y(),x("option",{key:_.id,value:_.id,disabled:_.status==="historical"||_.lifeStatus==="deceased"},k(_.name)+" "+k(_.label?`· ${_.label}`:""),9,zg))),128))],8,_g),[[Te,d.value]])]),a("label",jg,[I[16]||(I[16]=C("手机配对有效期",-1)),Y(a("select",{"onUpdate:modelValue":I[3]||(I[3]=_=>i.value=_),class:"form-select",disabled:l.value},[...I[15]||(I[15]=[a("option",{value:1},"1 天",-1),a("option",{value:7},"7 天",-1),a("option",{value:30},"30 天",-1)])],8,Fg),[[Te,i.value,void 0,{number:!0}]])])]),a("label",Vg,[Y(a("input",{type:"checkbox","onUpdate:modelValue":I[4]||(I[4]=_=>h.value=_),disabled:l.value},null,8,Hg),[[st,h.value]]),I[17]||(I[17]=C("先仅配对手机查看家人,本人可稍后在手机设置自己的共享",-1))]),h.value?D("",!0):(y(),x("fieldset",qg,[I[18]||(I[18]=a("legend",{class:"fs-6"},"允许哪些账号查看",-1)),(y(!0),x(H,null,J(e.value.viewers,_=>(y(),x("label",{key:_.id,class:"d-inline-flex gap-2 me-4 mb-2"},[Y(a("input",{type:"checkbox","onUpdate:modelValue":I[5]||(I[5]=fe=>u.value=fe),value:_.id,disabled:l.value},null,8,Ug),[[st,u.value]]),C(k(_.name)+"("+k(_.username)+")",1)]))),128))])),h.value?D("",!0):(y(),x("fieldset",Wg,[I[19]||(I[19]=a("legend",{class:"fs-6"},"允许哪些家人手机查看",-1)),(y(!0),x(H,null,J(e.value.phones||[],_=>(y(),x("label",{key:_.id,class:"d-inline-flex gap-2 me-4 mb-2"},[Y(a("input",{type:"checkbox","onUpdate:modelValue":I[6]||(I[6]=fe=>f.value=fe),value:_.id,disabled:l.value},null,8,Kg),[[st,f.value]]),C(k(_.name)+"的手机",1)]))),128))])),h.value?D("",!0):(y(),x("fieldset",Jg,[I[20]||(I[20]=a("legend",{class:"fs-6"},"允许哪些公共显示终端展示(默认不选)",-1)),e.value.displays.length?D("",!0):(y(),x("p",Gg,"尚无已配对显示终端。")),(y(!0),x(H,null,J(e.value.displays,_=>(y(),x("label",{key:_.id,class:"d-inline-flex gap-2 me-4 mb-2"},[Y(a("input",{type:"checkbox","onUpdate:modelValue":I[7]||(I[7]=fe=>p.value=fe),value:_.id,disabled:l.value},null,8,Yg),[[st,p.value]]),C(k(_.name),1)]))),128))])),g.value?(y(),x("p",Xg,k(g.value.enabled?"手机已开启共享":"手机已绑定,共享关闭")+" · "+k(B(g.value.expires))+" 到期",1)):D("",!0),a("div",Zg,[a("button",{class:"btn btn-primary",disabled:l.value||!d.value||!h.value&&!u.value.length&&!p.value.length&&!f.value.length},"生成配对码",8,Qg),g.value||r.value?(y(),x("button",{key:0,type:"button",class:"btn btn-outline-danger",disabled:l.value,onClick:I[8]||(I[8]=_=>T("stop"))},"解除该手机授权",8,eb)):D("",!0),I[21]||(I[21]=a("a",{class:"btn btn-outline-secondary",href:"/downloads",target:"_blank",rel:"noreferrer"},"下载配套 App",-1))]),r.value?(y(),x("div",tb,[I[22]||(I[22]=C("配对码 ",-1)),a("strong",nb,k(r.value),1),I[23]||(I[23]=C(" · 10 分钟内使用一次",-1)),I[24]||(I[24]=a("br",null,null,-1)),C("请在成员本人的手机核对姓名与查看名单,手机授权有效至 "+k(B(o.value))+"。重新配对会替换旧手机授权。",1)])):D("",!0)],32)):(y(),x("p",Lg,"请先在“家庭成员”登记本人或家人;普通账号需关联本人档案。")),I[27]||(I[27]=a("p",{class:"small text-secondary mt-3"},"手机可分别设置采集频率与上传周期:实时、1/5 分钟、1—5 小时、1—3 天,或自定义至 30 天。启用历史保存后,断网轨迹加密暂存在手机,联网后补传;百度网盘完整校验后清理对应本机记录。超过 15 分钟的旧坐标隐藏;长周期未到期显示等待上传,超过约定周期才提示更新中断,不表示人员失联。",-1))]),t.value?(y(),x("p",sb,k(t.value),1)):D("",!0)])):D("",!0)}}},rb=In(ib,[["__scopeId","data-v-6ce851ab"]]);function Vt(n=0){const e=Math.max(0,Number(n)||0);return e>=1e9?(e/1e9).toFixed(2)+" GB":e>=1e6?(e/1e6).toFixed(1)+" MB":e>=1e3?(e/1e3).toFixed(1)+" KB":e+" B"}function ob(n,e={}){return n.id===e.id?{preparing:"准备上传",uploading:"正在上传",verifying:"云端校验",cleaning:"清理本机"}[e.stage]||"处理中":n.state==="cloud"?n.releasedAt?"已上传 · 本机已清理":"已存网盘":n.state==="expired"?"云端已到期清理":n.error?"等待重试":n.state==="verified"?"待清理本机":"排队中"}function lb(n,e){return new URLSearchParams({state:n.state,family:n.family,camera:n.camera,page:String(e)}).toString()}const ab={key:0,class:"panel upload-tasks mb-4","aria-label":"上传任务"},cb={class:"row g-3 mb-3"},db={class:"col-6 col-xl-3"},ub={class:"upload-metric"},pb={class:"col-6 col-xl-3"},fb={class:"upload-metric freed"},hb={class:"col-6 col-xl-3"},mb={class:"upload-metric"},gb={class:"col-6 col-xl-3"},bb={class:"upload-metric"},vb={key:0,class:"upload-current mb-3",role:"status"},yb={class:"d-flex justify-content-between gap-2"},kb={key:0},xb={class:"small my-2"},wb=["aria-label","aria-valuenow"],Sb={key:1,class:"alert alert-warning"},Cb={class:"my-2"},Mb={class:"d-flex flex-wrap align-items-center gap-2"},Tb={class:"small"},Eb=["disabled"],Ab={key:2,class:"small",role:"status"},Ob={key:3,class:"alert alert-danger",role:"alert"},Nb={class:"upload-filters mb-3"},Ib=["value"],Db=["value"],$b={key:4,class:"py-4 text-center text-secondary"},Rb={key:5,class:"py-4 text-center text-secondary"},Lb={key:6,class:"upload-list list-unstyled mb-0"},Pb={class:"upload-task-heading"},Bb={class:"small mb-1"},_b={key:0,class:"small text-danger mb-1"},zb={class:"small upload-details"},jb={key:0},Fb={key:7,class:"d-flex flex-wrap justify-content-between gap-2 align-items-center mt-3"},Vb={class:"small text-secondary"},Hb={class:"d-flex gap-2"},qb=["disabled"],Ub=["disabled"],Wb={class:"border-top pt-3 mt-3"},Kb={class:"small mt-2"},Jb={class:"list-unstyled small"},Gb={class:"ms-2"},Yb={key:0,class:"text-danger mb-0"},Xb={key:0,class:"small text-secondary"},Zb={__name:"UploadTasks",setup(n){const e=P(null),t=P(null),s=P(""),i=P(!1),r=P(""),o=P(1),l=P({state:"pending",family:"",camera:""}),c=ee(()=>R.value.loggedIn&&R.value.platformAdmin&&R.value.page==="storage"),d=ee(()=>{var M;return((M=e.value)==null?void 0:M.totals)||{}}),u=ee(()=>R.value.state.storage||{}),p=ee(()=>{var M;return(((M=e.value)==null?void 0:M.cameras)||[]).filter(w=>!l.value.family||w.familyId===l.value.family)}),f=M=>M?new Date(M*1e3).toLocaleString("zh-CN",{hour12:!1,timeZone:"Asia/Shanghai"})+" 北京时间":"—",h=ee(()=>{var M,w;return(w=(M=e.value)==null?void 0:M.active)==null?void 0:w.stage}),g=ee(()=>({preparing:"核对本机片段并准备上传",uploading:"上传文件分片",verifying:"回读网盘文件,核对完整性",cleaning:"校验成功,正在删除本机片段"})[h.value]||"");let b,m=0;async function v(){const M=++m;if(clearTimeout(b),!(!c.value||document.hidden))try{const[w,T]=await Promise.all([K().api("/api/uploads/recordings?"+lb(l.value,o.value)),K().api("/api/backups")]);if(M!==m)return;e.value=w,o.value=w.page,t.value=T,s.value=""}catch(w){M===m&&(s.value=w.message)}finally{M===m&&c.value&&(b=setTimeout(v,5e3))}}function S(){o.value=1,r.value="",v()}function A(){l.value.camera="",S()}function N(M){o.value+=M,v()}async function B(){if(i.value)return;i.value=!0,r.value="";const M=m;try{if(await K().api("/api/uploads/recordings/retry",{}),M!==m)return;r.value="已安排重试最早的片段,后续片段仍按时间顺序上传。",v()}catch(w){M===m&&(r.value=w.message)}finally{i.value=!1}}function E(){document.hidden?(m++,clearTimeout(b)):c.value&&v()}return Ae([c,()=>R.value.session],()=>{m++,clearTimeout(b),e.value=null,t.value=null,s.value="",r.value="",i.value=!1,o.value=1,l.value={state:"pending",family:"",camera:""},c.value&&v()},{immediate:!0}),document.addEventListener("visibilitychange",E),Bt(()=>{m++,clearTimeout(b),document.removeEventListener("visibilitychange",E)}),(M,w)=>{var T,O,I,Z,Oe,le,ae,_,fe,rt,yt;return c.value?(y(),x("section",ab,[a("div",{class:"d-flex flex-wrap justify-content-between gap-3 align-items-start mb-3"},[w[5]||(w[5]=a("div",null,[a("span",{class:"eyebrow"},"百度网盘 · 自动归档"),a("h2",{class:"fs-4 mt-1"},"上传任务"),a("p",{class:"small text-secondary mb-0"},"录像按录制时间依次上传,云端校验成功后才清理本机。此页每 5 秒自动更新。")],-1)),a("button",{class:"btn btn-outline-secondary",onClick:v},"刷新任务")]),a("div",cb,[a("div",db,[a("div",ub,[w[6]||(w[6]=a("span",null,"待上传",-1)),a("strong",null,k(j(Vt)(d.value.pendingBytes)),1),a("small",null,k(d.value.pendingCount||0)+" 个片段保留在本机",1)])]),a("div",pb,[a("div",fb,[w[7]||(w[7]=a("span",null,"累计清理本机录像",-1)),a("strong",null,k(j(Vt)(d.value.releasedBytes)),1),a("small",null,"今日清理 "+k(j(Vt)(d.value.releasedTodayBytes)),1)])]),a("div",hb,[a("div",mb,[w[8]||(w[8]=a("span",null,"已归档至网盘",-1)),a("strong",null,k(j(Vt)(d.value.cloudBytes)),1),a("small",null,k(d.value.cloudCount||0)+" 个未到期片段",1)])]),a("div",gb,[a("div",bb,[w[9]||(w[9]=a("span",null,"服务器磁盘可用",-1)),a("strong",null,k((T=u.value.freeGB)!=null?T:"—")+" GB",1),a("small",null,"临时录像分区上限 "+k((O=u.value.temporaryMaxGB)!=null?O:"—")+" GB",1)])])]),w[33]||(w[33]=a("p",{class:"small text-secondary"},"清理量按已删除录像文件的大小累计;磁盘可用空间也会受系统和其他文件影响,两者并非同一个数值。",-1)),(Z=(I=e.value)==null?void 0:I.active)!=null&&Z.id?(y(),x("div",vb,[a("div",yb,[a("strong",null,k(g.value),1),e.value.active.percent!==null?(y(),x("span",kb,k(e.value.active.percent)+"%",1)):D("",!0)]),a("p",xb,k(((Oe=e.value.items.find(F=>F.id===e.value.active.id))==null?void 0:Oe.cameraName)||"正在处理队首片段")+" · "+k(h.value==="verifying"?"校验完成后才释放空间":"上传完成后还需云端校验"),1),e.value.active.percent!==null?(y(),x("div",{key:0,class:"progress",role:"progressbar","aria-label":g.value,"aria-valuenow":e.value.active.percent,"aria-valuemin":"0","aria-valuemax":"100"},[a("div",{class:"progress-bar",style:Nn({width:e.value.active.percent+"%"})},null,4)],8,wb)):D("",!0)])):(le=e.value)!=null&&le.status.error?(y(),x("div",Sb,[w[11]||(w[11]=a("strong",null,"队首片段等待重试",-1)),a("p",Cb,k(e.value.status.error)+"。本机文件已保留。",1),a("div",Mb,[a("span",Tb,"预计重试:"+k(f(e.value.status.retryAt)),1),a("button",{class:"btn btn-sm btn-outline-secondary",disabled:i.value,onClick:B},"重试队首任务",8,Eb),w[10]||(w[10]=a("button",{class:"btn btn-sm btn-outline-secondary","data-page":"settings","data-settings-section":"baidu"},"检查网盘连接",-1))])])):D("",!0),r.value?(y(),x("p",Ab,k(r.value),1)):D("",!0),s.value?(y(),x("p",Ob,k(s.value)+" · 当前列表可能尚未更新。",1)):D("",!0),a("div",Nb,[a("label",null,[w[13]||(w[13]=C("任务状态",-1)),Y(a("select",{"onUpdate:modelValue":w[0]||(w[0]=F=>l.value.state=F),class:"form-select",onChange:S},[...w[12]||(w[12]=[ge('',5)])],544),[[Te,l.value.state]])]),a("label",null,[w[15]||(w[15]=C("家庭或场所",-1)),Y(a("select",{"onUpdate:modelValue":w[1]||(w[1]=F=>l.value.family=F),class:"form-select",onChange:A},[w[14]||(w[14]=a("option",{value:""},"全部家庭或场所",-1)),(y(!0),x(H,null,J(((ae=e.value)==null?void 0:ae.families)||[],F=>(y(),x("option",{key:F.id,value:F.id},k(F.name),9,Ib))),128))],544),[[Te,l.value.family]])]),a("label",null,[w[17]||(w[17]=C("摄像机",-1)),Y(a("select",{"onUpdate:modelValue":w[2]||(w[2]=F=>l.value.camera=F),class:"form-select",onChange:S},[w[16]||(w[16]=a("option",{value:""},"全部摄像机",-1)),(y(!0),x(H,null,J(p.value,F=>(y(),x("option",{key:F.id+":"+F.familyId,value:F.id},k(F.name),9,Db))),128))],544),[[Te,l.value.camera]])])]),e.value?e.value.items.length?(y(),x("ol",Lb,[(y(!0),x(H,null,J(e.value.items,F=>{var jt;return y(),x("li",{key:F.id,class:"upload-task"},[a("div",Pb,[a("strong",null,k(F.cameraName),1),a("span",{class:De(["badge",F.error?"text-bg-warning":F.state==="cloud"?"text-bg-success":"text-bg-light"])},k(j(ob)(F,e.value.active)),3)]),a("p",Bb,k(F.familyName)+" · "+k(f(F.started))+" · "+k(Math.round(F.duration))+" 秒 · "+k(j(Vt)(F.size)),1),F.error&&F.id!==e.value.active.id?(y(),x("p",_b,k(F.error)+" · 已尝试 "+k(F.attempts)+" 次",1)):D("",!0),a("details",null,[w[30]||(w[30]=a("summary",{class:"small"},"文件与任务详情",-1)),a("dl",zb,[a("div",null,[w[18]||(w[18]=a("dt",null,"文件名称",-1)),a("dd",null,k(F.name),1)]),a("div",null,[w[19]||(w[19]=a("dt",null,"录制开始",-1)),a("dd",null,k(f(F.started)),1)]),a("div",null,[w[20]||(w[20]=a("dt",null,"录制结束",-1)),a("dd",null,k(f(F.ended)),1)]),a("div",null,[w[21]||(w[21]=a("dt",null,"编码 / 保存方式",-1)),a("dd",null,k(((jt=F.metadata.codec)==null?void 0:jt.toUpperCase())||"原始码流")+" · 连续保留原始编码画面",1)]),a("div",null,[w[22]||(w[22]=a("dt",null,"时间属性",-1)),a("dd",null,k(F.metadata.start?"已写入 MP4 文件;服务器录制时钟":"历史文件:时间保存在系统索引中"),1)]),a("div",null,[w[23]||(w[23]=a("dt",null,"网盘文件大小",-1)),a("dd",null,k(j(Vt)(F.archiveSize)),1)]),a("div",null,[w[24]||(w[24]=a("dt",null,"摄像机编号",-1)),a("dd",null,k(F.cameraId),1)]),a("div",null,[w[25]||(w[25]=a("dt",null,"保存位置",-1)),a("dd",null,k(F.remotePath||"家庭 / 摄像头类型 / 摄像机 / 年 / 月 / 日"),1)]),a("div",null,[w[26]||(w[26]=a("dt",null,"云端校验时间",-1)),a("dd",null,k(f(F.verifiedAt)),1)]),a("div",null,[w[27]||(w[27]=a("dt",null,"本机清理时间",-1)),a("dd",null,k(f(F.releasedAt)),1)]),a("div",null,[w[28]||(w[28]=a("dt",null,"清理文件大小",-1)),a("dd",null,k(j(Vt)(F.releasedBytes)),1)]),F.retryAt&&F.error?(y(),x("div",jb,[w[29]||(w[29]=a("dt",null,"下一次重试",-1)),a("dd",null,k(f(F.retryAt)),1)])):D("",!0)])])])}),128))])):(y(),x("div",Rb,"当前筛选下暂无任务。正在录制的片段完成后才会进入队列。")):(y(),x("div",$b,"正在读取上传队列…")),e.value?(y(),x("div",Fb,[a("span",Vb,"共 "+k(e.value.total)+" 个任务 · 第 "+k(e.value.page)+" / "+k(e.value.pages)+" 页 · 更新于 "+k(f(e.value.updatedAt)),1),a("div",Hb,[a("button",{class:"btn btn-sm btn-outline-secondary",disabled:o.value<=1,onClick:w[3]||(w[3]=F=>N(-1))},"上一页",8,qb),a("button",{class:"btn btn-sm btn-outline-secondary",disabled:o.value>=e.value.pages,onClick:w[4]||(w[4]=F=>N(1))},"下一页",8,Ub)])])):D("",!0),a("details",Wb,[w[31]||(w[31]=a("summary",null,"数据库备份上传",-1)),a("p",Kb,k((_=t.value)!=null&&_.running?t.value.stage:"备份任务未在执行")+"。数据库副本使用独立保留策略,不计入上方录像清理量。",1),a("ul",Jb,[(y(!0),x(H,null,J((((fe=t.value)==null?void 0:fe.history)||[]).filter(F=>F.baiduRequested).slice(0,5),F=>(y(),x("li",{key:F.file||F.at,class:"py-2 border-bottom"},[a("strong",null,k(F.file||"数据库备份"),1),a("span",Gb,k(F.baiduOk?"已上传并校验":"上传未完成"),1),F.error?(y(),x("p",Yb,k(F.error),1)):D("",!0)]))),128))]),(yt=(rt=t.value)==null?void 0:rt.history)!=null&&yt.some(F=>F.baiduRequested)?D("",!0):(y(),x("p",Xb,"尚无网盘备份记录。")),w[32]||(w[32]=a("button",{class:"btn btn-sm btn-outline-secondary","data-page":"settings","data-settings-section":"backup"},"打开备份设置",-1))])])):D("",!0)}}},Qb=In(Zb,[["__scopeId","data-v-0c20c09f"]]);var Bo=Object.defineProperty,ev=(n,e)=>{let t={};for(var s in n)Bo(t,s,{get:n[s],enumerable:!0});return Bo(t,Symbol.toStringTag,{value:"Module"}),t};function Se(n){this.content=n}Se.prototype={constructor:Se,find:function(n){for(var e=0;e>1}};Se.from=function(n){if(n instanceof Se)return n;var e=[];if(n)for(var t in n)e.push(t,n[t]);return new Se(e)};function La(n,e,t){for(let s=0;;s++){if(s==n.childCount||s==e.childCount)return n.childCount==e.childCount?null:t;let i=n.child(s),r=e.child(s);if(i==r){t+=i.nodeSize;continue}if(!i.sameMarkup(r))return t;if(i.isText&&i.text!=r.text){let o=i.text,l=r.text,c=0;for(;o[c]==l[c];c++)t++;return c&&c0&&f>0&&d[p-1]==u[f-1];)p--,f--,t--,s--;return p&&f&&p=56320&&n<57344}function _a(n){return n>=55296&&n<56320}class ${constructor(e,t){if(this.content=e,this.size=t||0,t==null)for(let s=0;se&&s(c,i+l,r||null,o)!==!1&&c.content.size){let u=l+1;c.nodesBetween(Math.max(0,e-u),Math.min(c.content.size,t-u),s,i+u)}l=d}}descendants(e){this.nodesBetween(0,this.size,e)}textBetween(e,t,s,i){let r="",o=!0;return this.nodesBetween(e,t,(l,c)=>{let d=l.isText?l.text.slice(Math.max(e,c)-c,t-c):l.isLeaf?i?typeof i=="function"?i(l):i:l.type.spec.leafText?l.type.spec.leafText(l):"":"";l.isBlock&&(l.isLeaf&&d||l.isTextblock)&&s&&(o?o=!1:r+=s),r+=d},0),r}append(e){if(!e.size)return this;if(!this.size)return e;let t=this.lastChild,s=e.firstChild,i=this.content.slice(),r=0;for(t.isText&&t.sameMarkup(s)&&(i[i.length-1]=t.withText(t.text+s.text),r=1);re)for(let r=0,o=0;oe&&((ot)&&(l.isText?l=l.cut(Math.max(0,e-o),Math.min(l.text.length,t-o)):l=l.cut(Math.max(0,e-o-1),Math.min(l.content.size,t-o-1))),s.push(l),i+=l.nodeSize),o=c}return new $(s,i)}cutByIndex(e,t){return e==t?$.empty:e==0&&t==this.content.length?this:new $(this.content.slice(e,t))}replaceChild(e,t){let s=this.content[e];if(s==t)return this;let i=this.content.slice(),r=this.size+t.nodeSize-s.nodeSize;return i[e]=t,new $(i,r)}addToStart(e){return new $([e].concat(this.content),this.size+e.nodeSize)}addToEnd(e){return new $(this.content.concat(e),this.size+e.nodeSize)}eq(e){if(this.content.length!=e.content.length)return!1;for(let t=0;tthis.size||e<0)throw new RangeError(`Position ${e} outside of fragment (${this})`);for(let t=0,s=0;;t++){let i=this.child(t),r=s+i.nodeSize;if(r>=e)return r==e?Ss(t+1,r):Ss(t,s);s=r}}toString(){return"<"+this.toStringInner()+">"}toStringInner(){return this.content.join(", ")}toJSON(){return this.content.length?this.content.map(e=>e.toJSON()):null}static fromJSON(e,t){if(!t)return $.empty;if(!Array.isArray(t))throw new RangeError("Invalid input for Fragment.fromJSON");return $.fromArray(t.map(e.nodeFromJSON))}static fromArray(e){if(!e.length)return $.empty;let t,s=0;for(let i=0;ithis.type.rank&&(t||(t=e.slice(0,i)),t.push(this),s=!0),t&&t.push(r)}}return t||(t=e.slice()),s||t.push(this),t}removeFromSet(e){for(let t=0;ts.type.rank-i.type.rank),t}};ie.none=[];class ss extends Error{}class z{constructor(e,t,s){this.content=e,this.openStart=t,this.openEnd=s}get size(){return this.content.size-this.openStart-this.openEnd}insertAt(e,t){let s=ja(this.content,e+this.openStart,t,this.openStart+1,this.openEnd+1);return s&&new z(s,this.openStart,this.openEnd)}removeBetween(e,t){return new z(za(this.content,e+this.openStart,t+this.openStart),this.openStart,this.openEnd)}eq(e){return this.content.eq(e.content)&&this.openStart==e.openStart&&this.openEnd==e.openEnd}toString(){return this.content+"("+this.openStart+","+this.openEnd+")"}toJSON(){if(!this.content.size)return null;let e={content:this.content.toJSON()};return this.openStart>0&&(e.openStart=this.openStart),this.openEnd>0&&(e.openEnd=this.openEnd),e}static fromJSON(e,t){if(!t)return z.empty;let s=t.openStart||0,i=t.openEnd||0;if(typeof s!="number"||typeof i!="number")throw new RangeError("Invalid input for Slice.fromJSON");return new z($.fromJSON(e,t.content),s,i)}static maxOpen(e,t=!0){let s=0,i=0;for(let r=e.firstChild;r&&!r.isLeaf&&(t||!r.type.spec.isolating);r=r.firstChild)s++;for(let r=e.lastChild;r&&!r.isLeaf&&(t||!r.type.spec.isolating);r=r.lastChild)i++;return new z(e,s,i)}}z.empty=new z($.empty,0,0);function za(n,e,t){let{index:s,offset:i}=n.findIndex(e),r=n.maybeChild(s),{index:o,offset:l}=n.findIndex(t);if(i==e||r.isText){if(l!=t&&!n.child(o).isText)throw new RangeError("Removing non-flat range");return n.cut(0,e).append(n.cut(t))}if(s!=o)throw new RangeError("Removing non-flat range");return n.replaceChild(s,r.copy(za(r.content,e-i-1,t-i-1)))}function ja(n,e,t,s,i,r){let{index:o,offset:l}=n.findIndex(e),c=n.maybeChild(o);if(l==e||c.isText)return r&&s<=0&&i<=0&&!r.canReplace(o,o,t)?null:n.cut(0,e).append(t).append(n.cut(e));let d=ja(c.content,e-l-1,t,o==0?s-1:0,o==n.childCount-1?i-1:0,c);return d&&n.replaceChild(o,c.copy(d))}function tv(n,e,t){if(t.openStart>n.depth)throw new ss("Inserted content deeper than insertion position");if(n.depth-t.openStart!=e.depth-t.openEnd)throw new ss("Inconsistent open depths");return Fa(n,e,t,0)}function Fa(n,e,t,s){let i=n.index(s),r=n.node(s);if(i==e.index(s)&&s=0&&n.isText&&n.sameMarkup(e[t])?e[t]=n.withText(e[t].text+n.text):e.push(n)}function Hn(n,e,t,s){let i=(e||n).node(t),r=0,o=e?e.index(t):i.childCount;n&&(r=n.index(t),n.depth>t?r++:n.textOffset&&(Yt(n.nodeAfter,s),r++));for(let l=r;li&&kr(n,e,i+1),o=s.depth>i&&kr(t,s,i+1),l=[];return Hn(null,n,i,l),r&&o&&e.index(i)==t.index(i)?(Va(r,o),Yt(Xt(r,Ha(n,e,t,s,i+1)),l)):(r&&Yt(Xt(r,Ws(n,e,i+1)),l),Hn(e,t,i,l),o&&Yt(Xt(o,Ws(t,s,i+1)),l)),Hn(s,null,i,l),new $(l)}function Ws(n,e,t){let s=[];if(Hn(null,n,t,s),n.depth>t){let i=kr(n,e,t+1);Yt(Xt(i,Ws(n,e,t+1)),s)}return Hn(e,null,t,s),new $(s)}function nv(n,e){let t=e.depth-n.openStart,i=e.node(t).copy(n.content);for(let r=t-1;r>=0;r--)i=e.node(r).copy($.from(i));return{start:i.resolveNoCache(n.openStart+t),end:i.resolveNoCache(i.content.size-n.openEnd-t)}}class is{constructor(e,t,s){this.pos=e,this.path=t,this.parentOffset=s,this.depth=t.length/3-1}resolveDepth(e){return e==null?this.depth:e<0?this.depth+e:e}get parent(){return this.node(this.depth)}get doc(){return this.node(0)}node(e){return this.path[this.resolveDepth(e)*3]}index(e){return this.path[this.resolveDepth(e)*3+1]}indexAfter(e){return e=this.resolveDepth(e),this.index(e)+(e==this.depth&&!this.textOffset?0:1)}start(e){return e=this.resolveDepth(e),e==0?0:this.path[e*3-1]+1}end(e){return e=this.resolveDepth(e),this.start(e)+this.node(e).content.size}before(e){if(e=this.resolveDepth(e),!e)throw new RangeError("There is no position before the top-level node");return e==this.depth+1?this.pos:this.path[e*3-1]}after(e){if(e=this.resolveDepth(e),!e)throw new RangeError("There is no position after the top-level node");return e==this.depth+1?this.pos:this.path[e*3-1]+this.path[e*3].nodeSize}get textOffset(){return this.pos-this.path[this.path.length-1]}get nodeAfter(){let e=this.parent,t=this.index(this.depth);if(t==e.childCount)return null;let s=this.pos-this.path[this.path.length-1],i=e.child(t);return s?e.child(t).cut(s):i}get nodeBefore(){let e=this.index(this.depth),t=this.pos-this.path[this.path.length-1];return t?this.parent.child(e).cut(0,t):e==0?null:this.parent.child(e-1)}posAtIndex(e,t){t=this.resolveDepth(t);let s=this.path[t*3],i=t==0?0:this.path[t*3-1]+1;for(let r=0;r0;t--)if(this.start(t)<=e&&this.end(t)>=e)return t;return 0}blockRange(e=this,t){if(e.pos=0;s--)if(e.pos<=this.end(s)&&(!t||t(this.node(s))))return new Ks(this,e,s);return null}sameParent(e){return this.pos-this.parentOffset==e.pos-e.parentOffset}max(e){return e.pos>this.pos?e:this}min(e){return e.pos=0&&t<=e.content.size))throw new RangeError("Position "+t+" out of range");let s=[],i=0,r=t;for(let o=e;;){let{index:l,offset:c}=o.content.findIndex(r),d=r-c;if(s.push(o,l,i+c),!d||(o=o.child(l),o.isText))break;r=d-1,i+=c+1}return new is(t,s,r)}static resolveCached(e,t){let s=_o.get(e);if(s)for(let r=0;re&&this.nodesBetween(e,t,r=>(s.isInSet(r.marks)&&(i=!0),!i)),i}get isBlock(){return this.type.isBlock}get isTextblock(){return this.type.isTextblock}get inlineContent(){return this.type.inlineContent}get isInline(){return this.type.isInline}get isText(){return this.type.isText}get isLeaf(){return this.type.isLeaf}get isAtom(){return this.type.isAtom}toString(){if(this.type.spec.toDebugString)return this.type.spec.toDebugString(this);let e=this.type.name;return this.content.size&&(e+="("+this.content.toStringInner()+")"),qa(this.marks,e)}contentMatchAt(e){let t=this.type.contentMatch.matchFragment(this.content,0,e);if(!t)throw new Error("Called contentMatchAt on a node with invalid content");return t}canReplace(e,t,s=$.empty,i=0,r=s.childCount){let o=this.contentMatchAt(e).matchFragment(s,i,r),l=o&&o.matchFragment(this.content,t);if(!l||!l.validEnd)return!1;for(let c=i;ct.type.name)}`);this.content.forEach(t=>t.check())}toJSON(){let e={type:this.type.name};for(let t in this.attrs){e.attrs=this.attrs;break}return this.content.size&&(e.content=this.content.toJSON()),this.marks.length&&(e.marks=this.marks.map(t=>t.toJSON())),e}static fromJSON(e,t){if(!t)throw new RangeError("Invalid input for Node.fromJSON");let s;if(t.marks){if(!Array.isArray(t.marks))throw new RangeError("Invalid mark data for Node.fromJSON");s=t.marks.map(e.markFromJSON)}if(t.type=="text"){if(typeof t.text!="string")throw new RangeError("Invalid text node in JSON");return e.text(t.text,s)}let i=$.fromJSON(e,t.content);return e.nodeType(t.type).create(t.attrs,i,s)}};Zt.prototype.text=void 0;class Js extends Zt{constructor(e,t,s,i){if(super(e,t,null,i),!s)throw new RangeError("Empty text nodes are not allowed");this.text=s}toString(){return this.type.spec.toDebugString?this.type.spec.toDebugString(this):qa(this.marks,JSON.stringify(this.text))}get textContent(){return this.text}textBetween(e,t){return this.text.slice(e,t)}get nodeSize(){return this.text.length}mark(e){return e==this.marks?this:new Js(this.type,this.attrs,this.text,e)}withText(e){return e==this.text?this:new Js(this.type,this.attrs,e,this.marks)}cut(e=0,t=this.text.length){return e==0&&t==this.text.length?this:this.withText(this.text.slice(e,t))}eq(e){return this.sameMarkup(e)&&this.text==e.text}toJSON(){let e=super.toJSON();return e.text=this.text,e}}function qa(n,e){for(let t=n.length-1;t>=0;t--)e=n[t].type.name+"("+e+")";return e}function zo(n,e,t,s){for(let i in e)if(!(i in n))throw new RangeError(`Unsupported attribute ${i} for ${t} of type ${s}`);for(let i in n)n[i].validate&&n[i].validate(e[i])}class tn{constructor(e){this.validEnd=e,this.next=[],this.wrapCache=[]}static parse(e,t){let s=new ov(e,t);if(s.next==null)return tn.empty;let i=Ua(s);s.next&&s.err("Unexpected trailing text");let r=fv(pv(i));return hv(r,s),r}matchType(e){for(let t=0;td.createAndFill()));for(let d=0;d=this.next.length)throw new RangeError(`There's no ${e}th edge in this content match`);return this.next[e]}toString(){let e=[];function t(s){e.push(s);for(let i=0;i{let r=i+(s.validEnd?"*":" ")+" ";for(let o=0;o"+e.indexOf(s.next[o].next);return r}).join(` +`)}}tn.empty=new tn(!0);class ov{constructor(e,t){this.string=e,this.nodeTypes=t,this.inline=null,this.pos=0,this.tokens=e.split(/\s*(?=\b|\W|$)/),this.tokens[this.tokens.length-1]==""&&this.tokens.pop(),this.tokens[0]==""&&this.tokens.shift()}get next(){return this.tokens[this.pos]}eat(e){return this.next==e&&(this.pos++||!0)}err(e){throw new SyntaxError(e+" (in content expression '"+this.string+"')")}}function Ua(n){let e=[];do e.push(lv(n));while(n.eat("|"));return e.length==1?e[0]:{type:"choice",exprs:e}}function lv(n){let e=[];do e.push(av(n));while(n.next&&n.next!=")"&&n.next!="|");return e.length==1?e[0]:{type:"seq",exprs:e}}function av(n){let e=uv(n);for(;;)if(n.eat("+"))e={type:"plus",expr:e};else if(n.eat("*"))e={type:"star",expr:e};else if(n.eat("?"))e={type:"opt",expr:e};else if(n.eat("{"))e=cv(n,e);else break;return e}function jo(n){/\D/.test(n.next)&&n.err("Expected number, got '"+n.next+"'");let e=Number(n.next);return n.pos++,e}function cv(n,e){let t=jo(n),s=t;return n.eat(",")&&(n.next!="}"?s=jo(n):s=-1),n.eat("}")||n.err("Unclosed braced range"),{type:"range",min:t,max:s,expr:e}}function dv(n,e){let t=n.nodeTypes,s=t[e];if(s)return[s];let i=[];for(let r in t){let o=t[r];o.isInGroup(e)&&i.push(o)}return i.length==0&&n.err("No node type or group '"+e+"' found"),i}function uv(n){if(n.eat("(")){let e=Ua(n);return n.eat(")")||n.err("Missing closing paren"),e}else if(/\W/.test(n.next))n.err("Unexpected token '"+n.next+"'");else{let e=dv(n,n.next).map(t=>(n.inline==null?n.inline=t.isInline:n.inline!=t.isInline&&n.err("Mixing inline and block content"),{type:"name",value:t}));return n.pos++,e.length==1?e[0]:{type:"choice",exprs:e}}}function pv(n){let e=[[]];return i(r(n,0),t()),e;function t(){return e.push([])-1}function s(o,l,c){let d={term:c,to:l};return e[o].push(d),d}function i(o,l){o.forEach(c=>c.to=l)}function r(o,l){if(o.type=="choice")return o.exprs.reduce((c,d)=>c.concat(r(d,l)),[]);if(o.type=="seq")for(let c=0;;c++){let d=r(o.exprs[c],l);if(c==o.exprs.length-1)return d;i(d,l=t())}else if(o.type=="star"){let c=t();return s(l,c),i(r(o.expr,c),c),[s(c)]}else if(o.type=="plus"){let c=t();return i(r(o.expr,l),c),i(r(o.expr,c),c),[s(c)]}else{if(o.type=="opt")return[s(l)].concat(r(o.expr,l));if(o.type=="range"){let c=l;for(let d=0;d{n[o].forEach(({term:l,to:c})=>{if(!l)return;let d;for(let u=0;u{d||i.push([l,d=[]]),d.indexOf(u)==-1&&d.push(u)})})});let r=e[s.join(",")]=new tn(s.indexOf(n.length-1)>-1);for(let o=0;o-1}get whitespace(){return this.spec.whitespace||(this.spec.code?"pre":"normal")}hasRequiredAttrs(){for(let e in this.attrs)if(this.attrs[e].isRequired)return!0;return!1}compatibleContent(e){return this==e||this.contentMatch.compatible(e.contentMatch)}computeAttrs(e){return!e&&this.defaultAttrs?this.defaultAttrs:Ja(this.attrs,e)}create(e=null,t,s){if(this.isText)throw new Error("NodeType.create can't construct text nodes");return new Zt(this,this.computeAttrs(e),$.from(t),ie.setFrom(s))}createChecked(e=null,t,s){return t=$.from(t),this.checkContent(t),new Zt(this,this.computeAttrs(e),t,ie.setFrom(s))}createAndFill(e=null,t,s){if(e=this.computeAttrs(e),t=$.from(t),t.size){let o=this.contentMatch.fillBefore(t);if(!o)return null;t=o.append(t)}let i=this.contentMatch.matchFragment(t),r=i&&i.fillBefore($.empty,!0);return r?new Zt(this,e,t.append(r),ie.setFrom(s)):null}validContent(e){let t=this.contentMatch.matchFragment(e);if(!t||!t.validEnd)return!1;for(let s=0;s-1}allowsMarks(e){if(this.markSet==null)return!0;for(let t=0;ts[r]=new Ya(r,t,o));let i=t.spec.topNode||"doc";if(!s[i])throw new RangeError("Schema is missing its top node type ('"+i+"')");if(!s.text)throw new RangeError("Every schema needs a 'text' type");for(let r in s.text.attrs)throw new RangeError("The text node type should not have attributes");return s}};function mv(n,e,t){let s=t.split("|");return i=>{let r=i===null?"null":typeof i;if(s.indexOf(r)<0)throw new RangeError(`Expected value of type ${s} for attribute ${e} on type ${n}, got ${r}`)}}class gv{constructor(e,t,s){this.hasDefault=Object.prototype.hasOwnProperty.call(s,"default"),this.default=s.default,this.validate=typeof s.validate=="string"?mv(e,t,s.validate):s.validate}get isRequired(){return!this.hasDefault}}class Ri{constructor(e,t,s,i){this.name=e,this.rank=t,this.schema=s,this.spec=i,this.attrs=Ga(e,i.attrs),this.excluded=null;let r=Ka(this.attrs);this.instance=r?new ie(this,r):null}create(e=null){return!e&&this.instance?this.instance:new ie(this,Ja(this.attrs,e))}static compile(e,t){let s=Object.create(null),i=0;return e.forEach((r,o)=>s[r]=new Ri(r,i++,t,o)),s}removeFromSet(e){for(var t=0;t-1}}class _s{constructor(e){this.linebreakReplacement=null,this.cached=Object.create(null);let t=this.spec={};for(let i in e)t[i]=e[i];t.nodes=Se.from(e.nodes),t.marks=Se.from(e.marks||{}),this.nodes=Vo.compile(this.spec.nodes,this),this.marks=Ri.compile(this.spec.marks,this);let s=Object.create(null);for(let i in this.nodes){if(i in this.marks)throw new RangeError(i+" can not be both a node and a mark");let r=this.nodes[i],o=r.spec.content||"",l=r.spec.marks;if(r.contentMatch=s[o]||(s[o]=tn.parse(o,this.nodes)),r.inlineContent=r.contentMatch.inlineContent,r.spec.linebreakReplacement){if(this.linebreakReplacement)throw new RangeError("Multiple linebreak nodes defined");if(!r.isInline||!r.isLeaf)throw new RangeError("Linebreak replacement nodes must be inline leaf nodes");this.linebreakReplacement=r}r.markSet=l=="_"?null:l?Ho(this,l.split(" ")):l==""||!r.inlineContent?[]:null}for(let i in this.marks){let r=this.marks[i],o=r.spec.excludes;r.excluded=o==null?[r]:o==""?[]:Ho(this,o.split(" "))}this.nodeFromJSON=i=>Zt.fromJSON(this,i),this.markFromJSON=i=>ie.fromJSON(this,i),this.topNodeType=this.nodes[this.spec.topNode||"doc"],this.cached.wrappings=Object.create(null)}node(e,t=null,s,i){if(typeof e=="string")e=this.nodeType(e);else if(e instanceof Vo){if(e.schema!=this)throw new RangeError("Node type from different schema used ("+e.name+")")}else throw new RangeError("Invalid node type: "+e);return e.createChecked(t,s,i)}text(e,t){let s=this.nodes.text;return new Js(s,s.defaultAttrs,e,ie.setFrom(t))}mark(e,t){return typeof e=="string"&&(e=this.marks[e]),e.create(t)}nodeType(e){let t=this.nodes[e];if(!t)throw new RangeError("Unknown node type: "+e);return t}}function Ho(n,e){let t=[];for(let s=0;s-1)&&t.push(o=c)}if(!o)throw new SyntaxError("Unknown mark type: '"+e[s]+"'")}return t}function bv(n){return n.tag!=null}function vv(n){return n.style!=null}class Ot{constructor(e,t){this.schema=e,this.rules=t,this.tags=[],this.styles=[];let s=this.matchedStyles=[];t.forEach(i=>{if(bv(i))this.tags.push(i);else if(vv(i)){let r=/[^=]*/.exec(i.style)[0];s.indexOf(r)<0&&s.push(r),this.styles.push(i)}}),this.normalizeLists=!this.tags.some(i=>{if(!/^(ul|ol)\b/.test(i.tag)||!i.node)return!1;let r=e.nodes[i.node];return r.contentMatch.matchType(r)})}parse(e,t={}){let s=new Uo(this,t,!1);return s.addAll(e,ie.none,t.from,t.to),s.finish()}parseSlice(e,t={}){let s=new Uo(this,t,!0);return s.addAll(e,ie.none,t.from,t.to),z.maxOpen(s.finish())}matchTag(e,t,s){for(let i=s?this.tags.indexOf(s)+1:0;ie.length&&(l.charCodeAt(e.length)!=61||l.slice(e.length+1)!=t))){if(o.getAttrs){let c=o.getAttrs(t);if(c===!1)continue;o.attrs=c||void 0}return o}}}static schemaRules(e){let t=[];function s(i){let r=i.priority==null?50:i.priority,o=0;for(;o{s(o=Wo(o)),o.mark||o.ignore||o.clearMark||(o.mark=i)})}for(let i in e.nodes){let r=e.nodes[i].spec.parseDOM;r&&r.forEach(o=>{s(o=Wo(o)),o.node||o.ignore||o.mark||(o.node=i)})}return t}static fromSchema(e){return e.cached.domParser||(e.cached.domParser=new Ot(e,Ot.schemaRules(e)))}}const Xa={address:!0,article:!0,aside:!0,blockquote:!0,body:!0,canvas:!0,dd:!0,div:!0,dl:!0,fieldset:!0,figcaption:!0,figure:!0,footer:!0,form:!0,h1:!0,h2:!0,h3:!0,h4:!0,h5:!0,h6:!0,header:!0,hgroup:!0,hr:!0,li:!0,noscript:!0,ol:!0,output:!0,p:!0,pre:!0,section:!0,table:!0,tfoot:!0,ul:!0},yv={head:!0,noscript:!0,object:!0,script:!0,style:!0,title:!0},Za={ol:!0,ul:!0},rs=1,wr=2,qn=4;function qo(n,e,t){return e!=null?(e?rs:0)|(e==="full"?wr:0):n&&n.whitespace=="pre"?rs|wr:t&~qn}class Cs{constructor(e,t,s,i,r,o){this.type=e,this.attrs=t,this.marks=s,this.solid=i,this.options=o,this.content=[],this.activeMarks=ie.none,this.match=r||(o&qn?null:e.contentMatch)}findWrapping(e){if(!this.match){if(!this.type)return[];let t=this.type.contentMatch.fillBefore($.from(e));if(t)this.match=this.type.contentMatch.matchFragment(t);else{let s=this.type.contentMatch,i;return(i=s.findWrapping(e.type))?(this.match=s,i):null}}return this.match.findWrapping(e.type)}finish(e){if(!(this.options&rs)){let s=this.content[this.content.length-1],i;if(s&&s.isText&&(i=/[ \t\r\n\u000c]+$/.exec(s.text))){let r=s;s.text.length==i[0].length?this.content.pop():this.content[this.content.length-1]=r.withText(r.text.slice(0,r.text.length-i[0].length))}}let t=$.from(this.content);return!e&&this.match&&(t=t.append(this.match.fillBefore($.empty,!0))),this.type?this.type.create(this.attrs,t,this.marks):t}inlineContext(e){return this.type?this.type.inlineContent:this.content.length?this.content[0].isInline:e.parentNode&&!Xa.hasOwnProperty(e.parentNode.nodeName.toLowerCase())}}class Uo{constructor(e,t,s){this.parser=e,this.options=t,this.isOpen=s,this.open=0,this.localPreserveWS=!1;let i=t.topNode,r,o=qo(null,t.preserveWhitespace,0)|(s?qn:0);i?r=new Cs(i.type,i.attrs,ie.none,!0,t.topMatch||i.type.contentMatch,o):s?r=new Cs(null,null,ie.none,!0,null,o):r=new Cs(e.schema.topNodeType,null,ie.none,!0,null,o),this.nodes=[r],this.find=t.findPositions,this.needsBlock=!1}get top(){return this.nodes[this.open]}addDOM(e,t){e.nodeType==3?this.addTextNode(e,t):e.nodeType==1&&this.addElement(e,t)}addTextNode(e,t){let s=e.nodeValue,i=this.top,r=i.options&wr?"full":this.localPreserveWS||(i.options&rs)>0,{schema:o}=this.parser;if(r==="full"||i.inlineContext(e)||/[^ \t\r\n\u000c]/.test(s)){if(r)if(r==="full")s=s.replace(/\r\n?/g,` +`);else if(o.linebreakReplacement&&/[\r\n]/.test(s)&&this.top.findWrapping(o.linebreakReplacement.create())){let l=s.split(/\r?\n|\r/);for(let c=0;c!c.clearMark(d)):t=t.concat(this.parser.schema.marks[c.mark].create(c.attrs)),c.consuming===!1)l=c;else break}}return t}addElementByRule(e,t,s,i){let r,o;if(t.node)if(o=this.parser.schema.nodes[t.node],o.isLeaf)this.insertNode(o.create(t.attrs),s,e.nodeName=="BR")||this.leafFallback(e,s);else{let c=this.enter(o,t.attrs||null,s,t.preserveWhitespace);c&&(r=!0,s=c)}else{let c=this.parser.schema.marks[t.mark];s=s.concat(c.create(t.attrs))}let l=this.top;if(o&&o.isLeaf)this.findInside(e);else if(i)this.addElement(e,s,i);else if(t.getContent)this.findInside(e),t.getContent(e,this.parser.schema).forEach(c=>this.insertNode(c,s,!1));else{let c=e;typeof t.contentElement=="string"?c=e.querySelector(t.contentElement):typeof t.contentElement=="function"?c=t.contentElement(e):t.contentElement&&(c=t.contentElement),this.findAround(e,c,!0),this.addAll(c,s),this.findAround(e,c,!1)}r&&this.sync(l)&&this.open--}addAll(e,t,s,i){let r=s||0;for(let o=s?e.childNodes[s]:e.firstChild,l=i==null?null:e.childNodes[i];o!=l;o=o.nextSibling,++r)this.findAtPoint(e,r),this.addDOM(o,t);this.findAtPoint(e,r)}findPlace(e,t,s){let i,r;for(let o=this.open,l=0;o>=0;o--){let c=this.nodes[o],d=c.findWrapping(e);if(d&&(!i||i.length>d.length+l)&&(i=d,r=c,!d.length))break;if(c.solid){if(s)break;l+=2}}if(!i)return null;this.sync(r);for(let o=0;o(o.type?o.type.allowsMarkType(d.type):Ko(d.type,e))?(c=d.addToSet(c),!1):!0),this.nodes.push(new Cs(e,t,c,i,null,l)),this.open++,s}closeExtra(e=!1){let t=this.nodes.length-1;if(t>this.open){for(;t>this.open;t--)this.nodes[t-1].content.push(this.nodes[t].finish(e));this.nodes.length=this.open+1}}finish(){return this.open=0,this.closeExtra(this.isOpen),this.nodes[0].finish(!!(this.isOpen||this.options.topOpen))}sync(e){for(let t=this.open;t>=0;t--){if(this.nodes[t]==e)return this.open=t,!0;this.localPreserveWS&&(this.nodes[t].options|=rs)}return!1}get currentPos(){this.closeExtra();let e=0;for(let t=this.open;t>=0;t--){let s=this.nodes[t].content;for(let i=s.length-1;i>=0;i--)e+=s[i].nodeSize;t&&e++}return e}findAtPoint(e,t){if(this.find)for(let s=0;s-1)return e.split(/\s*\|\s*/).some(this.matchesContext,this);let t=e.split("/"),s=this.options.context,i=!this.isOpen&&(!s||s.parent.type==this.nodes[0].type),r=-(s?s.depth+1:0)+(i?0:1),o=(l,c)=>{for(;l>=0;l--){let d=t[l];if(d==""){if(l==t.length-1||l==0)continue;for(;c>=r;c--)if(o(l-1,c))return!0;return!1}else{let u=c>0||c==0&&i?this.nodes[c].type:s&&c>=r?s.node(c-r).type:null;if(!u||u.name!=d&&!u.isInGroup(d))return!1;c--}}return!0};return o(t.length-1,this.open)}textblockFromContext(){let e=this.options.context;if(e)for(let t=e.depth;t>=0;t--){let s=e.node(t).contentMatchAt(e.indexAfter(t)).defaultType;if(s&&s.isTextblock&&s.defaultAttrs)return s}for(let t in this.parser.schema.nodes){let s=this.parser.schema.nodes[t];if(s.isTextblock&&s.defaultAttrs)return s}}}function kv(n){for(let e=n.firstChild,t=null;e;e=e.nextSibling){let s=e.nodeType==1?e.nodeName.toLowerCase():null;s&&Za.hasOwnProperty(s)&&t?(t.appendChild(e),e=t):s=="li"?t=e:s&&(t=null)}}function xv(n,e){return(n.matches||n.msMatchesSelector||n.webkitMatchesSelector||n.mozMatchesSelector).call(n,e)}function Wo(n){let e={};for(let t in n)e[t]=n[t];return e}function Ko(n,e){let t=e.schema.nodes;for(let s in t){let i=t[s];if(!i.allowsMarkType(n))continue;let r=[],o=l=>{r.push(l);for(let c=0;c{if(r.length||o.marks.length){let l=0,c=0;for(;l=0;i--){let r=this.serializeMark(e.marks[i],e.isInline,t);r&&((r.contentDOM||r.dom).appendChild(s),s=r.dom)}return s}serializeMark(e,t,s={}){let i=this.marks[e.type.name];return i&&zs(Ms(s),i(e,t),null,e.attrs)}static renderSpec(e,t,s=null,i){return typeof t=="string"?{dom:e.createTextNode(t)}:zs(e,t,s,i)}static fromSchema(e){return e.cached.domSerializer||(e.cached.domSerializer=new ln(this.nodesFromSchema(e),this.marksFromSchema(e)))}static nodesFromSchema(e){let t=Jo(e.nodes);return t.text||(t.text=s=>s.text),t}static marksFromSchema(e){return Jo(e.marks)}}function Jo(n){let e={};for(let t in n){let s=n[t].spec.toDOM;s&&(e[t]=s)}return e}function Ms(n){return n.document||window.document}const Go=new WeakMap;function wv(n){let e=Go.get(n);return e===void 0&&Go.set(n,e=Sv(n)),e}function Sv(n){let e=null;function t(s){if(s&&typeof s=="object")if(Array.isArray(s))if(typeof s[0]=="string")e||(e=[]),e.push(s);else for(let i=0;i-1)throw new RangeError("Using an array from an attribute object as a DOM spec. This may be an attempted cross site scripting attack.");let o=i.indexOf(" ");o>0&&(t=i.slice(0,o),i=i.slice(o+1));let l,c=t?n.createElementNS(t,i):n.createElement(i),d=e[1],u=1;if(d&&typeof d=="object"&&d.nodeType==null&&!Array.isArray(d)){u=2;for(let p in d)if(d[p]!=null){let f=p.indexOf(" ");f>0?c.setAttributeNS(p.slice(0,f),p.slice(f+1),d[p]):p=="style"&&c.style?c.style.cssText=d[p]:c.setAttribute(p,d[p])}}for(let p=u;pu)throw new RangeError("Content hole must be the only child of its parent node");return{dom:c,contentDOM:c}}else if(typeof f=="string")c.appendChild(n.createTextNode(f));else{let{dom:h,contentDOM:g}=zs(n,f,t,s);if(c.appendChild(h),g){if(l)throw new RangeError("Multiple content holes");l=g}}}return{dom:c,contentDOM:l}}const Qa=65535,ec=Math.pow(2,16);function Cv(n,e){return n+e*ec}function Yo(n){return n&Qa}function Mv(n){return(n-(n&Qa))/ec}const tc=1,nc=2,js=4,sc=8;class Sr{constructor(e,t,s){this.pos=e,this.delInfo=t,this.recover=s}get deleted(){return(this.delInfo&sc)>0}get deletedBefore(){return(this.delInfo&(tc|js))>0}get deletedAfter(){return(this.delInfo&(nc|js))>0}get deletedAcross(){return(this.delInfo&js)>0}}class He{constructor(e,t=!1){if(this.ranges=e,this.inverted=t,!e.length&&He.empty)return He.empty}recover(e){let t=0,s=Yo(e);if(!this.inverted)for(let i=0;ie)break;let d=this.ranges[l+r],u=this.ranges[l+o],p=c+d;if(e<=p){let f=d?e==c?-1:e==p?1:t:t,h=c+i+(f<0?0:u);if(s)return h;let g=e==(t<0?c:p)?null:Cv(l/3,e-c),b=0;return d&&(b|=e==c?nc:e==p?tc:js,(t<0?e!=c:e!=p)&&(b|=sc)),new Sr(h,b,g)}i+=u-d}return s?e+i:new Sr(e+i,0,null)}touches(e,t){let s=0,i=Yo(t),r=this.inverted?2:1,o=this.inverted?1:2;for(let l=0;le)break;let d=this.ranges[l+r],u=c+d;if(e<=u&&l==i*3)return!0;s+=this.ranges[l+o]-d}return!1}forEach(e){let t=this.inverted?2:1,s=this.inverted?1:2;for(let i=0,r=0;i=0;t--){let i=e.getMirror(t);this.appendMap(e._maps[t].invert(),i!=null&&i>t?s-i-1:void 0)}}invert(){let e=new ls;return e.appendMappingInverted(this),e}map(e,t=1){if(this.mirror)return this._map(e,t,!0);for(let s=this.from;sr&&c!o.isAtom||!l.type.allowsMarkType(this.mark.type)?o:o.mark(this.mark.addToSet(o.marks)),i),t.openStart,t.openEnd);return he.fromReplace(e,this.from,this.to,r)}invert(){return new Xe(this.from,this.to,this.mark)}map(e){let t=e.mapResult(this.from,1),s=e.mapResult(this.to,-1);return t.deleted&&s.deleted||t.pos>=s.pos?null:new Tt(t.pos,s.pos,this.mark)}merge(e){return e instanceof Tt&&e.mark.eq(this.mark)&&this.from<=e.to&&this.to>=e.from?new Tt(Math.min(this.from,e.from),Math.max(this.to,e.to),this.mark):null}toJSON(){return{stepType:"addMark",mark:this.mark.toJSON(),from:this.from,to:this.to}}static fromJSON(e,t){if(typeof t.from!="number"||typeof t.to!="number")throw new RangeError("Invalid input for AddMarkStep.fromJSON");return new Tt(t.from,t.to,e.markFromJSON(t.mark))}}Re.jsonID("addMark",Tt);class Xe extends Re{constructor(e,t,s){super(),this.from=e,this.to=t,this.mark=s}apply(e){let t=e.slice(this.from,this.to),s=new z(eo(t.content,i=>i.mark(this.mark.removeFromSet(i.marks)),e),t.openStart,t.openEnd);return he.fromReplace(e,this.from,this.to,s)}invert(){return new Tt(this.from,this.to,this.mark)}map(e){let t=e.mapResult(this.from,1),s=e.mapResult(this.to,-1);return t.deleted&&s.deleted||t.pos>=s.pos?null:new Xe(t.pos,s.pos,this.mark)}merge(e){return e instanceof Xe&&e.mark.eq(this.mark)&&this.from<=e.to&&this.to>=e.from?new Xe(Math.min(this.from,e.from),Math.max(this.to,e.to),this.mark):null}toJSON(){return{stepType:"removeMark",mark:this.mark.toJSON(),from:this.from,to:this.to}}static fromJSON(e,t){if(typeof t.from!="number"||typeof t.to!="number")throw new RangeError("Invalid input for RemoveMarkStep.fromJSON");return new Xe(t.from,t.to,e.markFromJSON(t.mark))}}Re.jsonID("removeMark",Xe);class Et extends Re{constructor(e,t){super(),this.pos=e,this.mark=t}apply(e){let t=e.nodeAt(this.pos);if(!t)return he.fail("No node at mark step's position");let s=t.type.create(t.attrs,null,this.mark.addToSet(t.marks));return he.fromReplace(e,this.pos,this.pos+1,new z($.from(s),0,t.isLeaf?0:1))}invert(e){let t=e.nodeAt(this.pos);if(t){let s=this.mark.addToSet(t.marks);if(s.length==t.marks.length){for(let i=0;is.pos?null:new xe(t.pos,s.pos,i,r,this.slice,this.insert,this.structure)}toJSON(){let e={stepType:"replaceAround",from:this.from,to:this.to,gapFrom:this.gapFrom,gapTo:this.gapTo,insert:this.insert};return this.slice.size&&(e.slice=this.slice.toJSON()),this.structure&&(e.structure=!0),e}static fromJSON(e,t){if(typeof t.from!="number"||typeof t.to!="number"||typeof t.gapFrom!="number"||typeof t.gapTo!="number"||typeof t.insert!="number")throw new RangeError("Invalid input for ReplaceAroundStep.fromJSON");return new xe(t.from,t.to,t.gapFrom,t.gapTo,z.fromJSON(e,t.slice),t.insert,!!t.structure)}}Re.jsonID("replaceAround",xe);function Cr(n,e,t){let s=n.resolve(e),i=t-e,r=s.depth;for(;i>0&&r>0&&s.indexAfter(r)==s.node(r).childCount;)r--,i--;if(i>0){let o=s.node(r).maybeChild(s.indexAfter(r));for(;i>0;){if(!o||o.isLeaf)return!0;o=o.firstChild,i--}}return!1}function Tv(n,e,t,s){let i=[],r=[],o,l;n.doc.nodesBetween(e,t,(c,d,u)=>{if(!c.isInline)return;let p=c.marks;if(!s.isInSet(p)&&u.type.allowsMarkType(s.type)){let f=Math.max(d,e),h=Math.min(d+c.nodeSize,t),g=s.addToSet(p);for(let b=0;bn.step(c)),r.forEach(c=>n.step(c))}function Ev(n,e,t,s){let i=[],r=0;n.doc.nodesBetween(e,t,(o,l)=>{if(!o.isInline)return;r++;let c=null;if(s instanceof Ri){let d=o.marks,u;for(;u=s.isInSet(d);)(c||(c=[])).push(u),d=u.removeFromSet(d)}else s?s.isInSet(o.marks)&&(c=[s]):c=o.marks;if(c&&c.length){let d=Math.min(l+o.nodeSize,t);for(let u=0;un.step(new Xe(o.from,o.to,o.style)))}function to(n,e,t,s=t.contentMatch,i=!0){let r=n.doc.nodeAt(e),o=[],l=e+1;for(let c=0;c=0;c--)n.step(o[c])}function Av(n,e,t){return(e==0||n.canReplace(e,n.childCount))&&(t==n.childCount||n.canReplace(0,t))}function Dn(n){let t=n.parent.content.cutByIndex(n.startIndex,n.endIndex);for(let s=n.depth,i=0,r=0;;--s){let o=n.$from.node(s),l=n.$from.index(s)+i,c=n.$to.indexAfter(s)-r;if(st;g--)b||s.index(g)>0?(b=!0,u=$.from(s.node(g).copy(u)),p++):c--;let f=$.empty,h=0;for(let g=r,b=!1;g>t;g--)b||i.after(g+1)=0;o--){if(s.size){let l=t[o].type.contentMatch.matchFragment(s);if(!l||!l.validEnd)throw new RangeError("Wrapper type given to Transform.wrap does not form valid content of its parent wrapper")}s=$.from(t[o].type.create(t[o].attrs,s))}let i=e.start,r=e.end;n.step(new xe(i,r,i,r,new z(s,0,0),t.length,!0))}function $v(n,e,t,s,i){if(!s.isTextblock)throw new RangeError("Type given to setBlockType should be a textblock");let r=n.steps.length;n.doc.nodesBetween(e,t,(o,l)=>{let c=typeof i=="function"?i(o):i;if(o.isTextblock&&!o.hasMarkup(s,c)&&Rv(n.doc,n.mapping.slice(r).map(l),s)){let d=null;if(s.schema.linebreakReplacement){let h=s.whitespace=="pre",g=!!s.contentMatch.matchType(s.schema.linebreakReplacement);h&&!g?d=!1:!h&&g&&(d=!0)}d===!1&&rc(n,o,l,r),to(n,n.mapping.slice(r).map(l,1),s,void 0,d===null);let u=n.mapping.slice(r),p=u.map(l,1),f=u.map(l+o.nodeSize,1);return n.step(new xe(p,f,p+1,f-1,new z($.from(s.create(c,null,o.marks)),0,0),1,!0)),d===!0&&ic(n,o,l,r),!1}})}function ic(n,e,t,s){e.forEach((i,r)=>{if(i.isText){let o,l=/\r?\n|\r/g;for(;o=l.exec(i.text);){let c=n.mapping.slice(s).map(t+1+r+o.index);n.replaceWith(c,c+1,e.type.schema.linebreakReplacement.create())}}})}function rc(n,e,t,s){e.forEach((i,r)=>{if(i.type==i.type.schema.linebreakReplacement){let o=n.mapping.slice(s).map(t+1+r);n.replaceWith(o,o+1,e.type.schema.text(` +`))}})}function Rv(n,e,t){let s=n.resolve(e),i=s.index();return s.parent.canReplaceWith(i,i+1,t)}function Lv(n,e,t,s,i){let r=n.doc.nodeAt(e);if(!r)throw new RangeError("No node at given position");t||(t=r.type);let o=t.create(s,null,i||r.marks);if(r.isLeaf)return n.replaceWith(e,e+r.nodeSize,o);if(!t.validContent(r.content))throw new RangeError("Invalid content for node type "+t.name);n.step(new xe(e,e+r.nodeSize,e+1,e+r.nodeSize-1,new z($.from(o),0,0),1,!0))}function mt(n,e,t=1,s){let i=n.resolve(e),r=i.depth-t,o=s&&s[s.length-1]||i.parent;if(r<0||i.parent.type.spec.isolating||!i.parent.canReplace(i.index(),i.parent.childCount)||!o.type.validContent(i.parent.content.cutByIndex(i.index(),i.parent.childCount)))return!1;for(let d=i.depth-1,u=t-2;d>r;d--,u--){let p=i.node(d),f=i.index(d);if(p.type.spec.isolating)return!1;let h=p.content.cutByIndex(f,p.childCount),g=s&&s[u+1];g&&(h=h.replaceChild(0,g.type.create(g.attrs)));let b=s&&s[u]||p;if(!p.canReplace(f+1,p.childCount)||!b.type.validContent(h))return!1}let l=i.indexAfter(r),c=s&&s[0];return i.node(r).canReplaceWith(l,l,c?c.type:i.node(r+1).type)}function Pv(n,e,t=1,s){let i=n.doc.resolve(e),r=$.empty,o=$.empty;for(let l=i.depth,c=i.depth-t,d=t-1;l>c;l--,d--){r=$.from(i.node(l).copy(r));let u=s&&s[d];o=$.from(u?u.type.create(u.attrs,o):i.node(l).copy(o))}n.step(new de(e,e,new z(r.append(o),t,t),!0))}function _t(n,e){let t=n.resolve(e),s=t.index();return oc(t.nodeBefore,t.nodeAfter)&&t.parent.canReplace(s,s+1)}function Bv(n,e){e.content.size||n.type.compatibleContent(e.type);let t=n.contentMatchAt(n.childCount),{linebreakReplacement:s}=n.type.schema;for(let i=0;i0?(r=s.node(i+1),l++,o=s.node(i).maybeChild(l)):(r=s.node(i).maybeChild(l-1),o=s.node(i+1)),r&&!r.isTextblock&&oc(r,o)&&s.node(i).canReplace(l,l+1))return e;if(i==0)break;e=t<0?s.before(i):s.after(i)}}function _v(n,e,t){let s=null,{linebreakReplacement:i}=n.doc.type.schema,r=n.doc.resolve(e-t),o=r.node().type;if(i&&o.inlineContent){let u=o.whitespace=="pre",p=!!o.contentMatch.matchType(i);u&&!p?s=!1:!u&&p&&(s=!0)}let l=n.steps.length;if(s===!1){let u=n.doc.resolve(e+t);rc(n,u.node(),u.before(),l)}o.inlineContent&&to(n,e+t-1,o,r.node().contentMatchAt(r.index()),s==null);let c=n.mapping.slice(l),d=c.map(e-t);if(n.step(new de(d,c.map(e+t,-1),z.empty,!0)),s===!0){let u=n.doc.resolve(d);ic(n,u.node(),u.before(),n.steps.length)}return n}function zv(n,e,t){let s=n.resolve(e);if(s.parent.canReplaceWith(s.index(),s.index(),t))return e;if(s.parentOffset==0)for(let i=s.depth-1;i>=0;i--){let r=s.index(i);if(s.node(i).canReplaceWith(r,r,t))return s.before(i+1);if(r>0)return null}if(s.parentOffset==s.parent.content.size)for(let i=s.depth-1;i>=0;i--){let r=s.indexAfter(i);if(s.node(i).canReplaceWith(r,r,t))return s.after(i+1);if(r=0;o--){let l=o==s.depth?0:s.pos<=(s.start(o+1)+s.end(o+1))/2?-1:1,c=s.index(o)+(l>0?1:0),d=s.node(o),u=!1;if(r==1)u=d.canReplace(c,c,i);else{let p=d.contentMatchAt(c).findWrapping(i.firstChild.type);u=p&&d.canReplaceWith(c,c,p[0])}if(u)return l==0?s.pos:l<0?s.before(o+1):s.after(o+1)}return null}function Pi(n,e,t=e,s=z.empty){if(e==t&&!s.size)return null;let i=n.resolve(e),r=n.resolve(t);return ac(i,r,s)?new de(e,t,s):new jv(i,r,s).fit()}function ac(n,e,t){return!t.openStart&&!t.openEnd&&n.start()==e.start()&&n.parent.canReplace(n.index(),e.index(),t.content)}class jv{constructor(e,t,s){this.$from=e,this.$to=t,this.unplaced=s,this.frontier=[],this.placed=$.empty;for(let i=0;i<=e.depth;i++){let r=e.node(i);this.frontier.push({type:r.type,match:r.contentMatchAt(e.indexAfter(i))})}for(let i=e.depth;i>0;i--)this.placed=$.from(e.node(i).copy(this.placed))}get depth(){return this.frontier.length-1}fit(){for(;this.unplaced.size;){let d=this.findFittable();d?this.placeNodes(d):this.openMore()||this.dropNode()}let e=this.mustMoveInline(),t=this.placed.size-this.depth-this.$from.depth,s=this.$from,i=this.close(e<0?this.$to:s.doc.resolve(e));if(!i)return null;let r=this.placed,o=s.depth,l=i.depth;for(;o&&l&&r.childCount==1;)r=r.firstChild.content,o--,l--;let c=new z(r,o,l);return e>-1?new xe(s.pos,e,this.$to.pos,this.$to.end(),c,t):c.size||s.pos!=this.$to.pos?new de(s.pos,i.pos,c):null}findFittable(){let e=this.unplaced.openStart;for(let t=this.unplaced.content,s=0,i=this.unplaced.openEnd;s1&&(i=0),r.type.spec.isolating&&i<=s){e=s;break}t=r.content}for(let t=1;t<=2;t++)for(let s=t==1?e:this.unplaced.openStart;s>=0;s--){let i,r=null;s?(r=Zo(this.unplaced.content,s-1).firstChild,i=r.content):i=this.unplaced.content;let o=i.firstChild;for(let l=this.depth;l>=0;l--){let{type:c,match:d}=this.frontier[l],u,p=null;if(t==1&&(o?d.matchType(o.type)||(p=d.fillBefore($.from(o),!1)):r&&c.compatibleContent(r.type)))return{sliceDepth:s,frontierDepth:l,parent:r,inject:p};if(t==2&&o&&(u=d.findWrapping(o.type)))return{sliceDepth:s,frontierDepth:l,parent:r,wrap:u};if(r&&d.matchType(r.type))break}}}openMore(){let{content:e,openStart:t,openEnd:s}=this.unplaced;return Qo(e,-1)<=t?!1:(this.unplaced.size>1&&Qo(e,1)>s&&s++,this.unplaced=new z(e,t+1,s),!0)}dropNode(){let{content:e,openStart:t,openEnd:s}=this.unplaced,i=Zo(e,t);if(i.childCount<=1&&t>0){let r=e.size-t<=t+i.size;this.unplaced=new z(_n(e,t-1,1),t-1,r?t-1:s)}else this.unplaced=new z(_n(e,t,1),t,s)}placeNodes({sliceDepth:e,frontierDepth:t,parent:s,inject:i,wrap:r}){for(;this.depth>t;)this.closeFrontierNode();if(r)for(let b=0;b1||c==0||b.content.size)&&(p=m,u.push(cc(b.mark(f.allowedMarks(b.marks)),d==1?c:0,d==l.childCount?h:-1)))}let g=d==l.childCount;g||(h=-1),this.placed=zn(this.placed,t,$.from(u)),this.frontier[t].match=p,g&&h<0&&s&&s.type==this.frontier[this.depth].type&&this.frontier.length>1&&this.closeFrontierNode();for(let b=0,m=l;b1&&i==this.$to.end(--s);)++i;return i}findCloseLevel(e){e:for(let t=Math.min(this.depth,e.depth);t>=0;t--){let{match:s,type:i}=this.frontier[t],r=t=0;l--){let{match:c,type:d}=this.frontier[l],u=Qi(e,l,d,c,!0);if(!u||u.childCount)continue e}return{depth:t,fit:o,move:r?e.doc.resolve(e.after(t+1)):e}}}}close(e){let t=this.findCloseLevel(e);if(!t)return null;for(;this.depth>t.depth;)this.closeFrontierNode();t.fit.childCount&&(this.placed=zn(this.placed,t.depth,t.fit)),e=t.move;for(let s=t.depth+1;s<=e.depth;s++){let i=e.node(s),r=i.type.contentMatch.fillBefore(i.content,!0,e.index(s));this.openFrontierNode(i.type,i.attrs,r)}return e}openFrontierNode(e,t=null,s){let i=this.frontier[this.depth];i.match=i.match.matchType(e),this.placed=zn(this.placed,this.depth,$.from(e.create(t,s))),this.frontier.push({type:e,match:e.contentMatch})}closeFrontierNode(){let t=this.frontier.pop().match.fillBefore($.empty,!0);t.childCount&&(this.placed=zn(this.placed,this.frontier.length,t))}}function _n(n,e,t){return e==0?n.cutByIndex(t,n.childCount):n.replaceChild(0,n.firstChild.copy(_n(n.firstChild.content,e-1,t)))}function zn(n,e,t){return e==0?n.append(t):n.replaceChild(n.childCount-1,n.lastChild.copy(zn(n.lastChild.content,e-1,t)))}function Zo(n,e){for(let t=0;t1&&(s=s.replaceChild(0,cc(s.firstChild,e-1,s.childCount==1?t-1:0))),e>0&&(s=n.type.contentMatch.fillBefore(s).append(s),t<=0&&(s=s.append(n.type.contentMatch.matchFragment(s).fillBefore($.empty,!0)))),n.copy(s)}function Qi(n,e,t,s,i){let r=n.node(e),o=i?n.indexAfter(e):n.index(e);if(o==r.childCount&&!t.compatibleContent(r.type))return null;let l=s.fillBefore(r.content,!0,o);return l&&!Fv(t,r.content,o)?l:null}function Fv(n,e,t){for(let s=t;s0;f--,h--){let g=i.node(f).type.spec;if(g.defining||g.definingAsContext||g.isolating)break;o.indexOf(f)>-1?l=f:i.before(f)==h&&o.splice(1,0,-f)}let c=o.indexOf(l),d=[],u=s.openStart;for(let f=s.content,h=0;;h++){let g=f.firstChild;if(d.push(g),h==s.openStart)break;f=g.content}for(let f=u-1;f>=0;f--){let h=d[f],g=Vv(h.type);if(g&&!h.sameMarkup(i.node(Math.abs(l)-1)))u=f;else if(g||!h.type.isTextblock)break}for(let f=s.openStart;f>=0;f--){let h=(f+u+1)%(s.openStart+1),g=d[h];if(g)for(let b=0;b=0&&(n.replace(e,t,s),!(n.steps.length>p));f--){let h=o[f];h<0||(e=i.before(h),t=r.after(h))}}function dc(n,e,t,s,i){if(es){let r=i.contentMatchAt(0),o=r.fillBefore(n).append(n);n=o.append(r.matchFragment(o).fillBefore($.empty,!0))}return n}function qv(n,e,t,s){if(!s.isInline&&e==t&&n.doc.resolve(e).parent.content.size){let i=zv(n.doc,e,s.type);i!=null&&(e=t=i)}n.replaceRange(e,t,new z($.from(s),0,0))}function Uv(n,e,t){let s=n.doc.resolve(e),i=n.doc.resolve(t);if(s.parent.isTextblock&&i.parent.isTextblock&&s.start()!=i.start()&&s.parentOffset==0&&i.parentOffset==0){let o=s.sharedDepth(t),l=!1;for(let c=s.depth;c>o;c--)s.node(c).type.spec.isolating&&(l=!0);for(let c=i.depth;c>o;c--)i.node(c).type.spec.isolating&&(l=!0);if(!l){for(let c=s.depth;c>0&&e==s.start(c);c--)e=s.before(c);for(let c=i.depth;c>0&&t==i.start(c);c--)t=i.before(c);s=n.doc.resolve(e),i=n.doc.resolve(t)}}let r=uc(s,i);for(let o=0;o0&&(c||s.node(l-1).canReplace(s.index(l-1),i.indexAfter(l-1))))return n.delete(s.before(l),i.after(l))}for(let o=1;o<=s.depth&&o<=i.depth;o++)if(e-s.start(o)==s.depth-o&&t>s.end(o)&&i.end(o)-t!=i.depth-o&&s.start(o-1)==i.start(o-1)&&s.node(o-1).canReplace(s.index(o-1),i.index(o-1)))return n.delete(s.before(o),t);n.delete(e,t)}function uc(n,e){let t=[],s=Math.min(n.depth,e.depth);for(let i=s;i>=0;i--){let r=n.start(i);if(re.pos+(e.depth-i)||n.node(i).type.spec.isolating||e.node(i).type.spec.isolating)break;(r==e.start(i)||i==n.depth&&i==e.depth&&n.parent.inlineContent&&e.parent.inlineContent&&i&&e.start(i-1)==r-1)&&t.push(i)}return t}class kn extends Re{constructor(e,t,s){super(),this.pos=e,this.attr=t,this.value=s}apply(e){let t=e.nodeAt(this.pos);if(!t)return he.fail("No node at attribute step's position");let s=Object.create(null);for(let r in t.attrs)s[r]=t.attrs[r];s[this.attr]=this.value;let i=t.type.create(s,null,t.marks);return he.fromReplace(e,this.pos,this.pos+1,new z($.from(i),0,t.isLeaf?0:1))}getMap(){return He.empty}invert(e){return new kn(this.pos,this.attr,e.nodeAt(this.pos).attrs[this.attr])}map(e){let t=e.mapResult(this.pos,1);return t.deletedAfter?null:new kn(t.pos,this.attr,this.value)}toJSON(){return{stepType:"attr",pos:this.pos,attr:this.attr,value:this.value}}static fromJSON(e,t){if(typeof t.pos!="number"||typeof t.attr!="string")throw new RangeError("Invalid input for AttrStep.fromJSON");return new kn(t.pos,t.attr,t.value)}}Re.jsonID("attr",kn);class as extends Re{constructor(e,t){super(),this.attr=e,this.value=t}apply(e){let t=Object.create(null);for(let i in e.attrs)t[i]=e.attrs[i];t[this.attr]=this.value;let s=e.type.create(t,e.content,e.marks);return he.ok(s)}getMap(){return He.empty}invert(e){return new as(this.attr,e.attrs[this.attr])}map(e){return this}toJSON(){return{stepType:"docAttr",attr:this.attr,value:this.value}}static fromJSON(e,t){if(typeof t.attr!="string")throw new RangeError("Invalid input for DocAttrStep.fromJSON");return new as(t.attr,t.value)}}Re.jsonID("docAttr",as);let Sn=class extends Error{};Sn=function n(e){let t=Error.call(this,e);return t.__proto__=n.prototype,t};Sn.prototype=Object.create(Error.prototype);Sn.prototype.constructor=Sn;Sn.prototype.name="TransformError";class pc{constructor(e){this.doc=e,this.steps=[],this.docs=[],this.mapping=new ls}get before(){return this.docs.length?this.docs[0]:this.doc}step(e){let t=this.maybeStep(e);if(t.failed)throw new Sn(t.failed);return this}maybeStep(e){let t=e.apply(this.doc);return t.failed||this.addStep(e,t.doc),t}get docChanged(){return this.steps.length>0}changedRange(){let e=1e9,t=-1e9;for(let s=0;s{e=Math.min(e,l),t=Math.max(t,c)})}return e==1e9?null:{from:e,to:t}}addStep(e,t){this.docs.push(this.doc),this.steps.push(e),this.mapping.appendMap(e.getMap()),this.doc=t}replace(e,t=e,s=z.empty){let i=Pi(this.doc,e,t,s);return i&&this.step(i),this}replaceWith(e,t,s){return this.replace(e,t,new z($.from(s),0,0))}delete(e,t){return this.replace(e,t,z.empty)}insert(e,t){return this.replaceWith(e,e,t)}replaceRange(e,t,s){return Hv(this,e,t,s),this}replaceRangeWith(e,t,s){return qv(this,e,t,s),this}deleteRange(e,t){return Uv(this,e,t),this}lift(e,t){return Ov(this,e,t),this}join(e,t=1){return _v(this,e,t),this}wrap(e,t){return Dv(this,e,t),this}setBlockType(e,t=e,s,i=null){return $v(this,e,t,s,i),this}setNodeMarkup(e,t,s=null,i){return Lv(this,e,t,s,i),this}setNodeAttribute(e,t,s){return this.step(new kn(e,t,s)),this}setDocAttribute(e,t){return this.step(new as(e,t)),this}addNodeMark(e,t){return this.step(new Et(e,t)),this}removeNodeMark(e,t){let s=this.doc.nodeAt(e);if(!s)throw new RangeError("No node at position "+e);if(t instanceof ie)t.isInSet(s.marks)&&this.step(new nn(e,t));else{let i=s.marks,r,o=[];for(;r=t.isInSet(i);)o.push(new nn(e,r)),i=r.removeFromSet(i);for(let l=o.length-1;l>=0;l--)this.step(o[l])}return this}split(e,t=1,s){return Pv(this,e,t,s),this}addMark(e,t,s){return Tv(this,e,t,s),this}removeMark(e,t,s){return Ev(this,e,t,s),this}clearIncompatible(e,t,s){return to(this,e,t,s),this}}const er=Object.create(null);class X{constructor(e,t,s){this.$anchor=e,this.$head=t,this.ranges=s||[new Wv(e.min(t),e.max(t))]}get anchor(){return this.$anchor.pos}get head(){return this.$head.pos}get from(){return this.$from.pos}get to(){return this.$to.pos}get $from(){return this.ranges[0].$from}get $to(){return this.ranges[0].$to}get empty(){let e=this.ranges;for(let t=0;t=0;r--){let o=t<0?mn(e.node(0),e.node(r),e.before(r+1),e.index(r),t,s):mn(e.node(0),e.node(r),e.after(r+1),e.index(r)+1,t,s);if(o)return o}return null}static near(e,t=1){return this.findFrom(e,t)||this.findFrom(e,-t)||new qe(e.node(0))}static atStart(e){return mn(e,e,0,0,1)||new qe(e)}static atEnd(e){return mn(e,e,e.content.size,e.childCount,-1)||new qe(e)}static fromJSON(e,t){if(!t||!t.type)throw new RangeError("Invalid input for Selection.fromJSON");let s=er[t.type];if(!s)throw new RangeError(`No selection type ${t.type} defined`);return s.fromJSON(e,t)}static jsonID(e,t){if(e in er)throw new RangeError("Duplicate use of selection JSON ID "+e);return er[e]=t,t.prototype.jsonID=e,t}getBookmark(){return U.between(this.$anchor,this.$head).getBookmark()}}X.prototype.visible=!0;class Wv{constructor(e,t){this.$from=e,this.$to=t}}let el=!1;function tl(n){!el&&!n.parent.inlineContent&&(el=!0,console.warn("TextSelection endpoint not pointing into a node with inline content ("+n.parent.type.name+")"))}class U extends X{constructor(e,t=e){tl(e),tl(t),super(e,t)}get $cursor(){return this.$anchor.pos==this.$head.pos?this.$head:null}map(e,t){let s=e.resolve(t.map(this.head));if(!s.parent.inlineContent)return X.near(s);let i=e.resolve(t.map(this.anchor));return new U(i.parent.inlineContent?i:s,s)}replace(e,t=z.empty){if(super.replace(e,t),t==z.empty){let s=this.$from.marksAcross(this.$to);s&&e.ensureMarks(s)}}eq(e){return e instanceof U&&e.anchor==this.anchor&&e.head==this.head}getBookmark(){return new Bi(this.anchor,this.head)}toJSON(){return{type:"text",anchor:this.anchor,head:this.head}}static fromJSON(e,t){if(typeof t.anchor!="number"||typeof t.head!="number")throw new RangeError("Invalid input for TextSelection.fromJSON");return new U(e.resolve(t.anchor),e.resolve(t.head))}static create(e,t,s=t){let i=e.resolve(t);return new this(i,s==t?i:e.resolve(s))}static between(e,t,s){let i=e.pos-t.pos;if((!s||i)&&(s=i>=0?1:-1),!t.parent.inlineContent){let r=X.findFrom(t,s,!0)||X.findFrom(t,-s,!0);if(r)t=r.$head;else return X.near(t,s)}return e.parent.inlineContent||(i==0?e=t:(e=(X.findFrom(e,-s,!0)||X.findFrom(e,s,!0)).$anchor,e.pos0?0:1);i>0?o=0;o+=i){let l=e.child(o);if(l.isAtom){if(!r&&W.isSelectable(l))return W.create(n,t-(i<0?l.nodeSize:0))}else{let c=mn(n,l,t+i,i<0?l.childCount:0,i,r);if(c)return c}t+=l.nodeSize*i}return null}function nl(n,e,t){let s=n.steps.length-1;if(s{o==null&&(o=u)}),n.setSelection(X.near(n.doc.resolve(o),t))}const sl=1,Ts=2,il=4;class Jv extends pc{constructor(e){super(e.doc),this.curSelectionFor=0,this.updated=0,this.meta=Object.create(null),this.time=Date.now(),this.curSelection=e.selection,this.storedMarks=e.storedMarks}get selection(){return this.curSelectionFor0}setStoredMarks(e){return this.storedMarks=e,this.updated|=Ts,this}ensureMarks(e){return ie.sameSet(this.storedMarks||this.selection.$from.marks(),e)||this.setStoredMarks(e),this}addStoredMark(e){return this.ensureMarks(e.addToSet(this.storedMarks||this.selection.$head.marks()))}removeStoredMark(e){return this.ensureMarks(e.removeFromSet(this.storedMarks||this.selection.$head.marks()))}get storedMarksSet(){return(this.updated&Ts)>0}addStep(e,t){super.addStep(e,t),this.updated=this.updated&~Ts,this.storedMarks=null}setTime(e){return this.time=e,this}replaceSelection(e){return this.selection.replace(this,e),this}replaceSelectionWith(e,t=!0){let s=this.selection;return t&&(e=e.mark(this.storedMarks||(s.empty?s.$from.marks():s.$from.marksAcross(s.$to)||ie.none))),s.replaceWith(this,e),this}deleteSelection(){return this.selection.replace(this),this}insertText(e,t,s){let i=this.doc.type.schema;if(t==null)return e?this.replaceSelectionWith(i.text(e),!0):this.deleteSelection();{if(s==null&&(s=t),!e)return this.deleteRange(t,s);let r=this.storedMarks;if(!r){let o=this.doc.resolve(t);r=s==t?o.marks():o.marksAcross(this.doc.resolve(s))}return this.replaceRangeWith(t,s,i.text(e,r)),!this.selection.empty&&this.selection.to==t+e.length&&this.setSelection(X.near(this.selection.$to)),this}}setMeta(e,t){return this.meta[typeof e=="string"?e:e.key]=t,this}getMeta(e){return this.meta[typeof e=="string"?e:e.key]}get isGeneric(){for(let e in this.meta)return!1;return!0}scrollIntoView(){return this.updated|=il,this}get scrolledIntoView(){return(this.updated&il)>0}}function rl(n,e){return!e||!n?n:n.bind(e)}class jn{constructor(e,t,s){this.name=e,this.init=rl(t.init,s),this.apply=rl(t.apply,s)}}const Gv=[new jn("doc",{init(n){return n.doc||n.schema.topNodeType.createAndFill()},apply(n){return n.doc}}),new jn("selection",{init(n,e){return n.selection||X.atStart(e.doc)},apply(n){return n.selection}}),new jn("storedMarks",{init(n){return n.storedMarks||null},apply(n,e,t,s){return s.selection.$cursor?n.storedMarks:null}}),new jn("scrollToSelection",{init(){return 0},apply(n,e){return n.scrolledIntoView?e+1:e}})];class tr{constructor(e,t){this.schema=e,this.plugins=[],this.pluginsByKey=Object.create(null),this.fields=Gv.slice(),t&&t.forEach(s=>{if(this.pluginsByKey[s.key])throw new RangeError("Adding different instances of a keyed plugin ("+s.key+")");this.plugins.push(s),this.pluginsByKey[s.key]=s,s.spec.state&&this.fields.push(new jn(s.key,s.spec.state,s))})}}class pt{constructor(e){this.config=e}get schema(){return this.config.schema}get plugins(){return this.config.plugins}apply(e){return this.applyTransaction(e).state}filterTransaction(e,t=-1){for(let s=0;ss.toJSON())),e&&typeof e=="object")for(let s in e){if(s=="doc"||s=="selection")throw new RangeError("The JSON fields `doc` and `selection` are reserved");let i=e[s],r=i.spec.state;r&&r.toJSON&&(t[s]=r.toJSON.call(i,this[i.key]))}return t}static fromJSON(e,t,s){if(!t)throw new RangeError("Invalid input for EditorState.fromJSON");if(!e.schema)throw new RangeError("Required config field 'schema' missing");let i=new tr(e.schema,e.plugins),r=new pt(i);return i.fields.forEach(o=>{if(o.name=="doc")r.doc=Zt.fromJSON(e.schema,t.doc);else if(o.name=="selection")r.selection=X.fromJSON(r.doc,t.selection);else if(o.name=="storedMarks")t.storedMarks&&(r.storedMarks=t.storedMarks.map(e.schema.markFromJSON));else{if(s)for(let l in s){let c=s[l],d=c.spec.state;if(c.key==o.name&&d&&d.fromJSON&&Object.prototype.hasOwnProperty.call(t,l)){r[o.name]=d.fromJSON.call(c,e,t[l],r);return}}r[o.name]=o.init(e,r)}}),r}}function fc(n,e,t){for(let s in n){let i=n[s];i instanceof Function?i=i.bind(e):s=="handleDOMEvents"&&(i=fc(i,e,{})),t[s]=i}return t}class oe{constructor(e){this.spec=e,this.props={},e.props&&fc(e.props,this,this.props),this.key=e.key?e.key.key:hc("plugin")}getState(e){return e[this.key]}}const nr=Object.create(null);function hc(n){return n in nr?n+"$"+ ++nr[n]:(nr[n]=0,n+"$")}class me{constructor(e="key"){this.key=hc(e)}get(e){return e.config.pluginsByKey[this.key]}getState(e){return e[this.key]}}const mc=(n,e)=>n.selection.empty?!1:(e&&e(n.tr.deleteSelection().scrollIntoView()),!0);function gc(n,e){let{$cursor:t}=n.selection;return!t||(e?!e.endOfTextblock("backward",n):t.parentOffset>0)?null:t}const bc=(n,e,t)=>{let s=gc(n,t);if(!s)return!1;let i=io(s);if(!i){let o=s.blockRange(),l=o&&Dn(o);return l==null?!1:(e&&e(n.tr.lift(o,l).scrollIntoView()),!0)}let r=i.nodeBefore;if(Tc(n,i,e,-1))return!0;if(s.parent.content.size==0&&(Cn(r,"end")||W.isSelectable(r)))for(let o=s.depth;;o--){let l=Pi(n.doc,s.before(o),s.after(o),z.empty);if(l&&l.slice.size1)break}return r.isAtom&&i.depth==s.depth-1?(e&&e(n.tr.delete(i.pos-r.nodeSize,i.pos).scrollIntoView()),!0):!1},Yv=(n,e,t)=>{let s=gc(n,t);if(!s)return!1;let i=io(s);return i?vc(n,i,e):!1},Xv=(n,e,t)=>{let s=kc(n,t);if(!s)return!1;let i=ro(s);return i?vc(n,i,e):!1};function vc(n,e,t){let s=e.nodeBefore,i=s,r=e.pos-1;for(;!i.isTextblock;r--){if(i.type.spec.isolating)return!1;let u=i.lastChild;if(!u)return!1;i=u}let o=e.nodeAfter,l=o,c=e.pos+1;for(;!l.isTextblock;c++){if(l.type.spec.isolating)return!1;let u=l.firstChild;if(!u)return!1;l=u}let d=Pi(n.doc,r,c,z.empty);if(!d||d.from!=r||d instanceof de&&d.slice.size>=c-r)return!1;if(t){let u=n.tr.step(d);u.setSelection(U.create(u.doc,r)),t(u.scrollIntoView())}return!0}function Cn(n,e,t=!1){for(let s=n;s;s=e=="start"?s.firstChild:s.lastChild){if(s.isTextblock)return!0;if(t&&s.childCount!=1)return!1}return!1}const yc=(n,e,t)=>{let{$head:s,empty:i}=n.selection,r=s;if(!i)return!1;if(s.parent.isTextblock){if(t?!t.endOfTextblock("backward",n):s.parentOffset>0)return!1;r=io(s)}let o=r&&r.nodeBefore;return!o||!W.isSelectable(o)?!1:(e&&e(n.tr.setSelection(W.create(n.doc,r.pos-o.nodeSize)).scrollIntoView()),!0)};function io(n){if(!n.parent.type.spec.isolating)for(let e=n.depth-1;e>=0;e--){if(n.index(e)>0)return n.doc.resolve(n.before(e+1));if(n.node(e).type.spec.isolating)break}return null}function kc(n,e){let{$cursor:t}=n.selection;return!t||(e?!e.endOfTextblock("forward",n):t.parentOffset{let s=kc(n,t);if(!s)return!1;let i=ro(s);if(!i)return!1;let r=i.nodeAfter;if(Tc(n,i,e,1))return!0;if(s.parent.content.size==0&&(Cn(r,"start")||W.isSelectable(r))){let o=Pi(n.doc,s.before(),s.after(),z.empty);if(o&&o.slice.size{let{$head:s,empty:i}=n.selection,r=s;if(!i)return!1;if(s.parent.isTextblock){if(t?!t.endOfTextblock("forward",n):s.parentOffset=0;e--){let t=n.node(e);if(n.index(e)+1{let t=n.selection,s=t instanceof W,i;if(s){if(t.node.isTextblock||!_t(n.doc,t.from))return!1;i=t.from}else if(i=Li(n.doc,t.from,-1),i==null)return!1;if(e){let r=n.tr.join(i);s&&r.setSelection(W.create(r.doc,i-n.doc.resolve(i).nodeBefore.nodeSize)),e(r.scrollIntoView())}return!0},Qv=(n,e)=>{let t=n.selection,s;if(t instanceof W){if(t.node.isTextblock||!_t(n.doc,t.to))return!1;s=t.to}else if(s=Li(n.doc,t.to,1),s==null)return!1;return e&&e(n.tr.join(s).scrollIntoView()),!0},ey=(n,e)=>{let{$from:t,$to:s}=n.selection,i=t.blockRange(s),r=i&&Dn(i);return r==null?!1:(e&&e(n.tr.lift(i,r).scrollIntoView()),!0)},Sc=(n,e)=>{let{$head:t,$anchor:s}=n.selection;return!t.parent.type.spec.code||!t.sameParent(s)?!1:(e&&e(n.tr.insertText(` +`).scrollIntoView()),!0)};function oo(n){for(let e=0;e{let{$head:t,$anchor:s}=n.selection;if(!t.parent.type.spec.code||!t.sameParent(s))return!1;let i=t.node(-1),r=t.indexAfter(-1),o=oo(i.contentMatchAt(r));if(!o||!i.canReplaceWith(r,r,o))return!1;if(e){let l=t.after(),c=n.tr.replaceWith(l,l,o.createAndFill());c.setSelection(X.near(c.doc.resolve(l),1)),e(c.scrollIntoView())}return!0},Cc=(n,e)=>{let t=n.selection,{$from:s,$to:i}=t;if(t instanceof qe||s.parent.inlineContent||i.parent.inlineContent)return!1;let r=oo(i.parent.contentMatchAt(i.indexAfter()));if(!r||!r.isTextblock)return!1;if(e){let o=(!s.parentOffset&&i.index(){let{$cursor:t}=n.selection;if(!t||t.parent.content.size)return!1;if(t.depth>1&&t.after()!=t.end(-1)){let r=t.before();if(mt(n.doc,r))return e&&e(n.tr.split(r).scrollIntoView()),!0}let s=t.blockRange(),i=s&&Dn(s);return i==null?!1:(e&&e(n.tr.lift(s,i).scrollIntoView()),!0)};function ny(n){return(e,t)=>{if(e.selection instanceof W&&e.selection.node.isBlock){let{$from:h}=e.selection;return!h.parentOffset||!mt(e.doc,h.pos)?!1:(t&&t(e.tr.split(h.pos).scrollIntoView()),!0)}if(!e.selection.$from.depth)return!1;let s=e.tr;!e.selection.empty&&(e.selection instanceof U||e.selection instanceof qe)&&s.deleteSelection();let{$from:i}=s.selection,r=s.steps.length,o=[],l,c,d=!1,u=!1;for(let h=i.depth;;h--)if(i.node(h).isBlock){d=i.end(h)==i.pos+(i.depth-h),u=i.start(h)==i.pos-(i.depth-h),c=oo(i.node(h-1).contentMatchAt(i.indexAfter(h-1))),o.unshift(d&&c?{type:c}:null),l=h;break}else{if(h==1)return!1;o.unshift(null)}let p=i.pos,f=mt(s.doc,p,o.length,o);if(f||(o[0]=c?{type:c}:null,f=mt(s.doc,p,o.length,o)),!f)return!1;if(s.split(p,o.length,o),!d&&u&&i.node(l).type!=c){let h=s.mapping.slice(r),g=h.map(i.before(l)),b=s.doc.resolve(g);c&&i.node(l-1).canReplaceWith(b.index(),b.index()+1,c)&&s.setNodeMarkup(h.map(i.before(l)),c)}return t&&t(s.scrollIntoView()),!0}}const sy=ny(),iy=(n,e)=>{let{$from:t,to:s}=n.selection,i,r=t.sharedDepth(s);return r==0?!1:(i=t.before(r),e&&e(n.tr.setSelection(W.create(n.doc,i))),!0)};function ry(n,e,t){let s=e.nodeBefore,i=e.nodeAfter,r=e.index();return!s||!i||!s.type.compatibleContent(i.type)?!1:!s.content.size&&e.parent.canReplace(r-1,r)?(t&&t(n.tr.delete(e.pos-s.nodeSize,e.pos).scrollIntoView()),!0):!e.parent.canReplace(r,r+1)||!(i.isTextblock||_t(n.doc,e.pos))?!1:(t&&t(n.tr.join(e.pos).scrollIntoView()),!0)}function Tc(n,e,t,s){let i=e.nodeBefore,r=e.nodeAfter,o,l,c=i.type.spec.isolating||r.type.spec.isolating;if(!c&&ry(n,e,t))return!0;let d=!c&&e.parent.canReplace(e.index(),e.index()+1);if(d&&(o=(l=i.contentMatchAt(i.childCount)).findWrapping(r.type))&&l.matchType(o[0]||r.type).validEnd){if(t){let h=e.pos+r.nodeSize,g=$.empty;for(let v=o.length-1;v>=0;v--)g=$.from(o[v].create(null,g));g=$.from(i.copy(g));let b=n.tr.step(new xe(e.pos-1,h,e.pos,h,new z(g,1,0),o.length,!0)),m=b.doc.resolve(h+2*o.length);m.nodeAfter&&m.nodeAfter.type==i.type&&_t(b.doc,m.pos)&&b.join(m.pos),t(b.scrollIntoView())}return!0}let u=r.type.spec.isolating||s>0&&c?null:X.findFrom(e,1),p=u&&u.$from.blockRange(u.$to),f=p&&Dn(p);if(f!=null&&f>=e.depth)return t&&t(n.tr.lift(p,f).scrollIntoView()),!0;if(d&&Cn(r,"start",!0)&&Cn(i,"end")){let h=i,g=[];for(;g.push(h),!h.isTextblock;)h=h.lastChild;let b=r,m=1;for(;!b.isTextblock;b=b.firstChild)m++;if(h.canReplace(h.childCount,h.childCount,b.content)){if(t){let v=$.empty;for(let A=g.length-1;A>=0;A--)v=$.from(g[A].copy(v));let S=n.tr.step(new xe(e.pos-g.length,e.pos+r.nodeSize,e.pos+m,e.pos+r.nodeSize-m,new z(v,g.length,0),0,!0));t(S.scrollIntoView())}return!0}}return!1}function Ec(n){return function(e,t){let s=e.selection,i=n<0?s.$from:s.$to,r=i.depth;for(;i.node(r).isInline;){if(!r)return!1;r--}return i.node(r).isTextblock?(t&&t(e.tr.setSelection(U.create(e.doc,n<0?i.start(r):i.end(r)))),!0):!1}}const oy=Ec(-1),ly=Ec(1);function ay(n,e=null){return function(t,s){let{$from:i,$to:r}=t.selection,o=i.blockRange(r),l=o&&no(o,n,e);return l?(s&&s(t.tr.wrap(o,l).scrollIntoView()),!0):!1}}function ol(n,e=null){return function(t,s){let i=!1;for(let r=0;r{if(i)return!1;if(!(!c.isTextblock||c.hasMarkup(n,e)))if(c.type==n)i=!0;else{let u=t.doc.resolve(d),p=u.index();i=u.parent.canReplaceWith(p,p+1,n)}})}if(!i)return!1;if(s){let r=t.tr;for(let o=0;o=2&&e.$from.node(e.depth-1).type.compatibleContent(t)&&e.startIndex==0){if(e.$from.index(e.depth-1)==0)return!1;let c=o.resolve(e.start-2);r=new Ks(c,c,e.depth),e.endIndex=0;u--)r=$.from(t[u].type.create(t[u].attrs,r));n.step(new xe(e.start-(s?2:0),e.end,e.start,e.end,new z(r,0,0),t.length,!0));let o=0;for(let u=0;uo.childCount>0&&o.firstChild.type==n);return r?t?s.node(r.depth-1).type==n?fy(e,t,n,r):hy(e,t,r):!0:!1}}function fy(n,e,t,s){let i=n.tr,r=s.end,o=s.$to.end(s.depth);rb;g--)h-=i.child(g).nodeSize,s.delete(h-1,h+1);let r=s.doc.resolve(t.start),o=r.nodeAfter;if(s.mapping.map(t.end)!=t.start+r.nodeAfter.nodeSize)return!1;let l=t.startIndex==0,c=t.endIndex==i.childCount,d=r.node(-1),u=r.index(-1);if(!d.canReplace(u+(l?0:1),u+1,o.content.append(c?$.empty:$.from(i))))return!1;let p=r.pos,f=p+o.nodeSize;return s.step(new xe(p-(l?1:0),f+(c?1:0),p+1,f-1,new z((l?$.empty:$.from(i.copy($.empty))).append(c?$.empty:$.from(i.copy($.empty))),l?0:1,c?0:1),l?0:1)),e(s.scrollIntoView()),!0}function my(n){return function(e,t){let{$from:s,$to:i}=e.selection,r=s.blockRange(i,d=>d.childCount>0&&d.firstChild.type==n);if(!r)return!1;let o=r.startIndex;if(o==0)return!1;let l=r.parent,c=l.child(o-1);if(c.type!=n)return!1;if(t){let d=c.lastChild&&c.lastChild.type==l.type,u=$.from(d?n.create():null),p=new z($.from(n.create(null,$.from(l.type.create(null,u)))),d?3:1,0),f=r.start,h=r.end;t(e.tr.step(new xe(f-(d?3:1),h,f,h,p,1,!0)).scrollIntoView())}return!0}}const Ce=function(n){for(var e=0;;e++)if(n=n.previousSibling,!n)return e},Mn=function(n){let e=n.assignedSlot||n.parentNode;return e&&e.nodeType==11?e.host:e};let Mr=null;const ut=function(n,e,t){let s=Mr||(Mr=document.createRange());return s.setEnd(n,t==null?n.nodeValue.length:t),s.setStart(n,e||0),s},gy=function(){Mr=null},sn=function(n,e,t,s){return t&&(ll(n,e,t,s,-1)||ll(n,e,t,s,1))},by=/^(img|br|input|textarea|hr)$/i;function ll(n,e,t,s,i){for(var r;;){if(n==t&&e==s)return!0;if(e==(i<0?0:Ie(n))){let o=n.parentNode;if(!o||!q(o)||ms(n)||by.test(n.nodeName)||n.contentEditable=="false")return!1;e=Ce(n)+(i<0?0:1),n=o}else if(q(n)){let o=n.childNodes[e+(i<0?-1:0)];if(q(o)&&o.contentEditable=="false")if(!((r=o.pmViewDesc)===null||r===void 0)&&r.ignoreForSelection)e+=i;else return!1;else n=o,e=i<0?Ie(n):0}else return!1}}function Ie(n){return n.nodeType==3?n.nodeValue.length:n.childNodes.length}function q(n){return n.nodeType==1}function ve(n){return n.nodeType==3}function rn(n,e){return e?n.contains(q(e)?e:e.parentNode):!1}function vy(n,e){for(;;){if(ve(n)&&e)return n;if(q(n)&&e>0){if(n.contentEditable=="false")return null;n=n.childNodes[e-1],e=Ie(n)}else if(n.parentNode&&!ms(n))e=Ce(n),n=n.parentNode;else return null}}function yy(n,e){for(;;){if(ve(n)&&e2),Je=Tn||(it?/Mac/.test(it.platform):!1),Nc=it?/Win/.test(it.platform):!1,ft=/Android \d/.test(zt),zi=!!al&&"webkitFontSmoothing"in al.documentElement.style,Sy=zi?+(/\bAppleWebKit\/(\d+)/.exec(navigator.userAgent)||[0,0])[1]:0;function Cy(n){let e=n.defaultView&&n.defaultView.visualViewport;return e?{left:0,right:e.width,top:0,bottom:e.height}:{left:0,right:n.documentElement.clientWidth,top:0,bottom:n.documentElement.clientHeight}}function ot(n,e){return typeof n=="number"?n:n[e]}function My(n){let e=n.getBoundingClientRect(),t=e.width/n.offsetWidth||1,s=e.height/n.offsetHeight||1;return{left:e.left,right:e.left+n.clientWidth*t,top:e.top,bottom:e.top+n.clientHeight*s}}function cl(n,e,t){if(!Or(e)&&e.left==0)return;let s=n.someProp("scrollThreshold")||0,i=n.someProp("scrollMargin")||5,r=n.dom.ownerDocument;for(let o=t||n.dom;o;){if(!q(o)){o=Mn(o);continue}let l=o==r.body,c=l?Cy(r):My(o),d=0,u=0;if(e.topc.bottom-ot(s,"bottom")&&(u=e.bottom-e.top>c.bottom-c.top?e.top+ot(i,"top")-c.top:e.bottom-c.bottom+ot(i,"bottom")),e.leftc.right-ot(s,"right")&&(d=e.right-c.right+ot(i,"right")),d||u)if(l)r.defaultView.scrollBy(d,u);else{let f=o.scrollLeft,h=o.scrollTop;u&&(o.scrollTop+=u),d&&(o.scrollLeft+=d);let g=o.scrollLeft-f,b=o.scrollTop-h;e={left:e.left-g,top:e.top-b,right:e.right-g,bottom:e.bottom-b}}let p=l?"fixed":getComputedStyle(o).position;if(/^(fixed|sticky)$/.test(p))break;o=p=="absolute"?o.offsetParent:Mn(o)}}function Ty(n){let e=n.dom.getBoundingClientRect(),t=Math.max(0,e.top),s,i;for(let r=(e.left+e.right)/2,o=t+1;o=t-20){s=l,i=c.top;break}}return{refDOM:s,refTop:i,stack:Ic(n.dom)}}function Ic(n){let e=[],t=n.ownerDocument;for(let s=n;s&&(e.push({dom:s,top:s.scrollTop,left:s.scrollLeft}),n!=t);s=Mn(s));return e}function Ey({refDOM:n,refTop:e,stack:t}){let s=n?n.getBoundingClientRect().top:0;Dc(t,s==0?0:s-e)}function Dc(n,e){for(let t=0;t=l){o=Math.max(g.bottom,o),l=Math.min(g.top,l);let b=g.left>e.left?g.left-e.left:g.right=(g.left+g.right)/2?1:0));continue}}else g.top>e.top&&!c&&g.left<=e.left&&g.right>=e.left&&(c=u,d={left:Math.max(g.left,Math.min(g.right,e.left)),top:g.top});!t&&(e.left>=g.right&&e.top>=g.top||e.left>=g.left&&e.top>=g.bottom)&&(r=p+1)}}return!t&&c&&(t=c,i=d,s=0),t&&ve(t)?Oy(t,i):!t||s?{node:n,offset:r}:$c(t,i)}function Oy(n,e){let t=n.nodeValue.length,s=document.createRange(),i;for(let r=0;r=(o.left+o.right)/2?1:0)};break}}return s.detach(),i||{node:n,offset:0}}function ao(n,e){return n.left>=e.left-1&&n.left<=e.right+1&&n.top>=e.top-1&&n.top<=e.bottom+1}function Ny(n,e){let t=n.parentNode;return t&&/^li$/i.test(t.nodeName)&&e.left(o.left+o.right)/2?1:-1}return n.docView.posFromDOM(s,i,r)}function Dy(n,e,t,s){let i=-1;for(let r=e,o=!1;r!=n.dom;){let l=n.docView.nearestDesc(r,!0),c;if(!l)return null;if(q(l.dom)&&(l.node.isBlock&&l.parent||!l.contentDOM)&&((c=l.dom.getBoundingClientRect()).width||c.height)&&(l.node.isBlock&&l.parent&&!/^T(R|BODY|HEAD|FOOT)$/.test(l.dom.nodeName)&&(!o&&c.left>s.left||c.top>s.top?i=l.posBefore:(!o&&c.right-1?i:n.docView.posFromDOM(e,t,-1)}function Rc(n,e,t){let s=n.childNodes.length;if(s&&t.tope.top&&i++}let d;zi&&i&&q(s)&&q(d=s.childNodes[i-1])&&d.contentEditable=="false"&&d.getBoundingClientRect().top>=e.top&&i--,s==n.dom&&i==s.childNodes.length-1&&q(s.lastChild)&&e.top>s.lastChild.getBoundingClientRect().bottom?l=n.state.doc.content.size:(i==0||!q(s)||s.childNodes[i-1].nodeName!="BR")&&(l=Dy(n,s,i,e))}l==null&&(l=Iy(n,o,e));let c=n.docView.nearestDesc(o,!0);return{pos:l,inside:c?c.posAtStart-c.border:-1}}function Or(n){return n.top=0&&i==s.nodeValue.length?(c--,u=1):t<0?c--:d++,$n(xt(ut(s,c,d),u),u<0)}if(!n.state.doc.resolve(e-(r||0)).parent.inlineContent){if(r==null&&i&&(t<0||i==Ie(s))){let c=s.childNodes[i-1];if(q(c))return sr(c.getBoundingClientRect(),!1)}if(r==null&&i=0)}if(r==null&&i&&(t<0||i==Ie(s))){let c=s.childNodes[i-1],d=ve(c)?ut(c,Ie(c)-(o?0:1)):q(c)&&(c.nodeName!="BR"||!c.nextSibling)?c:null;if(d)return $n(xt(d,1),!1)}if(r==null&&i=0)}function $n(n,e){if(n.width==0)return n;let t=e?n.left:n.right;return{top:n.top,bottom:n.bottom,left:t,right:t}}function sr(n,e){if(n.height==0)return n;let t=e?n.top:n.bottom;return{top:t,bottom:t,left:n.left,right:n.right}}function Pc(n,e,t){let s=n.state,i=n.root.activeElement;s!=e&&n.updateState(e),i!=n.dom&&n.focus();try{return t()}finally{s!=e&&n.updateState(s),i!=n.dom&&i&&i.focus()}}function Ly(n,e,t){let s=e.selection,i=t=="up"?s.$from:s.$to;return Pc(n,e,()=>{let{node:r}=n.docView.domFromPos(i.pos,t=="up"?-1:1);for(;;){let l=n.docView.nearestDesc(r,!0);if(!l)break;if(l.node.isBlock){r=l.contentDOM||l.dom;break}r=l.dom.parentNode}let o=Lc(n,i.pos,1);for(let l=r.firstChild;l;l=l.nextSibling){let c;if(q(l))c=l.getClientRects();else if(ve(l))c=ut(l,0,l.nodeValue.length).getClientRects();else continue;for(let d=0;du.top+1&&(t=="up"?o.top-u.top>(u.bottom-o.top)*2:u.bottom-o.bottom>(o.bottom-u.top)*2))return!1}}return!0})}const Py=/[\u0590-\u08ac]/;function By(n,e,t){let{$head:s}=e.selection;if(!s.parent.isTextblock)return!1;let i=s.parentOffset,r=!i,o=i==s.parent.content.size,l=n.domSelection();return l?!Py.test(s.parent.textContent)||!l.modify?t=="left"||t=="backward"?r:o:Pc(n,e,()=>{let{focusNode:c,focusOffset:d,anchorNode:u,anchorOffset:p}=n.domSelectionRange(),f=l.caretBidiLevel;l.modify("move",t,"character");let h=s.depth?n.docView.domAfterPos(s.before()):n.dom,{focusNode:g,focusOffset:b}=n.domSelectionRange(),m=g&&!rn(h,g)||c==g&&d==b;try{l.collapse(u,p),c&&(c!=u||d!=p)&&l.extend&&l.extend(c,d)}catch(v){}return f!=null&&(l.caretBidiLevel=f),m}):s.pos==s.start()||s.pos==s.end()}let dl=null,ul=null,pl=!1;function _y(n,e,t){return dl==e&&ul==t?pl:(dl=e,ul=t,pl=t=="up"||t=="down"?Ly(n,e,t):By(n,e,t))}const Ge=0,fl=1,Ut=2,Ze=3;class gs{constructor(e,t,s,i){this.parent=e,this.children=t,this.dom=s,this.contentDOM=i,this.dirty=Ge,s.pmViewDesc=this}matchesWidget(e){return!1}matchesMark(e){return!1}matchesNode(e,t,s){return!1}matchesHack(e){return!1}parseRule(e){return null}stopEvent(e){return!1}get size(){let e=0;for(let t=0;tCe(this.contentDOM);else if(this.contentDOM&&this.contentDOM!=this.dom&&this.dom.contains(this.contentDOM))i=!!(e.compareDocumentPosition(this.contentDOM)&4);else if(this.dom.firstChild){if(t==0)for(let r=e;;r=r.parentNode){if(r==this.dom){i=!1;break}if(r.previousSibling)break}if(i==null&&t==e.childNodes.length)for(let r=e;;r=r.parentNode){if(r==this.dom){i=!0;break}if(r.nextSibling)break}}return(i==null?s>0:i)?this.posAtEnd:this.posAtStart}nearestDesc(e,t=!1){for(let s=!0,i=e;i;i=i.parentNode){let r=this.getDesc(i),o;if(r&&(!t||r.node))if(s&&(o=r.nodeDOM)&&!(q(o)?rn(o,e):o==e))s=!1;else return r}}getDesc(e){let t=e.pmViewDesc;for(let s=t;s;s=s.parent)if(s==this)return t}posFromDOM(e,t,s){for(let i=e;i;i=i.parentNode){let r=this.getDesc(i);if(r)return r.localPosFromDOM(e,t,s)}return-1}descAt(e){for(let t=0,s=0;te){i=e-r;break}r=l}if(i)return this.children[s].domFromPos(i-this.children[s].border,t);for(;s>0;s--){let r=this.children[s-1];if(r.size||!(r instanceof _c||r instanceof Bc&&r.side>=0))break}if(t<=0){let r,o=!0;for(;r=s?this.children[s-1]:null,!(!r||r.dom.parentNode==this.contentDOM);s--,o=!1);return r&&t&&o&&!r.border&&!r.domAtom?r.domFromPos(r.size,t):{node:this.contentDOM,offset:r?Ce(r.dom)+1:0}}else{let r,o=!0;for(;r=s=u&&t<=d-c.border&&c.node&&c.contentDOM&&this.contentDOM.contains(c.contentDOM))return c.parseRange(e,t,u);e=o;for(let p=l;p>0;p--){let f=this.children[p-1];if(f.size&&f.dom.parentNode==this.contentDOM&&!f.emptyChildAt(1)){i=Ce(f.dom)+1;break}e-=f.size}i==-1&&(i=0)}if(i>-1&&(d>t||l==this.children.length-1)){t=d;for(let u=l+1;ug&&ot){let g=l;l=c,c=g}let h=document.createRange();h.setEnd(c.node,c.offset),h.setStart(l.node,l.offset),d.removeAllRanges(),d.addRange(h)}}ignoreMutation(e){return!this.contentDOM&&e.type!="selection"}get contentLost(){return this.contentDOM&&this.contentDOM!=this.dom&&!this.dom.contains(this.contentDOM)}markDirty(e,t){for(let s=0,i=0;i=s:es){let l=s+r.border,c=o-r.border;if(e>=l&&t<=c){this.dirty=e==s||t==o?Ut:fl,e==l&&t==c&&(r.contentLost||r.dom.parentNode!=this.contentDOM)?r.dirty=Ze:r.markDirty(e-l,t-l);return}else r.dirty=r.dom==r.contentDOM&&r.dom.parentNode==this.contentDOM&&!r.children.length?Ut:Ze}s=o}this.dirty=Ut}markParentsDirty(){let e=1;for(let t=this.parent;t;t=t.parent,e++){let s=e==1?Ut:fl;t.dirty{if(!r)return i;if(r.parent)return r.parent.posBeforeChild(r)})),!t.type.spec.raw){let l=q(o)?o:document.createElement("span");l!=o&&l.appendChild(o),l.hasAttribute("contenteditable")||(l.contentEditable="false"),l.classList.add("ProseMirror-widget")}super(e,[],o,null),this.widget=t,this.widget=t,r=this}matchesWidget(e){return this.dirty==Ge&&e.type.eq(this.widget.type)}parseRule(){return{ignore:!0}}stopEvent(e){let t=this.widget.spec.stopEvent;return t?t(e):!1}ignoreMutation(e){return e.type!="selection"||this.widget.spec.ignoreSelection}destroy(){this.widget.type.destroy(this.dom),super.destroy()}get domAtom(){return!0}get ignoreForSelection(){return!!this.widget.type.spec.relaxedSide}get side(){return this.widget.type.side}}class zy extends gs{constructor(e,t,s,i){super(e,[],t,null),this.textDOM=s,this.text=i}get size(){return this.text.length}localPosFromDOM(e,t){return e!=this.textDOM?this.posAtStart+(t?this.size:0):this.posAtStart+t}domFromPos(e){return{node:this.textDOM,offset:e}}ignoreMutation(e){return e.type==="characterData"&&e.target.nodeValue==e.oldValue}}class It extends gs{constructor(e,t,s,i,r){super(e,[],s,i),this.mark=t,this.spec=r}static create(e,t,s,i){let r=i.nodeViews[t.type.name],o=r&&r(t,i,s);return(!o||!o.dom)&&(o=ln.renderSpec(document,t.type.spec.toDOM(t,s),null,t.attrs)),new It(e,t,o.dom,o.contentDOM||o.dom,o)}parseRule(){return this.dirty&Ze||this.mark.type.spec.reparseInView?null:{mark:this.mark.type.name,attrs:this.mark.attrs,contentElement:this.contentDOM}}matchesMark(e){return this.dirty!=Ze&&this.mark.eq(e)}markDirty(e,t){if(super.markDirty(e,t),this.dirty!=Ge){let s=this.parent;for(;!s.node;)s=s.parent;s.dirty0&&(r=Ir(r,0,e,s));for(let l=0;l{if(!c)return o;if(c.parent)return c.parent.posBeforeChild(c)},s,i),u=d&&d.dom,p=d&&d.contentDOM;if(t.isText){if(!u)u=document.createTextNode(t.text);else if(!ve(u))throw new RangeError("Text must be rendered as a DOM text node")}else u||({dom:u,contentDOM:p}=ln.renderSpec(document,t.type.spec.toDOM(t),null,t.attrs));!p&&!t.isText&&u.nodeName!="BR"&&(u.hasAttribute("contenteditable")||(u.contentEditable="false"),t.type.spec.draggable&&(u.draggable=!0));let f=u;return u=Fc(u,s,t),d?c=new jy(e,t,s,i,u,p||null,f,d):t.isText?new ji(e,t,s,i,u,f):new Dt(e,t,s,i,u,p||null,f)}parseRule(e){if(this.node.type.spec.reparseInView)return null;let t={node:this.node.type.name,attrs:this.node.attrs};if(this.node.type.whitespace=="pre"&&(t.preserveWhitespace="full"),!this.contentDOM)t.getContent=()=>this.node.content;else if(!this.contentLost)t.contentElement=this.contentDOM;else{for(let s=this.children.length-1;s>=0;s--){let i=this.children[s];if(this.dom.contains(i.dom.parentNode)){t.contentElement=i.dom.parentNode;break}}if(!t.contentElement){let s=e&&e.find(i=>q(i)&&e.indexOf(i.parentNode)<0&&this.dom.contains(i));s?t.contentElement=s:t.getContent=()=>$.empty}}return t}matchesNode(e,t,s){return this.dirty==Ge&&e.eq(this.node)&&Gs(t,this.outerDeco)&&s.eq(this.innerDeco)}get size(){return this.node.nodeSize}get border(){return this.node.isLeaf?0:1}updateChildren(e,t){let s=this.node.inlineContent,i=t,r=e.composing?this.localCompositionInfo(e,t):null,o=r&&r.pos>-1?r:null,l=r&&r.pos<0,c=new Vy(this,o&&o.node,e),d=this.node.inlineContent,u=d&&this.node.isBlock;Uy(this.node,this.innerDeco,(p,f,h)=>{p.spec.marks?c.syncToMarks(p.spec.marks,s,e,f):p.type.side>=0&&!h&&c.syncToMarks(f==this.node.childCount?ie.none:this.node.child(f).marks,s,e,f),c.placeWidget(p,e,i)},(p,f,h,g)=>{c.syncToMarks(p.marks,s,e,g),u&&p.isAtom&&!p.isText&&c.addHackNode("IMG",c.top);let b;c.findNodeMatch(p,f,h,g)||l&&e.state.selection.from>i&&e.state.selection.to-1&&c.updateNodeAt(p,f,h,b,e)||c.updateNextNode(p,f,h,e,g,i)||c.addNode(p,f,h,e,i),i+=p.nodeSize,d&&(u=p.isAtom&&!p.isText)}),c.syncToMarks([],s,e,0),this.node.isTextblock&&c.addTextblockHacks(),c.destroyRest(),(c.changed||this.dirty==Ut)&&(o&&this.protectLocalComposition(e,o),zc(this.contentDOM,this.children,e),Tn&&Wy(this.dom))}localCompositionInfo(e,t){let{from:s,to:i}=e.state.selection;if(!(e.state.selection instanceof U)||st+this.node.content.size)return null;let r=e.input.compositionNode;if(!r||!this.dom.contains(r.parentNode))return null;if(this.node.inlineContent){let o=r.nodeValue,l=Ky(this.node.content,o,s-t,i-t);return l<0?null:{node:r,pos:l,text:o}}else return{node:r,pos:-1,text:""}}protectLocalComposition(e,{node:t,pos:s,text:i}){if(this.getDesc(t))return;let r=t;for(;r.parentNode!=this.contentDOM;r=r.parentNode){for(;r.previousSibling;)r.parentNode.removeChild(r.previousSibling);for(;r.nextSibling;)r.parentNode.removeChild(r.nextSibling);r.pmViewDesc&&(r.pmViewDesc=void 0)}let o=new zy(this,r,t,i);e.input.compositionNodes.push(o),this.children=Ir(this.children,s,s+i.length,e,o)}update(e,t,s,i){return this.dirty==Ze||!e.sameMarkup(this.node)?!1:(this.updateInner(e,t,s,i),!0)}updateInner(e,t,s,i){this.updateOuterDeco(t),this.node=e,this.innerDeco=s,this.contentDOM&&this.updateChildren(i,this.posAtStart),this.dirty=Ge}updateOuterDeco(e){if(Gs(e,this.outerDeco))return;let t=!q(this.nodeDOM),s=this.dom;this.dom=jc(this.dom,this.nodeDOM,Nr(this.outerDeco,this.node,t),Nr(e,this.node,t)),this.dom!=s&&(s.pmViewDesc=void 0,this.dom.pmViewDesc=this),this.outerDeco=e}selectNode(){q(this.nodeDOM)&&(this.nodeDOM.classList.add("ProseMirror-selectednode"),(this.contentDOM||!this.node.type.spec.draggable)&&(this.nodeDOM.draggable=!0))}deselectNode(){q(this.nodeDOM)&&(this.nodeDOM.classList.remove("ProseMirror-selectednode"),(this.contentDOM||!this.node.type.spec.draggable)&&this.nodeDOM.removeAttribute("draggable"))}get domAtom(){return this.node.isAtom}}function hl(n,e,t,s,i){Fc(s,e,n);let r=new Dt(void 0,n,e,t,s,s,s);return r.contentDOM&&r.updateChildren(i,0),r}class ji extends Dt{constructor(e,t,s,i,r,o){super(e,t,s,i,r,null,o)}parseRule(){let e=this.nodeDOM.parentNode;for(;e&&e!=this.dom&&!e.pmIsDeco;)e=e.parentNode;return{skip:e||!0}}update(e,t,s,i){return this.dirty==Ze||this.dirty!=Ge&&!this.inParent()||!e.sameMarkup(this.node)?!1:(this.updateOuterDeco(t),(this.dirty!=Ge||e.text!=this.node.text)&&e.text!=this.nodeDOM.nodeValue&&(this.nodeDOM.nodeValue=e.text,i.trackWrites==this.nodeDOM&&(i.trackWrites=null)),this.node=e,this.dirty=Ge,!0)}inParent(){let e=this.parent.contentDOM;for(let t=this.nodeDOM;t;t=t.parentNode)if(t==e)return!0;return!1}domFromPos(e){return{node:this.nodeDOM,offset:e}}localPosFromDOM(e,t,s){return e==this.nodeDOM?this.posAtStart+Math.min(t,this.node.text.length):super.localPosFromDOM(e,t,s)}ignoreMutation(e){return e.type!="characterData"&&e.type!="selection"}slice(e,t,s){let i=this.node.cut(e,t),r=document.createTextNode(i.text);return new ji(this.parent,i,this.outerDeco,this.innerDeco,r,r)}markDirty(e,t){super.markDirty(e,t),this.dom!=this.nodeDOM&&(e==0||t==this.nodeDOM.nodeValue.length)&&(this.dirty=Ze)}get domAtom(){return!1}isText(e){return this.node.text==e}}class _c extends gs{parseRule(){return{ignore:!0}}matchesHack(e){return this.dirty==Ge&&this.dom.nodeName==e}get domAtom(){return!0}get ignoreForCoords(){return this.dom.nodeName=="IMG"}}class jy extends Dt{constructor(e,t,s,i,r,o,l,c){super(e,t,s,i,r,o,l),this.spec=c}update(e,t,s,i){if(this.dirty==Ze)return!1;if(this.spec.update&&(this.node.type==e.type||this.spec.multiType)){let r=this.spec.update(e,t,s);return r&&this.updateInner(e,t,s,i),r}else return!this.contentDOM&&!e.isLeaf?!1:super.update(e,t,s,i)}selectNode(){this.spec.selectNode?this.spec.selectNode():super.selectNode()}deselectNode(){this.spec.deselectNode?this.spec.deselectNode():super.deselectNode()}setSelection(e,t,s,i){this.spec.setSelection?this.spec.setSelection(e,t,s.root):super.setSelection(e,t,s,i)}destroy(){this.spec.destroy&&this.spec.destroy(),super.destroy()}stopEvent(e){return this.spec.stopEvent?this.spec.stopEvent(e):!1}ignoreMutation(e){return this.spec.ignoreMutation?this.spec.ignoreMutation(e):super.ignoreMutation(e)}}function zc(n,e,t){let s=n.firstChild,i=!1;for(let r=0;r>1,l=Math.min(o,e.length);for(;r-1)c>this.index&&(this.changed=!0,this.destroyBetween(this.index,c)),this.top=this.top.children[this.index];else{let u=It.create(this.top,e[o],t,s);this.top.children.splice(this.index,0,u),this.top=u,this.changed=!0}this.index=0,o++}}findNodeMatch(e,t,s,i){let r=-1,o;if(i>=this.preMatch.index&&(o=this.preMatch.matches[i-this.preMatch.index]).parent==this.top&&o.matchesNode(e,t,s))r=this.top.children.indexOf(o,this.index);else for(let l=this.index,c=Math.min(this.top.children.length,l+5);l0;){let l;for(;;)if(s){let d=t.children[s-1];if(d instanceof It)t=d,s=d.children.length;else{l=d,s--;break}}else{if(t==e)break e;s=t.parent.children.indexOf(t),t=t.parent}let c=l.node;if(c){if(c!=n.child(i-1))break;--i,r.set(l,i),o.push(l)}}return{index:i,matched:r,matches:o.reverse()}}function qy(n,e){return n.type.side-e.type.side}function Uy(n,e,t,s){let i=e.locals(n),r=0;if(i.length==0){for(let d=0;dr;)l.push(i[o++]);let g=r+f.nodeSize;if(f.isText){let m=g;o!m.inline):l.slice();s(f,b,e.forChild(r,f),h),r=g}}function Wy(n){if(n.nodeName=="UL"||n.nodeName=="OL"){let e=n.style.cssText;n.style.cssText=e+"; list-style: square !important",window.getComputedStyle(n).listStyle,n.style.cssText=e}}function Ky(n,e,t,s){for(let i=0,r=0;i=t){if(r>=s&&c.slice(s-e.length-l,s-l)==e)return s-e.length;let d=l=0&&d+e.length+l>=t)return l+d;if(t==s&&c.length>=s+e.length-l&&c.slice(s-l,s-l+e.length)==e)return s}}return-1}function Ir(n,e,t,s,i){let r=[];for(let o=0,l=0;o=t||u<=e?r.push(c):(dt&&r.push(c.slice(t-d,c.size,s)))}return r}function co(n,e=null){let t=n.domSelectionRange(),s=n.state.doc;if(!t.focusNode)return null;let i=n.docView.nearestDesc(t.focusNode),r=i&&i.size==0,o=n.docView.posFromDOM(t.focusNode,t.focusOffset,1);if(o<0)return null;let l=s.resolve(o),c,d;if(_i(t)){for(c=o;i&&!i.node;)i=i.parent;if(i&&i.node.isAtom&&W.isSelectable(i.node)&&i.parent&&!(i.node.isInline&&ky(t.focusNode,t.focusOffset,i.dom))){let p=i.posBefore;d=new W(o==p?l:s.resolve(p))}else if(Ue&&e=="key"&&o>n.state.selection.to&&q(t.focusNode)&&t.focusOffset==t.focusNode.childNodes.length&&i&&i.posAtStart>n.state.selection.to)for(let p=t.focusNode;;p=p.parentNode){if(getComputedStyle(p).overflow!="visible"){d=X.findFrom(s.resolve(i.posAtStart),1);break}if(p==i.dom||p.nextSibling||!p.parentNode||!q(p.parentNode))break}}else{if(t instanceof n.dom.ownerDocument.defaultView.Selection&&t.rangeCount>1){let p=o,f=o;for(let h=0;h{(t.anchorNode!=s||t.anchorOffset!=i)&&(e.removeEventListener("selectionchange",n.input.hideSelectionGuard),setTimeout(()=>{(!Vc(n)||n.state.selection.visible)&&n.dom.classList.remove("ProseMirror-hideselection")},20))})}function Gy(n){let e=n.domSelection();if(!e)return;let t=n.cursorWrapper.dom,s=t.nodeName=="IMG";s?e.collapse(t.parentNode,Ce(t)+1):e.collapse(t,0),!s&&!n.state.selection.visible&&je&&Nt<=11&&(t.disabled=!0,t.disabled=!1)}function Hc(n,e){if(e instanceof W){let t=n.docView.descAt(e.from);t!=n.lastSelectedViewDesc&&(yl(n),t&&t.selectNode(),n.lastSelectedViewDesc=t)}else yl(n)}function yl(n){n.lastSelectedViewDesc&&(n.lastSelectedViewDesc.parent&&n.lastSelectedViewDesc.deselectNode(),n.lastSelectedViewDesc=void 0)}function uo(n,e,t,s){return n.someProp("createSelectionBetween",i=>i(n,e,t))||U.between(e,t,s)}function kl(n){return n.editable&&!n.hasFocus()?!1:qc(n)}function qc(n){let e=n.domSelectionRange();if(!e.anchorNode)return!1;try{return rn(n.dom,e.anchorNode)&&(n.editable||rn(n.dom,e.focusNode))}catch(t){return!1}}function Yy(n){let e=n.docView.domFromPos(n.state.selection.anchor,0),t=n.domSelectionRange();return sn(e.node,e.offset,t.anchorNode,t.anchorOffset)}function Dr(n,e){let{$anchor:t,$head:s}=n.selection,i=e>0?t.max(s):t.min(s),r=i.parent.inlineContent?i.depth?n.doc.resolve(e>0?i.after():i.before()):null:i;return r&&X.findFrom(r,e)}function wt(n,e){return n.dispatch(n.state.tr.setSelection(e).scrollIntoView()),!0}function xl(n,e,t){let s=n.state.selection;if(s instanceof U)if(t.indexOf("s")>-1){let{$head:i}=s,r=i.textOffset?null:e<0?i.nodeBefore:i.nodeAfter;if(!r||r.isText||!r.isLeaf)return!1;let o=n.state.doc.resolve(i.pos+r.nodeSize*(e<0?-1:1));return wt(n,new U(s.$anchor,o))}else if(s.empty){if(n.endOfTextblock(e>0?"forward":"backward")){let i=Dr(n.state,e);return i&&i instanceof W?wt(n,i):!1}else if(!(Je&&t.indexOf("m")>-1)){let i=s.$head,r=i.textOffset?null:e<0?i.nodeBefore:i.nodeAfter,o;if(!r||r.isText)return!1;let l=e<0?i.pos-r.nodeSize:i.pos;return r.isAtom||(o=n.docView.descAt(l))&&!o.contentDOM?W.isSelectable(r)?wt(n,new W(e<0?n.state.doc.resolve(i.pos-r.nodeSize):i)):wt(n,new U(n.state.doc.resolve(e<0?l:l+r.nodeSize))):!1}}else return!1;else{if(s instanceof W&&s.node.isInline)return wt(n,new U(e>0?s.$to:s.$from));{let i=Dr(n.state,e);return i?wt(n,i):!1}}}function Wn(n,e){let t=n.pmViewDesc;return t?t.size==0&&(e<0||n.nextSibling||n.nodeName!="BR"):q(n)&&n.contentEditable=="false"}function pn(n,e){return e<0?Xy(n):Zy(n)}function Xy(n){let e=n.domSelectionRange(),t=e.focusNode,s=e.focusOffset;if(!t)return;let i,r,o=!1;for(Ue&&q(t)&&s0){if(!q(t))break;let l=t.childNodes[s-1];if(Wn(l,-1))i=t,r=--s;else if(ve(l))t=l,s=t.nodeValue.length;else break}else{if(Uc(t))break;{let l=t.previousSibling;for(;l&&Wn(l,-1);)i=t.parentNode,r=Ce(l),l=l.previousSibling;if(l)t=l,s=Ie(t);else{if(t=t.parentNode,t==n.dom)break;s=0}}}o?$r(n,t,s):i&&$r(n,i,r)}function Zy(n){let e=n.domSelectionRange(),t=e.focusNode,s=e.focusOffset;if(!t)return;let i=Ie(t),r,o;for(;;)if(s{n.state==i&>(n)},50)}function wl(n,e){let t=n.state.doc.resolve(e);if(!(Ee||Nc)&&t.parent.inlineContent){let i=n.coordsAtPos(e);if(e>t.start()){let r=n.coordsAtPos(e-1),o=(r.top+r.bottom)/2;if(o>i.top&&o1)return r.lefti.top&&o1)return r.left>i.left?"ltr":"rtl"}}return getComputedStyle(n.dom).direction=="rtl"?"rtl":"ltr"}function Sl(n,e,t){let s=n.state.selection;if(s instanceof U&&!s.empty||t.indexOf("s")>-1||Je&&t.indexOf("m")>-1)return!1;let{$from:i,$to:r}=s;if(!i.parent.inlineContent||n.endOfTextblock(e<0?"up":"down")){let o=Dr(n.state,e);if(o&&o instanceof W)return wt(n,o)}if(!i.parent.inlineContent){let o=e<0?i:r,l=s instanceof qe?X.near(o,e):X.findFrom(o,e);return l?wt(n,l):!1}return!1}function Cl(n,e){if(!(n.state.selection instanceof U))return!0;let{$head:t,$anchor:s,empty:i}=n.state.selection;if(!t.sameParent(s))return!0;if(!i)return!1;if(n.endOfTextblock(e>0?"forward":"backward"))return!0;let r=!t.textOffset&&(e<0?t.nodeBefore:t.nodeAfter);if(r&&!r.isText){let o=n.state.tr;return e<0?o.delete(t.pos-r.nodeSize,t.pos):o.delete(t.pos,t.pos+r.nodeSize),n.dispatch(o),!0}return!1}function Ml(n,e,t){n.domObserver.stop(),e.contentEditable=t,n.domObserver.start()}function t0(n){if(!$e||n.state.selection.$head.parentOffset>0)return!1;let{focusNode:e,focusOffset:t}=n.domSelectionRange();if(e&&q(e)&&t==0&&e.firstChild&&q(e.firstChild)&&e.firstChild.contentEditable=="false"){let s=e.firstChild;Ml(n,s,"true"),setTimeout(()=>Ml(n,s,"false"),20)}return!1}function n0(n){let e="";return n.ctrlKey&&(e+="c"),n.metaKey&&(e+="m"),n.altKey&&(e+="a"),n.shiftKey&&(e+="s"),e}function s0(n,e){let t=e.keyCode,s=n0(e);if(t==8||Je&&t==72&&s=="c")return Cl(n,-1)||pn(n,-1);if(t==46&&!e.shiftKey||Je&&t==68&&s=="c")return Cl(n,1)||pn(n,1);if(t==13||t==27)return!0;if(t==37||Je&&t==66&&s=="c"){let i=t==37?wl(n,n.state.selection.from)=="ltr"?-1:1:-1;return xl(n,i,s)||pn(n,i)}else if(t==39||Je&&t==70&&s=="c"){let i=t==39?wl(n,n.state.selection.from)=="ltr"?1:-1:1;return xl(n,i,s)||pn(n,i)}else{if(t==38||Je&&t==80&&s=="c")return Sl(n,-1,s)||pn(n,-1);if(t==40||Je&&t==78&&s=="c")return t0(n)||Sl(n,1,s)||pn(n,1);if(s==(Je?"m":"c")&&(t==66||t==73||t==89||t==90))return!0}return!1}function po(n,e){n.someProp("transformCopied",h=>{e=h(e,n)});let t=[],{content:s,openStart:i,openEnd:r}=e;for(;i>1&&r>1&&s.childCount==1&&s.firstChild.childCount==1;){i--,r--;let h=s.firstChild;t.push(h.type.name,h.attrs!=h.type.defaultAttrs?h.attrs:null),s=h.content}let o=n.someProp("clipboardSerializer")||ln.fromSchema(n.state.schema),l=Xc(),c=l.createElement("div");c.appendChild(o.serializeFragment(s,{document:l}));let d=c.firstChild,u,p=0;for(;d&&q(d)&&(u=Yc[d.nodeName.toLowerCase()]);){for(let h=u.length-1;h>=0;h--){let g=l.createElement(u[h]);for(;c.firstChild;)g.appendChild(c.firstChild);c.appendChild(g),p++}d=c.firstChild}d&&q(d)&&d.setAttribute("data-pm-slice",`${i} ${r}${p?` -${p}`:""} ${JSON.stringify(t)}`);let f=n.someProp("clipboardTextSerializer",h=>h(e,n))||e.content.textBetween(0,e.content.size,` `);return{dom:c,text:f,slice:e}}function Wc(n,e,t,s,i){let r=i.parent.type.spec.code,o,l;if(!t&&!e)return null;let c=!!e&&(s||r||!t);if(c){if(n.someProp("transformPastedText",f=>{e=f(e,r||s,n)}),r)return l=new z($.from(n.state.schema.text(e.replace(/\r\n?/g,` -`))),0,0),n.someProp("transformPasted",f=>{l=f(l,n,!0)}),l;let p=n.someProp("clipboardTextParser",f=>f(e,i,s,n));if(p)l=p;else{let f=i.marks(),{schema:h}=n.state,g=ln.fromSchema(h);o=document.createElement("div"),e.split(/(?:\r\n?|\n)+/).forEach(b=>{let m=o.appendChild(document.createElement("p"));b&&m.appendChild(g.serializeNode(h.text(b,f)))})}}else n.someProp("transformPastedHTML",p=>{t=p(t,n)}),o=o0(t),zi&&l0(o);let d=o&&o.querySelector("[data-pm-slice]"),u=d&&/^(\d+) (\d+)(?: -(\d+))? (.*)/.exec(d.getAttribute("data-pm-slice")||"");if(u&&u[3])for(let p=+u[3];p>0;p--){let f=o.firstChild;for(;f&&!q(f);)f=f.nextSibling;if(!f)break;o=f}if(l||(l=(n.someProp("clipboardParser")||n.someProp("domParser")||Ot.fromSchema(n.state.schema)).parseSlice(o,{preserveWhitespace:!!(c||u),context:i,ruleFromNode(f){return f.nodeName=="BR"&&!f.nextSibling&&f.parentNode&&!s0.test(f.parentNode.nodeName)?{ignore:!0}:null}})),u)l=a0(Tl(l,+u[1],+u[2]),u[4]);else if(l=z.maxOpen(i0(l.content,i),!0),l.openStart||l.openEnd){let p=0,f=0;for(let h=l.content.firstChild;p{l=p(l,n,c)}),l}const s0=/^(a|abbr|acronym|b|cite|code|del|em|i|ins|kbd|label|output|q|ruby|s|samp|span|strong|sub|sup|time|u|tt|var)$/i;function i0(n,e){if(n.childCount<2)return n;for(let t=e.depth;t>=0;t--){let i=e.node(t).contentMatchAt(e.index(t)),r,o=[];if(n.forEach(l=>{if(!o)return;let c=i.findWrapping(l.type),d;if(!c)return o=null;if(d=o.length&&r.length&&Jc(c,r,l,o[o.length-1],0))o[o.length-1]=d;else{o.length&&(o[o.length-1]=Gc(o[o.length-1],r.length));let u=Kc(l,c);o.push(u),i=i.matchType(u.type),r=c}}),o)return $.from(o)}return n}function Kc(n,e,t=0){for(let s=e.length-1;s>=t;s--)n=e[s].create(null,$.from(n));return n}function Jc(n,e,t,s,i){if(i1&&(r=0),i=t&&(l=e<0?o.contentMatchAt(0).fillBefore(l,r<=i).append(l):l.append(o.contentMatchAt(o.childCount).fillBefore($.empty,!0))),n.replaceChild(e<0?0:n.childCount-1,o.copy(l))}function Tl(n,e,t){return et})}return Rn.createHTML(n)}function o0(n){let e=/^(\s*]*>)*/.exec(n);e&&(n=n.slice(e[0].length));let t=Xc(),s=t.body,i=/<([a-z][^>\s]+)/i.exec(n),r;if((r=i&&Yc[i[1].toLowerCase()])&&(n=r.map(o=>"<"+o+">").join("")+n+r.map(o=>"").reverse().join("")),s.innerHTML=r0(n),r)for(let o=0;o=0;l-=2){let c=t.nodes[s[l]];if(!c||c.hasRequiredAttrs())break;try{i=$.from(c.create(s[l+1],i))}catch(d){break}r++,o++}return new z(i,r,o)}const Pe={},Be={},c0={touchstart:!0,touchmove:!0};class d0{constructor(){this.shiftKey=!1,this.mouseDown=null,this.lastKeyCode=null,this.lastKeyCodeTime=0,this.lastClick={time:0,x:0,y:0,type:"",button:0},this.lastSelectionOrigin=null,this.lastSelectionTime=0,this.lastIOSEnter=0,this.lastIOSEnterFallbackTimeout=-1,this.lastFocus=0,this.lastTouch=0,this.lastChromeDelete=0,this.composing=!1,this.compositionNode=null,this.composingTimeout=-1,this.compositionNodes=[],this.compositionEndedAt=-2e8,this.compositionID=1,this.badSafariComposition=!1,this.compositionPendingChanges=0,this.domChangeCount=0,this.eventHandlers=Object.create(null),this.hideSelectionGuard=null}}function u0(n){for(let e in Pe){let t=Pe[e];n.dom.addEventListener(e,n.input.eventHandlers[e]=s=>{f0(n,s)&&!fo(n,s)&&(n.editable||!(s.type in Be))&&t(n,s)},c0[e]?{passive:!0}:void 0)}$e&&n.dom.addEventListener("input",()=>null),Lr(n)}function ht(n,e){n.input.lastSelectionOrigin=e,n.input.lastSelectionTime=Date.now()}function p0(n){n.input.mouseDown&&n.input.mouseDown.done(),n.domObserver.stop();for(let e in n.input.eventHandlers)n.dom.removeEventListener(e,n.input.eventHandlers[e]);clearTimeout(n.input.composingTimeout),clearTimeout(n.input.lastIOSEnterFallbackTimeout)}function Lr(n){n.someProp("handleDOMEvents",e=>{for(let t in e)n.input.eventHandlers[t]||n.dom.addEventListener(t,n.input.eventHandlers[t]=s=>fo(n,s))})}function fo(n,e){return n.someProp("handleDOMEvents",t=>{let s=t[e.type];return s?s(n,e)||e.defaultPrevented:!1})}function f0(n,e){if(!e.bubbles)return!0;if(e.defaultPrevented)return!1;for(let t=e.target;t!=n.dom;t=t.parentNode)if(!t||t.nodeType==11||t.pmViewDesc&&t.pmViewDesc.stopEvent(e))return!1;return!0}function h0(n,e){!fo(n,e)&&Pe[e.type]&&(n.editable||!(e.type in Be))&&Pe[e.type](n,e)}Be.keydown=(n,e)=>{let t=e;if(n.input.shiftKey=t.keyCode==16||t.shiftKey,!td(n)&&(n.input.lastKeyCode=t.keyCode,n.input.lastKeyCodeTime=Date.now(),!(ft&&Ee&&t.keyCode==13)))if(t.keyCode!=229&&n.domObserver.forceFlush(),Tn&&t.keyCode==13&&!t.ctrlKey&&!t.altKey&&!t.metaKey){let s=Date.now();n.input.lastIOSEnter=s,n.input.lastIOSEnterFallbackTimeout=setTimeout(()=>{n.input.lastIOSEnter==s&&(n.someProp("handleKeyDown",i=>i(n,qt(13,"Enter"))),n.input.lastIOSEnter=0)},200)}else n.someProp("handleKeyDown",s=>s(n,t))||n0(n,t)?t.preventDefault():ht(n,"key")};Be.keyup=(n,e)=>{e.keyCode==16&&(n.input.shiftKey=!1)};Be.keypress=(n,e)=>{let t=e;if(td(n)||!t.charCode||t.ctrlKey&&!t.altKey||Je&&t.metaKey)return;if(n.someProp("handleKeyPress",i=>i(n,t))){t.preventDefault();return}let s=n.state.selection;if(!(s instanceof U)||!s.$from.sameParent(s.$to)){let i=String.fromCharCode(t.charCode),r=()=>n.state.tr.insertText(i).scrollIntoView();!/[\r\n]/.test(i)&&!n.someProp("handleTextInput",o=>o(n,s.$from.pos,s.$to.pos,i,r))&&n.dispatch(r()),t.preventDefault()}};function bs(n){return{left:n.clientX,top:n.clientY}}function m0(n,e){let t=e.x-n.clientX,s=e.y-n.clientY;return t*t+s*s<100}function ho(n,e,t,s,i){if(s==-1)return!1;let r=n.state.doc.resolve(s);for(let o=r.depth+1;o>0;o--)if(n.someProp(e,l=>o>r.depth?l(n,t,r.nodeAfter,r.before(o),i,!0):l(n,t,r.node(o),r.before(o),i,!1)))return!0;return!1}function vs(n,e,t){if(n.focused||n.focus(),n.state.selection.eq(e))return;let s=n.state.tr.setSelection(e);s.setMeta("pointer",!0),n.dispatch(s)}function g0(n,e){if(e==-1)return!1;let t=n.state.doc.resolve(e),s=t.nodeAfter;return s&&s.isAtom&&W.isSelectable(s)?(vs(n,new W(t)),!0):!1}function b0(n,e){if(e==-1)return!1;let t=n.state.selection,s,i;t instanceof W&&(s=t.node);let r=n.state.doc.resolve(e);for(let o=r.depth+1;o>0;o--){let l=o>r.depth?r.nodeAfter:r.node(o);if(W.isSelectable(l)){s&&t.$from.depth>0&&o>=t.$from.depth&&r.before(t.$from.depth+1)==t.$from.pos?i=r.before(t.$from.depth):i=r.before(o);break}}return i!=null?(vs(n,W.create(n.state.doc,i)),!0):!1}function v0(n,e,t,s,i){return ho(n,"handleClickOn",e,t,s)||n.someProp("handleClick",r=>r(n,e,s))||(i?b0(n,t):g0(n,t))}function y0(n,e,t,s){return ho(n,"handleDoubleClickOn",e,t,s)||n.someProp("handleDoubleClick",i=>i(n,e,s))}function k0(n,e,t,s){return ho(n,"handleTripleClickOn",e,t,s)||n.someProp("handleTripleClick",i=>i(n,e,s))||x0(n,t,s)}function x0(n,e,t){if(t.button!=0)return!1;let s=Zc(n,e,!0),i=n.state.doc;return s?(vs(n,s),s instanceof U&&i.eq(n.state.doc)&&(n.input.mouseDown=new S0(n,s)),!0):!1}function Zc(n,e,t){let s=n.state.doc;if(e==-1)return s.inlineContent?U.create(s,0,s.content.size):null;let i=s.resolve(e);for(let r=i.depth+1;r>0;r--){let o=r>i.depth?i.nodeAfter:i.node(r),l=i.before(r);if(o.inlineContent)return U.create(s,l+1,l+1+o.content.size);if(t&&W.isSelectable(o))return W.create(s,l)}return null}function mo(n){return Ys(n)}const Qc=Je?"metaKey":"ctrlKey";Pe.mousedown=(n,e)=>{let t=e;n.input.shiftKey=t.shiftKey;let s=mo(n),i=Date.now(),r="singleClick";i-n.input.lastClick.time<500&&m0(t,n.input.lastClick)&&!t[Qc]&&n.input.lastClick.button==t.button&&(n.input.lastClick.type=="singleClick"?r="doubleClick":n.input.lastClick.type=="doubleClick"&&(r="tripleClick")),n.input.lastClick={time:i,x:t.clientX,y:t.clientY,type:r,button:t.button},n.input.mouseDown&&n.input.mouseDown.done();let o=n.posAtCoords(bs(t));o&&(r=="singleClick"?n.input.mouseDown=new w0(n,o,t,!!s):(r=="doubleClick"?y0:k0)(n,o.pos,o.inside,t)?t.preventDefault():ht(n,"pointer"))};class ed{constructor(e){this.view=e,this.mightDrag=null,e.root.addEventListener("mouseup",this.up=this.up.bind(this)),e.root.addEventListener("mousemove",this.move=this.move.bind(this))}up(e){this.done()}move(e){e.buttons==0&&this.done()}done(){this.view.root.removeEventListener("mouseup",this.up),this.view.root.removeEventListener("mousemove",this.move),this.view.input.mouseDown==this&&(this.view.input.mouseDown=null)}delaySelUpdate(){return!1}}class w0 extends ed{constructor(e,t,s,i){super(e),this.pos=t,this.event=s,this.flushed=i,this.delayedSelectionSync=!1,this.startDoc=e.state.doc,this.selectNode=!!s[Qc],this.allowDefault=s.shiftKey;let r,o;if(t.inside>-1)r=e.state.doc.nodeAt(t.inside),o=t.inside;else{let u=e.state.doc.resolve(t.pos);r=u.parent,o=u.depth?u.before():0}const l=i?null:s.target,c=l?e.docView.nearestDesc(l,!0):null;this.target=c&&q(c.nodeDOM)?c.nodeDOM:null;let{selection:d}=e.state;s.button==0&&(r.type.spec.draggable&&r.type.spec.selectable!==!1||d instanceof W&&d.from<=o&&d.to>o)&&(this.mightDrag={node:r,pos:o,addAttr:!!(this.target&&!this.target.draggable),setUneditable:!!(this.target&&Ue&&!this.target.hasAttribute("contentEditable"))}),this.target&&this.mightDrag&&(this.mightDrag.addAttr||this.mightDrag.setUneditable)&&(this.view.domObserver.stop(),this.mightDrag.addAttr&&(this.target.draggable=!0),this.mightDrag.setUneditable&&setTimeout(()=>{this.view.input.mouseDown==this&&this.target.setAttribute("contentEditable","false")},20),this.view.domObserver.start()),ht(e,"pointer")}done(){super.done(),this.mightDrag&&this.target&&(this.view.domObserver.stop(),this.mightDrag.addAttr&&this.target.removeAttribute("draggable"),this.mightDrag.setUneditable&&this.target.removeAttribute("contentEditable"),this.view.domObserver.start()),this.delayedSelectionSync&&setTimeout(()=>{this.view.isDestroyed||gt(this.view)})}up(e){if(this.done(),!this.view.dom.contains(e.target))return;let t=this.pos;this.view.state.doc!=this.startDoc&&(t=this.view.posAtCoords(bs(e))),this.updateAllowDefault(e),this.allowDefault||!t?ht(this.view,"pointer"):v0(this.view,t.pos,t.inside,e,this.selectNode)?e.preventDefault():e.button==0&&(this.flushed||$e&&this.mightDrag&&!this.mightDrag.node.isAtom||Ee&&!this.view.state.selection.visible&&Math.min(Math.abs(t.pos-this.view.state.selection.from),Math.abs(t.pos-this.view.state.selection.to))<=2)?(vs(this.view,X.near(this.view.state.doc.resolve(t.pos))),e.preventDefault()):ht(this.view,"pointer")}move(e){this.updateAllowDefault(e),ht(this.view,"pointer"),super.move(e)}updateAllowDefault(e){!this.allowDefault&&(Math.abs(this.event.x-e.clientX)>4||Math.abs(this.event.y-e.clientY)>4)&&(this.allowDefault=!0)}delaySelUpdate(){return this.allowDefault?(this.delayedSelectionSync=!0,!0):!1}}class S0 extends ed{constructor(e,t){super(e),this.startSelection=t,this.startDoc=e.state.doc}move(e){if(e.buttons==0||this.view.isDestroyed||!this.view.state.doc.eq(this.startDoc)){this.done();return}e.preventDefault(),ht(this.view,"pointer");let t=this.view.posAtCoords(bs(e)),s=t&&Zc(this.view,t.inside,!1);if(!s)return;let{doc:i}=this.view.state,r=this.startSelection,[o,l]=s.from{n.input.lastTouch=Date.now(),mo(n),ht(n,"pointer")};Pe.touchmove=n=>{n.input.lastTouch=Date.now(),ht(n,"pointer")};Pe.contextmenu=n=>mo(n);function td(n,e){return n.composing?!0:$e&&Math.abs(Date.now()-n.input.compositionEndedAt)<500?(n.input.compositionEndedAt=-2e8,!0):!1}const C0=ft?5e3:-1;Be.compositionstart=Be.compositionupdate=n=>{if(!n.composing){n.domObserver.flush();let{state:e}=n,t=e.selection.$to;if(e.selection instanceof U&&e.selection.empty&&(e.storedMarks||!t.textOffset&&t.parentOffset&&t.nodeBefore.marks.some(s=>s.type.spec.inclusive===!1)||Ee&&Nc&&M0(n)))n.markCursor=n.state.storedMarks||t.marks(),Ys(n,!0),n.markCursor=null;else if(Ys(n,!e.selection.empty),Ue&&e.selection.empty&&t.parentOffset&&!t.textOffset&&t.nodeBefore.marks.length){let s=n.domSelectionRange();for(let i=s.focusNode,r=s.focusOffset;i&&q(i)&&r!=0;){let o=r<0?i.lastChild:i.childNodes[r-1];if(!o)break;if(ve(o)){let l=n.domSelection();l&&l.collapse(o,o.nodeValue.length);break}else i=o,r=-1}}n.input.composing=!0}nd(n,C0)};function M0(n){let{focusNode:e,focusOffset:t}=n.domSelectionRange();if(!e||!q(e)||t>=e.childNodes.length)return!1;let s=e.childNodes[t];return q(s)&&s.contentEditable=="false"}Be.compositionend=(n,e)=>{n.composing&&(n.input.composing=!1,n.input.compositionEndedAt=Date.now(),n.input.compositionPendingChanges=n.domObserver.pendingRecords().length?n.input.compositionID:0,n.input.compositionNode=null,n.input.badSafariComposition?n.domObserver.forceFlush():n.input.compositionPendingChanges&&Promise.resolve().then(()=>n.domObserver.flush()),n.input.compositionID++,nd(n,20))};function nd(n,e){clearTimeout(n.input.composingTimeout),e>-1&&(n.input.composingTimeout=setTimeout(()=>Ys(n),e))}function sd(n){for(n.composing&&(n.input.composing=!1,n.input.compositionEndedAt=Date.now());n.input.compositionNodes.length>0;)n.input.compositionNodes.pop().markParentsDirty()}function T0(n){let e=n.domSelectionRange();if(!e.focusNode)return null;let t=by(e.focusNode,e.focusOffset),s=vy(e.focusNode,e.focusOffset);if(t&&s&&t!=s){let i=s.pmViewDesc,r=n.domObserver.lastChangedTextNode;if(t==r||s==r)return r;if(!i||!i.isText(s.nodeValue))return s;if(n.input.compositionNode==s){let o=t.pmViewDesc;if(!(!o||!o.isText(t.nodeValue)))return s}}return t||s}function Ys(n,e=!1){if(!(ft&&n.domObserver.flushingSoon>=0)){if(n.domObserver.forceFlush(),sd(n),e||n.docView&&n.docView.dirty){let t=co(n),s=n.state.selection;return t&&!t.eq(s)?n.dispatch(n.state.tr.setSelection(t)):(n.markCursor||e)&&!s.$from.node(s.$from.sharedDepth(s.to)).inlineContent?n.dispatch(n.state.tr.deleteSelection()):n.updateState(n.state),!0}return!1}}function E0(n,e){if(!n.dom.parentNode)return;let t=n.dom.parentNode.appendChild(document.createElement("div"));t.appendChild(e),t.style.cssText="position: fixed; left: -10000px; top: 10px";let s=getSelection(),i=document.createRange();i.selectNodeContents(e),n.dom.blur(),s.removeAllRanges(),s.addRange(i),setTimeout(()=>{t.parentNode&&t.parentNode.removeChild(t),n.focus()},50)}const cs=je&&Nt<15||Tn&&wy<604;Pe.copy=Be.cut=(n,e)=>{let t=e,s=n.state.selection,i=t.type=="cut";if(s.empty)return;let r=cs?null:t.clipboardData,o=s.content(),{dom:l,text:c}=po(n,o);r?(t.preventDefault(),r.clearData(),r.setData("text/html",l.innerHTML),r.setData("text/plain",c)):E0(n,l),i&&n.dispatch(n.state.tr.deleteSelection().scrollIntoView().setMeta("uiEvent","cut"))};function A0(n){return n.openStart==0&&n.openEnd==0&&n.content.childCount==1?n.content.firstChild:null}function O0(n,e){if(!n.dom.parentNode)return;let t=n.input.shiftKey||n.state.selection.$from.parent.type.spec.code,s=n.dom.parentNode.appendChild(document.createElement(t?"textarea":"div"));t||(s.contentEditable="true"),s.style.cssText="position: fixed; left: -10000px; top: 10px",s.focus();let i=n.input.shiftKey&&n.input.lastKeyCode!=45;setTimeout(()=>{n.focus(),s.parentNode&&s.parentNode.removeChild(s),t?ds(n,s.value,null,i,e):ds(n,s.textContent,s.innerHTML,i,e)},50)}function ds(n,e,t,s,i){let r=Wc(n,e,t,s,n.state.selection.$from);if(n.someProp("handlePaste",c=>c(n,i,r||z.empty)))return!0;if(!r)return!1;let o=A0(r),l=o?n.state.tr.replaceSelectionWith(o,s):n.state.tr.replaceSelection(r);return n.dispatch(l.scrollIntoView().setMeta("paste",!0).setMeta("uiEvent","paste")),!0}function id(n){let e=n.getData("text/plain")||n.getData("Text");if(e)return e;let t=n.getData("text/uri-list");return t?t.replace(/\r?\n/g," "):""}Be.paste=(n,e)=>{let t=e;if(n.composing&&!ft)return;let s=cs?null:t.clipboardData,i=n.input.shiftKey&&n.input.lastKeyCode!=45;s&&ds(n,id(s),s.getData("text/html"),i,t)?t.preventDefault():O0(n,t)};class rd{constructor(e,t,s){this.slice=e,this.move=t,this.node=s}}const N0=Je?"altKey":"ctrlKey";function od(n,e){let t;return n.someProp("dragCopies",s=>{t=t||s(e)}),t!=null?!t:!e[N0]}Pe.dragstart=(n,e)=>{let t=e,s=n.input.mouseDown;if(s&&s.done(),!t.dataTransfer)return;let i=n.state.selection,r=i.empty?null:n.posAtCoords(bs(t)),o;if(!(r&&r.pos>=i.from&&r.pos<=(i instanceof W?i.to-1:i.to))){if(s&&s.mightDrag)o=W.create(n.state.doc,s.mightDrag.pos);else if(t.target&&q(t.target)){let p=n.docView.nearestDesc(t.target,!0);p&&p.node.type.spec.draggable&&p!=n.docView&&(o=W.create(n.state.doc,p.posBefore))}}let l=(o||n.state.selection).content(),{dom:c,text:d,slice:u}=po(n,l);(!t.dataTransfer.files.length||!Ee||Oc>120)&&t.dataTransfer.clearData(),t.dataTransfer.setData(cs?"Text":"text/html",c.innerHTML),t.dataTransfer.effectAllowed="copyMove",cs||t.dataTransfer.setData("text/plain",d),n.dragging=new rd(u,od(n,t),o)};Pe.dragend=n=>{let e=n.dragging;window.setTimeout(()=>{n.dragging==e&&(n.dragging=null)},50)};Be.dragover=Be.dragenter=(n,e)=>e.preventDefault();Be.drop=(n,e)=>{try{I0(n,e,n.dragging)}finally{n.dragging=null}};function I0(n,e,t){if(!e.dataTransfer)return;let s=n.posAtCoords(bs(e));if(!s)return;let i=n.state.doc.resolve(s.pos),r=t&&t.slice;r?n.someProp("transformPasted",h=>{r=h(r,n,!1)}):r=Wc(n,id(e.dataTransfer),cs?null:e.dataTransfer.getData("text/html"),!1,i);let o=!!(t&&od(n,e));if(n.someProp("handleDrop",h=>h(n,e,r||z.empty,o))){e.preventDefault();return}if(!r)return;e.preventDefault();let l=r?lc(n.state.doc,i.pos,r):i.pos;l==null&&(l=i.pos);let c=n.state.tr;if(o){let{node:h}=t;h?h.replace(c):c.deleteSelection()}let d=c.mapping.map(l),u=r.openStart==0&&r.openEnd==0&&r.content.childCount==1,p=c.doc;if(u?c.replaceRangeWith(d,d,r.content.firstChild):c.replaceRange(d,d,r),c.doc.eq(p))return;let f=c.doc.resolve(d);if(u&&W.isSelectable(r.content.firstChild)&&f.nodeAfter&&f.nodeAfter.sameMarkup(r.content.firstChild))c.setSelection(new W(f));else{let h=c.mapping.map(l);c.mapping.maps[c.mapping.maps.length-1].forEach((g,b,m,v)=>h=v),c.setSelection(uo(n,f,c.doc.resolve(h)))}n.focus(),n.dispatch(c.setMeta("uiEvent","drop"))}Pe.focus=n=>{n.input.lastFocus=Date.now(),n.focused||(n.domObserver.stop(),n.dom.classList.add("ProseMirror-focused"),n.domObserver.start(),n.focused=!0,setTimeout(()=>{n.docView&&n.hasFocus()&&!n.domObserver.currentSelection.eq(n.domSelectionRange())&>(n)},20))};Pe.blur=(n,e)=>{let t=e;n.focused&&(n.domObserver.stop(),n.dom.classList.remove("ProseMirror-focused"),n.domObserver.start(),t.relatedTarget&&n.dom.contains(t.relatedTarget)&&n.domObserver.currentSelection.clear(),n.focused=!1)};Pe.beforeinput=(n,e)=>{if(ft&&e.inputType=="deleteContentBackward"){n.domObserver.flushSoon();let{domChangeCount:s}=n.input;setTimeout(()=>{if(n.input.domChangeCount!=s||(n.dom.blur(),n.focus(),n.someProp("handleKeyDown",r=>r(n,qt(8,"Backspace")))))return;let{$cursor:i}=n.state.selection;i&&i.pos>0&&n.dispatch(n.state.tr.delete(i.pos-1,i.pos).scrollIntoView())},50)}};for(let n in Be)Pe[n]=Be[n];function us(n,e){if(n==e)return!0;for(let t in n)if(n[t]!==e[t])return!1;for(let t in e)if(!(t in n))return!1;return!0}class Xs{constructor(e,t){this.toDOM=e,this.spec=t||Qt,this.side=this.spec.side||0}map(e,t,s,i){let{pos:r,deleted:o}=e.mapResult(t.from+i,this.side<0?-1:1);return o?null:new Le(r-s,r-s,this)}valid(){return!0}eq(e){return this==e||e instanceof Xs&&(this.spec.key&&this.spec.key==e.spec.key||this.toDOM==e.toDOM&&us(this.spec,e.spec))}destroy(e){this.spec.destroy&&this.spec.destroy(e)}}class $t{constructor(e,t){this.attrs=e,this.spec=t||Qt}map(e,t,s,i){let r=e.map(t.from+i,this.spec.inclusiveStart?-1:1)-s,o=e.map(t.to+i,this.spec.inclusiveEnd?1:-1)-s;return r>=o?null:new Le(r,o,this)}valid(e,t){return t.from=e&&(!r||r(l.spec))&&s.push(l.copy(l.from+i,l.to+i))}for(let o=0;oe){let l=this.children[o]+1;this.children[o+2].findInner(e-l,t-l,s,i+l,r)}}map(e,t,s){return this==Ne||e.maps.length==0?this:this.mapInner(e,t,0,0,s||Qt)}mapInner(e,t,s,i,r){let o;for(let l=0;l{let d=c+s,u;if(u=ad(t,l,d)){for(i||(i=this.children.slice());rl&&p.to=e){this.children[l]==e&&(s=this.children[l+2]);break}let r=e+1,o=r+t.content.size;for(let l=0;lr&&c.type instanceof $t){let d=Math.max(r,c.from)-r,u=Math.min(o,c.to)-r;di.map(e,t,Qt));return Mt.from(s)}forChild(e,t){if(t.isLeaf)return ne.empty;let s=[];for(let i=0;it instanceof ne)?e:e.reduce((t,s)=>t.concat(s instanceof ne?s:s.members),[]))}}forEachSet(e){for(let t=0;t{let m=b-g-(h-f);for(let v=0;vS+u-p)continue;let A=l[v]+u-p;h>=A?l[v+1]=f<=A?-2:-1:f>=u&&m&&(l[v]+=m,l[v+1]+=m)}p+=m}),u=t.maps[d].map(u,-1)}let c=!1;for(let d=0;d=s.content.size){c=!0;continue}let f=t.map(n[d+1]+r,-1),h=f-i,{index:g,offset:b}=s.content.findIndex(p),m=s.maybeChild(g);if(m&&b==p&&b+m.nodeSize==h){let v=l[d+2].mapInner(t,m,u+1,n[d]+r+1,o);v!=Ne?(l[d]=p,l[d+1]=h,l[d+2]=v):(l[d+1]=-2,c=!0)}else c=!0}if(c){let d=$0(l,n,e,t,i,r,o),u=Zs(d,s,0,o);e=u.local;for(let p=0;pt&&o.to{let d=ad(n,l,c+t);if(d){r=!0;let u=Zs(d,l,t+c+1,s);u!=Ne&&i.push(c,c+l.nodeSize,u)}});let o=ld(r?cd(n):n,-t).sort(en);for(let l=0;l0;)e++;n.splice(e,0,t)}function rr(n){let e=[];return n.someProp("decorations",t=>{let s=t(n.state);s&&s!=Ne&&e.push(s)}),n.cursorWrapper&&e.push(ne.create(n.state.doc,[n.cursorWrapper.deco])),Mt.from(e)}const R0={childList:!0,characterData:!0,characterDataOldValue:!0,attributes:!0,attributeOldValue:!0,subtree:!0},L0=je&&Nt<=11;class P0{constructor(){this.anchorNode=null,this.anchorOffset=0,this.focusNode=null,this.focusOffset=0}set(e){this.anchorNode=e.anchorNode,this.anchorOffset=e.anchorOffset,this.focusNode=e.focusNode,this.focusOffset=e.focusOffset}clear(){this.anchorNode=this.focusNode=null}eq(e){return e.anchorNode==this.anchorNode&&e.anchorOffset==this.anchorOffset&&e.focusNode==this.focusNode&&e.focusOffset==this.focusOffset}}class B0{constructor(e,t){this.view=e,this.handleDOMChange=t,this.queue=[],this.flushingSoon=-1,this.observer=null,this.currentSelection=new P0,this.onCharData=null,this.suppressingSelectionUpdates=!1,this.lastChangedTextNode=null,this.observer=window.MutationObserver&&new window.MutationObserver(s=>{for(let i=0;ii.type=="childList"&&i.removedNodes.length||i.type=="characterData"&&i.oldValue.length>i.target.nodeValue.length)?this.flushSoon():$e&&e.composing&&s.some(i=>i.type=="childList"&&i.target.nodeName=="TR")?(e.input.badSafariComposition=!0,this.flushSoon()):this.flush()}),L0&&(this.onCharData=s=>{this.queue.push({target:s.target,type:"characterData",oldValue:s.prevValue}),this.flushSoon()}),this.onSelectionChange=this.onSelectionChange.bind(this)}flushSoon(){this.flushingSoon<0&&(this.flushingSoon=window.setTimeout(()=>{this.flushingSoon=-1,this.flush()},20))}forceFlush(){this.flushingSoon>-1&&(window.clearTimeout(this.flushingSoon),this.flushingSoon=-1,this.flush())}start(){this.observer&&(this.observer.takeRecords(),this.observer.observe(this.view.dom,R0)),this.onCharData&&this.view.dom.addEventListener("DOMCharacterDataModified",this.onCharData),this.connectSelection()}stop(){if(this.observer){let e=this.observer.takeRecords();if(e.length){for(let t=0;tthis.flush(),20)}this.observer.disconnect()}this.onCharData&&this.view.dom.removeEventListener("DOMCharacterDataModified",this.onCharData),this.disconnectSelection()}connectSelection(){this.view.dom.ownerDocument.addEventListener("selectionchange",this.onSelectionChange)}disconnectSelection(){this.view.dom.ownerDocument.removeEventListener("selectionchange",this.onSelectionChange)}suppressSelectionUpdates(){this.suppressingSelectionUpdates=!0,setTimeout(()=>this.suppressingSelectionUpdates=!1,50)}onSelectionChange(){if(kl(this.view)){if(this.suppressingSelectionUpdates)return gt(this.view);if(je&&Nt<=11&&!this.view.state.selection.empty){let e=this.view.domSelectionRange();if(e.focusNode&&sn(e.focusNode,e.focusOffset,e.anchorNode,e.anchorOffset))return this.flushSoon()}this.flush()}}setCurSelection(){this.currentSelection.set(this.view.domSelectionRange())}ignoreSelectionChange(e){if(!e.focusNode)return!0;let t=new Set,s;for(let r=e.focusNode;r;r=Mn(r))t.add(r);for(let r=e.anchorNode;r;r=Mn(r))if(t.has(r)){s=r;break}let i=s&&this.view.docView.nearestDesc(s);if(i&&i.ignoreMutation({type:"selection",target:ve(s)?s.parentNode:s}))return this.setCurSelection(),!0}pendingRecords(){if(this.observer)for(let e of this.observer.takeRecords())this.queue.push(e);return this.queue}flush(){let{view:e}=this;if(!e.docView||this.flushingSoon>-1)return;let t=this.pendingRecords();t.length&&(this.queue=[]);let s=e.domSelectionRange(),i=!this.suppressingSelectionUpdates&&!this.currentSelection.eq(s)&&kl(e)&&!this.ignoreSelectionChange(s),r=-1,o=-1,l=!1,c=[];if(e.editable)for(let u=0;uu.nodeName=="BR")&&(e.input.lastKeyCode==8||e.input.lastKeyCode==46||Ee&&(e.composing||e.input.compositionEndedAt>Date.now()-50)&&t.some(u=>u.type=="childList"&&u.removedNodes.length))){for(let u of c)if(u.nodeName=="BR"&&u.parentNode){let p=u.nextSibling;for(;p&&q(p);){if(p.contentEditable=="false"){u.parentNode.removeChild(u);break}p=p.firstChild}}}else if(Ue&&c.length){let u=c.filter(p=>p.nodeName=="BR");if(u.length==2){let[p,f]=u;p.parentNode&&p.parentNode.parentNode==f.parentNode?f.remove():p.remove()}else{let{focusNode:p}=this.currentSelection;for(let f of u){let h=f.parentNode;h&&h.nodeName=="LI"&&(!p||j0(e,p)!=h)&&f.remove()}}}let d=null;r<0&&i&&e.input.lastFocus>Date.now()-200&&Math.max(e.input.lastTouch,e.input.lastClick.time)-1||i)&&(r>-1&&(e.docView.markDirty(r,o),_0(e)),e.input.badSafariComposition&&(e.input.badSafariComposition=!1,F0(e,c)),this.handleDOMChange(r,o,l,c),e.docView&&e.docView.dirty?e.updateState(e.state):this.currentSelection.eq(s)||gt(e),this.currentSelection.set(s))}registerMutation(e,t){if(t.indexOf(e.target)>-1)return null;let s=this.view.docView.nearestDesc(e.target);if(e.type=="attributes"&&(s==this.view.docView||e.attributeName=="contenteditable"||e.attributeName=="style"&&!e.oldValue&&!e.target.getAttribute("style"))||!s||s.ignoreMutation(e))return null;if(e.type=="childList"){for(let u=0;ur;v--){let S=i.childNodes[v-1],A=S.pmViewDesc;if(S.nodeName=="BR"&&!A){o=v;break}if(!A||A.size)break}let f=n.state.doc,h=n.someProp("domParser")||Ot.fromSchema(n.state.schema),g=f.resolve(l),b=null,m=h.parse(i,{topNode:g.parent,topMatch:g.parent.contentMatchAt(g.index()),topOpen:!0,from:r,to:o,preserveWhitespace:g.parent.type.whitespace=="pre"?"full":!0,findPositions:u,ruleFromNode:H0(s),context:g});if(u&&u[0].pos!=null){let v=u[0].pos,S=u[1]&&u[1].pos;S==null&&(S=v),b={anchor:v+l,head:S+l}}return{doc:m,sel:b,from:l,to:c}}const H0=n=>e=>{let t=e.pmViewDesc;if(t)return t.parseRule(n);if(e.nodeName=="BR"&&e.parentNode){if($e&&/^(ul|ol)$/i.test(e.parentNode.nodeName)){let s=document.createElement("div");return s.appendChild(document.createElement("li")),{skip:s}}else if(e.parentNode.lastChild==e||$e&&/^(tr|table)$/i.test(e.parentNode.nodeName))return{ignore:!0}}else if(e.nodeName=="IMG"&&e.getAttribute("mark-placeholder"))return{ignore:!0};return null},q0=/^(a|abbr|acronym|b|bd[io]|big|br|button|cite|code|data(list)?|del|dfn|em|i|img|ins|kbd|label|map|mark|meter|output|q|ruby|s|samp|small|span|strong|su[bp]|time|u|tt|var)$/i;function U0(n,e,t,s,i){let r=n.input.compositionPendingChanges||(n.composing?n.input.compositionID:0);if(n.input.compositionPendingChanges=0,e<0){let M=n.input.lastSelectionTime>Date.now()-50?n.input.lastSelectionOrigin:null,w=co(n,M);if(w&&!n.state.selection.eq(w)){if(Ee&&ft&&n.input.lastKeyCode===13&&Date.now()-100N(n,qt(13,"Enter"))))return;let T=n.state.tr.setSelection(w);M=="pointer"?T.setMeta("pointer",!0):M=="key"&&T.scrollIntoView(),r&&T.setMeta("composition",r),n.dispatch(T)}return}let o=n.state.doc.resolve(e),l=o.sharedDepth(t);e=o.before(l+1),t=n.state.doc.resolve(t).after(l+1);let c=n.state.selection,d=V0(n,e,t,i),u=n.state.doc,p=u.slice(d.from,d.to),f,h;n.input.lastKeyCode===8&&Date.now()-100Date.now()-225||ft)&&i.some(M=>q(M)&&!q0.test(M.nodeName))&&(!g||g.endA>=g.endB)&&n.someProp("handleKeyDown",M=>M(n,qt(13,"Enter")))){n.input.lastIOSEnter=0;return}if(!g)if(s&&c instanceof U&&!c.empty&&c.$head.sameParent(c.$anchor)&&!n.composing&&!(d.sel&&d.sel.anchor!=d.sel.head))g={start:c.from,endA:c.to,endB:c.to};else{if(d.sel){let M=Il(n,n.state.doc,d.sel);if(M&&!M.eq(n.state.selection)){let w=n.state.tr.setSelection(M);r&&w.setMeta("composition",r),n.dispatch(w)}}return}n.state.selection.fromn.state.selection.from&&g.start<=n.state.selection.from+2&&n.state.selection.from>=d.from?g.start=n.state.selection.from:g.endA=n.state.selection.to-2&&n.state.selection.to<=d.to&&(g.endB+=n.state.selection.to-g.endA,g.endA=n.state.selection.to)),je&&Nt<=11&&g.endB==g.start+1&&g.endA==g.start&&g.start>d.from&&d.doc.textBetween(g.start-d.from-1,g.start-d.from+1)=="  "&&(g.start--,g.endA--,g.endB--);let b=d.doc.resolveNoCache(g.start-d.from),m=d.doc.resolveNoCache(g.endB-d.from),v=u.resolve(g.start),S=b.sameParent(m)&&b.parent.inlineContent&&v.end()>=g.endA;if((Tn&&n.input.lastIOSEnter>Date.now()-225&&(!S||i.some(M=>M.nodeName=="DIV"||M.nodeName=="P"))||!S&&J0(d.doc,b.pos,m.pos))&&n.someProp("handleKeyDown",M=>M(n,qt(13,"Enter")))){n.input.lastIOSEnter=0;return}if(n.state.selection.anchor>g.start&&K0(u,g.start,g.endA,b,m)&&n.someProp("handleKeyDown",M=>M(n,qt(8,"Backspace")))){ft&&Ee&&n.domObserver.suppressSelectionUpdates();return}Ee&&g.endB==g.start&&(n.input.lastChromeDelete=Date.now()),ft&&!S&&b.start()!=m.start()&&m.parentOffset==0&&b.depth==m.depth&&d.sel&&d.sel.anchor==d.sel.head&&d.sel.head==g.endA&&(g.endB-=2,m=d.doc.resolveNoCache(g.endB-d.from),setTimeout(()=>{n.someProp("handleKeyDown",function(M){return M(n,qt(13,"Enter"))})},20));let A=g.start,O=g.endA,B=M=>{let w=M||n.state.tr.replace(A,O,d.doc.slice(g.start-d.from,g.endB-d.from));if(d.sel){let T=Il(n,w.doc,d.sel);T&&!(Ee&&n.composing&&T.empty&&(g.start!=g.endB||n.input.lastChromeDeletegt(n),20));let M=B(n.state.tr.delete(A,O)),w=u.resolve(g.start).marksAcross(u.resolve(g.endA));w&&M.ensureMarks(w),n.dispatch(M)}else if(g.endA==g.endB&&(E=W0(b.parent.content.cut(b.parentOffset,m.parentOffset),v.parent.content.cut(v.parentOffset,g.endA-v.start())))){let M=B(n.state.tr);E.type=="add"?M.addMark(A,O,E.mark):M.removeMark(A,O,E.mark),n.dispatch(M)}else if(b.parent.child(b.index()).isText&&b.index()==m.index()-(m.textOffset?0:1)){let M=b.parent.textBetween(b.parentOffset,m.parentOffset),w=()=>B(n.state.tr.insertText(M,A,O));n.someProp("handleTextInput",T=>T(n,A,O,M,w))||n.dispatch(w())}else n.dispatch(B());else n.dispatch(B())}function Il(n,e,t){return Math.max(t.anchor,t.head)>e.content.size?null:uo(n,e.resolve(t.anchor),e.resolve(t.head))}function W0(n,e){let t=n.firstChild.marks,s=e.firstChild.marks,i=t,r=s,o,l,c;for(let u=0;uu.mark(l.addToSet(u.marks));else if(i.length==0&&r.length==1)l=r[0],o="remove",c=u=>u.mark(l.removeFromSet(u.marks));else return null;let d=[];for(let u=0;ut||or(o,!0,!1){r.isTextblock&&o>=e&&o0&&(e||n.indexAfter(s)==n.node(s).childCount);)s--,i++,e=!1;if(t){let r=n.node(s).maybeChild(n.indexAfter(s));for(;r&&!r.isLeaf;)r=r.firstChild,i++}return i}function G0(n,e,t,s,i){let r=n.findDiffStart(e,t),o=t+n.size,l=t+e.size;if(r==null)return null;let{a:c,b:d}=n.findDiffEnd(e,o,l);if(i=="end"){let u=Math.max(0,r-Math.min(c,d));s-=c+u-r}if(c=c?r-s:0;r-=u,d=r+(d-c),c=r}else if(d=d?r-s:0;r-=u,c=r+(c-d),d=r}return{start:r,endA:c,endB:d}}class dd{constructor(e,t){this._root=null,this.focused=!1,this.trackWrites=null,this.mounted=!1,this.markCursor=null,this.cursorWrapper=null,this.lastSelectedViewDesc=void 0,this.input=new d0,this.prevDirectPlugins=[],this.pluginViews=[],this.requiresGeckoHackNode=!1,this.dragging=null,this._props=t,this.state=t.state,this.directPlugins=t.plugins||[],this.directPlugins.forEach(Pl),this.dispatch=this.dispatch.bind(this),this.dom=e&&e.mount||document.createElement("div"),e&&(e.appendChild?e.appendChild(this.dom):typeof e=="function"?e(this.dom):e.mount&&(this.mounted=!0)),this.editable=Rl(this),$l(this),this.nodeViews=Ll(this),this.docView=hl(this.state.doc,Dl(this),rr(this),this.dom,this),this.domObserver=new B0(this,(s,i,r,o)=>U0(this,s,i,r,o)),this.domObserver.start(),u0(this),this.updatePluginViews()}get composing(){return this.input.composing}get props(){if(this._props.state!=this.state){let e=this._props;this._props={};for(let t in e)this._props[t]=e[t];this._props.state=this.state}return this._props}update(e){e.handleDOMEvents!=this._props.handleDOMEvents&&Lr(this);let t=this._props;this._props=e,e.plugins&&(e.plugins.forEach(Pl),this.directPlugins=e.plugins),this.updateStateInner(e.state,t)}setProps(e){let t={};for(let s in this._props)t[s]=this._props[s];t.state=this.state;for(let s in e)t[s]=e[s];this.update(t)}updateState(e){this.updateStateInner(e,this._props)}updateStateInner(e,t){var s;let i=this.state,r=!1,o=!1;e.storedMarks&&this.composing&&(sd(this),o=!0),this.state=e;let l=i.plugins!=e.plugins||this._props.plugins!=t.plugins;if(l||this._props.plugins!=t.plugins||this._props.nodeViews!=t.nodeViews){let h=Ll(this);X0(h,this.nodeViews)&&(this.nodeViews=h,r=!0)}(l||t.handleDOMEvents!=this._props.handleDOMEvents)&&Lr(this),this.editable=Rl(this),$l(this);let c=rr(this),d=Dl(this),u=i.plugins!=e.plugins&&!i.doc.eq(e.doc)?"reset":e.scrollToSelection>i.scrollToSelection?"to selection":"preserve",p=r||!this.docView.matchesNode(e.doc,d,c);(p||!e.selection.eq(i.selection))&&(o=!0);let f=u=="preserve"&&o&&this.dom.style.overflowAnchor==null&&My(this);if(o){this.domObserver.stop();let h=p&&(je||Ee)&&!this.composing&&!i.selection.empty&&!e.selection.empty&&Y0(i.selection,e.selection);if(p){let b=Ee?this.trackWrites=this.domSelectionRange().focusNode:null;this.composing&&(this.input.compositionNode=T0(this)),(r||!this.docView.update(e.doc,d,c,this))&&(this.docView.updateOuterDeco(d),this.docView.destroy(),this.docView=hl(e.doc,d,c,this.dom,this)),b&&(!this.trackWrites||!this.dom.contains(this.trackWrites))&&(h=!0)}let g=this.input.mouseDown;h||!(g&&this.domObserver.currentSelection.eq(this.domSelectionRange())&&Gy(this)&&g.delaySelUpdate())?gt(this,h):(Hc(this,e.selection),this.domObserver.setCurSelection()),this.domObserver.start()}this.updatePluginViews(i),!((s=this.dragging)===null||s===void 0)&&s.node&&!i.doc.eq(e.doc)&&this.updateDraggedNode(this.dragging,i),u=="reset"?this.dom.scrollTop=0:u=="to selection"?this.scrollToSelection():f&&Ty(f)}scrollToSelection(){let e=this.domSelectionRange().focusNode;if(!(!e||!rn(this.dom,e))){if(!this.someProp("handleScrollToSelection",t=>t(this)))if(this.state.selection instanceof W){let t=this.docView.domAfterPos(this.state.selection.from);q(t)&&cl(this,t.getBoundingClientRect(),e)}else cl(this,this.coordsAtPos(this.state.selection.head,1),e)}}destroyPluginViews(){let e;for(;e=this.pluginViews.pop();)e.destroy&&e.destroy()}updatePluginViews(e){if(!e||e.plugins!=this.state.plugins||this.directPlugins!=this.prevDirectPlugins){this.prevDirectPlugins=this.directPlugins,this.destroyPluginViews();for(let t=0;t0&&rt.ownerDocument.getSelection()),this._root=t}return e||document}updateRoot(){this._root=null}posAtCoords(e){return Dy(this,e)}coordsAtPos(e,t=1){return Lc(this,e,t)}domAtPos(e,t=0){return this.docView.domFromPos(e,t)}nodeDOM(e){let t=this.docView.descAt(e);return t?t.nodeDOM:null}posAtDOM(e,t,s=-1){let i=this.docView.posFromDOM(e,t,s);if(i==null)throw new RangeError("DOM position not inside the editor");return i}endOfTextblock(e,t){return By(this,t||this.state,e)}pasteHTML(e,t){return ds(this,"",e,!1,t||new ClipboardEvent("paste"))}pasteText(e,t){return ds(this,e,null,!0,t||new ClipboardEvent("paste"))}serializeForClipboard(e){return po(this,e)}destroy(){this.docView&&(p0(this),this.destroyPluginViews(),this.mounted?(this.docView.update(this.state.doc,[],rr(this),this),this.dom.textContent=""):this.dom.parentNode&&this.dom.parentNode.removeChild(this.dom),this.docView.destroy(),this.docView=null,my())}get isDestroyed(){return this.docView==null}dispatchEvent(e){return h0(this,e)}domSelectionRange(){let e=this.dom.isConnected!==!1&&this.domSelection();return e?$e&&this.root.nodeType===11&&ky(this.dom.ownerDocument)==this.dom&&z0(this,e)||e:{focusNode:null,focusOffset:0,anchorNode:null,anchorOffset:0}}domSelection(){return this.root.getSelection()}}dd.prototype.dispatch=function(n){let e=this._props.dispatchTransaction;e?e.call(this,n):this.updateState(this.state.apply(n))};function Dl(n){let e=Object.create(null);return e.class="ProseMirror",e.contenteditable=String(n.editable),n.someProp("attributes",t=>{if(typeof t=="function"&&(t=t(n.state)),t)for(let s in t)s=="class"?e.class+=" "+t[s]:s=="style"?e.style=(e.style?e.style+";":"")+t[s]:!e[s]&&s!="contenteditable"&&s!="nodeName"&&(e[s]=String(t[s]))}),e.translate||(e.translate="no"),[Le.node(0,n.state.doc.content.size,e)]}function $l(n){if(n.markCursor){let e=document.createElement("img");e.className="ProseMirror-separator",e.setAttribute("mark-placeholder","true"),e.setAttribute("alt",""),n.cursorWrapper={dom:e,deco:Le.widget(n.state.selection.from,e,{raw:!0,marks:n.markCursor})}}else n.cursorWrapper=null}function Rl(n){return!n.someProp("editable",e=>e(n.state)===!1)}function Y0(n,e){let t=Math.min(n.$anchor.sharedDepth(n.head),e.$anchor.sharedDepth(e.head));return n.$anchor.start(t)!=e.$anchor.start(t)}function Ll(n){let e=Object.create(null);function t(s){for(let i in s)Object.prototype.hasOwnProperty.call(e,i)||(e[i]=s[i])}return n.someProp("nodeViews",t),n.someProp("markViews",t),e}function X0(n,e){let t=0,s=0;for(let i in n){if(n[i]!=e[i])return!0;t++}for(let i in e)s++;return t!=s}function Pl(n){if(n.spec.state||n.spec.filterTransaction||n.spec.appendTransaction)throw new RangeError("Plugins passed directly to the view must not have a state component")}var Lt={8:"Backspace",9:"Tab",10:"Enter",12:"NumLock",13:"Enter",16:"Shift",17:"Control",18:"Alt",20:"CapsLock",27:"Escape",32:" ",33:"PageUp",34:"PageDown",35:"End",36:"Home",37:"ArrowLeft",38:"ArrowUp",39:"ArrowRight",40:"ArrowDown",44:"PrintScreen",45:"Insert",46:"Delete",59:";",61:"=",91:"Meta",92:"Meta",106:"*",107:"+",108:",",109:"-",110:".",111:"/",144:"NumLock",145:"ScrollLock",160:"Shift",161:"Shift",162:"Control",163:"Control",164:"Alt",165:"Alt",173:"-",186:";",187:"=",188:",",189:"-",190:".",191:"/",192:"`",219:"[",220:"\\",221:"]",222:"'"},Qs={48:")",49:"!",50:"@",51:"#",52:"$",53:"%",54:"^",55:"&",56:"*",57:"(",59:":",61:"+",173:"_",186:":",187:"+",188:"<",189:"_",190:">",191:"?",192:"~",219:"{",220:"|",221:"}",222:'"'},Z0=typeof navigator!="undefined"&&/Mac/.test(navigator.platform),Q0=typeof navigator!="undefined"&&/MSIE \d|Trident\/(?:[7-9]|\d{2,})\..*rv:(\d+)/.exec(navigator.userAgent);for(var Me=0;Me<10;Me++)Lt[48+Me]=Lt[96+Me]=String(Me);for(var Me=1;Me<=24;Me++)Lt[Me+111]="F"+Me;for(var Me=65;Me<=90;Me++)Lt[Me]=String.fromCharCode(Me+32),Qs[Me]=String.fromCharCode(Me);for(var lr in Lt)Qs.hasOwnProperty(lr)||(Qs[lr]=Lt[lr]);function e1(n){var e=Z0&&n.metaKey&&n.shiftKey&&!n.ctrlKey&&!n.altKey||Q0&&n.shiftKey&&n.key&&n.key.length==1||n.key=="Unidentified",t=!e&&n.key||(n.shiftKey?Qs:Lt)[n.keyCode]||n.key||"Unidentified";return t=="Esc"&&(t="Escape"),t=="Del"&&(t="Delete"),t=="Left"&&(t="ArrowLeft"),t=="Up"&&(t="ArrowUp"),t=="Right"&&(t="ArrowRight"),t=="Down"&&(t="ArrowDown"),t}const t1=typeof navigator!="undefined"&&/Mac|iP(hone|[oa]d)/.test(navigator.platform),n1=typeof navigator!="undefined"&&/Win/.test(navigator.platform);function s1(n){let e=n.split(/-(?!$)/),t=e[e.length-1];t=="Space"&&(t=" ");let s,i,r,o;for(let l=0;l=t?we.empty:this.sliceInner(Math.max(0,e),Math.min(this.length,t))};we.prototype.get=function(e){if(!(e<0||e>=this.length))return this.getInner(e)};we.prototype.forEach=function(e,t,s){t===void 0&&(t=0),s===void 0&&(s=this.length),t<=s?this.forEachInner(e,t,s,0):this.forEachInvertedInner(e,t,s,0)};we.prototype.map=function(e,t,s){t===void 0&&(t=0),s===void 0&&(s=this.length);var i=[];return this.forEach(function(r,o){return i.push(e(r,o))},t,s),i};we.from=function(e){return e instanceof we?e:e&&e.length?new pd(e):we.empty};var pd=(function(n){function e(s){n.call(this),this.values=s}n&&(e.__proto__=n),e.prototype=Object.create(n&&n.prototype),e.prototype.constructor=e;var t={length:{configurable:!0},depth:{configurable:!0}};return e.prototype.flatten=function(){return this.values},e.prototype.sliceInner=function(i,r){return i==0&&r==this.length?this:new e(this.values.slice(i,r))},e.prototype.getInner=function(i){return this.values[i]},e.prototype.forEachInner=function(i,r,o,l){for(var c=r;c=o;c--)if(i(this.values[c],l+c)===!1)return!1},e.prototype.leafAppend=function(i){if(this.length+i.length<=ei)return new e(this.values.concat(i.flatten()))},e.prototype.leafPrepend=function(i){if(this.length+i.length<=ei)return new e(i.flatten().concat(this.values))},t.length.get=function(){return this.values.length},t.depth.get=function(){return 0},Object.defineProperties(e.prototype,t),e})(we);we.empty=new pd([]);var o1=(function(n){function e(t,s){n.call(this),this.left=t,this.right=s,this.length=t.length+s.length,this.depth=Math.max(t.depth,s.depth)+1}return n&&(e.__proto__=n),e.prototype=Object.create(n&&n.prototype),e.prototype.constructor=e,e.prototype.flatten=function(){return this.left.flatten().concat(this.right.flatten())},e.prototype.getInner=function(s){return sl&&this.right.forEachInner(s,Math.max(i-l,0),Math.min(this.length,r)-l,o+l)===!1)return!1},e.prototype.forEachInvertedInner=function(s,i,r,o){var l=this.left.length;if(i>l&&this.right.forEachInvertedInner(s,i-l,Math.max(r,l)-l,o+l)===!1||r=r?this.right.slice(s-r,i-r):this.left.slice(s,r).append(this.right.slice(0,i-r))},e.prototype.leafAppend=function(s){var i=this.right.leafAppend(s);if(i)return new e(this.left,i)},e.prototype.leafPrepend=function(s){var i=this.left.leafPrepend(s);if(i)return new e(i,this.right)},e.prototype.appendInner=function(s){return this.left.depth>=Math.max(this.right.depth,s.depth)+1?new e(this.left,new e(this.right,s)):new e(this,s)},e})(we);const l1=500;class Ye{constructor(e,t){this.items=e,this.eventCount=t}popEvent(e,t){if(this.eventCount==0)return null;let s=this.items.length;for(;;s--)if(this.items.get(s-1).selection){--s;break}let i,r;t&&(i=this.remapping(s,this.items.length),r=i.maps.length);let o=e.tr,l,c,d=[],u=[];return this.items.forEach((p,f)=>{if(!p.step){i||(i=this.remapping(s,f+1),r=i.maps.length),r--,u.push(p);return}if(i){u.push(new et(p.map));let h=p.step.map(i.slice(r)),g;h&&o.maybeStep(h).doc&&(g=o.mapping.maps[o.mapping.maps.length-1],d.push(new et(g,void 0,void 0,d.length+u.length))),r--,g&&i.appendMap(g,r)}else o.maybeStep(p.step);if(p.selection)return l=i?p.selection.map(i.slice(r)):p.selection,c=new Ye(this.items.slice(0,s).append(u.reverse().concat(d)),this.eventCount-1),!1},this.items.length,0),{remaining:c,transform:o,selection:l}}addTransform(e,t,s,i){let r=[],o=this.eventCount,l=this.items,c=!i&&l.length?l.get(l.length-1):null;for(let u=0;uc1&&(l=a1(l,d),o-=d),new Ye(l.append(r),o)}remapping(e,t){let s=new ls;return this.items.forEach((i,r)=>{let o=i.mirrorOffset!=null&&r-i.mirrorOffset>=e?s.maps.length-i.mirrorOffset:void 0;s.appendMap(i.map,o)},e,t),s}addMaps(e){return this.eventCount==0?this:new Ye(this.items.append(e.map(t=>new et(t))),this.eventCount)}rebased(e,t){if(!this.eventCount)return this;t=Math.min(this.items.length,t);let s=[],i=this.items.length-t,r=e.mapping,o=e.steps.length,l=this.eventCount;this.items.forEach(f=>{f.selection&&l--},i);let c=t;this.items.forEach(f=>{let h=r.getMirror(--c);if(h==null)return;o=Math.min(o,h);let g=r.maps[h];if(f.step){let b=e.steps[h].invert(e.docs[h]),m=f.selection&&f.selection.map(r.slice(c+1,h));m&&l++,s.push(new et(g,b,m))}else s.push(new et(g))},i);let d=[];for(let f=t;fl1&&(p=p.compress(this.items.length-s.length)),p}emptyItemCount(){let e=0;return this.items.forEach(t=>{t.step||e++}),e}compress(e=this.items.length){let t=this.remapping(0,e),s=t.maps.length,i=[],r=0;return this.items.forEach((o,l)=>{if(l>=e)i.push(o),o.selection&&r++;else if(o.step){let c=o.step.map(t.slice(s)),d=c&&c.getMap();if(s--,d&&t.appendMap(d,s),c){let u=o.selection&&o.selection.map(t.slice(s));u&&r++;let p=new et(d.invert(),c,u),f,h=i.length-1;(f=i.length&&i[h].merge(p))?i[h]=f:i.push(p)}}else o.map&&s--},this.items.length,0),new Ye(we.from(i.reverse()),r)}}Ye.empty=new Ye(we.empty,0);function a1(n,e){let t;return n.forEach((s,i)=>{if(s.selection&&e--==0)return t=i,!1}),n.slice(t)}class et{constructor(e,t,s,i){this.map=e,this.step=t,this.selection=s,this.mirrorOffset=i}merge(e){if(this.step&&e.step&&!e.selection){let t=e.step.merge(this.step);if(t)return new et(t.getMap().invert(),t,this.selection)}}}class St{constructor(e,t,s,i,r){this.done=e,this.undone=t,this.prevRanges=s,this.prevTime=i,this.prevComposition=r}}const c1=20;function d1(n,e,t,s){let i=t.getMeta(Rt),r;if(i)return i.historyState;t.getMeta(fd)&&(n=new St(n.done,n.undone,null,0,-1));let o=t.getMeta("appendedTransaction");if(t.steps.length==0)return n;if(o&&o.getMeta(Rt))return o.getMeta(Rt).redo?new St(n.done.addTransform(t,void 0,s,Fs(e)),n.undone,Bl(t.mapping.maps),n.prevTime,n.prevComposition):new St(n.done,n.undone.addTransform(t,void 0,s,Fs(e)),null,n.prevTime,n.prevComposition);if(t.getMeta("addToHistory")!==!1&&!(o&&o.getMeta("addToHistory")===!1)){let l=t.getMeta("composition"),c=n.prevTime==0||!o&&n.prevComposition!=l&&(n.prevTime<(t.time||0)-s.newGroupDelay||!u1(t,n.prevRanges)),d=o?cr(n.prevRanges,t.mapping):Bl(t.mapping.maps);return new St(n.done.addTransform(t,c?e.selection.getBookmark():void 0,s,Fs(e)),Ye.empty,d,t.time,l==null?n.prevComposition:l)}else return(r=t.getMeta("rebased"))?new St(n.done.rebased(t,r),n.undone.rebased(t,r),cr(n.prevRanges,t.mapping),n.prevTime,n.prevComposition):new St(n.done.addMaps(t.mapping.maps),n.undone.addMaps(t.mapping.maps),cr(n.prevRanges,t.mapping),n.prevTime,n.prevComposition)}function u1(n,e){if(!e)return!1;if(!n.docChanged)return!0;let t=!1;return n.mapping.maps[0].forEach((s,i)=>{for(let r=0;r=e[r]&&(t=!0)}),t}function Bl(n){let e=[];for(let t=n.length-1;t>=0&&e.length==0;t--)n[t].forEach((s,i,r,o)=>e.push(r,o));return e}function cr(n,e){if(!n)return null;let t=[];for(let s=0;s{let i=Rt.getState(t);if(!i||(n?i.undone:i.done).eventCount==0)return!1;if(s){let r=p1(i,t,n);r&&s(e?r.scrollIntoView():r)}return!0}}const md=hd(!1,!0),gd=hd(!0,!0);function m1(n){return n.getMeta(Rt)!=null}function Fi(n){const{state:e,transaction:t}=n;let{selection:s}=t,{doc:i}=t,{storedMarks:r}=t;return{...e,apply:e.apply.bind(e),applyTransaction:e.applyTransaction.bind(e),plugins:e.plugins,schema:e.schema,reconfigure:e.reconfigure.bind(e),toJSON:e.toJSON.bind(e),get storedMarks(){return r},get selection(){return s},get doc(){return i},get tr(){return s=t.selection,i=t.doc,r=t.storedMarks,t}}}var xn=class bd{constructor(e){this.editor=e.editor,this.rawCommands=this.editor.extensionManager.commands,this.customState=e.state}get hasCustomState(){return!!this.customState}get state(){return this.customState||this.editor.state}get commands(){const{rawCommands:e,editor:t,state:s}=this,{view:i}=t,{tr:r}=s,o=this.buildProps(r);return Object.fromEntries(Object.entries(e).map(([l,c])=>[l,(...u)=>{const p=c(...u)(o);return!r.getMeta("preventDispatch")&&!this.hasCustomState&&i.dispatch(r),p}]))}get chain(){return()=>this.createChain()}get can(){return()=>this.createCan()}createChain(e,t=!0){const{rawCommands:s,editor:i,state:r}=this,{view:o}=i,l=[],c=!!e,d=e||r.tr,u=()=>(!c&&t&&!d.getMeta("preventDispatch")&&!this.hasCustomState&&o.dispatch(d),l.every(f=>f===!0)),p={...Object.fromEntries(Object.entries(s).map(([f,h])=>[f,(...b)=>{const m=this.buildProps(d,t),v=h(...b)(m);return l.push(v),p}])),run:u};return p}static createFakeChain(){const e=new Proxy({},{get:(t,s)=>{if(s!=="then")return s==="run"?()=>!1:()=>e}});return e}createCan(e){const{rawCommands:t,state:s}=this,i=!1,r=e||s.tr,o=this.buildProps(r,i);return{...Object.fromEntries(Object.entries(t).map(([l,c])=>[l,(...d)=>c(...d)({...o,dispatch:void 0})])),chain:()=>this.createChain(r,i)}}static createFallbackCan(){const e=bd.createFakeChain();return new Proxy({chain:()=>e},{get:(t,s)=>{if(s!=="then")return s==="chain"?t.chain:()=>!1}})}buildProps(e,t=!0){const{rawCommands:s,editor:i,state:r}=this,{view:o}=i,l={tr:e,editor:i,view:o,state:Fi({state:r,transaction:e}),dispatch:t?()=>{}:void 0,chain:()=>this.createChain(e,t),can:()=>this.createCan(e),get commands(){return Object.fromEntries(Object.entries(s).map(([c,d])=>[c,(...u)=>d(...u)(l)]))}};return l}};const g1=()=>({editor:n,view:e})=>(requestAnimationFrame(()=>{if(!n.isDestroyed){var t;e.dom.blur(),(t=window)===null||t===void 0||(t=t.getSelection())===null||t===void 0||t.removeAllRanges()}}),!0),b1=(n=!0)=>({commands:e})=>e.setContent("",{emitUpdate:n}),v1=()=>({state:n,tr:e,dispatch:t})=>{const{selection:s}=e,{ranges:i}=s;return t&&i.forEach(({$from:r,$to:o})=>{n.doc.nodesBetween(r.pos,o.pos,(l,c)=>{if(l.type.isText)return;const{doc:d,mapping:u}=e,p=d.resolve(u.map(c)),f=d.resolve(u.map(c+l.nodeSize)),h=p.blockRange(f);if(!h)return;const g=Dn(h);if(l.type.isTextblock){const{defaultType:b}=p.parent.contentMatchAt(p.index());e.setNodeMarkup(h.start,b)}(g||g===0)&&e.lift(h,g)})}),!0},y1=n=>e=>n(e),k1=()=>({state:n,dispatch:e})=>Cc(n,e),x1=(n,e)=>({editor:t,tr:s})=>{const{state:i}=t,r=i.doc.slice(n.from,n.to);s.deleteRange(n.from,n.to);const o=s.mapping.map(e);return s.insert(o,r.content),s.setSelection(new U(s.doc.resolve(Math.max(o-1,0)))),!0},w1=()=>({tr:n,dispatch:e})=>{const{selection:t}=n,s=t.$anchor.node();if(s.content.size>0)return!1;const i=n.selection.$anchor;for(let r=i.depth;r>0;r-=1)if(i.node(r).type===s.type){if(e){const o=i.before(r),l=i.after(r);n.delete(o,l).scrollIntoView()}return!0}return!1};function ye(n,e){if(typeof n=="string"){if(!e.nodes[n])throw Error(`There is no node type named '${n}'. Maybe you forgot to add the extension?`);return e.nodes[n]}return n}const S1=n=>({tr:e,state:t,dispatch:s})=>{const i=ye(n,t.schema),r=e.selection.$anchor;for(let o=r.depth;o>0;o-=1)if(r.node(o).type===i){if(s){const l=r.before(o),c=r.after(o);e.delete(l,c).scrollIntoView()}return!0}return!1},C1=n=>({tr:e,dispatch:t})=>{const{from:s,to:i}=n;return t&&e.delete(s,i),!0},M1=n=>n.content?/^text(\*|\+)/.test(n.content):!1,zl=(n,e,t)=>{if(!n.parent.isInline||t==="left"&&n.pos>n.start()||t==="right"&&n.pos({from:zl(n,t,"left"),to:zl(e,t,"right")}),E1=()=>({state:n,dispatch:e})=>{if(n.selection.empty)return!1;if(e){const t=n.tr,{ranges:s}=n.selection,i=t.steps.length;s.forEach(r=>{const o=t.mapping.slice(i),l=t.doc.resolve(o.map(r.$from.pos)),c=t.doc.resolve(o.map(r.$to.pos)),{from:d,to:u}=T1(l,c,n.schema);t.deleteRange(d,u)}),t.selection.empty||t.setSelection(U.near(t.doc.resolve(t.selection.from))),t.scrollIntoView(),e(t)}return!0},A1=()=>({commands:n})=>n.keyboardShortcut("Enter"),O1=()=>({state:n,dispatch:e})=>ey(n,e);function vo(n){return Object.prototype.toString.call(n)==="[object RegExp]"}function ti(n,e,t={strict:!0}){const s=Object.keys(e);return s.length?s.every(i=>t.strict?e[i]===n[i]:vo(e[i])?e[i].test(n[i]):e[i]===n[i]):!0}function vd(n,e,t={}){return n.find(s=>s.type===e&&ti(Object.fromEntries(Object.keys(t).map(i=>[i,s.attrs[i]])),t))}function jl(n,e,t={}){return!!vd(n,e,t)}function yo(n,e,t){if(!n||!e)return;let s=n.parent.childAfter(n.parentOffset);if((!s.node||!s.node.marks.some(c=>c.type===e))&&(s=n.parent.childBefore(n.parentOffset)),!s.node||!s.node.marks.some(c=>c.type===e))return;if(!t){const c=s.node.marks.find(d=>d.type===e);c&&(t=c.attrs)}if(!vd([...s.node.marks],e,t))return;let i=s.index,r=n.start()+s.offset,o=i+1,l=r+s.node.nodeSize;for(;i>0&&jl([...n.parent.child(i-1).marks],e,t);)i-=1,r-=n.parent.child(i).nodeSize;for(;o({tr:t,state:s,dispatch:i})=>{const r=vt(n,s.schema),{doc:o,selection:l}=t,{$from:c,from:d,to:u}=l;if(i){const p=yo(c,r,e);if(p&&p.from<=d&&p.to>=u){const f=U.create(o,p.from,p.to);t.setSelection(f)}}return!0},I1=n=>e=>{const t=typeof n=="function"?n(e):n;for(let s=0;s({editor:t,view:s,tr:i,dispatch:r})=>{e={scrollIntoView:!0,...e};const o=()=>{(ni()||Fl())&&s.dom.focus(),D1()&&!ni()&&!Fl()&&s.dom.focus({preventScroll:!0}),requestAnimationFrame(()=>{t.isDestroyed||(s.focus(),e!=null&&e.scrollIntoView&&t.commands.scrollIntoView())})};try{if(s.hasFocus()&&n===null||n===!1)return!0}catch(d){return!1}if(r&&n===null&&!yd(t.state.selection))return o(),!0;const l=Pr(i.doc,n)||t.state.selection,c=t.state.selection.eq(l);return r&&(c||i.setSelection(l),c&&i.storedMarks&&i.setStoredMarks(i.storedMarks),o()),!0},R1=(n,e)=>t=>n.every((s,i)=>e(s,{...t,index:i})),L1=(n,e)=>({tr:t,commands:s})=>s.insertContentAt({from:t.selection.from,to:t.selection.to},n,e),kd=n=>{const e=n.childNodes;for(let t=e.length-1;t>=0;t-=1){const s=e[t];s.nodeType===3&&s.nodeValue&&/^(\n\s\s|\n)$/.test(s.nodeValue)?n.removeChild(s):s.nodeType===1&&kd(s)}return n};function Es(n){if(typeof window=="undefined")throw new Error("[tiptap error]: there is no window object available, so this function cannot be used");const e=`${n}`,t=new window.DOMParser().parseFromString(e,"text/html").body;return kd(t)}function xd(n){return typeof(n==null?void 0:n.nodesBetween)=="function"}function En(n,e,t){if(xd(n))return n;const s=typeof n=="object"&&n!==null;t={slice:!0,parseOptions:{},...t};const i=typeof n=="string";if(s)try{if(Array.isArray(n)&&n.length>0)return $.fromArray(n.map(o=>e.nodeFromJSON(o)));const r=e.nodeFromJSON(n);return t.errorOnInvalidContent&&r.check(),r}catch(r){if(t.errorOnInvalidContent)throw new Error("[tiptap error]: Invalid JSON content",{cause:r});return console.warn("[tiptap warn]: Invalid content.","Passed value:",n,"Error:",r),En("",e,t)}if(i){if(t.errorOnInvalidContent){let o=!1,l="";const c=new _s({topNode:e.spec.topNode,marks:e.spec.marks,nodes:e.spec.nodes.append({__tiptap__private__unknown__catch__all__node:{content:"inline*",group:"block",parseDOM:[{tag:"*",getAttrs:d=>(o=!0,l=typeof d=="string"?d:d.outerHTML,null)}]}})});if(t.slice?Ot.fromSchema(c).parseSlice(Es(n),t.parseOptions):Ot.fromSchema(c).parse(Es(n),t.parseOptions),t.errorOnInvalidContent&&o)throw new Error("[tiptap error]: Invalid HTML content",{cause:new Error(`Invalid element found: ${l}`)})}const r=Ot.fromSchema(e);return t.slice?r.parseSlice(Es(n),t.parseOptions).content:r.parse(Es(n),t.parseOptions)}return En("",e,t)}function wd(n){return!("type"in n)}function Sd(n,e,t){const s=n.steps.length-1;if(s{o===0&&(o=u)}),n.setSelection(X.near(n.doc.resolve(o),t))}const P1=(n,e,t)=>({tr:s,dispatch:i,editor:r})=>{if(i){t={parseOptions:r.options.parseOptions,updateSelection:!0,applyInputRules:!1,applyPasteRules:!1,...t};let l;const c=m=>{r.emit("contentError",{editor:r,error:m,disableCollaboration:()=>{"collaboration"in r.storage&&typeof r.storage.collaboration=="object"&&r.storage.collaboration&&(r.storage.collaboration.isDisabled=!0)}})},d={preserveWhitespace:"full",...t.parseOptions};if(!t.errorOnInvalidContent&&!r.options.enableContentCheck&&r.options.emitContentError)try{En(e,r.schema,{parseOptions:d,errorOnInvalidContent:!0})}catch(m){c(m)}try{var o;l=En(e,r.schema,{parseOptions:d,errorOnInvalidContent:(o=t.errorOnInvalidContent)!==null&&o!==void 0?o:r.options.enableContentCheck})}catch(m){return c(m),!1}let{from:u,to:p}=typeof n=="number"?{from:n,to:n}:{from:n.from,to:n.to},f=!0,h=!0;const g=wd(l)?l.content:[l];if(g.forEach(m=>{m.check(),f=f?m.isText&&m.marks.length===0:!1,h=h?m.isBlock:!1}),u===p&&h){const{parent:m}=s.doc.resolve(u);m.isTextblock&&!m.type.spec.code&&!m.childCount&&(u-=1,p+=1)}let b;if(f)Array.isArray(e)?b=e.map(m=>m.text||"").join(""):xd(e)?b=g.map(m=>{var v;return(v=m.text)!==null&&v!==void 0?v:""}).join(""):typeof e=="object"&&e&&e.text?b=e.text:b=e,s.insertText(b,u,p);else{b=$.from(g);const m=s.doc.resolve(u),v=m.node(),S=m.parentOffset===0,A=v.isText||v.isTextblock,O=v.content.size>0;S&&A&&O&&h&&(u=Math.max(0,u-1)),s.replaceWith(u,p,g)}t.updateSelection&&Sd(s,s.steps.length-1,-1),t.applyInputRules&&s.setMeta("applyInputRules",{from:u,text:b}),t.applyPasteRules&&s.setMeta("applyPasteRules",{from:u,text:b})}return!0};function Cd(n){for(let e=0;e({tr:e,dispatch:t,editor:s})=>{const{pos:i,attrs:r,content:o,updateSelection:l=!0}=n;let c;typeof i=="number"?c=e.doc.resolve(i):i?c=i:c=e.selection.$from;const d=Cd(c.parent.contentMatchAt(c.index()));if(!d)return!1;const u=Object.keys(d.spec.attrs||{}),p=r?Object.fromEntries(Object.entries(r).filter(([h])=>u.includes(h))):{};let f;if(o){const h=En(o,s.schema);f=d.createAndFill(p,h)}else f=d.createAndFill(p);return f?(t&&(e.insert(c.pos,f),l&&Sd(e,e.steps.length-1,-1)),!0):!1},_1=()=>({state:n,dispatch:e})=>Xv(n,e),z1=()=>({state:n,dispatch:e})=>Zv(n,e),j1=()=>({state:n,dispatch:e})=>bc(n,e),F1=()=>({state:n,dispatch:e})=>xc(n,e),Md=(n,e)=>{const t=n.resolve(e),s=t.nodeBefore,i=t.nodeAfter;return!s||!i?!1:!s.type.spec.isolating&&!i.type.spec.isolating},V1=()=>({state:n,dispatch:e,tr:t})=>{try{const s=Li(n.doc,n.selection.$from.pos,-1);return s==null||!Md(n.doc,s)?!1:(t.join(s,2),e&&e(t),!0)}catch(s){return!1}},H1=()=>({state:n,dispatch:e,tr:t})=>{try{const s=Li(n.doc,n.selection.$from.pos,1);return s==null||!Md(n.doc,s)?!1:(t.join(s,2),e&&e(t),!0)}catch(s){return!1}},q1=()=>({state:n,dispatch:e})=>Gv(n,e),U1=()=>({state:n,dispatch:e})=>Yv(n,e);function Td(){return typeof navigator!="undefined"?/Mac/.test(navigator.platform):!1}function W1(n){const e=n.split(/-(?!$)/);let t=e[e.length-1];t==="Space"&&(t=" ");let s,i,r,o;for(let l=0;l({editor:e,view:t,tr:s,dispatch:i})=>{const r=W1(n).split(/-(?!$)/),o=r.find(d=>!["Alt","Ctrl","Meta","Shift"].includes(d)),l=new KeyboardEvent("keydown",{key:o==="Space"?" ":o,altKey:r.includes("Alt"),ctrlKey:r.includes("Ctrl"),metaKey:r.includes("Meta"),shiftKey:r.includes("Shift"),bubbles:!0,cancelable:!0}),c=e.captureTransaction(()=>{t.someProp("handleKeyDown",d=>d(t,l))});return c==null||c.steps.forEach(d=>{const u=d.map(s.mapping);u&&i&&s.maybeStep(u)}),!0};function bt(n,e,t={}){const{from:s,to:i,empty:r}=n.selection,o=e?ye(e,n.schema):null,l=[];n.doc.nodesBetween(s,i,(u,p)=>{if(u.isText)return;const f=Math.max(s,p),h=Math.min(i,p+u.nodeSize);l.push({node:u,from:f,to:h})});const c=i-s,d=l.filter(u=>o?o.name===u.node.type.name:!0).filter(u=>ti(u.node.attrs,t,{strict:!1}));return r?!!d.length:d.reduce((u,p)=>u+p.to-p.from,0)>=c}const J1=(n,e={})=>({state:t,dispatch:s})=>bt(t,ye(n,t.schema),e)?Qv(t,s):!1,G1=()=>({state:n,dispatch:e})=>Mc(n,e),Y1=n=>({state:e,dispatch:t})=>{const s=ye(n,e.schema);return uy(s)(e,t)},X1=()=>({state:n,dispatch:e})=>Sc(n,e);function Vi(n,e){return e.nodes[n]?"node":e.marks[n]?"mark":null}function Vl(n,e){const t=typeof e=="string"?[e]:e;return Object.keys(n).reduce((s,i)=>(t.includes(i)||(s[i]=n[i]),s),{})}const Z1=(n,e)=>({tr:t,state:s,dispatch:i})=>{let r=null,o=null;const l=Vi(typeof n=="string"?n:n.name,s.schema);if(!l)return!1;l==="node"&&(r=ye(n,s.schema)),l==="mark"&&(o=vt(n,s.schema));let c=!1;return t.selection.ranges.forEach(d=>{s.doc.nodesBetween(d.$from.pos,d.$to.pos,(u,p)=>{r&&r===u.type&&(c=!0,i&&t.setNodeMarkup(p,void 0,Vl(u.attrs,e))),o&&u.marks.length&&u.marks.forEach(f=>{o===f.type&&(c=!0,i&&t.addMark(p,p+u.nodeSize,o.create(Vl(f.attrs,e))))})})}),c},Q1=()=>({tr:n,dispatch:e})=>(e&&n.scrollIntoView(),!0),ek=()=>({tr:n,dispatch:e})=>{if(e){const t=new qe(n.doc);n.setSelection(t)}return!0},tk=()=>({state:n,dispatch:e})=>yc(n,e),nk=()=>({state:n,dispatch:e})=>wc(n,e),sk=()=>({state:n,dispatch:e})=>sy(n,e),ik=()=>({state:n,dispatch:e})=>oy(n,e),rk=()=>({state:n,dispatch:e})=>ry(n,e);function Br(n,e,t={},s={}){return En(n,e,{slice:!1,parseOptions:t,errorOnInvalidContent:s.errorOnInvalidContent})}const ok=(n,{errorOnInvalidContent:e,emitUpdate:t=!0,parseOptions:s={}}={})=>({editor:i,tr:r,dispatch:o,commands:l})=>{const{doc:c}=r;if(s.preserveWhitespace!=="full"){const d=Br(n,i.schema,s,{errorOnInvalidContent:e!=null?e:i.options.enableContentCheck});if(o){const u=wd(d)?d.content:[d];r.replaceWith(0,c.content.size,u).setMeta("preventUpdate",!t)}return!0}return o&&r.setMeta("preventUpdate",!t),l.insertContentAt({from:0,to:c.content.size},n,{parseOptions:s,errorOnInvalidContent:e!=null?e:i.options.enableContentCheck})};function Ed(n,e){const t=vt(e,n.schema),{from:s,to:i,empty:r}=n.selection,o=[];r?(n.storedMarks&&o.push(...n.storedMarks),o.push(...n.selection.$head.marks())):n.doc.nodesBetween(s,i,c=>{o.push(...c.marks)});const l=o.find(c=>c.type.name===t.name);return l?{...l.attrs}:{}}function Ad(n,e){const t=new pc(n);return e.forEach(s=>{s.steps.forEach(i=>{t.step(i)})}),t}function lk(n,e,t){const s=[];return n.nodesBetween(e.from,e.to,(i,r)=>{t(i)&&s.push({node:i,pos:r})}),s}function ak(n,e){for(let t=n.depth;t>0;t-=1){const s=n.node(t);if(e(s))return{pos:t>0?n.before(t):0,start:n.start(t),depth:t,node:s}}}function Hi(n){return e=>ak(e.$from,n)}function V(n,e,t){return n.config[e]===void 0&&n.parent?V(n.parent,e,t):typeof n.config[e]=="function"?n.config[e].bind({...t,parent:n.parent?V(n.parent,e,t):null}):n.config[e]}function ko(n){return n.map(e=>{const t=V(e,"addExtensions",{name:e.name,options:e.options,storage:e.storage});return t?[e,...ko(t())]:e}).flat(10)}function xo(n,e){const t=ln.fromSchema(e).serializeFragment(n),s=document.implementation.createHTMLDocument().createElement("div");return s.appendChild(t),s.innerHTML}function Od(n,e){const t=new Map;for(const i of n){var s;const r=(s=t.get(i.type))!==null&&s!==void 0?s:new Map;r.set(i.name,i),t.set(i.type,r)}return[...Object.values(e.nodes),...Object.values(e.marks)].flatMap(i=>{var r;return Object.entries((r=i.spec.attrs)!==null&&r!==void 0?r:{}).map(([o,l])=>{var c;const d=(c=t.get(i.name))===null||c===void 0?void 0:c.get(o),u=Object.hasOwn(l,"default");return{type:i.name,name:o,attribute:{rendered:!0,renderHTML:null,parseHTML:null,keepOnSplit:!0,...d==null?void 0:d.attribute,default:l.default,isRequired:!u,validate:l.validate}}})})}const ck={content:"string",marks:"string",group:"string",inline:"boolean",atom:"boolean",selectable:"boolean",draggable:"boolean",code:"boolean",whitespace:["pre","normal"],definingAsContext:"boolean",definingForContent:"boolean",defining:"boolean",isolating:"boolean",linebreakReplacement:"boolean"},dk={inclusive:"boolean",excludes:"string",group:"string",spanning:"boolean",code:"boolean"};function uk(n,e,t){return Object.fromEntries(Object.entries(e).flatMap(([s,i])=>{const r=n[s];if(r===void 0)return[];if(!(typeof i=="string"?typeof r===i:typeof r=="string"&&i.includes(r)))throw new RangeError(`Invalid schemaSpec field '${t}.${s}'`);return[[s,r]]}))}function Hl(n,e,t,s){return{...Object.fromEntries(Object.entries(e).filter(([i])=>i!=="attrs"&&!Object.hasOwn(s,i))),...uk(t,s,n),attrs:t.attrs}}function ql(n,e,t){for(const s of Object.keys(e))if(!Object.hasOwn(n,s))throw new RangeError(`schemaSpec requires a local ${t} extension named '${s}'`);for(const s of Object.keys(n))if(!Object.hasOwn(e,s))throw new RangeError(`Local ${t} extension '${s}' is not in schemaSpec`)}function pk(n,e){ql(n.nodes,e.nodes,"node"),ql(n.marks,e.marks,"mark");let t=e.spec.nodes,s=e.spec.marks;return e.spec.nodes.forEach((i,r)=>{t=t.update(i,Hl(i,n.nodes[i],r,ck))}),e.spec.marks.forEach((i,r)=>{s=s.update(i,Hl(i,n.marks[i],r,dk))}),{topNode:e.topNodeType.name,nodes:t,marks:s}}function Nd(n){const e=n.filter((t,s)=>n.indexOf(t)!==s);return Array.from(new Set(e))}function An(n){return{baseExtensions:n.filter(e=>e.type==="extension"),nodeExtensions:n.filter(e=>e.type==="node"),markExtensions:n.filter(e=>e.type==="mark")}}function wo(n){const e=[],{nodeExtensions:t,markExtensions:s}=An(n),i=[...t,...s],r={default:null,validate:void 0,rendered:!0,renderHTML:null,parseHTML:null,keepOnSplit:!0,isRequired:!1},o=t.filter(d=>d.name!=="text").map(d=>d.name),l=s.map(d=>d.name),c=[...o,...l];return n.forEach(d=>{const u=V(d,"addGlobalAttributes",{name:d.name,options:d.options,storage:d.storage,extensions:i});u&&u().forEach(p=>{let f;Array.isArray(p.types)?f=p.types:p.types==="*"?f=c:p.types==="nodes"?f=o:p.types==="marks"?f=l:f=[],f.forEach(h=>{Object.entries(p.attributes).forEach(([g,b])=>{e.push({type:h,name:g,attribute:{...r,...b}})})})})}),i.forEach(d=>{const u=V(d,"addAttributes",{name:d.name,options:d.options,storage:d.storage});if(!u)return;const p=u();Object.entries(p).forEach(([f,h])=>{const g={...r,...h};typeof(g==null?void 0:g.default)=="function"&&(g.default=g.default()),g!=null&&g.isRequired&&(g==null?void 0:g.default)===void 0&&delete g.default,e.push({type:d.name,name:f,attribute:g})})}),e}function _r(n){return typeof n=="function"}function se(n,e=void 0,...t){return _r(n)?e?n.bind(e)(...t):n(...t):n}function fk(n={}){return Object.keys(n).length===0&&n.constructor===Object}function hk(n){const e=[];let t="",s=!1,i=!1,r=0;const o=n.length;for(let l=0;l0){r-=1,t+=c;continue}if(c===";"&&r===0){e.push(t),t="";continue}}t+=c}return t&&e.push(t),e}function Ul(n){const e=[],t=hk(n||""),s=t.length;for(let i=0;i!!e).reduce((e,t)=>{const s={...e};return Object.entries(t).forEach(([i,r])=>{if(i==="__proto__"){Object.defineProperty(s,i,{configurable:!0,enumerable:!0,value:r,writable:!0});return}if(!s[i]){s[i]=r;return}if(i==="class"){const o=r?String(r).split(" "):[],l=s[i]?s[i].split(" "):[],c=o.filter(d=>!l.includes(d));s[i]=[...l,...c].join(" ")}else if(i==="style"){const o=new Map([...Ul(s[i]),...Ul(r)]);s[i]=Array.from(o.entries()).map(([l,c])=>`${l}: ${c}`).join("; ")}else s[i]=r}),s},{})}function ps(n,e){return e.filter(t=>t.type===n.type.name).filter(t=>t.attribute.rendered).map(t=>t.attribute.renderHTML?t.attribute.renderHTML(n.attrs)||{}:{[t.name]:n.attrs[t.name]}).reduce((t,s)=>ke(t,s),{})}function mk(n){return typeof n!="string"?n:n.match(/^[+-]?(?:\d*\.)?\d+$/)?Number(n):n==="true"?!0:n==="false"?!1:n}function Wl(n,e){return"style"in n?n:{...n,getAttrs:t=>{const s=n.getAttrs?n.getAttrs(t):n.attrs;if(s===!1)return!1;const i=e.reduce((r,o)=>{const l=o.attribute.parseHTML?o.attribute.parseHTML(t):mk(t.getAttribute(o.name));return l==null?r:{...r,[o.name]:l}},{});return{...s,...i}}}}function Kl(n){return Object.fromEntries(Object.entries(n).filter(([e,t])=>e==="attrs"&&fk(t)?!1:t!=null))}function Jl(n){var e,t;const s={};return!(!(n==null||(e=n.attribute)===null||e===void 0)&&e.isRequired)&&"default"in((n==null?void 0:n.attribute)||{})&&(s.default=n.attribute.default),(n==null||(t=n.attribute)===null||t===void 0?void 0:t.validate)!==void 0&&(s.validate=n.attribute.validate),[n.name,s]}function Gl(n,e,t=wo(n)){var s;const{nodeExtensions:i,markExtensions:r}=An(n);return{topNode:(s=i.find(o=>V(o,"topNode")))===null||s===void 0?void 0:s.name,nodes:Object.fromEntries(i.map(o=>{const l=t.filter(h=>h.type===o.name),c={name:o.name,options:o.options,storage:o.storage,editor:e},d=Kl({...n.reduce((h,g)=>{const b=V(g,"extendNodeSchema",c);return{...h,...b?b(o):{}}},{}),content:se(V(o,"content",c)),marks:se(V(o,"marks",c)),group:se(V(o,"group",c)),inline:se(V(o,"inline",c)),atom:se(V(o,"atom",c)),selectable:se(V(o,"selectable",c)),draggable:se(V(o,"draggable",c)),code:se(V(o,"code",c)),whitespace:se(V(o,"whitespace",c)),linebreakReplacement:se(V(o,"linebreakReplacement",c)),defining:se(V(o,"defining",c)),isolating:se(V(o,"isolating",c)),attrs:Object.fromEntries(l.map(Jl))}),u=se(V(o,"parseHTML",c));u&&(d.parseDOM=u.map(h=>Wl(h,l)));const p=V(o,"renderHTML",c);p&&(d.toDOM=h=>p({node:h,HTMLAttributes:ps(h,l)}));const f=V(o,"renderText",c);return f&&(d.toText=f),[o.name,d]})),marks:Object.fromEntries(r.map(o=>{const l=t.filter(f=>f.type===o.name),c={name:o.name,options:o.options,storage:o.storage,editor:e},d=Kl({...n.reduce((f,h)=>{const g=V(h,"extendMarkSchema",c);return{...f,...g?g(o):{}}},{}),inclusive:se(V(o,"inclusive",c)),excludes:se(V(o,"excludes",c)),group:se(V(o,"group",c)),spanning:se(V(o,"spanning",c)),code:se(V(o,"code",c)),attrs:Object.fromEntries(l.map(Jl))}),u=se(V(o,"parseHTML",c));u&&(d.parseDOM=u.map(f=>Wl(f,l)));const p=V(o,"renderHTML",c);return p&&(d.toDOM=f=>p({mark:f,HTMLAttributes:ps(f,l)})),[o.name,d]}))}}function gk(n,e,t){if(t===void 0)return new _s(Gl(n,e));const s=Nd(n.filter(o=>o.type!=="extension").map(o=>o.name));if(s.length)throw new RangeError(`Duplicate local schema types: ${s.join(", ")}`);const i=new _s(t),r=Gl(n,e,Od(wo(n),i));return new _s(pk(r,i))}function Kn(n){return n.sort((t,s)=>{const i=V(t,"priority")||100,r=V(s,"priority")||100;return i>r?-1:is.name));return t.length&&console.warn(`[tiptap warn]: Duplicate extension names found: [${t.map(s=>`'${s}'`).join(", ")}]. This can lead to issues.`),e}function Dd(n,e,t){const{from:s,to:i}=e,{blockSeparator:r=` +`))),0,0),n.someProp("transformPasted",f=>{l=f(l,n,!0)}),l;let p=n.someProp("clipboardTextParser",f=>f(e,i,s,n));if(p)l=p;else{let f=i.marks(),{schema:h}=n.state,g=ln.fromSchema(h);o=document.createElement("div"),e.split(/(?:\r\n?|\n)+/).forEach(b=>{let m=o.appendChild(document.createElement("p"));b&&m.appendChild(g.serializeNode(h.text(b,f)))})}}else n.someProp("transformPastedHTML",p=>{t=p(t,n)}),o=l0(t),zi&&a0(o);let d=o&&o.querySelector("[data-pm-slice]"),u=d&&/^(\d+) (\d+)(?: -(\d+))? (.*)/.exec(d.getAttribute("data-pm-slice")||"");if(u&&u[3])for(let p=+u[3];p>0;p--){let f=o.firstChild;for(;f&&!q(f);)f=f.nextSibling;if(!f)break;o=f}if(l||(l=(n.someProp("clipboardParser")||n.someProp("domParser")||Ot.fromSchema(n.state.schema)).parseSlice(o,{preserveWhitespace:!!(c||u),context:i,ruleFromNode(f){return f.nodeName=="BR"&&!f.nextSibling&&f.parentNode&&!i0.test(f.parentNode.nodeName)?{ignore:!0}:null}})),u)l=c0(Tl(l,+u[1],+u[2]),u[4]);else if(l=z.maxOpen(r0(l.content,i),!0),l.openStart||l.openEnd){let p=0,f=0;for(let h=l.content.firstChild;p{l=p(l,n,c)}),l}const i0=/^(a|abbr|acronym|b|cite|code|del|em|i|ins|kbd|label|output|q|ruby|s|samp|span|strong|sub|sup|time|u|tt|var)$/i;function r0(n,e){if(n.childCount<2)return n;for(let t=e.depth;t>=0;t--){let i=e.node(t).contentMatchAt(e.index(t)),r,o=[];if(n.forEach(l=>{if(!o)return;let c=i.findWrapping(l.type),d;if(!c)return o=null;if(d=o.length&&r.length&&Jc(c,r,l,o[o.length-1],0))o[o.length-1]=d;else{o.length&&(o[o.length-1]=Gc(o[o.length-1],r.length));let u=Kc(l,c);o.push(u),i=i.matchType(u.type),r=c}}),o)return $.from(o)}return n}function Kc(n,e,t=0){for(let s=e.length-1;s>=t;s--)n=e[s].create(null,$.from(n));return n}function Jc(n,e,t,s,i){if(i1&&(r=0),i=t&&(l=e<0?o.contentMatchAt(0).fillBefore(l,r<=i).append(l):l.append(o.contentMatchAt(o.childCount).fillBefore($.empty,!0))),n.replaceChild(e<0?0:n.childCount-1,o.copy(l))}function Tl(n,e,t){return et})}return Rn.createHTML(n)}function l0(n){let e=/^(\s*]*>)*/.exec(n);e&&(n=n.slice(e[0].length));let t=Xc(),s=t.body,i=/<([a-z][^>\s]+)/i.exec(n),r;if((r=i&&Yc[i[1].toLowerCase()])&&(n=r.map(o=>"<"+o+">").join("")+n+r.map(o=>"").reverse().join("")),s.innerHTML=o0(n),r)for(let o=0;o=0;l-=2){let c=t.nodes[s[l]];if(!c||c.hasRequiredAttrs())break;try{i=$.from(c.create(s[l+1],i))}catch(d){break}r++,o++}return new z(i,r,o)}const Pe={},Be={},d0={touchstart:!0,touchmove:!0};class u0{constructor(){this.shiftKey=!1,this.mouseDown=null,this.lastKeyCode=null,this.lastKeyCodeTime=0,this.lastClick={time:0,x:0,y:0,type:"",button:0},this.lastSelectionOrigin=null,this.lastSelectionTime=0,this.lastIOSEnter=0,this.lastIOSEnterFallbackTimeout=-1,this.lastFocus=0,this.lastTouch=0,this.lastChromeDelete=0,this.composing=!1,this.compositionNode=null,this.composingTimeout=-1,this.compositionNodes=[],this.compositionEndedAt=-2e8,this.compositionID=1,this.badSafariComposition=!1,this.compositionPendingChanges=0,this.domChangeCount=0,this.eventHandlers=Object.create(null),this.hideSelectionGuard=null}}function p0(n){for(let e in Pe){let t=Pe[e];n.dom.addEventListener(e,n.input.eventHandlers[e]=s=>{h0(n,s)&&!fo(n,s)&&(n.editable||!(s.type in Be))&&t(n,s)},d0[e]?{passive:!0}:void 0)}$e&&n.dom.addEventListener("input",()=>null),Lr(n)}function ht(n,e){n.input.lastSelectionOrigin=e,n.input.lastSelectionTime=Date.now()}function f0(n){n.input.mouseDown&&n.input.mouseDown.done(),n.domObserver.stop();for(let e in n.input.eventHandlers)n.dom.removeEventListener(e,n.input.eventHandlers[e]);clearTimeout(n.input.composingTimeout),clearTimeout(n.input.lastIOSEnterFallbackTimeout)}function Lr(n){n.someProp("handleDOMEvents",e=>{for(let t in e)n.input.eventHandlers[t]||n.dom.addEventListener(t,n.input.eventHandlers[t]=s=>fo(n,s))})}function fo(n,e){return n.someProp("handleDOMEvents",t=>{let s=t[e.type];return s?s(n,e)||e.defaultPrevented:!1})}function h0(n,e){if(!e.bubbles)return!0;if(e.defaultPrevented)return!1;for(let t=e.target;t!=n.dom;t=t.parentNode)if(!t||t.nodeType==11||t.pmViewDesc&&t.pmViewDesc.stopEvent(e))return!1;return!0}function m0(n,e){!fo(n,e)&&Pe[e.type]&&(n.editable||!(e.type in Be))&&Pe[e.type](n,e)}Be.keydown=(n,e)=>{let t=e;if(n.input.shiftKey=t.keyCode==16||t.shiftKey,!td(n)&&(n.input.lastKeyCode=t.keyCode,n.input.lastKeyCodeTime=Date.now(),!(ft&&Ee&&t.keyCode==13)))if(t.keyCode!=229&&n.domObserver.forceFlush(),Tn&&t.keyCode==13&&!t.ctrlKey&&!t.altKey&&!t.metaKey){let s=Date.now();n.input.lastIOSEnter=s,n.input.lastIOSEnterFallbackTimeout=setTimeout(()=>{n.input.lastIOSEnter==s&&(n.someProp("handleKeyDown",i=>i(n,qt(13,"Enter"))),n.input.lastIOSEnter=0)},200)}else n.someProp("handleKeyDown",s=>s(n,t))||s0(n,t)?t.preventDefault():ht(n,"key")};Be.keyup=(n,e)=>{e.keyCode==16&&(n.input.shiftKey=!1)};Be.keypress=(n,e)=>{let t=e;if(td(n)||!t.charCode||t.ctrlKey&&!t.altKey||Je&&t.metaKey)return;if(n.someProp("handleKeyPress",i=>i(n,t))){t.preventDefault();return}let s=n.state.selection;if(!(s instanceof U)||!s.$from.sameParent(s.$to)){let i=String.fromCharCode(t.charCode),r=()=>n.state.tr.insertText(i).scrollIntoView();!/[\r\n]/.test(i)&&!n.someProp("handleTextInput",o=>o(n,s.$from.pos,s.$to.pos,i,r))&&n.dispatch(r()),t.preventDefault()}};function bs(n){return{left:n.clientX,top:n.clientY}}function g0(n,e){let t=e.x-n.clientX,s=e.y-n.clientY;return t*t+s*s<100}function ho(n,e,t,s,i){if(s==-1)return!1;let r=n.state.doc.resolve(s);for(let o=r.depth+1;o>0;o--)if(n.someProp(e,l=>o>r.depth?l(n,t,r.nodeAfter,r.before(o),i,!0):l(n,t,r.node(o),r.before(o),i,!1)))return!0;return!1}function vs(n,e,t){if(n.focused||n.focus(),n.state.selection.eq(e))return;let s=n.state.tr.setSelection(e);s.setMeta("pointer",!0),n.dispatch(s)}function b0(n,e){if(e==-1)return!1;let t=n.state.doc.resolve(e),s=t.nodeAfter;return s&&s.isAtom&&W.isSelectable(s)?(vs(n,new W(t)),!0):!1}function v0(n,e){if(e==-1)return!1;let t=n.state.selection,s,i;t instanceof W&&(s=t.node);let r=n.state.doc.resolve(e);for(let o=r.depth+1;o>0;o--){let l=o>r.depth?r.nodeAfter:r.node(o);if(W.isSelectable(l)){s&&t.$from.depth>0&&o>=t.$from.depth&&r.before(t.$from.depth+1)==t.$from.pos?i=r.before(t.$from.depth):i=r.before(o);break}}return i!=null?(vs(n,W.create(n.state.doc,i)),!0):!1}function y0(n,e,t,s,i){return ho(n,"handleClickOn",e,t,s)||n.someProp("handleClick",r=>r(n,e,s))||(i?v0(n,t):b0(n,t))}function k0(n,e,t,s){return ho(n,"handleDoubleClickOn",e,t,s)||n.someProp("handleDoubleClick",i=>i(n,e,s))}function x0(n,e,t,s){return ho(n,"handleTripleClickOn",e,t,s)||n.someProp("handleTripleClick",i=>i(n,e,s))||w0(n,t,s)}function w0(n,e,t){if(t.button!=0)return!1;let s=Zc(n,e,!0),i=n.state.doc;return s?(vs(n,s),s instanceof U&&i.eq(n.state.doc)&&(n.input.mouseDown=new C0(n,s)),!0):!1}function Zc(n,e,t){let s=n.state.doc;if(e==-1)return s.inlineContent?U.create(s,0,s.content.size):null;let i=s.resolve(e);for(let r=i.depth+1;r>0;r--){let o=r>i.depth?i.nodeAfter:i.node(r),l=i.before(r);if(o.inlineContent)return U.create(s,l+1,l+1+o.content.size);if(t&&W.isSelectable(o))return W.create(s,l)}return null}function mo(n){return Ys(n)}const Qc=Je?"metaKey":"ctrlKey";Pe.mousedown=(n,e)=>{let t=e;n.input.shiftKey=t.shiftKey;let s=mo(n),i=Date.now(),r="singleClick";i-n.input.lastClick.time<500&&g0(t,n.input.lastClick)&&!t[Qc]&&n.input.lastClick.button==t.button&&(n.input.lastClick.type=="singleClick"?r="doubleClick":n.input.lastClick.type=="doubleClick"&&(r="tripleClick")),n.input.lastClick={time:i,x:t.clientX,y:t.clientY,type:r,button:t.button},n.input.mouseDown&&n.input.mouseDown.done();let o=n.posAtCoords(bs(t));o&&(r=="singleClick"?n.input.mouseDown=new S0(n,o,t,!!s):(r=="doubleClick"?k0:x0)(n,o.pos,o.inside,t)?t.preventDefault():ht(n,"pointer"))};class ed{constructor(e){this.view=e,this.mightDrag=null,e.root.addEventListener("mouseup",this.up=this.up.bind(this)),e.root.addEventListener("mousemove",this.move=this.move.bind(this))}up(e){this.done()}move(e){e.buttons==0&&this.done()}done(){this.view.root.removeEventListener("mouseup",this.up),this.view.root.removeEventListener("mousemove",this.move),this.view.input.mouseDown==this&&(this.view.input.mouseDown=null)}delaySelUpdate(){return!1}}class S0 extends ed{constructor(e,t,s,i){super(e),this.pos=t,this.event=s,this.flushed=i,this.delayedSelectionSync=!1,this.startDoc=e.state.doc,this.selectNode=!!s[Qc],this.allowDefault=s.shiftKey;let r,o;if(t.inside>-1)r=e.state.doc.nodeAt(t.inside),o=t.inside;else{let u=e.state.doc.resolve(t.pos);r=u.parent,o=u.depth?u.before():0}const l=i?null:s.target,c=l?e.docView.nearestDesc(l,!0):null;this.target=c&&q(c.nodeDOM)?c.nodeDOM:null;let{selection:d}=e.state;s.button==0&&(r.type.spec.draggable&&r.type.spec.selectable!==!1||d instanceof W&&d.from<=o&&d.to>o)&&(this.mightDrag={node:r,pos:o,addAttr:!!(this.target&&!this.target.draggable),setUneditable:!!(this.target&&Ue&&!this.target.hasAttribute("contentEditable"))}),this.target&&this.mightDrag&&(this.mightDrag.addAttr||this.mightDrag.setUneditable)&&(this.view.domObserver.stop(),this.mightDrag.addAttr&&(this.target.draggable=!0),this.mightDrag.setUneditable&&setTimeout(()=>{this.view.input.mouseDown==this&&this.target.setAttribute("contentEditable","false")},20),this.view.domObserver.start()),ht(e,"pointer")}done(){super.done(),this.mightDrag&&this.target&&(this.view.domObserver.stop(),this.mightDrag.addAttr&&this.target.removeAttribute("draggable"),this.mightDrag.setUneditable&&this.target.removeAttribute("contentEditable"),this.view.domObserver.start()),this.delayedSelectionSync&&setTimeout(()=>{this.view.isDestroyed||gt(this.view)})}up(e){if(this.done(),!this.view.dom.contains(e.target))return;let t=this.pos;this.view.state.doc!=this.startDoc&&(t=this.view.posAtCoords(bs(e))),this.updateAllowDefault(e),this.allowDefault||!t?ht(this.view,"pointer"):y0(this.view,t.pos,t.inside,e,this.selectNode)?e.preventDefault():e.button==0&&(this.flushed||$e&&this.mightDrag&&!this.mightDrag.node.isAtom||Ee&&!this.view.state.selection.visible&&Math.min(Math.abs(t.pos-this.view.state.selection.from),Math.abs(t.pos-this.view.state.selection.to))<=2)?(vs(this.view,X.near(this.view.state.doc.resolve(t.pos))),e.preventDefault()):ht(this.view,"pointer")}move(e){this.updateAllowDefault(e),ht(this.view,"pointer"),super.move(e)}updateAllowDefault(e){!this.allowDefault&&(Math.abs(this.event.x-e.clientX)>4||Math.abs(this.event.y-e.clientY)>4)&&(this.allowDefault=!0)}delaySelUpdate(){return this.allowDefault?(this.delayedSelectionSync=!0,!0):!1}}class C0 extends ed{constructor(e,t){super(e),this.startSelection=t,this.startDoc=e.state.doc}move(e){if(e.buttons==0||this.view.isDestroyed||!this.view.state.doc.eq(this.startDoc)){this.done();return}e.preventDefault(),ht(this.view,"pointer");let t=this.view.posAtCoords(bs(e)),s=t&&Zc(this.view,t.inside,!1);if(!s)return;let{doc:i}=this.view.state,r=this.startSelection,[o,l]=s.from{n.input.lastTouch=Date.now(),mo(n),ht(n,"pointer")};Pe.touchmove=n=>{n.input.lastTouch=Date.now(),ht(n,"pointer")};Pe.contextmenu=n=>mo(n);function td(n,e){return n.composing?!0:$e&&Math.abs(Date.now()-n.input.compositionEndedAt)<500?(n.input.compositionEndedAt=-2e8,!0):!1}const M0=ft?5e3:-1;Be.compositionstart=Be.compositionupdate=n=>{if(!n.composing){n.domObserver.flush();let{state:e}=n,t=e.selection.$to;if(e.selection instanceof U&&e.selection.empty&&(e.storedMarks||!t.textOffset&&t.parentOffset&&t.nodeBefore.marks.some(s=>s.type.spec.inclusive===!1)||Ee&&Nc&&T0(n)))n.markCursor=n.state.storedMarks||t.marks(),Ys(n,!0),n.markCursor=null;else if(Ys(n,!e.selection.empty),Ue&&e.selection.empty&&t.parentOffset&&!t.textOffset&&t.nodeBefore.marks.length){let s=n.domSelectionRange();for(let i=s.focusNode,r=s.focusOffset;i&&q(i)&&r!=0;){let o=r<0?i.lastChild:i.childNodes[r-1];if(!o)break;if(ve(o)){let l=n.domSelection();l&&l.collapse(o,o.nodeValue.length);break}else i=o,r=-1}}n.input.composing=!0}nd(n,M0)};function T0(n){let{focusNode:e,focusOffset:t}=n.domSelectionRange();if(!e||!q(e)||t>=e.childNodes.length)return!1;let s=e.childNodes[t];return q(s)&&s.contentEditable=="false"}Be.compositionend=(n,e)=>{n.composing&&(n.input.composing=!1,n.input.compositionEndedAt=Date.now(),n.input.compositionPendingChanges=n.domObserver.pendingRecords().length?n.input.compositionID:0,n.input.compositionNode=null,n.input.badSafariComposition?n.domObserver.forceFlush():n.input.compositionPendingChanges&&Promise.resolve().then(()=>n.domObserver.flush()),n.input.compositionID++,nd(n,20))};function nd(n,e){clearTimeout(n.input.composingTimeout),e>-1&&(n.input.composingTimeout=setTimeout(()=>Ys(n),e))}function sd(n){for(n.composing&&(n.input.composing=!1,n.input.compositionEndedAt=Date.now());n.input.compositionNodes.length>0;)n.input.compositionNodes.pop().markParentsDirty()}function E0(n){let e=n.domSelectionRange();if(!e.focusNode)return null;let t=vy(e.focusNode,e.focusOffset),s=yy(e.focusNode,e.focusOffset);if(t&&s&&t!=s){let i=s.pmViewDesc,r=n.domObserver.lastChangedTextNode;if(t==r||s==r)return r;if(!i||!i.isText(s.nodeValue))return s;if(n.input.compositionNode==s){let o=t.pmViewDesc;if(!(!o||!o.isText(t.nodeValue)))return s}}return t||s}function Ys(n,e=!1){if(!(ft&&n.domObserver.flushingSoon>=0)){if(n.domObserver.forceFlush(),sd(n),e||n.docView&&n.docView.dirty){let t=co(n),s=n.state.selection;return t&&!t.eq(s)?n.dispatch(n.state.tr.setSelection(t)):(n.markCursor||e)&&!s.$from.node(s.$from.sharedDepth(s.to)).inlineContent?n.dispatch(n.state.tr.deleteSelection()):n.updateState(n.state),!0}return!1}}function A0(n,e){if(!n.dom.parentNode)return;let t=n.dom.parentNode.appendChild(document.createElement("div"));t.appendChild(e),t.style.cssText="position: fixed; left: -10000px; top: 10px";let s=getSelection(),i=document.createRange();i.selectNodeContents(e),n.dom.blur(),s.removeAllRanges(),s.addRange(i),setTimeout(()=>{t.parentNode&&t.parentNode.removeChild(t),n.focus()},50)}const cs=je&&Nt<15||Tn&&Sy<604;Pe.copy=Be.cut=(n,e)=>{let t=e,s=n.state.selection,i=t.type=="cut";if(s.empty)return;let r=cs?null:t.clipboardData,o=s.content(),{dom:l,text:c}=po(n,o);r?(t.preventDefault(),r.clearData(),r.setData("text/html",l.innerHTML),r.setData("text/plain",c)):A0(n,l),i&&n.dispatch(n.state.tr.deleteSelection().scrollIntoView().setMeta("uiEvent","cut"))};function O0(n){return n.openStart==0&&n.openEnd==0&&n.content.childCount==1?n.content.firstChild:null}function N0(n,e){if(!n.dom.parentNode)return;let t=n.input.shiftKey||n.state.selection.$from.parent.type.spec.code,s=n.dom.parentNode.appendChild(document.createElement(t?"textarea":"div"));t||(s.contentEditable="true"),s.style.cssText="position: fixed; left: -10000px; top: 10px",s.focus();let i=n.input.shiftKey&&n.input.lastKeyCode!=45;setTimeout(()=>{n.focus(),s.parentNode&&s.parentNode.removeChild(s),t?ds(n,s.value,null,i,e):ds(n,s.textContent,s.innerHTML,i,e)},50)}function ds(n,e,t,s,i){let r=Wc(n,e,t,s,n.state.selection.$from);if(n.someProp("handlePaste",c=>c(n,i,r||z.empty)))return!0;if(!r)return!1;let o=O0(r),l=o?n.state.tr.replaceSelectionWith(o,s):n.state.tr.replaceSelection(r);return n.dispatch(l.scrollIntoView().setMeta("paste",!0).setMeta("uiEvent","paste")),!0}function id(n){let e=n.getData("text/plain")||n.getData("Text");if(e)return e;let t=n.getData("text/uri-list");return t?t.replace(/\r?\n/g," "):""}Be.paste=(n,e)=>{let t=e;if(n.composing&&!ft)return;let s=cs?null:t.clipboardData,i=n.input.shiftKey&&n.input.lastKeyCode!=45;s&&ds(n,id(s),s.getData("text/html"),i,t)?t.preventDefault():N0(n,t)};class rd{constructor(e,t,s){this.slice=e,this.move=t,this.node=s}}const I0=Je?"altKey":"ctrlKey";function od(n,e){let t;return n.someProp("dragCopies",s=>{t=t||s(e)}),t!=null?!t:!e[I0]}Pe.dragstart=(n,e)=>{let t=e,s=n.input.mouseDown;if(s&&s.done(),!t.dataTransfer)return;let i=n.state.selection,r=i.empty?null:n.posAtCoords(bs(t)),o;if(!(r&&r.pos>=i.from&&r.pos<=(i instanceof W?i.to-1:i.to))){if(s&&s.mightDrag)o=W.create(n.state.doc,s.mightDrag.pos);else if(t.target&&q(t.target)){let p=n.docView.nearestDesc(t.target,!0);p&&p.node.type.spec.draggable&&p!=n.docView&&(o=W.create(n.state.doc,p.posBefore))}}let l=(o||n.state.selection).content(),{dom:c,text:d,slice:u}=po(n,l);(!t.dataTransfer.files.length||!Ee||Oc>120)&&t.dataTransfer.clearData(),t.dataTransfer.setData(cs?"Text":"text/html",c.innerHTML),t.dataTransfer.effectAllowed="copyMove",cs||t.dataTransfer.setData("text/plain",d),n.dragging=new rd(u,od(n,t),o)};Pe.dragend=n=>{let e=n.dragging;window.setTimeout(()=>{n.dragging==e&&(n.dragging=null)},50)};Be.dragover=Be.dragenter=(n,e)=>e.preventDefault();Be.drop=(n,e)=>{try{D0(n,e,n.dragging)}finally{n.dragging=null}};function D0(n,e,t){if(!e.dataTransfer)return;let s=n.posAtCoords(bs(e));if(!s)return;let i=n.state.doc.resolve(s.pos),r=t&&t.slice;r?n.someProp("transformPasted",h=>{r=h(r,n,!1)}):r=Wc(n,id(e.dataTransfer),cs?null:e.dataTransfer.getData("text/html"),!1,i);let o=!!(t&&od(n,e));if(n.someProp("handleDrop",h=>h(n,e,r||z.empty,o))){e.preventDefault();return}if(!r)return;e.preventDefault();let l=r?lc(n.state.doc,i.pos,r):i.pos;l==null&&(l=i.pos);let c=n.state.tr;if(o){let{node:h}=t;h?h.replace(c):c.deleteSelection()}let d=c.mapping.map(l),u=r.openStart==0&&r.openEnd==0&&r.content.childCount==1,p=c.doc;if(u?c.replaceRangeWith(d,d,r.content.firstChild):c.replaceRange(d,d,r),c.doc.eq(p))return;let f=c.doc.resolve(d);if(u&&W.isSelectable(r.content.firstChild)&&f.nodeAfter&&f.nodeAfter.sameMarkup(r.content.firstChild))c.setSelection(new W(f));else{let h=c.mapping.map(l);c.mapping.maps[c.mapping.maps.length-1].forEach((g,b,m,v)=>h=v),c.setSelection(uo(n,f,c.doc.resolve(h)))}n.focus(),n.dispatch(c.setMeta("uiEvent","drop"))}Pe.focus=n=>{n.input.lastFocus=Date.now(),n.focused||(n.domObserver.stop(),n.dom.classList.add("ProseMirror-focused"),n.domObserver.start(),n.focused=!0,setTimeout(()=>{n.docView&&n.hasFocus()&&!n.domObserver.currentSelection.eq(n.domSelectionRange())&>(n)},20))};Pe.blur=(n,e)=>{let t=e;n.focused&&(n.domObserver.stop(),n.dom.classList.remove("ProseMirror-focused"),n.domObserver.start(),t.relatedTarget&&n.dom.contains(t.relatedTarget)&&n.domObserver.currentSelection.clear(),n.focused=!1)};Pe.beforeinput=(n,e)=>{if(ft&&e.inputType=="deleteContentBackward"){n.domObserver.flushSoon();let{domChangeCount:s}=n.input;setTimeout(()=>{if(n.input.domChangeCount!=s||(n.dom.blur(),n.focus(),n.someProp("handleKeyDown",r=>r(n,qt(8,"Backspace")))))return;let{$cursor:i}=n.state.selection;i&&i.pos>0&&n.dispatch(n.state.tr.delete(i.pos-1,i.pos).scrollIntoView())},50)}};for(let n in Be)Pe[n]=Be[n];function us(n,e){if(n==e)return!0;for(let t in n)if(n[t]!==e[t])return!1;for(let t in e)if(!(t in n))return!1;return!0}class Xs{constructor(e,t){this.toDOM=e,this.spec=t||Qt,this.side=this.spec.side||0}map(e,t,s,i){let{pos:r,deleted:o}=e.mapResult(t.from+i,this.side<0?-1:1);return o?null:new Le(r-s,r-s,this)}valid(){return!0}eq(e){return this==e||e instanceof Xs&&(this.spec.key&&this.spec.key==e.spec.key||this.toDOM==e.toDOM&&us(this.spec,e.spec))}destroy(e){this.spec.destroy&&this.spec.destroy(e)}}class $t{constructor(e,t){this.attrs=e,this.spec=t||Qt}map(e,t,s,i){let r=e.map(t.from+i,this.spec.inclusiveStart?-1:1)-s,o=e.map(t.to+i,this.spec.inclusiveEnd?1:-1)-s;return r>=o?null:new Le(r,o,this)}valid(e,t){return t.from=e&&(!r||r(l.spec))&&s.push(l.copy(l.from+i,l.to+i))}for(let o=0;oe){let l=this.children[o]+1;this.children[o+2].findInner(e-l,t-l,s,i+l,r)}}map(e,t,s){return this==Ne||e.maps.length==0?this:this.mapInner(e,t,0,0,s||Qt)}mapInner(e,t,s,i,r){let o;for(let l=0;l{let d=c+s,u;if(u=ad(t,l,d)){for(i||(i=this.children.slice());rl&&p.to=e){this.children[l]==e&&(s=this.children[l+2]);break}let r=e+1,o=r+t.content.size;for(let l=0;lr&&c.type instanceof $t){let d=Math.max(r,c.from)-r,u=Math.min(o,c.to)-r;di.map(e,t,Qt));return Mt.from(s)}forChild(e,t){if(t.isLeaf)return ne.empty;let s=[];for(let i=0;it instanceof ne)?e:e.reduce((t,s)=>t.concat(s instanceof ne?s:s.members),[]))}}forEachSet(e){for(let t=0;t{let m=b-g-(h-f);for(let v=0;vS+u-p)continue;let A=l[v]+u-p;h>=A?l[v+1]=f<=A?-2:-1:f>=u&&m&&(l[v]+=m,l[v+1]+=m)}p+=m}),u=t.maps[d].map(u,-1)}let c=!1;for(let d=0;d=s.content.size){c=!0;continue}let f=t.map(n[d+1]+r,-1),h=f-i,{index:g,offset:b}=s.content.findIndex(p),m=s.maybeChild(g);if(m&&b==p&&b+m.nodeSize==h){let v=l[d+2].mapInner(t,m,u+1,n[d]+r+1,o);v!=Ne?(l[d]=p,l[d+1]=h,l[d+2]=v):(l[d+1]=-2,c=!0)}else c=!0}if(c){let d=R0(l,n,e,t,i,r,o),u=Zs(d,s,0,o);e=u.local;for(let p=0;pt&&o.to{let d=ad(n,l,c+t);if(d){r=!0;let u=Zs(d,l,t+c+1,s);u!=Ne&&i.push(c,c+l.nodeSize,u)}});let o=ld(r?cd(n):n,-t).sort(en);for(let l=0;l0;)e++;n.splice(e,0,t)}function rr(n){let e=[];return n.someProp("decorations",t=>{let s=t(n.state);s&&s!=Ne&&e.push(s)}),n.cursorWrapper&&e.push(ne.create(n.state.doc,[n.cursorWrapper.deco])),Mt.from(e)}const L0={childList:!0,characterData:!0,characterDataOldValue:!0,attributes:!0,attributeOldValue:!0,subtree:!0},P0=je&&Nt<=11;class B0{constructor(){this.anchorNode=null,this.anchorOffset=0,this.focusNode=null,this.focusOffset=0}set(e){this.anchorNode=e.anchorNode,this.anchorOffset=e.anchorOffset,this.focusNode=e.focusNode,this.focusOffset=e.focusOffset}clear(){this.anchorNode=this.focusNode=null}eq(e){return e.anchorNode==this.anchorNode&&e.anchorOffset==this.anchorOffset&&e.focusNode==this.focusNode&&e.focusOffset==this.focusOffset}}class _0{constructor(e,t){this.view=e,this.handleDOMChange=t,this.queue=[],this.flushingSoon=-1,this.observer=null,this.currentSelection=new B0,this.onCharData=null,this.suppressingSelectionUpdates=!1,this.lastChangedTextNode=null,this.observer=window.MutationObserver&&new window.MutationObserver(s=>{for(let i=0;ii.type=="childList"&&i.removedNodes.length||i.type=="characterData"&&i.oldValue.length>i.target.nodeValue.length)?this.flushSoon():$e&&e.composing&&s.some(i=>i.type=="childList"&&i.target.nodeName=="TR")?(e.input.badSafariComposition=!0,this.flushSoon()):this.flush()}),P0&&(this.onCharData=s=>{this.queue.push({target:s.target,type:"characterData",oldValue:s.prevValue}),this.flushSoon()}),this.onSelectionChange=this.onSelectionChange.bind(this)}flushSoon(){this.flushingSoon<0&&(this.flushingSoon=window.setTimeout(()=>{this.flushingSoon=-1,this.flush()},20))}forceFlush(){this.flushingSoon>-1&&(window.clearTimeout(this.flushingSoon),this.flushingSoon=-1,this.flush())}start(){this.observer&&(this.observer.takeRecords(),this.observer.observe(this.view.dom,L0)),this.onCharData&&this.view.dom.addEventListener("DOMCharacterDataModified",this.onCharData),this.connectSelection()}stop(){if(this.observer){let e=this.observer.takeRecords();if(e.length){for(let t=0;tthis.flush(),20)}this.observer.disconnect()}this.onCharData&&this.view.dom.removeEventListener("DOMCharacterDataModified",this.onCharData),this.disconnectSelection()}connectSelection(){this.view.dom.ownerDocument.addEventListener("selectionchange",this.onSelectionChange)}disconnectSelection(){this.view.dom.ownerDocument.removeEventListener("selectionchange",this.onSelectionChange)}suppressSelectionUpdates(){this.suppressingSelectionUpdates=!0,setTimeout(()=>this.suppressingSelectionUpdates=!1,50)}onSelectionChange(){if(kl(this.view)){if(this.suppressingSelectionUpdates)return gt(this.view);if(je&&Nt<=11&&!this.view.state.selection.empty){let e=this.view.domSelectionRange();if(e.focusNode&&sn(e.focusNode,e.focusOffset,e.anchorNode,e.anchorOffset))return this.flushSoon()}this.flush()}}setCurSelection(){this.currentSelection.set(this.view.domSelectionRange())}ignoreSelectionChange(e){if(!e.focusNode)return!0;let t=new Set,s;for(let r=e.focusNode;r;r=Mn(r))t.add(r);for(let r=e.anchorNode;r;r=Mn(r))if(t.has(r)){s=r;break}let i=s&&this.view.docView.nearestDesc(s);if(i&&i.ignoreMutation({type:"selection",target:ve(s)?s.parentNode:s}))return this.setCurSelection(),!0}pendingRecords(){if(this.observer)for(let e of this.observer.takeRecords())this.queue.push(e);return this.queue}flush(){let{view:e}=this;if(!e.docView||this.flushingSoon>-1)return;let t=this.pendingRecords();t.length&&(this.queue=[]);let s=e.domSelectionRange(),i=!this.suppressingSelectionUpdates&&!this.currentSelection.eq(s)&&kl(e)&&!this.ignoreSelectionChange(s),r=-1,o=-1,l=!1,c=[];if(e.editable)for(let u=0;uu.nodeName=="BR")&&(e.input.lastKeyCode==8||e.input.lastKeyCode==46||Ee&&(e.composing||e.input.compositionEndedAt>Date.now()-50)&&t.some(u=>u.type=="childList"&&u.removedNodes.length))){for(let u of c)if(u.nodeName=="BR"&&u.parentNode){let p=u.nextSibling;for(;p&&q(p);){if(p.contentEditable=="false"){u.parentNode.removeChild(u);break}p=p.firstChild}}}else if(Ue&&c.length){let u=c.filter(p=>p.nodeName=="BR");if(u.length==2){let[p,f]=u;p.parentNode&&p.parentNode.parentNode==f.parentNode?f.remove():p.remove()}else{let{focusNode:p}=this.currentSelection;for(let f of u){let h=f.parentNode;h&&h.nodeName=="LI"&&(!p||F0(e,p)!=h)&&f.remove()}}}let d=null;r<0&&i&&e.input.lastFocus>Date.now()-200&&Math.max(e.input.lastTouch,e.input.lastClick.time)-1||i)&&(r>-1&&(e.docView.markDirty(r,o),z0(e)),e.input.badSafariComposition&&(e.input.badSafariComposition=!1,V0(e,c)),this.handleDOMChange(r,o,l,c),e.docView&&e.docView.dirty?e.updateState(e.state):this.currentSelection.eq(s)||gt(e),this.currentSelection.set(s))}registerMutation(e,t){if(t.indexOf(e.target)>-1)return null;let s=this.view.docView.nearestDesc(e.target);if(e.type=="attributes"&&(s==this.view.docView||e.attributeName=="contenteditable"||e.attributeName=="style"&&!e.oldValue&&!e.target.getAttribute("style"))||!s||s.ignoreMutation(e))return null;if(e.type=="childList"){for(let u=0;ur;v--){let S=i.childNodes[v-1],A=S.pmViewDesc;if(S.nodeName=="BR"&&!A){o=v;break}if(!A||A.size)break}let f=n.state.doc,h=n.someProp("domParser")||Ot.fromSchema(n.state.schema),g=f.resolve(l),b=null,m=h.parse(i,{topNode:g.parent,topMatch:g.parent.contentMatchAt(g.index()),topOpen:!0,from:r,to:o,preserveWhitespace:g.parent.type.whitespace=="pre"?"full":!0,findPositions:u,ruleFromNode:q0(s),context:g});if(u&&u[0].pos!=null){let v=u[0].pos,S=u[1]&&u[1].pos;S==null&&(S=v),b={anchor:v+l,head:S+l}}return{doc:m,sel:b,from:l,to:c}}const q0=n=>e=>{let t=e.pmViewDesc;if(t)return t.parseRule(n);if(e.nodeName=="BR"&&e.parentNode){if($e&&/^(ul|ol)$/i.test(e.parentNode.nodeName)){let s=document.createElement("div");return s.appendChild(document.createElement("li")),{skip:s}}else if(e.parentNode.lastChild==e||$e&&/^(tr|table)$/i.test(e.parentNode.nodeName))return{ignore:!0}}else if(e.nodeName=="IMG"&&e.getAttribute("mark-placeholder"))return{ignore:!0};return null},U0=/^(a|abbr|acronym|b|bd[io]|big|br|button|cite|code|data(list)?|del|dfn|em|i|img|ins|kbd|label|map|mark|meter|output|q|ruby|s|samp|small|span|strong|su[bp]|time|u|tt|var)$/i;function W0(n,e,t,s,i){let r=n.input.compositionPendingChanges||(n.composing?n.input.compositionID:0);if(n.input.compositionPendingChanges=0,e<0){let M=n.input.lastSelectionTime>Date.now()-50?n.input.lastSelectionOrigin:null,w=co(n,M);if(w&&!n.state.selection.eq(w)){if(Ee&&ft&&n.input.lastKeyCode===13&&Date.now()-100O(n,qt(13,"Enter"))))return;let T=n.state.tr.setSelection(w);M=="pointer"?T.setMeta("pointer",!0):M=="key"&&T.scrollIntoView(),r&&T.setMeta("composition",r),n.dispatch(T)}return}let o=n.state.doc.resolve(e),l=o.sharedDepth(t);e=o.before(l+1),t=n.state.doc.resolve(t).after(l+1);let c=n.state.selection,d=H0(n,e,t,i),u=n.state.doc,p=u.slice(d.from,d.to),f,h;n.input.lastKeyCode===8&&Date.now()-100Date.now()-225||ft)&&i.some(M=>q(M)&&!U0.test(M.nodeName))&&(!g||g.endA>=g.endB)&&n.someProp("handleKeyDown",M=>M(n,qt(13,"Enter")))){n.input.lastIOSEnter=0;return}if(!g)if(s&&c instanceof U&&!c.empty&&c.$head.sameParent(c.$anchor)&&!n.composing&&!(d.sel&&d.sel.anchor!=d.sel.head))g={start:c.from,endA:c.to,endB:c.to};else{if(d.sel){let M=Il(n,n.state.doc,d.sel);if(M&&!M.eq(n.state.selection)){let w=n.state.tr.setSelection(M);r&&w.setMeta("composition",r),n.dispatch(w)}}return}n.state.selection.fromn.state.selection.from&&g.start<=n.state.selection.from+2&&n.state.selection.from>=d.from?g.start=n.state.selection.from:g.endA=n.state.selection.to-2&&n.state.selection.to<=d.to&&(g.endB+=n.state.selection.to-g.endA,g.endA=n.state.selection.to)),je&&Nt<=11&&g.endB==g.start+1&&g.endA==g.start&&g.start>d.from&&d.doc.textBetween(g.start-d.from-1,g.start-d.from+1)=="  "&&(g.start--,g.endA--,g.endB--);let b=d.doc.resolveNoCache(g.start-d.from),m=d.doc.resolveNoCache(g.endB-d.from),v=u.resolve(g.start),S=b.sameParent(m)&&b.parent.inlineContent&&v.end()>=g.endA;if((Tn&&n.input.lastIOSEnter>Date.now()-225&&(!S||i.some(M=>M.nodeName=="DIV"||M.nodeName=="P"))||!S&&G0(d.doc,b.pos,m.pos))&&n.someProp("handleKeyDown",M=>M(n,qt(13,"Enter")))){n.input.lastIOSEnter=0;return}if(n.state.selection.anchor>g.start&&J0(u,g.start,g.endA,b,m)&&n.someProp("handleKeyDown",M=>M(n,qt(8,"Backspace")))){ft&&Ee&&n.domObserver.suppressSelectionUpdates();return}Ee&&g.endB==g.start&&(n.input.lastChromeDelete=Date.now()),ft&&!S&&b.start()!=m.start()&&m.parentOffset==0&&b.depth==m.depth&&d.sel&&d.sel.anchor==d.sel.head&&d.sel.head==g.endA&&(g.endB-=2,m=d.doc.resolveNoCache(g.endB-d.from),setTimeout(()=>{n.someProp("handleKeyDown",function(M){return M(n,qt(13,"Enter"))})},20));let A=g.start,N=g.endA,B=M=>{let w=M||n.state.tr.replace(A,N,d.doc.slice(g.start-d.from,g.endB-d.from));if(d.sel){let T=Il(n,w.doc,d.sel);T&&!(Ee&&n.composing&&T.empty&&(g.start!=g.endB||n.input.lastChromeDeletegt(n),20));let M=B(n.state.tr.delete(A,N)),w=u.resolve(g.start).marksAcross(u.resolve(g.endA));w&&M.ensureMarks(w),n.dispatch(M)}else if(g.endA==g.endB&&(E=K0(b.parent.content.cut(b.parentOffset,m.parentOffset),v.parent.content.cut(v.parentOffset,g.endA-v.start())))){let M=B(n.state.tr);E.type=="add"?M.addMark(A,N,E.mark):M.removeMark(A,N,E.mark),n.dispatch(M)}else if(b.parent.child(b.index()).isText&&b.index()==m.index()-(m.textOffset?0:1)){let M=b.parent.textBetween(b.parentOffset,m.parentOffset),w=()=>B(n.state.tr.insertText(M,A,N));n.someProp("handleTextInput",T=>T(n,A,N,M,w))||n.dispatch(w())}else n.dispatch(B());else n.dispatch(B())}function Il(n,e,t){return Math.max(t.anchor,t.head)>e.content.size?null:uo(n,e.resolve(t.anchor),e.resolve(t.head))}function K0(n,e){let t=n.firstChild.marks,s=e.firstChild.marks,i=t,r=s,o,l,c;for(let u=0;uu.mark(l.addToSet(u.marks));else if(i.length==0&&r.length==1)l=r[0],o="remove",c=u=>u.mark(l.removeFromSet(u.marks));else return null;let d=[];for(let u=0;ut||or(o,!0,!1){r.isTextblock&&o>=e&&o0&&(e||n.indexAfter(s)==n.node(s).childCount);)s--,i++,e=!1;if(t){let r=n.node(s).maybeChild(n.indexAfter(s));for(;r&&!r.isLeaf;)r=r.firstChild,i++}return i}function Y0(n,e,t,s,i){let r=n.findDiffStart(e,t),o=t+n.size,l=t+e.size;if(r==null)return null;let{a:c,b:d}=n.findDiffEnd(e,o,l);if(i=="end"){let u=Math.max(0,r-Math.min(c,d));s-=c+u-r}if(c=c?r-s:0;r-=u,d=r+(d-c),c=r}else if(d=d?r-s:0;r-=u,c=r+(c-d),d=r}return{start:r,endA:c,endB:d}}class dd{constructor(e,t){this._root=null,this.focused=!1,this.trackWrites=null,this.mounted=!1,this.markCursor=null,this.cursorWrapper=null,this.lastSelectedViewDesc=void 0,this.input=new u0,this.prevDirectPlugins=[],this.pluginViews=[],this.requiresGeckoHackNode=!1,this.dragging=null,this._props=t,this.state=t.state,this.directPlugins=t.plugins||[],this.directPlugins.forEach(Pl),this.dispatch=this.dispatch.bind(this),this.dom=e&&e.mount||document.createElement("div"),e&&(e.appendChild?e.appendChild(this.dom):typeof e=="function"?e(this.dom):e.mount&&(this.mounted=!0)),this.editable=Rl(this),$l(this),this.nodeViews=Ll(this),this.docView=hl(this.state.doc,Dl(this),rr(this),this.dom,this),this.domObserver=new _0(this,(s,i,r,o)=>W0(this,s,i,r,o)),this.domObserver.start(),p0(this),this.updatePluginViews()}get composing(){return this.input.composing}get props(){if(this._props.state!=this.state){let e=this._props;this._props={};for(let t in e)this._props[t]=e[t];this._props.state=this.state}return this._props}update(e){e.handleDOMEvents!=this._props.handleDOMEvents&&Lr(this);let t=this._props;this._props=e,e.plugins&&(e.plugins.forEach(Pl),this.directPlugins=e.plugins),this.updateStateInner(e.state,t)}setProps(e){let t={};for(let s in this._props)t[s]=this._props[s];t.state=this.state;for(let s in e)t[s]=e[s];this.update(t)}updateState(e){this.updateStateInner(e,this._props)}updateStateInner(e,t){var s;let i=this.state,r=!1,o=!1;e.storedMarks&&this.composing&&(sd(this),o=!0),this.state=e;let l=i.plugins!=e.plugins||this._props.plugins!=t.plugins;if(l||this._props.plugins!=t.plugins||this._props.nodeViews!=t.nodeViews){let h=Ll(this);Z0(h,this.nodeViews)&&(this.nodeViews=h,r=!0)}(l||t.handleDOMEvents!=this._props.handleDOMEvents)&&Lr(this),this.editable=Rl(this),$l(this);let c=rr(this),d=Dl(this),u=i.plugins!=e.plugins&&!i.doc.eq(e.doc)?"reset":e.scrollToSelection>i.scrollToSelection?"to selection":"preserve",p=r||!this.docView.matchesNode(e.doc,d,c);(p||!e.selection.eq(i.selection))&&(o=!0);let f=u=="preserve"&&o&&this.dom.style.overflowAnchor==null&&Ty(this);if(o){this.domObserver.stop();let h=p&&(je||Ee)&&!this.composing&&!i.selection.empty&&!e.selection.empty&&X0(i.selection,e.selection);if(p){let b=Ee?this.trackWrites=this.domSelectionRange().focusNode:null;this.composing&&(this.input.compositionNode=E0(this)),(r||!this.docView.update(e.doc,d,c,this))&&(this.docView.updateOuterDeco(d),this.docView.destroy(),this.docView=hl(e.doc,d,c,this.dom,this)),b&&(!this.trackWrites||!this.dom.contains(this.trackWrites))&&(h=!0)}let g=this.input.mouseDown;h||!(g&&this.domObserver.currentSelection.eq(this.domSelectionRange())&&Yy(this)&&g.delaySelUpdate())?gt(this,h):(Hc(this,e.selection),this.domObserver.setCurSelection()),this.domObserver.start()}this.updatePluginViews(i),!((s=this.dragging)===null||s===void 0)&&s.node&&!i.doc.eq(e.doc)&&this.updateDraggedNode(this.dragging,i),u=="reset"?this.dom.scrollTop=0:u=="to selection"?this.scrollToSelection():f&&Ey(f)}scrollToSelection(){let e=this.domSelectionRange().focusNode;if(!(!e||!rn(this.dom,e))){if(!this.someProp("handleScrollToSelection",t=>t(this)))if(this.state.selection instanceof W){let t=this.docView.domAfterPos(this.state.selection.from);q(t)&&cl(this,t.getBoundingClientRect(),e)}else cl(this,this.coordsAtPos(this.state.selection.head,1),e)}}destroyPluginViews(){let e;for(;e=this.pluginViews.pop();)e.destroy&&e.destroy()}updatePluginViews(e){if(!e||e.plugins!=this.state.plugins||this.directPlugins!=this.prevDirectPlugins){this.prevDirectPlugins=this.directPlugins,this.destroyPluginViews();for(let t=0;t0&&rt.ownerDocument.getSelection()),this._root=t}return e||document}updateRoot(){this._root=null}posAtCoords(e){return $y(this,e)}coordsAtPos(e,t=1){return Lc(this,e,t)}domAtPos(e,t=0){return this.docView.domFromPos(e,t)}nodeDOM(e){let t=this.docView.descAt(e);return t?t.nodeDOM:null}posAtDOM(e,t,s=-1){let i=this.docView.posFromDOM(e,t,s);if(i==null)throw new RangeError("DOM position not inside the editor");return i}endOfTextblock(e,t){return _y(this,t||this.state,e)}pasteHTML(e,t){return ds(this,"",e,!1,t||new ClipboardEvent("paste"))}pasteText(e,t){return ds(this,e,null,!0,t||new ClipboardEvent("paste"))}serializeForClipboard(e){return po(this,e)}destroy(){this.docView&&(f0(this),this.destroyPluginViews(),this.mounted?(this.docView.update(this.state.doc,[],rr(this),this),this.dom.textContent=""):this.dom.parentNode&&this.dom.parentNode.removeChild(this.dom),this.docView.destroy(),this.docView=null,gy())}get isDestroyed(){return this.docView==null}dispatchEvent(e){return m0(this,e)}domSelectionRange(){let e=this.dom.isConnected!==!1&&this.domSelection();return e?$e&&this.root.nodeType===11&&xy(this.dom.ownerDocument)==this.dom&&j0(this,e)||e:{focusNode:null,focusOffset:0,anchorNode:null,anchorOffset:0}}domSelection(){return this.root.getSelection()}}dd.prototype.dispatch=function(n){let e=this._props.dispatchTransaction;e?e.call(this,n):this.updateState(this.state.apply(n))};function Dl(n){let e=Object.create(null);return e.class="ProseMirror",e.contenteditable=String(n.editable),n.someProp("attributes",t=>{if(typeof t=="function"&&(t=t(n.state)),t)for(let s in t)s=="class"?e.class+=" "+t[s]:s=="style"?e.style=(e.style?e.style+";":"")+t[s]:!e[s]&&s!="contenteditable"&&s!="nodeName"&&(e[s]=String(t[s]))}),e.translate||(e.translate="no"),[Le.node(0,n.state.doc.content.size,e)]}function $l(n){if(n.markCursor){let e=document.createElement("img");e.className="ProseMirror-separator",e.setAttribute("mark-placeholder","true"),e.setAttribute("alt",""),n.cursorWrapper={dom:e,deco:Le.widget(n.state.selection.from,e,{raw:!0,marks:n.markCursor})}}else n.cursorWrapper=null}function Rl(n){return!n.someProp("editable",e=>e(n.state)===!1)}function X0(n,e){let t=Math.min(n.$anchor.sharedDepth(n.head),e.$anchor.sharedDepth(e.head));return n.$anchor.start(t)!=e.$anchor.start(t)}function Ll(n){let e=Object.create(null);function t(s){for(let i in s)Object.prototype.hasOwnProperty.call(e,i)||(e[i]=s[i])}return n.someProp("nodeViews",t),n.someProp("markViews",t),e}function Z0(n,e){let t=0,s=0;for(let i in n){if(n[i]!=e[i])return!0;t++}for(let i in e)s++;return t!=s}function Pl(n){if(n.spec.state||n.spec.filterTransaction||n.spec.appendTransaction)throw new RangeError("Plugins passed directly to the view must not have a state component")}var Lt={8:"Backspace",9:"Tab",10:"Enter",12:"NumLock",13:"Enter",16:"Shift",17:"Control",18:"Alt",20:"CapsLock",27:"Escape",32:" ",33:"PageUp",34:"PageDown",35:"End",36:"Home",37:"ArrowLeft",38:"ArrowUp",39:"ArrowRight",40:"ArrowDown",44:"PrintScreen",45:"Insert",46:"Delete",59:";",61:"=",91:"Meta",92:"Meta",106:"*",107:"+",108:",",109:"-",110:".",111:"/",144:"NumLock",145:"ScrollLock",160:"Shift",161:"Shift",162:"Control",163:"Control",164:"Alt",165:"Alt",173:"-",186:";",187:"=",188:",",189:"-",190:".",191:"/",192:"`",219:"[",220:"\\",221:"]",222:"'"},Qs={48:")",49:"!",50:"@",51:"#",52:"$",53:"%",54:"^",55:"&",56:"*",57:"(",59:":",61:"+",173:"_",186:":",187:"+",188:"<",189:"_",190:">",191:"?",192:"~",219:"{",220:"|",221:"}",222:'"'},Q0=typeof navigator!="undefined"&&/Mac/.test(navigator.platform),e1=typeof navigator!="undefined"&&/MSIE \d|Trident\/(?:[7-9]|\d{2,})\..*rv:(\d+)/.exec(navigator.userAgent);for(var Me=0;Me<10;Me++)Lt[48+Me]=Lt[96+Me]=String(Me);for(var Me=1;Me<=24;Me++)Lt[Me+111]="F"+Me;for(var Me=65;Me<=90;Me++)Lt[Me]=String.fromCharCode(Me+32),Qs[Me]=String.fromCharCode(Me);for(var lr in Lt)Qs.hasOwnProperty(lr)||(Qs[lr]=Lt[lr]);function t1(n){var e=Q0&&n.metaKey&&n.shiftKey&&!n.ctrlKey&&!n.altKey||e1&&n.shiftKey&&n.key&&n.key.length==1||n.key=="Unidentified",t=!e&&n.key||(n.shiftKey?Qs:Lt)[n.keyCode]||n.key||"Unidentified";return t=="Esc"&&(t="Escape"),t=="Del"&&(t="Delete"),t=="Left"&&(t="ArrowLeft"),t=="Up"&&(t="ArrowUp"),t=="Right"&&(t="ArrowRight"),t=="Down"&&(t="ArrowDown"),t}const n1=typeof navigator!="undefined"&&/Mac|iP(hone|[oa]d)/.test(navigator.platform),s1=typeof navigator!="undefined"&&/Win/.test(navigator.platform);function i1(n){let e=n.split(/-(?!$)/),t=e[e.length-1];t=="Space"&&(t=" ");let s,i,r,o;for(let l=0;l=t?we.empty:this.sliceInner(Math.max(0,e),Math.min(this.length,t))};we.prototype.get=function(e){if(!(e<0||e>=this.length))return this.getInner(e)};we.prototype.forEach=function(e,t,s){t===void 0&&(t=0),s===void 0&&(s=this.length),t<=s?this.forEachInner(e,t,s,0):this.forEachInvertedInner(e,t,s,0)};we.prototype.map=function(e,t,s){t===void 0&&(t=0),s===void 0&&(s=this.length);var i=[];return this.forEach(function(r,o){return i.push(e(r,o))},t,s),i};we.from=function(e){return e instanceof we?e:e&&e.length?new pd(e):we.empty};var pd=(function(n){function e(s){n.call(this),this.values=s}n&&(e.__proto__=n),e.prototype=Object.create(n&&n.prototype),e.prototype.constructor=e;var t={length:{configurable:!0},depth:{configurable:!0}};return e.prototype.flatten=function(){return this.values},e.prototype.sliceInner=function(i,r){return i==0&&r==this.length?this:new e(this.values.slice(i,r))},e.prototype.getInner=function(i){return this.values[i]},e.prototype.forEachInner=function(i,r,o,l){for(var c=r;c=o;c--)if(i(this.values[c],l+c)===!1)return!1},e.prototype.leafAppend=function(i){if(this.length+i.length<=ei)return new e(this.values.concat(i.flatten()))},e.prototype.leafPrepend=function(i){if(this.length+i.length<=ei)return new e(i.flatten().concat(this.values))},t.length.get=function(){return this.values.length},t.depth.get=function(){return 0},Object.defineProperties(e.prototype,t),e})(we);we.empty=new pd([]);var l1=(function(n){function e(t,s){n.call(this),this.left=t,this.right=s,this.length=t.length+s.length,this.depth=Math.max(t.depth,s.depth)+1}return n&&(e.__proto__=n),e.prototype=Object.create(n&&n.prototype),e.prototype.constructor=e,e.prototype.flatten=function(){return this.left.flatten().concat(this.right.flatten())},e.prototype.getInner=function(s){return sl&&this.right.forEachInner(s,Math.max(i-l,0),Math.min(this.length,r)-l,o+l)===!1)return!1},e.prototype.forEachInvertedInner=function(s,i,r,o){var l=this.left.length;if(i>l&&this.right.forEachInvertedInner(s,i-l,Math.max(r,l)-l,o+l)===!1||r=r?this.right.slice(s-r,i-r):this.left.slice(s,r).append(this.right.slice(0,i-r))},e.prototype.leafAppend=function(s){var i=this.right.leafAppend(s);if(i)return new e(this.left,i)},e.prototype.leafPrepend=function(s){var i=this.left.leafPrepend(s);if(i)return new e(i,this.right)},e.prototype.appendInner=function(s){return this.left.depth>=Math.max(this.right.depth,s.depth)+1?new e(this.left,new e(this.right,s)):new e(this,s)},e})(we);const a1=500;class Ye{constructor(e,t){this.items=e,this.eventCount=t}popEvent(e,t){if(this.eventCount==0)return null;let s=this.items.length;for(;;s--)if(this.items.get(s-1).selection){--s;break}let i,r;t&&(i=this.remapping(s,this.items.length),r=i.maps.length);let o=e.tr,l,c,d=[],u=[];return this.items.forEach((p,f)=>{if(!p.step){i||(i=this.remapping(s,f+1),r=i.maps.length),r--,u.push(p);return}if(i){u.push(new et(p.map));let h=p.step.map(i.slice(r)),g;h&&o.maybeStep(h).doc&&(g=o.mapping.maps[o.mapping.maps.length-1],d.push(new et(g,void 0,void 0,d.length+u.length))),r--,g&&i.appendMap(g,r)}else o.maybeStep(p.step);if(p.selection)return l=i?p.selection.map(i.slice(r)):p.selection,c=new Ye(this.items.slice(0,s).append(u.reverse().concat(d)),this.eventCount-1),!1},this.items.length,0),{remaining:c,transform:o,selection:l}}addTransform(e,t,s,i){let r=[],o=this.eventCount,l=this.items,c=!i&&l.length?l.get(l.length-1):null;for(let u=0;ud1&&(l=c1(l,d),o-=d),new Ye(l.append(r),o)}remapping(e,t){let s=new ls;return this.items.forEach((i,r)=>{let o=i.mirrorOffset!=null&&r-i.mirrorOffset>=e?s.maps.length-i.mirrorOffset:void 0;s.appendMap(i.map,o)},e,t),s}addMaps(e){return this.eventCount==0?this:new Ye(this.items.append(e.map(t=>new et(t))),this.eventCount)}rebased(e,t){if(!this.eventCount)return this;t=Math.min(this.items.length,t);let s=[],i=this.items.length-t,r=e.mapping,o=e.steps.length,l=this.eventCount;this.items.forEach(f=>{f.selection&&l--},i);let c=t;this.items.forEach(f=>{let h=r.getMirror(--c);if(h==null)return;o=Math.min(o,h);let g=r.maps[h];if(f.step){let b=e.steps[h].invert(e.docs[h]),m=f.selection&&f.selection.map(r.slice(c+1,h));m&&l++,s.push(new et(g,b,m))}else s.push(new et(g))},i);let d=[];for(let f=t;fa1&&(p=p.compress(this.items.length-s.length)),p}emptyItemCount(){let e=0;return this.items.forEach(t=>{t.step||e++}),e}compress(e=this.items.length){let t=this.remapping(0,e),s=t.maps.length,i=[],r=0;return this.items.forEach((o,l)=>{if(l>=e)i.push(o),o.selection&&r++;else if(o.step){let c=o.step.map(t.slice(s)),d=c&&c.getMap();if(s--,d&&t.appendMap(d,s),c){let u=o.selection&&o.selection.map(t.slice(s));u&&r++;let p=new et(d.invert(),c,u),f,h=i.length-1;(f=i.length&&i[h].merge(p))?i[h]=f:i.push(p)}}else o.map&&s--},this.items.length,0),new Ye(we.from(i.reverse()),r)}}Ye.empty=new Ye(we.empty,0);function c1(n,e){let t;return n.forEach((s,i)=>{if(s.selection&&e--==0)return t=i,!1}),n.slice(t)}class et{constructor(e,t,s,i){this.map=e,this.step=t,this.selection=s,this.mirrorOffset=i}merge(e){if(this.step&&e.step&&!e.selection){let t=e.step.merge(this.step);if(t)return new et(t.getMap().invert(),t,this.selection)}}}class St{constructor(e,t,s,i,r){this.done=e,this.undone=t,this.prevRanges=s,this.prevTime=i,this.prevComposition=r}}const d1=20;function u1(n,e,t,s){let i=t.getMeta(Rt),r;if(i)return i.historyState;t.getMeta(fd)&&(n=new St(n.done,n.undone,null,0,-1));let o=t.getMeta("appendedTransaction");if(t.steps.length==0)return n;if(o&&o.getMeta(Rt))return o.getMeta(Rt).redo?new St(n.done.addTransform(t,void 0,s,Fs(e)),n.undone,Bl(t.mapping.maps),n.prevTime,n.prevComposition):new St(n.done,n.undone.addTransform(t,void 0,s,Fs(e)),null,n.prevTime,n.prevComposition);if(t.getMeta("addToHistory")!==!1&&!(o&&o.getMeta("addToHistory")===!1)){let l=t.getMeta("composition"),c=n.prevTime==0||!o&&n.prevComposition!=l&&(n.prevTime<(t.time||0)-s.newGroupDelay||!p1(t,n.prevRanges)),d=o?cr(n.prevRanges,t.mapping):Bl(t.mapping.maps);return new St(n.done.addTransform(t,c?e.selection.getBookmark():void 0,s,Fs(e)),Ye.empty,d,t.time,l==null?n.prevComposition:l)}else return(r=t.getMeta("rebased"))?new St(n.done.rebased(t,r),n.undone.rebased(t,r),cr(n.prevRanges,t.mapping),n.prevTime,n.prevComposition):new St(n.done.addMaps(t.mapping.maps),n.undone.addMaps(t.mapping.maps),cr(n.prevRanges,t.mapping),n.prevTime,n.prevComposition)}function p1(n,e){if(!e)return!1;if(!n.docChanged)return!0;let t=!1;return n.mapping.maps[0].forEach((s,i)=>{for(let r=0;r=e[r]&&(t=!0)}),t}function Bl(n){let e=[];for(let t=n.length-1;t>=0&&e.length==0;t--)n[t].forEach((s,i,r,o)=>e.push(r,o));return e}function cr(n,e){if(!n)return null;let t=[];for(let s=0;s{let i=Rt.getState(t);if(!i||(n?i.undone:i.done).eventCount==0)return!1;if(s){let r=f1(i,t,n);r&&s(e?r.scrollIntoView():r)}return!0}}const md=hd(!1,!0),gd=hd(!0,!0);function g1(n){return n.getMeta(Rt)!=null}function Fi(n){const{state:e,transaction:t}=n;let{selection:s}=t,{doc:i}=t,{storedMarks:r}=t;return{...e,apply:e.apply.bind(e),applyTransaction:e.applyTransaction.bind(e),plugins:e.plugins,schema:e.schema,reconfigure:e.reconfigure.bind(e),toJSON:e.toJSON.bind(e),get storedMarks(){return r},get selection(){return s},get doc(){return i},get tr(){return s=t.selection,i=t.doc,r=t.storedMarks,t}}}var xn=class bd{constructor(e){this.editor=e.editor,this.rawCommands=this.editor.extensionManager.commands,this.customState=e.state}get hasCustomState(){return!!this.customState}get state(){return this.customState||this.editor.state}get commands(){const{rawCommands:e,editor:t,state:s}=this,{view:i}=t,{tr:r}=s,o=this.buildProps(r);return Object.fromEntries(Object.entries(e).map(([l,c])=>[l,(...u)=>{const p=c(...u)(o);return!r.getMeta("preventDispatch")&&!this.hasCustomState&&i.dispatch(r),p}]))}get chain(){return()=>this.createChain()}get can(){return()=>this.createCan()}createChain(e,t=!0){const{rawCommands:s,editor:i,state:r}=this,{view:o}=i,l=[],c=!!e,d=e||r.tr,u=()=>(!c&&t&&!d.getMeta("preventDispatch")&&!this.hasCustomState&&o.dispatch(d),l.every(f=>f===!0)),p={...Object.fromEntries(Object.entries(s).map(([f,h])=>[f,(...b)=>{const m=this.buildProps(d,t),v=h(...b)(m);return l.push(v),p}])),run:u};return p}static createFakeChain(){const e=new Proxy({},{get:(t,s)=>{if(s!=="then")return s==="run"?()=>!1:()=>e}});return e}createCan(e){const{rawCommands:t,state:s}=this,i=!1,r=e||s.tr,o=this.buildProps(r,i);return{...Object.fromEntries(Object.entries(t).map(([l,c])=>[l,(...d)=>c(...d)({...o,dispatch:void 0})])),chain:()=>this.createChain(r,i)}}static createFallbackCan(){const e=bd.createFakeChain();return new Proxy({chain:()=>e},{get:(t,s)=>{if(s!=="then")return s==="chain"?t.chain:()=>!1}})}buildProps(e,t=!0){const{rawCommands:s,editor:i,state:r}=this,{view:o}=i,l={tr:e,editor:i,view:o,state:Fi({state:r,transaction:e}),dispatch:t?()=>{}:void 0,chain:()=>this.createChain(e,t),can:()=>this.createCan(e),get commands(){return Object.fromEntries(Object.entries(s).map(([c,d])=>[c,(...u)=>d(...u)(l)]))}};return l}};const b1=()=>({editor:n,view:e})=>(requestAnimationFrame(()=>{if(!n.isDestroyed){var t;e.dom.blur(),(t=window)===null||t===void 0||(t=t.getSelection())===null||t===void 0||t.removeAllRanges()}}),!0),v1=(n=!0)=>({commands:e})=>e.setContent("",{emitUpdate:n}),y1=()=>({state:n,tr:e,dispatch:t})=>{const{selection:s}=e,{ranges:i}=s;return t&&i.forEach(({$from:r,$to:o})=>{n.doc.nodesBetween(r.pos,o.pos,(l,c)=>{if(l.type.isText)return;const{doc:d,mapping:u}=e,p=d.resolve(u.map(c)),f=d.resolve(u.map(c+l.nodeSize)),h=p.blockRange(f);if(!h)return;const g=Dn(h);if(l.type.isTextblock){const{defaultType:b}=p.parent.contentMatchAt(p.index());e.setNodeMarkup(h.start,b)}(g||g===0)&&e.lift(h,g)})}),!0},k1=n=>e=>n(e),x1=()=>({state:n,dispatch:e})=>Cc(n,e),w1=(n,e)=>({editor:t,tr:s})=>{const{state:i}=t,r=i.doc.slice(n.from,n.to);s.deleteRange(n.from,n.to);const o=s.mapping.map(e);return s.insert(o,r.content),s.setSelection(new U(s.doc.resolve(Math.max(o-1,0)))),!0},S1=()=>({tr:n,dispatch:e})=>{const{selection:t}=n,s=t.$anchor.node();if(s.content.size>0)return!1;const i=n.selection.$anchor;for(let r=i.depth;r>0;r-=1)if(i.node(r).type===s.type){if(e){const o=i.before(r),l=i.after(r);n.delete(o,l).scrollIntoView()}return!0}return!1};function ye(n,e){if(typeof n=="string"){if(!e.nodes[n])throw Error(`There is no node type named '${n}'. Maybe you forgot to add the extension?`);return e.nodes[n]}return n}const C1=n=>({tr:e,state:t,dispatch:s})=>{const i=ye(n,t.schema),r=e.selection.$anchor;for(let o=r.depth;o>0;o-=1)if(r.node(o).type===i){if(s){const l=r.before(o),c=r.after(o);e.delete(l,c).scrollIntoView()}return!0}return!1},M1=n=>({tr:e,dispatch:t})=>{const{from:s,to:i}=n;return t&&e.delete(s,i),!0},T1=n=>n.content?/^text(\*|\+)/.test(n.content):!1,zl=(n,e,t)=>{if(!n.parent.isInline||t==="left"&&n.pos>n.start()||t==="right"&&n.pos({from:zl(n,t,"left"),to:zl(e,t,"right")}),A1=()=>({state:n,dispatch:e})=>{if(n.selection.empty)return!1;if(e){const t=n.tr,{ranges:s}=n.selection,i=t.steps.length;s.forEach(r=>{const o=t.mapping.slice(i),l=t.doc.resolve(o.map(r.$from.pos)),c=t.doc.resolve(o.map(r.$to.pos)),{from:d,to:u}=E1(l,c,n.schema);t.deleteRange(d,u)}),t.selection.empty||t.setSelection(U.near(t.doc.resolve(t.selection.from))),t.scrollIntoView(),e(t)}return!0},O1=()=>({commands:n})=>n.keyboardShortcut("Enter"),N1=()=>({state:n,dispatch:e})=>ty(n,e);function vo(n){return Object.prototype.toString.call(n)==="[object RegExp]"}function ti(n,e,t={strict:!0}){const s=Object.keys(e);return s.length?s.every(i=>t.strict?e[i]===n[i]:vo(e[i])?e[i].test(n[i]):e[i]===n[i]):!0}function vd(n,e,t={}){return n.find(s=>s.type===e&&ti(Object.fromEntries(Object.keys(t).map(i=>[i,s.attrs[i]])),t))}function jl(n,e,t={}){return!!vd(n,e,t)}function yo(n,e,t){if(!n||!e)return;let s=n.parent.childAfter(n.parentOffset);if((!s.node||!s.node.marks.some(c=>c.type===e))&&(s=n.parent.childBefore(n.parentOffset)),!s.node||!s.node.marks.some(c=>c.type===e))return;if(!t){const c=s.node.marks.find(d=>d.type===e);c&&(t=c.attrs)}if(!vd([...s.node.marks],e,t))return;let i=s.index,r=n.start()+s.offset,o=i+1,l=r+s.node.nodeSize;for(;i>0&&jl([...n.parent.child(i-1).marks],e,t);)i-=1,r-=n.parent.child(i).nodeSize;for(;o({tr:t,state:s,dispatch:i})=>{const r=vt(n,s.schema),{doc:o,selection:l}=t,{$from:c,from:d,to:u}=l;if(i){const p=yo(c,r,e);if(p&&p.from<=d&&p.to>=u){const f=U.create(o,p.from,p.to);t.setSelection(f)}}return!0},D1=n=>e=>{const t=typeof n=="function"?n(e):n;for(let s=0;s({editor:t,view:s,tr:i,dispatch:r})=>{e={scrollIntoView:!0,...e};const o=()=>{(ni()||Fl())&&s.dom.focus(),$1()&&!ni()&&!Fl()&&s.dom.focus({preventScroll:!0}),requestAnimationFrame(()=>{t.isDestroyed||(s.focus(),e!=null&&e.scrollIntoView&&t.commands.scrollIntoView())})};try{if(s.hasFocus()&&n===null||n===!1)return!0}catch(d){return!1}if(r&&n===null&&!yd(t.state.selection))return o(),!0;const l=Pr(i.doc,n)||t.state.selection,c=t.state.selection.eq(l);return r&&(c||i.setSelection(l),c&&i.storedMarks&&i.setStoredMarks(i.storedMarks),o()),!0},L1=(n,e)=>t=>n.every((s,i)=>e(s,{...t,index:i})),P1=(n,e)=>({tr:t,commands:s})=>s.insertContentAt({from:t.selection.from,to:t.selection.to},n,e),kd=n=>{const e=n.childNodes;for(let t=e.length-1;t>=0;t-=1){const s=e[t];s.nodeType===3&&s.nodeValue&&/^(\n\s\s|\n)$/.test(s.nodeValue)?n.removeChild(s):s.nodeType===1&&kd(s)}return n};function Es(n){if(typeof window=="undefined")throw new Error("[tiptap error]: there is no window object available, so this function cannot be used");const e=`${n}`,t=new window.DOMParser().parseFromString(e,"text/html").body;return kd(t)}function xd(n){return typeof(n==null?void 0:n.nodesBetween)=="function"}function En(n,e,t){if(xd(n))return n;const s=typeof n=="object"&&n!==null;t={slice:!0,parseOptions:{},...t};const i=typeof n=="string";if(s)try{if(Array.isArray(n)&&n.length>0)return $.fromArray(n.map(o=>e.nodeFromJSON(o)));const r=e.nodeFromJSON(n);return t.errorOnInvalidContent&&r.check(),r}catch(r){if(t.errorOnInvalidContent)throw new Error("[tiptap error]: Invalid JSON content",{cause:r});return console.warn("[tiptap warn]: Invalid content.","Passed value:",n,"Error:",r),En("",e,t)}if(i){if(t.errorOnInvalidContent){let o=!1,l="";const c=new _s({topNode:e.spec.topNode,marks:e.spec.marks,nodes:e.spec.nodes.append({__tiptap__private__unknown__catch__all__node:{content:"inline*",group:"block",parseDOM:[{tag:"*",getAttrs:d=>(o=!0,l=typeof d=="string"?d:d.outerHTML,null)}]}})});if(t.slice?Ot.fromSchema(c).parseSlice(Es(n),t.parseOptions):Ot.fromSchema(c).parse(Es(n),t.parseOptions),t.errorOnInvalidContent&&o)throw new Error("[tiptap error]: Invalid HTML content",{cause:new Error(`Invalid element found: ${l}`)})}const r=Ot.fromSchema(e);return t.slice?r.parseSlice(Es(n),t.parseOptions).content:r.parse(Es(n),t.parseOptions)}return En("",e,t)}function wd(n){return!("type"in n)}function Sd(n,e,t){const s=n.steps.length-1;if(s{o===0&&(o=u)}),n.setSelection(X.near(n.doc.resolve(o),t))}const B1=(n,e,t)=>({tr:s,dispatch:i,editor:r})=>{if(i){t={parseOptions:r.options.parseOptions,updateSelection:!0,applyInputRules:!1,applyPasteRules:!1,...t};let l;const c=m=>{r.emit("contentError",{editor:r,error:m,disableCollaboration:()=>{"collaboration"in r.storage&&typeof r.storage.collaboration=="object"&&r.storage.collaboration&&(r.storage.collaboration.isDisabled=!0)}})},d={preserveWhitespace:"full",...t.parseOptions};if(!t.errorOnInvalidContent&&!r.options.enableContentCheck&&r.options.emitContentError)try{En(e,r.schema,{parseOptions:d,errorOnInvalidContent:!0})}catch(m){c(m)}try{var o;l=En(e,r.schema,{parseOptions:d,errorOnInvalidContent:(o=t.errorOnInvalidContent)!==null&&o!==void 0?o:r.options.enableContentCheck})}catch(m){return c(m),!1}let{from:u,to:p}=typeof n=="number"?{from:n,to:n}:{from:n.from,to:n.to},f=!0,h=!0;const g=wd(l)?l.content:[l];if(g.forEach(m=>{m.check(),f=f?m.isText&&m.marks.length===0:!1,h=h?m.isBlock:!1}),u===p&&h){const{parent:m}=s.doc.resolve(u);m.isTextblock&&!m.type.spec.code&&!m.childCount&&(u-=1,p+=1)}let b;if(f)Array.isArray(e)?b=e.map(m=>m.text||"").join(""):xd(e)?b=g.map(m=>{var v;return(v=m.text)!==null&&v!==void 0?v:""}).join(""):typeof e=="object"&&e&&e.text?b=e.text:b=e,s.insertText(b,u,p);else{b=$.from(g);const m=s.doc.resolve(u),v=m.node(),S=m.parentOffset===0,A=v.isText||v.isTextblock,N=v.content.size>0;S&&A&&N&&h&&(u=Math.max(0,u-1)),s.replaceWith(u,p,g)}t.updateSelection&&Sd(s,s.steps.length-1,-1),t.applyInputRules&&s.setMeta("applyInputRules",{from:u,text:b}),t.applyPasteRules&&s.setMeta("applyPasteRules",{from:u,text:b})}return!0};function Cd(n){for(let e=0;e({tr:e,dispatch:t,editor:s})=>{const{pos:i,attrs:r,content:o,updateSelection:l=!0}=n;let c;typeof i=="number"?c=e.doc.resolve(i):i?c=i:c=e.selection.$from;const d=Cd(c.parent.contentMatchAt(c.index()));if(!d)return!1;const u=Object.keys(d.spec.attrs||{}),p=r?Object.fromEntries(Object.entries(r).filter(([h])=>u.includes(h))):{};let f;if(o){const h=En(o,s.schema);f=d.createAndFill(p,h)}else f=d.createAndFill(p);return f?(t&&(e.insert(c.pos,f),l&&Sd(e,e.steps.length-1,-1)),!0):!1},z1=()=>({state:n,dispatch:e})=>Zv(n,e),j1=()=>({state:n,dispatch:e})=>Qv(n,e),F1=()=>({state:n,dispatch:e})=>bc(n,e),V1=()=>({state:n,dispatch:e})=>xc(n,e),Md=(n,e)=>{const t=n.resolve(e),s=t.nodeBefore,i=t.nodeAfter;return!s||!i?!1:!s.type.spec.isolating&&!i.type.spec.isolating},H1=()=>({state:n,dispatch:e,tr:t})=>{try{const s=Li(n.doc,n.selection.$from.pos,-1);return s==null||!Md(n.doc,s)?!1:(t.join(s,2),e&&e(t),!0)}catch(s){return!1}},q1=()=>({state:n,dispatch:e,tr:t})=>{try{const s=Li(n.doc,n.selection.$from.pos,1);return s==null||!Md(n.doc,s)?!1:(t.join(s,2),e&&e(t),!0)}catch(s){return!1}},U1=()=>({state:n,dispatch:e})=>Yv(n,e),W1=()=>({state:n,dispatch:e})=>Xv(n,e);function Td(){return typeof navigator!="undefined"?/Mac/.test(navigator.platform):!1}function K1(n){const e=n.split(/-(?!$)/);let t=e[e.length-1];t==="Space"&&(t=" ");let s,i,r,o;for(let l=0;l({editor:e,view:t,tr:s,dispatch:i})=>{const r=K1(n).split(/-(?!$)/),o=r.find(d=>!["Alt","Ctrl","Meta","Shift"].includes(d)),l=new KeyboardEvent("keydown",{key:o==="Space"?" ":o,altKey:r.includes("Alt"),ctrlKey:r.includes("Ctrl"),metaKey:r.includes("Meta"),shiftKey:r.includes("Shift"),bubbles:!0,cancelable:!0}),c=e.captureTransaction(()=>{t.someProp("handleKeyDown",d=>d(t,l))});return c==null||c.steps.forEach(d=>{const u=d.map(s.mapping);u&&i&&s.maybeStep(u)}),!0};function bt(n,e,t={}){const{from:s,to:i,empty:r}=n.selection,o=e?ye(e,n.schema):null,l=[];n.doc.nodesBetween(s,i,(u,p)=>{if(u.isText)return;const f=Math.max(s,p),h=Math.min(i,p+u.nodeSize);l.push({node:u,from:f,to:h})});const c=i-s,d=l.filter(u=>o?o.name===u.node.type.name:!0).filter(u=>ti(u.node.attrs,t,{strict:!1}));return r?!!d.length:d.reduce((u,p)=>u+p.to-p.from,0)>=c}const G1=(n,e={})=>({state:t,dispatch:s})=>bt(t,ye(n,t.schema),e)?ey(t,s):!1,Y1=()=>({state:n,dispatch:e})=>Mc(n,e),X1=n=>({state:e,dispatch:t})=>{const s=ye(n,e.schema);return py(s)(e,t)},Z1=()=>({state:n,dispatch:e})=>Sc(n,e);function Vi(n,e){return e.nodes[n]?"node":e.marks[n]?"mark":null}function Vl(n,e){const t=typeof e=="string"?[e]:e;return Object.keys(n).reduce((s,i)=>(t.includes(i)||(s[i]=n[i]),s),{})}const Q1=(n,e)=>({tr:t,state:s,dispatch:i})=>{let r=null,o=null;const l=Vi(typeof n=="string"?n:n.name,s.schema);if(!l)return!1;l==="node"&&(r=ye(n,s.schema)),l==="mark"&&(o=vt(n,s.schema));let c=!1;return t.selection.ranges.forEach(d=>{s.doc.nodesBetween(d.$from.pos,d.$to.pos,(u,p)=>{r&&r===u.type&&(c=!0,i&&t.setNodeMarkup(p,void 0,Vl(u.attrs,e))),o&&u.marks.length&&u.marks.forEach(f=>{o===f.type&&(c=!0,i&&t.addMark(p,p+u.nodeSize,o.create(Vl(f.attrs,e))))})})}),c},ek=()=>({tr:n,dispatch:e})=>(e&&n.scrollIntoView(),!0),tk=()=>({tr:n,dispatch:e})=>{if(e){const t=new qe(n.doc);n.setSelection(t)}return!0},nk=()=>({state:n,dispatch:e})=>yc(n,e),sk=()=>({state:n,dispatch:e})=>wc(n,e),ik=()=>({state:n,dispatch:e})=>iy(n,e),rk=()=>({state:n,dispatch:e})=>ly(n,e),ok=()=>({state:n,dispatch:e})=>oy(n,e);function Br(n,e,t={},s={}){return En(n,e,{slice:!1,parseOptions:t,errorOnInvalidContent:s.errorOnInvalidContent})}const lk=(n,{errorOnInvalidContent:e,emitUpdate:t=!0,parseOptions:s={}}={})=>({editor:i,tr:r,dispatch:o,commands:l})=>{const{doc:c}=r;if(s.preserveWhitespace!=="full"){const d=Br(n,i.schema,s,{errorOnInvalidContent:e!=null?e:i.options.enableContentCheck});if(o){const u=wd(d)?d.content:[d];r.replaceWith(0,c.content.size,u).setMeta("preventUpdate",!t)}return!0}return o&&r.setMeta("preventUpdate",!t),l.insertContentAt({from:0,to:c.content.size},n,{parseOptions:s,errorOnInvalidContent:e!=null?e:i.options.enableContentCheck})};function Ed(n,e){const t=vt(e,n.schema),{from:s,to:i,empty:r}=n.selection,o=[];r?(n.storedMarks&&o.push(...n.storedMarks),o.push(...n.selection.$head.marks())):n.doc.nodesBetween(s,i,c=>{o.push(...c.marks)});const l=o.find(c=>c.type.name===t.name);return l?{...l.attrs}:{}}function Ad(n,e){const t=new pc(n);return e.forEach(s=>{s.steps.forEach(i=>{t.step(i)})}),t}function ak(n,e,t){const s=[];return n.nodesBetween(e.from,e.to,(i,r)=>{t(i)&&s.push({node:i,pos:r})}),s}function ck(n,e){for(let t=n.depth;t>0;t-=1){const s=n.node(t);if(e(s))return{pos:t>0?n.before(t):0,start:n.start(t),depth:t,node:s}}}function Hi(n){return e=>ck(e.$from,n)}function V(n,e,t){return n.config[e]===void 0&&n.parent?V(n.parent,e,t):typeof n.config[e]=="function"?n.config[e].bind({...t,parent:n.parent?V(n.parent,e,t):null}):n.config[e]}function ko(n){return n.map(e=>{const t=V(e,"addExtensions",{name:e.name,options:e.options,storage:e.storage});return t?[e,...ko(t())]:e}).flat(10)}function xo(n,e){const t=ln.fromSchema(e).serializeFragment(n),s=document.implementation.createHTMLDocument().createElement("div");return s.appendChild(t),s.innerHTML}function Od(n,e){const t=new Map;for(const i of n){var s;const r=(s=t.get(i.type))!==null&&s!==void 0?s:new Map;r.set(i.name,i),t.set(i.type,r)}return[...Object.values(e.nodes),...Object.values(e.marks)].flatMap(i=>{var r;return Object.entries((r=i.spec.attrs)!==null&&r!==void 0?r:{}).map(([o,l])=>{var c;const d=(c=t.get(i.name))===null||c===void 0?void 0:c.get(o),u=Object.hasOwn(l,"default");return{type:i.name,name:o,attribute:{rendered:!0,renderHTML:null,parseHTML:null,keepOnSplit:!0,...d==null?void 0:d.attribute,default:l.default,isRequired:!u,validate:l.validate}}})})}const dk={content:"string",marks:"string",group:"string",inline:"boolean",atom:"boolean",selectable:"boolean",draggable:"boolean",code:"boolean",whitespace:["pre","normal"],definingAsContext:"boolean",definingForContent:"boolean",defining:"boolean",isolating:"boolean",linebreakReplacement:"boolean"},uk={inclusive:"boolean",excludes:"string",group:"string",spanning:"boolean",code:"boolean"};function pk(n,e,t){return Object.fromEntries(Object.entries(e).flatMap(([s,i])=>{const r=n[s];if(r===void 0)return[];if(!(typeof i=="string"?typeof r===i:typeof r=="string"&&i.includes(r)))throw new RangeError(`Invalid schemaSpec field '${t}.${s}'`);return[[s,r]]}))}function Hl(n,e,t,s){return{...Object.fromEntries(Object.entries(e).filter(([i])=>i!=="attrs"&&!Object.hasOwn(s,i))),...pk(t,s,n),attrs:t.attrs}}function ql(n,e,t){for(const s of Object.keys(e))if(!Object.hasOwn(n,s))throw new RangeError(`schemaSpec requires a local ${t} extension named '${s}'`);for(const s of Object.keys(n))if(!Object.hasOwn(e,s))throw new RangeError(`Local ${t} extension '${s}' is not in schemaSpec`)}function fk(n,e){ql(n.nodes,e.nodes,"node"),ql(n.marks,e.marks,"mark");let t=e.spec.nodes,s=e.spec.marks;return e.spec.nodes.forEach((i,r)=>{t=t.update(i,Hl(i,n.nodes[i],r,dk))}),e.spec.marks.forEach((i,r)=>{s=s.update(i,Hl(i,n.marks[i],r,uk))}),{topNode:e.topNodeType.name,nodes:t,marks:s}}function Nd(n){const e=n.filter((t,s)=>n.indexOf(t)!==s);return Array.from(new Set(e))}function An(n){return{baseExtensions:n.filter(e=>e.type==="extension"),nodeExtensions:n.filter(e=>e.type==="node"),markExtensions:n.filter(e=>e.type==="mark")}}function wo(n){const e=[],{nodeExtensions:t,markExtensions:s}=An(n),i=[...t,...s],r={default:null,validate:void 0,rendered:!0,renderHTML:null,parseHTML:null,keepOnSplit:!0,isRequired:!1},o=t.filter(d=>d.name!=="text").map(d=>d.name),l=s.map(d=>d.name),c=[...o,...l];return n.forEach(d=>{const u=V(d,"addGlobalAttributes",{name:d.name,options:d.options,storage:d.storage,extensions:i});u&&u().forEach(p=>{let f;Array.isArray(p.types)?f=p.types:p.types==="*"?f=c:p.types==="nodes"?f=o:p.types==="marks"?f=l:f=[],f.forEach(h=>{Object.entries(p.attributes).forEach(([g,b])=>{e.push({type:h,name:g,attribute:{...r,...b}})})})})}),i.forEach(d=>{const u=V(d,"addAttributes",{name:d.name,options:d.options,storage:d.storage});if(!u)return;const p=u();Object.entries(p).forEach(([f,h])=>{const g={...r,...h};typeof(g==null?void 0:g.default)=="function"&&(g.default=g.default()),g!=null&&g.isRequired&&(g==null?void 0:g.default)===void 0&&delete g.default,e.push({type:d.name,name:f,attribute:g})})}),e}function _r(n){return typeof n=="function"}function se(n,e=void 0,...t){return _r(n)?e?n.bind(e)(...t):n(...t):n}function hk(n={}){return Object.keys(n).length===0&&n.constructor===Object}function mk(n){const e=[];let t="",s=!1,i=!1,r=0;const o=n.length;for(let l=0;l0){r-=1,t+=c;continue}if(c===";"&&r===0){e.push(t),t="";continue}}t+=c}return t&&e.push(t),e}function Ul(n){const e=[],t=mk(n||""),s=t.length;for(let i=0;i!!e).reduce((e,t)=>{const s={...e};return Object.entries(t).forEach(([i,r])=>{if(i==="__proto__"){Object.defineProperty(s,i,{configurable:!0,enumerable:!0,value:r,writable:!0});return}if(!s[i]){s[i]=r;return}if(i==="class"){const o=r?String(r).split(" "):[],l=s[i]?s[i].split(" "):[],c=o.filter(d=>!l.includes(d));s[i]=[...l,...c].join(" ")}else if(i==="style"){const o=new Map([...Ul(s[i]),...Ul(r)]);s[i]=Array.from(o.entries()).map(([l,c])=>`${l}: ${c}`).join("; ")}else s[i]=r}),s},{})}function ps(n,e){return e.filter(t=>t.type===n.type.name).filter(t=>t.attribute.rendered).map(t=>t.attribute.renderHTML?t.attribute.renderHTML(n.attrs)||{}:{[t.name]:n.attrs[t.name]}).reduce((t,s)=>ke(t,s),{})}function gk(n){return typeof n!="string"?n:n.match(/^[+-]?(?:\d*\.)?\d+$/)?Number(n):n==="true"?!0:n==="false"?!1:n}function Wl(n,e){return"style"in n?n:{...n,getAttrs:t=>{const s=n.getAttrs?n.getAttrs(t):n.attrs;if(s===!1)return!1;const i=e.reduce((r,o)=>{const l=o.attribute.parseHTML?o.attribute.parseHTML(t):gk(t.getAttribute(o.name));return l==null?r:{...r,[o.name]:l}},{});return{...s,...i}}}}function Kl(n){return Object.fromEntries(Object.entries(n).filter(([e,t])=>e==="attrs"&&hk(t)?!1:t!=null))}function Jl(n){var e,t;const s={};return!(!(n==null||(e=n.attribute)===null||e===void 0)&&e.isRequired)&&"default"in((n==null?void 0:n.attribute)||{})&&(s.default=n.attribute.default),(n==null||(t=n.attribute)===null||t===void 0?void 0:t.validate)!==void 0&&(s.validate=n.attribute.validate),[n.name,s]}function Gl(n,e,t=wo(n)){var s;const{nodeExtensions:i,markExtensions:r}=An(n);return{topNode:(s=i.find(o=>V(o,"topNode")))===null||s===void 0?void 0:s.name,nodes:Object.fromEntries(i.map(o=>{const l=t.filter(h=>h.type===o.name),c={name:o.name,options:o.options,storage:o.storage,editor:e},d=Kl({...n.reduce((h,g)=>{const b=V(g,"extendNodeSchema",c);return{...h,...b?b(o):{}}},{}),content:se(V(o,"content",c)),marks:se(V(o,"marks",c)),group:se(V(o,"group",c)),inline:se(V(o,"inline",c)),atom:se(V(o,"atom",c)),selectable:se(V(o,"selectable",c)),draggable:se(V(o,"draggable",c)),code:se(V(o,"code",c)),whitespace:se(V(o,"whitespace",c)),linebreakReplacement:se(V(o,"linebreakReplacement",c)),defining:se(V(o,"defining",c)),isolating:se(V(o,"isolating",c)),attrs:Object.fromEntries(l.map(Jl))}),u=se(V(o,"parseHTML",c));u&&(d.parseDOM=u.map(h=>Wl(h,l)));const p=V(o,"renderHTML",c);p&&(d.toDOM=h=>p({node:h,HTMLAttributes:ps(h,l)}));const f=V(o,"renderText",c);return f&&(d.toText=f),[o.name,d]})),marks:Object.fromEntries(r.map(o=>{const l=t.filter(f=>f.type===o.name),c={name:o.name,options:o.options,storage:o.storage,editor:e},d=Kl({...n.reduce((f,h)=>{const g=V(h,"extendMarkSchema",c);return{...f,...g?g(o):{}}},{}),inclusive:se(V(o,"inclusive",c)),excludes:se(V(o,"excludes",c)),group:se(V(o,"group",c)),spanning:se(V(o,"spanning",c)),code:se(V(o,"code",c)),attrs:Object.fromEntries(l.map(Jl))}),u=se(V(o,"parseHTML",c));u&&(d.parseDOM=u.map(f=>Wl(f,l)));const p=V(o,"renderHTML",c);return p&&(d.toDOM=f=>p({mark:f,HTMLAttributes:ps(f,l)})),[o.name,d]}))}}function bk(n,e,t){if(t===void 0)return new _s(Gl(n,e));const s=Nd(n.filter(o=>o.type!=="extension").map(o=>o.name));if(s.length)throw new RangeError(`Duplicate local schema types: ${s.join(", ")}`);const i=new _s(t),r=Gl(n,e,Od(wo(n),i));return new _s(fk(r,i))}function Kn(n){return n.sort((t,s)=>{const i=V(t,"priority")||100,r=V(s,"priority")||100;return i>r?-1:is.name));return t.length&&console.warn(`[tiptap warn]: Duplicate extension names found: [${t.map(s=>`'${s}'`).join(", ")}]. This can lead to issues.`),e}function Dd(n,e,t){const{from:s,to:i}=e,{blockSeparator:r=` -`,textSerializers:o={}}=t||{};let l="";return n.nodesBetween(s,i,(c,d,u,p)=>{c.isBlock&&d>s&&(l+=r);const f=o==null?void 0:o[c.type.name];if(f)return u&&(l+=f({node:c,pos:d,parent:u,index:p,range:e})),!1;if(c.isText){var h;l+=c==null||(h=c.text)===null||h===void 0?void 0:h.slice(Math.max(s,d)-d,i-d)}}),l}function bk(n,e){return Dd(n,{from:0,to:n.content.size},e)}function $d(n){return Object.fromEntries(Object.entries(n.nodes).filter(([,e])=>e.spec.toText).map(([e,t])=>[e,t.spec.toText]))}function vk(n,e){const t=ye(e,n.schema),{from:s,to:i}=n.selection,r=[];n.doc.nodesBetween(s,i,l=>{r.push(l)});const o=r.reverse().find(l=>l.type.name===t.name);return o?{...o.attrs}:{}}function Rd(n,e){const t=Vi(typeof e=="string"?e:e.name,n.schema);return t==="node"?vk(n,e):t==="mark"?Ed(n,e):{}}function yk(n,e=JSON.stringify){const t={};return n.filter(s=>{const i=e(s);return Object.prototype.hasOwnProperty.call(t,i)?!1:t[i]=!0})}function kk(n){const e=yk(n);return e.length===1?e:e.filter((t,s)=>!e.filter((i,r)=>r!==s).some(i=>t.oldRange.from>=i.oldRange.from&&t.oldRange.to<=i.oldRange.to&&t.newRange.from>=i.newRange.from&&t.newRange.to<=i.newRange.to))}function qi(n){const{mapping:e,steps:t}=n,s=[];return e.maps.forEach((i,r)=>{const o=[];if(i.ranges.length)i.forEach((l,c)=>{o.push({from:l,to:c})});else{const{from:l,to:c}=t[r];if(l===void 0||c===void 0)return;o.push({from:l,to:c})}o.forEach(({from:l,to:c})=>{const d=e.slice(r).map(l,-1),u=e.slice(r).map(c),p=e.invert().map(d,-1),f=e.invert().map(u);s.push({oldRange:{from:p,to:f},newRange:{from:d,to:u}})})}),kk(s)}function Ui(n,e,t){const s=[];return n===e?t.resolve(n).marks().forEach(i=>{const r=yo(t.resolve(n),i.type);r&&s.push({mark:i,...r})}):t.nodesBetween(n,e,(i,r)=>{!i||(i==null?void 0:i.nodeSize)===void 0||s.push(...i.marks.map(o=>({from:r,to:r+i.nodeSize,mark:o})))}),s}const xk=(n,e,t,s=20)=>{const i=n.doc.resolve(t);let r=s,o=null;for(;r>0&&o===null;){const l=i.node(r);(l==null?void 0:l.type.name)===e?o=l:r-=1}return[o,r]},wk=n=>{const e=n.depth-1;if(e<0)return null;const t=n.index(e);return t===0?null:n.node(e).child(t-1)};function fn(n,e){return e.nodes[n]||e.marks[n]||null}function Vs(n,e,t){return Object.fromEntries(Object.entries(t).filter(([s])=>{const i=n.find(r=>r.type===e&&r.name===s);return i?i.attribute.keepOnSplit:!1}))}const Sk=(n,e=500)=>{let t="";const s=n.parentOffset;return n.parent.nodesBetween(Math.max(0,s-e),s,(i,r,o,l)=>{var c,d;const u=((c=(d=i.type.spec).toText)===null||c===void 0?void 0:c.call(d,{node:i,pos:r,parent:o,index:l}))||i.textContent||"%leaf%";t+=i.isAtom&&!i.isText?u:u.slice(0,Math.max(0,s-r))}),t};function zr(n,e,t={}){const{empty:s,ranges:i}=n.selection,r=e?vt(e,n.schema):null;if(s)return!!(n.storedMarks||n.selection.$from.marks()).filter(u=>r?r.name===u.type.name:!0).find(u=>ti(u.attrs,t,{strict:!1}));let o=0;const l=[];if(i.forEach(({$from:u,$to:p})=>{const f=u.pos,h=p.pos;n.doc.nodesBetween(f,h,(g,b)=>{if(r&&g.inlineContent&&!g.type.allowsMarkType(r))return!1;if(!g.isText&&!g.marks.length)return;const m=Math.max(f,b),v=Math.min(h,b+g.nodeSize),S=v-m;o+=S,l.push(...g.marks.map(A=>({mark:A,from:m,to:v})))})}),o===0)return!1;const c=l.filter(u=>r?r.name===u.mark.type.name:!0).filter(u=>ti(u.mark.attrs,t,{strict:!1})).reduce((u,p)=>u+p.to-p.from,0),d=l.filter(u=>r?u.mark.type!==r&&u.mark.type.excludes(r):!0).reduce((u,p)=>u+p.to-p.from,0);return(c>0?c+d:c)>=o}function Ck(n,e,t={}){if(!e)return bt(n,null,t)||zr(n,null,t);const s=Vi(e,n.schema);return s==="node"?bt(n,e,t):s==="mark"?zr(n,e,t):!1}const Mk=(n,e)=>{const{$from:t,$to:s,$anchor:i}=n.selection;if(e){const r=Hi(l=>l.type.name===e)(n.selection);if(!r)return!1;const o=n.doc.resolve(r.pos+1);return i.pos+1===o.end()}return!(s.parentOffset{const{$from:e,$to:t}=n.selection;return!(e.parentOffset>0||e.pos!==t.pos)};function Yl(n,e){return Array.isArray(e)?e.some(t=>(typeof t=="string"?t:t.name)===n.name):e}function Ln(n,e){const{nodeExtensions:t}=An(e),s=t.find(r=>r.name===n);if(!s)return!1;const i=se(V(s,"group",{name:s.name,options:s.options,storage:s.storage}));return typeof i!="string"?!1:i.split(" ").includes("list")}function ys(n,{checkChildren:e=!0,ignoreWhitespace:t=!1}={}){if(t){if(n.type.name==="hardBreak")return!0;if(n.isText){var s;return!/\S/.test((s=n.text)!==null&&s!==void 0?s:"")}}if(n.isText)return!n.text;if(n.isAtom||n.isLeaf)return!1;if(n.content.childCount===0)return!0;if(e){let i=!0;return n.content.forEach(r=>{i!==!1&&(ys(r,{ignoreWhitespace:t,checkChildren:e})||(i=!1))}),i}return!1}function Ld(n){return n instanceof W}function Ek(n){if(n===null||typeof n!="object")return!1;const e=n;return!(typeof e.apply!="function"||typeof e.getMap!="function"||typeof e.invert!="function"||typeof e.map!="function"||typeof e.merge!="function"||typeof e.toJSON!="function")}function Ak(n){if(n===null||typeof n!="object")return!1;const e=n;if(!Ek(e))return!1;const t=e.toJSON();return!(t===null||typeof t!="object"||t.stepType!=="replace")}var Pd=class Bd{constructor(e){this.position=e}static fromJSON(e){return new Bd(e.position)}toJSON(){return{position:this.position}}};function Ok(n,e){const t=e.mapping.mapResult(n.position);return{position:new Pd(t.pos),mapResult:t}}function Nk(n){return new Pd(n)}function Ik(n,e,t){const{selection:s}=e;let i=null;if(yd(s)&&(i=s.$cursor),i){var r;const l=(r=n.storedMarks)!==null&&r!==void 0?r:i.marks();return i.parent.type.allowsMarkType(t)&&(!!t.isInSet(l)||!l.some(c=>c.type.excludes(t)))}const{ranges:o}=s;return o.some(({$from:l,$to:c})=>{let d=l.depth===0?n.doc.inlineContent&&n.doc.type.allowsMarkType(t):!1;return n.doc.nodesBetween(l.pos,c.pos,(u,p,f)=>{if(d)return!1;if(u.isInline){const h=!f||f.type.allowsMarkType(t),g=!!t.isInSet(u.marks)||!u.marks.some(b=>b.type.excludes(t));d=h&&g}return!d}),d})}const Dk=(n,e={})=>({tr:t,state:s,dispatch:i})=>{const{selection:r}=t,{empty:o,ranges:l}=r,c=vt(n,s.schema);if(i)if(o){const d=Ed(s,c);t.addStoredMark(c.create({...d,...e}))}else l.forEach(d=>{const u=d.$from.pos,p=d.$to.pos;s.doc.nodesBetween(u,p,(f,h)=>{const g=Math.max(h,u),b=Math.min(h+f.nodeSize,p);f.marks.find(m=>m.type===c)?f.marks.forEach(m=>{c===m.type&&t.addMark(g,b,c.create({...m.attrs,...e}))}):t.addMark(g,b,c.create(e))})});return Ik(s,t,c)},$k=(n,e)=>({tr:t})=>(t.setMeta(n,e),!0),Rk=(n,e={})=>({state:t,dispatch:s,chain:i})=>{const r=ye(n,t.schema);let o;return t.selection.$anchor.sameParent(t.selection.$head)&&(o=t.selection.$anchor.parent.attrs),r.isTextblock?i().command(({commands:l})=>ol(r,{...o,...e})(t)?!0:l.clearNodes()).command(({state:l})=>ol(r,{...o,...e})(l,s)).run():(console.warn('[tiptap warn]: Currently "setNode()" only supports text block nodes.'),!1)},Lk=n=>({tr:e,dispatch:t})=>{if(t){const{doc:s}=e,i=Kt(n,0,s.content.size),r=W.create(s,i);e.setSelection(r)}return!0},Pk=(n,e)=>({tr:t,state:s,dispatch:i})=>{const{selection:r}=s;let o,l;return typeof e=="number"?(o=e,l=e):e&&"from"in e&&"to"in e?(o=e.from,l=e.to):(o=r.from,l=r.to),i&&t.doc.nodesBetween(o,l,(c,d)=>{c.isText||t.setNodeMarkup(d,void 0,{...c.attrs,dir:n})}),!0},Bk=n=>({tr:e,dispatch:t})=>{if(t){const{doc:s}=e,{from:i,to:r}=typeof n=="number"?{from:n,to:n}:n,o=U.atStart(s).from,l=U.atEnd(s).to,c=Kt(i,o,l),d=Kt(r,o,l),u=U.create(s,c,d);e.setSelection(u)}return!0},_k=n=>({state:e,dispatch:t})=>{const s=ye(n,e.schema);return hy(s)(e,t)};function Xl(n,e){const t=n.storedMarks||n.selection.$to.parentOffset&&n.selection.$from.marks();if(t){const s=t.filter(i=>e==null?void 0:e.includes(i.type.name));n.tr.ensureMarks(s)}}const zk=({keepMarks:n=!0}={})=>({tr:e,state:t,dispatch:s,editor:i})=>{const{selection:r,doc:o}=e,{$from:l,$to:c}=r,d=i.extensionManager.attributes,u=Vs(d,l.node().type.name,l.node().attrs);if(r instanceof W&&r.node.isBlock)return!l.parentOffset||!mt(o,l.pos)?!1:(s&&(n&&Xl(t,i.extensionManager.splittableMarks),e.split(l.pos).scrollIntoView()),!0);if(!l.parent.isBlock)return!1;const p=c.parentOffset===c.parent.content.size,f=l.depth===0?void 0:Cd(l.node(-1).contentMatchAt(l.indexAfter(-1)));let h=p&&f?[{type:f,attrs:u}]:void 0;const g=r instanceof U&&!r.empty?pt.create({doc:e.doc,selection:r}).tr.deleteSelection():null,b=g?g.doc:e.doc,m=g?g.mapping.map(l.pos):l.pos;let v=mt(b,m,1,h);if(!h&&!v&&mt(b,m,1,f?[{type:f}]:void 0)&&(v=!0,h=f?[{type:f,attrs:u}]:void 0),s){if(v){const S=e.steps.length;if(r instanceof U&&e.deleteSelection(),e.split(e.mapping.slice(S).map(l.pos),1,h),f&&!p&&!l.parentOffset&&l.parent.type!==f){const A=e.mapping.slice(S).map(l.before()),O=e.doc.resolve(A);l.node(-1).canReplaceWith(O.index(),O.index()+1,f)&&e.setNodeMarkup(e.mapping.slice(S).map(l.before()),f)}}n&&Xl(t,i.extensionManager.splittableMarks),e.scrollIntoView()}return v},jk=(n,e={})=>({tr:t,state:s,dispatch:i,editor:r})=>{const o=ye(n,s.schema),{$from:l,$to:c}=s.selection,d=s.selection.node;if(d&&d.isBlock||l.depth<2||!l.sameParent(c))return!1;const u=l.node(-1);if(u.type!==o)return!1;const p=r.extensionManager.attributes;if(l.parent.content.size===0&&l.node(-1).childCount===l.indexAfter(-1)){if(l.depth===2||l.node(-3).type!==o||l.index(-2)!==l.node(-2).childCount-1)return!1;if(i){var f;let O=$.empty;const B=l.index(-1)?1:l.index(-2)?2:3;for(let I=l.depth-B;I>=l.depth-3;I-=1)O=$.from(l.node(I).copy(O));const E=l.indexAfter(-1){if(N>-1)return!1;I.isTextblock&&I.content.size===0&&(N=Z+1)}),N>-1&&t.setSelection(U.near(t.doc.resolve(N))),t.scrollIntoView()}return!0}const h=c.pos===l.end()?u.contentMatchAt(0).defaultType:null,g={...Vs(p,u.type.name,u.attrs),...e},b={...Vs(p,l.node().type.name,l.node().attrs),...e},m=l.parentOffset===0&&l.index(-1)===0,v=l.before(-1);t.delete(l.pos,c.pos);const S=m?u.attrs:g,A=h?[{type:o,attrs:S},{type:h,attrs:b}]:[{type:o,attrs:S}];if(!mt(t.doc,l.pos,2))return!1;if(i){const{selection:O,storedMarks:B}=s,{splittableMarks:E}=r.extensionManager,M=B||O.$to.parentOffset&&O.$from.marks();if(t.split(l.pos,2,A).scrollIntoView(),m&&t.setNodeMarkup(v,void 0,g),!M||!i)return!0;const w=M.filter(T=>E.includes(T.type.name));t.ensureMarks(w)}return!0};function _d(n,e,t){if(!n.validContent(e))return null;try{return n.create(t,e)}catch(s){return null}}function So(n,e){if(n.pendingContent.length===0)return!0;const t=_d(e,$.from(n.pendingContent));return t?(n.items.push(t),n.pendingContent=[],!0):!1}function Fk(n,e,t){return t.validContent($.from([...e.pendingContent,n]))?(e.pendingContent.push(n),!0):!So(e,t)||!t.validContent($.from(n))?!1:(e.pendingContent.push(n),!0)}function Vk(n,e,t,s){const i=s(n,t);if(!i)return!1;const r=_d(t.listType,$.from(i),n.attrs);return r?t.itemType.validContent($.from([...e.pendingContent,r]))?(e.pendingContent.push(r),!0):So(e,t.itemType)?(e.items.push(...i),!0):!1:!1}function Hk(n,e,t){const s={items:[],pendingContent:[]};for(let i=0;is!==e?!0:(t=i,!1)),t}function Ql(n){return!n||n==="1"?null:n}function jd(n,e){return Ql(n)===Ql(e)}const As=(n,e)=>{const t=Hi(r=>r.type===e)(n.selection);if(!t)return!0;const s=n.doc.resolve(Math.max(0,t.pos-1)).before(t.depth);if(s===void 0)return!0;const i=n.doc.nodeAt(s);return!(t.node.type===(i==null?void 0:i.type)&&_t(n.doc,t.pos))||!jd(t.node.attrs.type,i==null?void 0:i.attrs.type)||n.join(t.pos),!0},Os=(n,e)=>{const t=Hi(r=>r.type===e)(n.selection);if(!t)return!0;const s=n.doc.resolve(t.start).after(t.depth);if(s===void 0)return!0;const i=n.doc.nodeAt(s);return!(t.node.type===(i==null?void 0:i.type)&&_t(n.doc,s))||!jd(t.node.attrs.type,i==null?void 0:i.attrs.type)||n.join(s),!0};function qk(n){const e=n.doc,t=e.firstChild;if(!t)return null;const s=e.resolve(1),i=e.resolve(t.nodeSize-1);return U.between(s,i)}const Uk=(n,e,t,s={})=>({editor:i,tr:r,state:o,dispatch:l,chain:c,commands:d,can:u})=>{const{extensions:p,splittableMarks:f}=i.extensionManager,h=ye(n,o.schema),g=ye(e,o.schema),{selection:b,storedMarks:m}=o,{$from:v,$to:S}=b,A=v.blockRange(S),O=m||b.$to.parentOffset&&b.$from.marks();if(!A)return!1;const B=Hi(le=>Ln(le.type.name,p))(b),E=b.from===0&&b.to===o.doc.content.size,M=o.doc.content.content,w=M.length===1?M[0]:null,T=E&&w&&Ln(w.type.name,p)?{node:w,pos:0}:null,N=B!=null?B:T,I=!!B&&A.depth>=1&&A.depth-B.depth<=1,Z=!!T;if((I||Z)&&N){if(N.node.type===h)return E&&Z?c().command(({tr:le,dispatch:ae})=>{const _=qk(le);return _?(le.setSelection(_),ae&&ae(le),!0):!1}).liftListItem(g).run():d.liftListItem(g);if(Ln(N.node.type.name,p)&&h.validContent(N.node.content))return c().command(()=>(r.setNodeMarkup(N.pos,h),!0)).command(()=>As(r,h)).command(()=>Os(r,h)).run();if(Ln(N.node.type.name,p)){var Oe;const le=(Oe=N.node.firstChild)===null||Oe===void 0?void 0:Oe.type;if(le&&le!==g){const ae=zd(N.node,{listType:h,itemType:g,isListNode:fe=>Ln(fe.type.name,p)}),_=ae?$.from(ae):null;return!_||!h.validContent(_)?!1:c().command(()=>{const{$anchor:fe,$head:rt}=r.selection,yt=fe.parent,F=rt.parent,jt=fe.parentOffset,xs=rt.parentOffset;let Ft;try{Ft=h.create(s,_)}catch(cn){return!1}if(r.replaceWith(N.pos,N.pos+N.node.nodeSize,Ft),yt.inlineContent&&F.inlineContent){const cn=Zl(Ft,yt),te=Zl(Ft,F);if(cn!==null&&te!==null){const ws=N.pos+cn+2+jt,Ou=N.pos+te+2+xs;r.setSelection(U.create(r.doc,ws,Ou))}}return!0}).command(()=>As(r,h)).command(()=>Os(r,h)).run()}}}return!t||!O||!l?c().command(()=>u().wrapInList(h,s)?!0:d.clearNodes()).wrapInList(h,s).command(()=>As(r,h)).command(()=>Os(r,h)).run():c().command(()=>{const le=u().wrapInList(h,s),ae=O.filter(_=>f.includes(_.type.name));return r.ensureMarks(ae),le?!0:d.clearNodes()}).wrapInList(h,s).command(()=>As(r,h)).command(()=>Os(r,h)).run()},Wk=(n,e={},t={})=>({state:s,commands:i})=>{const{extendEmptyMarkRange:r=!1}=t,o=vt(n,s.schema);return zr(s,o,e)?i.unsetMark(o,{extendEmptyMarkRange:r}):i.setMark(o,e)},Kk=(n,e,t={})=>({state:s,commands:i})=>{const r=ye(n,s.schema),o=ye(e,s.schema),l=bt(s,r,t);let c;return s.selection.$anchor.sameParent(s.selection.$head)&&(c=s.selection.$anchor.parent.attrs),l?i.setNode(o,c):i.setNode(r,{...c,...t})},Jk=(n,e={})=>({state:t,commands:s})=>{const i=ye(n,t.schema);return bt(t,i,e)?s.lift(i):s.wrapIn(i,e)},Gk=()=>({state:n,dispatch:e})=>{const t=n.plugins;for(let s=0;s=0;c-=1)o.step(l.steps[c].invert(l.docs[c]));if(r.text){const c=o.doc.resolve(r.from).marks();o.replaceWith(r.from,r.to,n.schema.text(r.text,c))}else o.delete(r.from,r.to)}return!0}}return!1},Yk=(n={})=>({tr:e,dispatch:t,editor:s})=>{const{ignoreClearable:i=!1}=n,{selection:r}=e,{empty:o,ranges:l}=r;if(o)return!0;const{nonClearableMarks:c}=s.extensionManager;if(t){const d=Object.values(s.schema.marks).filter(u=>i||!c.includes(u.name));l.forEach(u=>{for(const p of d)e.removeMark(u.$from.pos,u.$to.pos,p)})}return!0},Xk=(n,e={})=>({tr:t,state:s,dispatch:i})=>{const{extendEmptyMarkRange:r=!1}=e,{selection:o}=t,l=vt(n,s.schema),{$from:c,empty:d,ranges:u}=o;if(!i)return!0;if(d&&r){var p;let{from:f,to:h}=o;const g=yo(c,l,(p=c.marks().find(b=>b.type===l))===null||p===void 0?void 0:p.attrs);g&&(f=g.from,h=g.to),t.removeMark(f,h,l)}else u.forEach(f=>{t.removeMark(f.$from.pos,f.$to.pos,l)});return t.removeStoredMark(l),!0},Zk=n=>({tr:e,state:t,dispatch:s})=>{const{selection:i}=t;let r,o;return typeof n=="number"?(r=n,o=n):n&&"from"in n&&"to"in n?(r=n.from,o=n.to):(r=i.from,o=i.to),s&&e.doc.nodesBetween(r,o,(l,c)=>{if(l.isText)return;const d={...l.attrs};delete d.dir,e.setNodeMarkup(c,void 0,d)}),!0},Qk=(n,e={})=>({tr:t,state:s,dispatch:i})=>{let r=null,o=null;const l=Vi(typeof n=="string"?n:n.name,s.schema);if(!l)return!1;l==="node"&&(r=ye(n,s.schema)),l==="mark"&&(o=vt(n,s.schema));let c=!1;return t.selection.ranges.forEach(d=>{const u=d.$from.pos,p=d.$to.pos;let f,h,g,b;t.selection.empty?s.doc.nodesBetween(u,p,(m,v)=>{r&&r===m.type&&(c=!0,g=Math.max(v,u),b=Math.min(v+m.nodeSize,p),f=v,h=m)}):s.doc.nodesBetween(u,p,(m,v)=>{v=u&&v<=p&&(r&&r===m.type&&(c=!0,i&&t.setNodeMarkup(v,void 0,{...m.attrs,...e})),o&&m.marks.length&&m.marks.forEach(S=>{if(o===S.type&&(c=!0,i)){const A=Math.max(v,u),O=Math.min(v+m.nodeSize,p);t.addMark(A,O,o.create({...S.attrs,...e}))}}))}),h&&(f!==void 0&&i&&t.setNodeMarkup(f,void 0,{...h.attrs,...e}),o&&h.marks.length&&h.marks.forEach(m=>{o===m.type&&i&&t.addMark(g,b,o.create({...m.attrs,...e}))}))}),c},bn=new me("__tiptap_decorations__"),ex=n=>({tr:e,dispatch:t})=>(t&&e.setMeta(bn,{type:"force",name:n}),!0),tx=(n,e={})=>({state:t,dispatch:s})=>{const i=ye(n,t.schema);return ly(i,e)(t,s)},nx=(n,e={})=>({state:t,dispatch:s})=>{const i=ye(n,t.schema);return ay(i,e)(t,s)};var sx=Qb({blur:()=>g1,clearContent:()=>b1,clearNodes:()=>v1,command:()=>y1,createParagraphNear:()=>k1,cut:()=>x1,deleteCurrentNode:()=>w1,deleteNode:()=>S1,deleteRange:()=>C1,deleteSelection:()=>E1,enter:()=>A1,exitCode:()=>O1,extendMarkRange:()=>N1,first:()=>I1,focus:()=>$1,forEach:()=>R1,insertContent:()=>L1,insertContentAt:()=>P1,insertDefaultBlock:()=>B1,joinBackward:()=>j1,joinDown:()=>z1,joinForward:()=>F1,joinItemBackward:()=>V1,joinItemForward:()=>H1,joinTextblockBackward:()=>q1,joinTextblockForward:()=>U1,joinUp:()=>_1,keyboardShortcut:()=>K1,lift:()=>J1,liftEmptyBlock:()=>G1,liftListItem:()=>Y1,newlineInCode:()=>X1,resetAttributes:()=>Z1,scrollIntoView:()=>Q1,selectAll:()=>ek,selectNodeBackward:()=>tk,selectNodeForward:()=>nk,selectParentNode:()=>sk,selectTextblockEnd:()=>ik,selectTextblockStart:()=>rk,setContent:()=>ok,setMark:()=>Dk,setMeta:()=>$k,setNode:()=>Rk,setNodeSelection:()=>Lk,setTextDirection:()=>Pk,setTextSelection:()=>Bk,sinkListItem:()=>_k,splitBlock:()=>zk,splitListItem:()=>jk,toggleList:()=>Uk,toggleMark:()=>Wk,toggleNode:()=>Kk,toggleWrap:()=>Jk,undoInputRule:()=>Gk,unsetAllMarks:()=>Yk,unsetMark:()=>Xk,unsetTextDirection:()=>Zk,updateAttributes:()=>Qk,updateDecorations:()=>ex,wrapIn:()=>tx,wrapInList:()=>nx});const Pn=new WeakMap;function ix(n,e){var t;Pn.set(n,((t=Pn.get(n))!==null&&t!==void 0?t:0)+1);try{return e()}finally{var s;const i=((s=Pn.get(n))!==null&&s!==void 0?s:1)-1;i>0?Pn.set(n,i):Pn.delete(n)}}var rx=class{constructor(){this.callbacks={}}on(n,e){return this.callbacks[n]||(this.callbacks[n]=[]),this.callbacks[n].push(e),this}emit(n,...e){const t=this.callbacks[n];return t&&t.forEach(s=>s.apply(this,e)),this}off(n,e){const t=this.callbacks[n];return t&&(e?this.callbacks[n]=t.filter(s=>s!==e):delete this.callbacks[n]),this}once(n,e){const t=(...s)=>{this.off(n,t),e.apply(this,s)};return this.on(n,t)}removeAllListeners(){this.callbacks={}}};function ox(n){return n.kind==="widget"}function Fd(n,e){const t=[],s=new Set;for(const i of n)i.kind==="widget"&&ox(i)&&s.add(i.key),t.push(i.toPMDecoration(e));return{decorations:t,widgetKeys:s}}function lx(n,e,t){const{decorations:s,widgetKeys:i}=Fd(e,t);return{set:ne.create(n,s),widgetKeys:i}}function Vd({position:n,from:e,to:t,docSize:s}){return nVd({position:o.anchor,from:e,to:t,docSize:s})?!0:(o.anchor===t||r.has(i)||(r.add(i),console.warn(`[tiptap warn]: Extension "${i}" returned a decoration outside the requested range [${e}, ${t}). It was ignored.`)),!1))}function cx(n){var e;const t=(e=n.spec)===null||e===void 0?void 0:e.key;return typeof t=="string"?t:void 0}function Hd(n){return n.jsonID==="attr"}function dx(n){let e=!1;if(n.getMap().forEach(()=>{e=!0}),e||Hd(n))return!0;const t=n;return typeof t.from=="number"&&typeof t.to=="number"}function ux(n,e){let t=null,s=0,i=0;for(let r=0;re.to);r+=1){const o=i+n.child(r).nodeSize;o>=e.from&&(t===null&&(t=i),s=o),i=o}return t===null?null:{from:t,to:s}}function px(n,e){if(n.steps.some(r=>!dx(r)))return{type:"full"};const t=qi(n).map(({newRange:r})=>r);n.steps.forEach((r,o)=>{if(!Hd(r))return;const l=n.mapping.slice(o);t.push({from:l.map(r.pos,-1),to:l.map(r.pos+1)})});const s=[];for(const r of t){const o=ux(e,r);o&&s.push(o)}s.sort((r,o)=>r.from-o.from);const i=[];for(const r of s){const o=i[i.length-1];o&&r.from<=o.to?o.to=Math.max(o.to,r.to):i.push({...r})}return{type:"ranges",ranges:i}}function qd(n,e,t,s){return n.map(e,t,{onRemove:i=>{const r=i==null?void 0:i.key;typeof r=="string"&&s.delete(r)}})}function fx(n,e,t){var s,i;const r=(s=e.decorationSetsByExtension[n])!==null&&s!==void 0?s:ne.empty,o=new Set((i=e.widgetKeysByExtension[n])!==null&&i!==void 0?i:[]);return{set:qd(r,t.mapping,t.doc,o),widgetKeys:o}}function ea(n,e){const t=Object.values(e).flatMap(s=>s.find());return ne.create(n,t)}function ta(n){const e=new Set;for(const t of Object.values(n))for(const s of t)e.add(s);return e}function hx(n,e){var t;switch((t=e.update)!==null&&t!==void 0?t:"document"){case"document":if(e.createInRange)throw new Error(`[tiptap error]: Extension "${n}" provides createInRange() but does not use the "changedRanges" decoration update strategy.`);return;case"changedRanges":if(!e.createInRange)throw new Error(`[tiptap error]: Extension "${n}" uses the "changedRanges" decoration update strategy but does not provide createInRange().`);return;case"manual":if(e.createInRange)throw new Error(`[tiptap error]: Extension "${n}" uses the "manual" decoration update strategy, which is not compatible with createInRange(). createInRange() requires the "changedRanges" strategy.`);if(e.shouldUpdate)throw new Error(`[tiptap error]: Extension "${n}" cannot combine the "manual" decoration update strategy with shouldUpdate().`);return;default:throw new Error(`[tiptap error]: Extension "${n}" uses an unknown decoration update strategy. Expected "document", "changedRanges", or "manual".`)}}function mx(n,e,t){return t?!0:n.update==="manual"?!1:n.shouldUpdate?n.shouldUpdate(e):e.tr.docChanged}const gx=new Set;var bx=class{constructor(n){this.warnedWidgetKeys=new Set,this.warnedOutOfRangeExtensions=new Set,this.handleBeforeTransaction=({nextState:e})=>{const t=bn.getState(e);t&&this.warnDuplicateWidgetKeys(t)},this.editor=n.editor,this.entries=this.resolveEntries(n.entries),this.entries.forEach(({name:e,spec:t})=>hx(e,t)),this.plugin=this.entries.length>0?this.createPlugin():null,this.editor.on("beforeTransaction",this.handleBeforeTransaction)}destroy(){this.editor.off("beforeTransaction",this.handleBeforeTransaction)}liveWidgetKeys(){var n,e;return(n=(e=bn.getState(this.editor.state))===null||e===void 0?void 0:e.widgetKeys)!==null&&n!==void 0?n:gx}get mountedView(){return this.editor.isDestroyed?null:this.editor.view}resolveEntries(n){const e=[];for(const{name:t,addDecorations:s}of n){const i=s();i&&e.push({name:t,spec:i})}return e}createPlugin(){const{editor:n,entries:e}=this;return new oe({key:bn,state:{init:(t,s)=>{const i={},r={};for(const{name:l,spec:c}of e){const{set:d,widgetKeys:u}=this.buildFullSet(l,c,s);i[l]=d,r[l]=u}const o={decorationSetsByExtension:i,widgetKeysByExtension:r,mergedDecorationSet:this.buildMergedSet(s.doc,i),widgetKeys:ta(r)};return this.warnDuplicateWidgetKeys(o),o},apply:(t,s,i,r)=>{const o=t.getMeta(bn),l=(o==null?void 0:o.type)==="force"&&!o.name,c=(o==null?void 0:o.type)==="force"?o.name:void 0,d={},u={},p=new Set;return ix(n,()=>{for(const{name:f,spec:h}of e){const g=l||c===f;if(mx(h,{editor:n,tr:t,oldState:i,newState:r},g))if(h.update==="changedRanges"&&t.docChanged&&!g){const b=this.applyChangedRangesRecompute(f,h,s,t,r);d[f]=b.set,u[f]=b.widgetKeys,p.add(f)}else{const{set:b,widgetKeys:m}=this.buildFullSet(f,h,r);d[f]=b,u[f]=m,p.add(f)}else{const b=fx(f,s,t);d[f]=b.set,u[f]=b.widgetKeys}}}),p.size===0&&!t.docChanged?s:{decorationSetsByExtension:d,widgetKeysByExtension:u,mergedDecorationSet:this.mergeAfterApply({entries:e,previous:s,tr:t,decorationSetsByExtension:d,recomputedNames:p}),widgetKeys:ta(u)}}},props:{decorations(t){var s,i;return(s=(i=bn.getState(t))===null||i===void 0?void 0:i.mergedDecorationSet)!==null&&s!==void 0?s:ne.empty}}})}applyChangedRangesRecompute(n,e,t,s,i){const r=px(s,i.doc);return r.type==="full"?this.buildFullSet(n,e,i):this.rebuildRanges(n,e,t,s,i,r.ranges)}rebuildRanges(n,e,t,s,i,r){var o,l;const c=(o=t.decorationSetsByExtension[n])!==null&&o!==void 0?o:ne.empty,d=new Set((l=t.widgetKeysByExtension[n])!==null&&l!==void 0?l:[]);let u=qd(c,s.mapping,s.doc,d);const p=i.doc.content.size;for(const{from:f,to:h}of r){const g=u.find(f,h).filter(v=>Vd({position:v.from,from:f,to:h,docSize:p}));for(const v of g){const S=cx(v);S&&d.delete(S)}u=u.remove(g);const{decorations:b,widgetKeys:m}=Fd(ax({decorations:this.runCreate(n,"createInRange",()=>e.createInRange({editor:this.editor,state:i,view:this.mountedView,from:f,to:h})),from:f,to:h,docSize:p,extensionName:n,warnedExtensions:this.warnedOutOfRangeExtensions}),n);u=u.add(i.doc,b);for(const v of m)d.add(v)}return{set:u,widgetKeys:d}}buildFullSet(n,e,t){const s=this.runCreate(n,"create",()=>e.create({editor:this.editor,state:t,view:this.mountedView}));return lx(t.doc,s,n)}runCreate(n,e,t){try{return t()}catch(s){return console.error(`[tiptap error]: Extension "${n}" threw in \`addDecorations().${e}()\`. Its decorations were dropped for this update.`,s),[]}}warnDuplicateWidgetKeys(n){}buildMergedSet(n,e){const t=Object.keys(e);return t.length===1?e[t[0]]:ea(n,e)}mergeAfterApply({entries:n,previous:e,tr:t,decorationSetsByExtension:s,recomputedNames:i}){return n.length===1?s[n[0].name]:i.size===0?e.mergedDecorationSet.map(t.mapping,t.doc):ea(t.doc,s)}};function vx(n,e){const{selection:t}=n,{$from:s}=t;if(t instanceof W){const r=s.index();return s.parent.canReplaceWith(r,r+1,e)}let i=s.depth;for(;i>=0;){const r=s.index(i);if(s.node(i).contentMatchAt(r).matchType(e))return!0;i-=1}return!1}function yx(n,e,t){const s=document.querySelector("style[data-tiptap-style]");if(s!==null)return s;const i=document.createElement("style");return e&&i.setAttribute("nonce",e),i.setAttribute("data-tiptap-style",""),i.innerHTML=n,document.getElementsByTagName("head")[0].appendChild(i),i}function kx(n){return typeof n=="number"}function xx(n){return Object.prototype.toString.call(n).slice(8,-1)}function Ns(n){return xx(n)!=="Object"?!1:n.constructor===Object&&Object.getPrototypeOf(n)===Object.prototype}function na(n,e,t){const s=n.split(` +`,textSerializers:o={}}=t||{};let l="";return n.nodesBetween(s,i,(c,d,u,p)=>{c.isBlock&&d>s&&(l+=r);const f=o==null?void 0:o[c.type.name];if(f)return u&&(l+=f({node:c,pos:d,parent:u,index:p,range:e})),!1;if(c.isText){var h;l+=c==null||(h=c.text)===null||h===void 0?void 0:h.slice(Math.max(s,d)-d,i-d)}}),l}function vk(n,e){return Dd(n,{from:0,to:n.content.size},e)}function $d(n){return Object.fromEntries(Object.entries(n.nodes).filter(([,e])=>e.spec.toText).map(([e,t])=>[e,t.spec.toText]))}function yk(n,e){const t=ye(e,n.schema),{from:s,to:i}=n.selection,r=[];n.doc.nodesBetween(s,i,l=>{r.push(l)});const o=r.reverse().find(l=>l.type.name===t.name);return o?{...o.attrs}:{}}function Rd(n,e){const t=Vi(typeof e=="string"?e:e.name,n.schema);return t==="node"?yk(n,e):t==="mark"?Ed(n,e):{}}function kk(n,e=JSON.stringify){const t={};return n.filter(s=>{const i=e(s);return Object.prototype.hasOwnProperty.call(t,i)?!1:t[i]=!0})}function xk(n){const e=kk(n);return e.length===1?e:e.filter((t,s)=>!e.filter((i,r)=>r!==s).some(i=>t.oldRange.from>=i.oldRange.from&&t.oldRange.to<=i.oldRange.to&&t.newRange.from>=i.newRange.from&&t.newRange.to<=i.newRange.to))}function qi(n){const{mapping:e,steps:t}=n,s=[];return e.maps.forEach((i,r)=>{const o=[];if(i.ranges.length)i.forEach((l,c)=>{o.push({from:l,to:c})});else{const{from:l,to:c}=t[r];if(l===void 0||c===void 0)return;o.push({from:l,to:c})}o.forEach(({from:l,to:c})=>{const d=e.slice(r).map(l,-1),u=e.slice(r).map(c),p=e.invert().map(d,-1),f=e.invert().map(u);s.push({oldRange:{from:p,to:f},newRange:{from:d,to:u}})})}),xk(s)}function Ui(n,e,t){const s=[];return n===e?t.resolve(n).marks().forEach(i=>{const r=yo(t.resolve(n),i.type);r&&s.push({mark:i,...r})}):t.nodesBetween(n,e,(i,r)=>{!i||(i==null?void 0:i.nodeSize)===void 0||s.push(...i.marks.map(o=>({from:r,to:r+i.nodeSize,mark:o})))}),s}const wk=(n,e,t,s=20)=>{const i=n.doc.resolve(t);let r=s,o=null;for(;r>0&&o===null;){const l=i.node(r);(l==null?void 0:l.type.name)===e?o=l:r-=1}return[o,r]},Sk=n=>{const e=n.depth-1;if(e<0)return null;const t=n.index(e);return t===0?null:n.node(e).child(t-1)};function fn(n,e){return e.nodes[n]||e.marks[n]||null}function Vs(n,e,t){return Object.fromEntries(Object.entries(t).filter(([s])=>{const i=n.find(r=>r.type===e&&r.name===s);return i?i.attribute.keepOnSplit:!1}))}const Ck=(n,e=500)=>{let t="";const s=n.parentOffset;return n.parent.nodesBetween(Math.max(0,s-e),s,(i,r,o,l)=>{var c,d;const u=((c=(d=i.type.spec).toText)===null||c===void 0?void 0:c.call(d,{node:i,pos:r,parent:o,index:l}))||i.textContent||"%leaf%";t+=i.isAtom&&!i.isText?u:u.slice(0,Math.max(0,s-r))}),t};function zr(n,e,t={}){const{empty:s,ranges:i}=n.selection,r=e?vt(e,n.schema):null;if(s)return!!(n.storedMarks||n.selection.$from.marks()).filter(u=>r?r.name===u.type.name:!0).find(u=>ti(u.attrs,t,{strict:!1}));let o=0;const l=[];if(i.forEach(({$from:u,$to:p})=>{const f=u.pos,h=p.pos;n.doc.nodesBetween(f,h,(g,b)=>{if(r&&g.inlineContent&&!g.type.allowsMarkType(r))return!1;if(!g.isText&&!g.marks.length)return;const m=Math.max(f,b),v=Math.min(h,b+g.nodeSize),S=v-m;o+=S,l.push(...g.marks.map(A=>({mark:A,from:m,to:v})))})}),o===0)return!1;const c=l.filter(u=>r?r.name===u.mark.type.name:!0).filter(u=>ti(u.mark.attrs,t,{strict:!1})).reduce((u,p)=>u+p.to-p.from,0),d=l.filter(u=>r?u.mark.type!==r&&u.mark.type.excludes(r):!0).reduce((u,p)=>u+p.to-p.from,0);return(c>0?c+d:c)>=o}function Mk(n,e,t={}){if(!e)return bt(n,null,t)||zr(n,null,t);const s=Vi(e,n.schema);return s==="node"?bt(n,e,t):s==="mark"?zr(n,e,t):!1}const Tk=(n,e)=>{const{$from:t,$to:s,$anchor:i}=n.selection;if(e){const r=Hi(l=>l.type.name===e)(n.selection);if(!r)return!1;const o=n.doc.resolve(r.pos+1);return i.pos+1===o.end()}return!(s.parentOffset{const{$from:e,$to:t}=n.selection;return!(e.parentOffset>0||e.pos!==t.pos)};function Yl(n,e){return Array.isArray(e)?e.some(t=>(typeof t=="string"?t:t.name)===n.name):e}function Ln(n,e){const{nodeExtensions:t}=An(e),s=t.find(r=>r.name===n);if(!s)return!1;const i=se(V(s,"group",{name:s.name,options:s.options,storage:s.storage}));return typeof i!="string"?!1:i.split(" ").includes("list")}function ys(n,{checkChildren:e=!0,ignoreWhitespace:t=!1}={}){if(t){if(n.type.name==="hardBreak")return!0;if(n.isText){var s;return!/\S/.test((s=n.text)!==null&&s!==void 0?s:"")}}if(n.isText)return!n.text;if(n.isAtom||n.isLeaf)return!1;if(n.content.childCount===0)return!0;if(e){let i=!0;return n.content.forEach(r=>{i!==!1&&(ys(r,{ignoreWhitespace:t,checkChildren:e})||(i=!1))}),i}return!1}function Ld(n){return n instanceof W}function Ak(n){if(n===null||typeof n!="object")return!1;const e=n;return!(typeof e.apply!="function"||typeof e.getMap!="function"||typeof e.invert!="function"||typeof e.map!="function"||typeof e.merge!="function"||typeof e.toJSON!="function")}function Ok(n){if(n===null||typeof n!="object")return!1;const e=n;if(!Ak(e))return!1;const t=e.toJSON();return!(t===null||typeof t!="object"||t.stepType!=="replace")}var Pd=class Bd{constructor(e){this.position=e}static fromJSON(e){return new Bd(e.position)}toJSON(){return{position:this.position}}};function Nk(n,e){const t=e.mapping.mapResult(n.position);return{position:new Pd(t.pos),mapResult:t}}function Ik(n){return new Pd(n)}function Dk(n,e,t){const{selection:s}=e;let i=null;if(yd(s)&&(i=s.$cursor),i){var r;const l=(r=n.storedMarks)!==null&&r!==void 0?r:i.marks();return i.parent.type.allowsMarkType(t)&&(!!t.isInSet(l)||!l.some(c=>c.type.excludes(t)))}const{ranges:o}=s;return o.some(({$from:l,$to:c})=>{let d=l.depth===0?n.doc.inlineContent&&n.doc.type.allowsMarkType(t):!1;return n.doc.nodesBetween(l.pos,c.pos,(u,p,f)=>{if(d)return!1;if(u.isInline){const h=!f||f.type.allowsMarkType(t),g=!!t.isInSet(u.marks)||!u.marks.some(b=>b.type.excludes(t));d=h&&g}return!d}),d})}const $k=(n,e={})=>({tr:t,state:s,dispatch:i})=>{const{selection:r}=t,{empty:o,ranges:l}=r,c=vt(n,s.schema);if(i)if(o){const d=Ed(s,c);t.addStoredMark(c.create({...d,...e}))}else l.forEach(d=>{const u=d.$from.pos,p=d.$to.pos;s.doc.nodesBetween(u,p,(f,h)=>{const g=Math.max(h,u),b=Math.min(h+f.nodeSize,p);f.marks.find(m=>m.type===c)?f.marks.forEach(m=>{c===m.type&&t.addMark(g,b,c.create({...m.attrs,...e}))}):t.addMark(g,b,c.create(e))})});return Dk(s,t,c)},Rk=(n,e)=>({tr:t})=>(t.setMeta(n,e),!0),Lk=(n,e={})=>({state:t,dispatch:s,chain:i})=>{const r=ye(n,t.schema);let o;return t.selection.$anchor.sameParent(t.selection.$head)&&(o=t.selection.$anchor.parent.attrs),r.isTextblock?i().command(({commands:l})=>ol(r,{...o,...e})(t)?!0:l.clearNodes()).command(({state:l})=>ol(r,{...o,...e})(l,s)).run():(console.warn('[tiptap warn]: Currently "setNode()" only supports text block nodes.'),!1)},Pk=n=>({tr:e,dispatch:t})=>{if(t){const{doc:s}=e,i=Kt(n,0,s.content.size),r=W.create(s,i);e.setSelection(r)}return!0},Bk=(n,e)=>({tr:t,state:s,dispatch:i})=>{const{selection:r}=s;let o,l;return typeof e=="number"?(o=e,l=e):e&&"from"in e&&"to"in e?(o=e.from,l=e.to):(o=r.from,l=r.to),i&&t.doc.nodesBetween(o,l,(c,d)=>{c.isText||t.setNodeMarkup(d,void 0,{...c.attrs,dir:n})}),!0},_k=n=>({tr:e,dispatch:t})=>{if(t){const{doc:s}=e,{from:i,to:r}=typeof n=="number"?{from:n,to:n}:n,o=U.atStart(s).from,l=U.atEnd(s).to,c=Kt(i,o,l),d=Kt(r,o,l),u=U.create(s,c,d);e.setSelection(u)}return!0},zk=n=>({state:e,dispatch:t})=>{const s=ye(n,e.schema);return my(s)(e,t)};function Xl(n,e){const t=n.storedMarks||n.selection.$to.parentOffset&&n.selection.$from.marks();if(t){const s=t.filter(i=>e==null?void 0:e.includes(i.type.name));n.tr.ensureMarks(s)}}const jk=({keepMarks:n=!0}={})=>({tr:e,state:t,dispatch:s,editor:i})=>{const{selection:r,doc:o}=e,{$from:l,$to:c}=r,d=i.extensionManager.attributes,u=Vs(d,l.node().type.name,l.node().attrs);if(r instanceof W&&r.node.isBlock)return!l.parentOffset||!mt(o,l.pos)?!1:(s&&(n&&Xl(t,i.extensionManager.splittableMarks),e.split(l.pos).scrollIntoView()),!0);if(!l.parent.isBlock)return!1;const p=c.parentOffset===c.parent.content.size,f=l.depth===0?void 0:Cd(l.node(-1).contentMatchAt(l.indexAfter(-1)));let h=p&&f?[{type:f,attrs:u}]:void 0;const g=r instanceof U&&!r.empty?pt.create({doc:e.doc,selection:r}).tr.deleteSelection():null,b=g?g.doc:e.doc,m=g?g.mapping.map(l.pos):l.pos;let v=mt(b,m,1,h);if(!h&&!v&&mt(b,m,1,f?[{type:f}]:void 0)&&(v=!0,h=f?[{type:f,attrs:u}]:void 0),s){if(v){const S=e.steps.length;if(r instanceof U&&e.deleteSelection(),e.split(e.mapping.slice(S).map(l.pos),1,h),f&&!p&&!l.parentOffset&&l.parent.type!==f){const A=e.mapping.slice(S).map(l.before()),N=e.doc.resolve(A);l.node(-1).canReplaceWith(N.index(),N.index()+1,f)&&e.setNodeMarkup(e.mapping.slice(S).map(l.before()),f)}}n&&Xl(t,i.extensionManager.splittableMarks),e.scrollIntoView()}return v},Fk=(n,e={})=>({tr:t,state:s,dispatch:i,editor:r})=>{const o=ye(n,s.schema),{$from:l,$to:c}=s.selection,d=s.selection.node;if(d&&d.isBlock||l.depth<2||!l.sameParent(c))return!1;const u=l.node(-1);if(u.type!==o)return!1;const p=r.extensionManager.attributes;if(l.parent.content.size===0&&l.node(-1).childCount===l.indexAfter(-1)){if(l.depth===2||l.node(-3).type!==o||l.index(-2)!==l.node(-2).childCount-1)return!1;if(i){var f;let N=$.empty;const B=l.index(-1)?1:l.index(-2)?2:3;for(let I=l.depth-B;I>=l.depth-3;I-=1)N=$.from(l.node(I).copy(N));const E=l.indexAfter(-1){if(O>-1)return!1;I.isTextblock&&I.content.size===0&&(O=Z+1)}),O>-1&&t.setSelection(U.near(t.doc.resolve(O))),t.scrollIntoView()}return!0}const h=c.pos===l.end()?u.contentMatchAt(0).defaultType:null,g={...Vs(p,u.type.name,u.attrs),...e},b={...Vs(p,l.node().type.name,l.node().attrs),...e},m=l.parentOffset===0&&l.index(-1)===0,v=l.before(-1);t.delete(l.pos,c.pos);const S=m?u.attrs:g,A=h?[{type:o,attrs:S},{type:h,attrs:b}]:[{type:o,attrs:S}];if(!mt(t.doc,l.pos,2))return!1;if(i){const{selection:N,storedMarks:B}=s,{splittableMarks:E}=r.extensionManager,M=B||N.$to.parentOffset&&N.$from.marks();if(t.split(l.pos,2,A).scrollIntoView(),m&&t.setNodeMarkup(v,void 0,g),!M||!i)return!0;const w=M.filter(T=>E.includes(T.type.name));t.ensureMarks(w)}return!0};function _d(n,e,t){if(!n.validContent(e))return null;try{return n.create(t,e)}catch(s){return null}}function So(n,e){if(n.pendingContent.length===0)return!0;const t=_d(e,$.from(n.pendingContent));return t?(n.items.push(t),n.pendingContent=[],!0):!1}function Vk(n,e,t){return t.validContent($.from([...e.pendingContent,n]))?(e.pendingContent.push(n),!0):!So(e,t)||!t.validContent($.from(n))?!1:(e.pendingContent.push(n),!0)}function Hk(n,e,t,s){const i=s(n,t);if(!i)return!1;const r=_d(t.listType,$.from(i),n.attrs);return r?t.itemType.validContent($.from([...e.pendingContent,r]))?(e.pendingContent.push(r),!0):So(e,t.itemType)?(e.items.push(...i),!0):!1:!1}function qk(n,e,t){const s={items:[],pendingContent:[]};for(let i=0;is!==e?!0:(t=i,!1)),t}function Ql(n){return!n||n==="1"?null:n}function jd(n,e){return Ql(n)===Ql(e)}const As=(n,e)=>{const t=Hi(r=>r.type===e)(n.selection);if(!t)return!0;const s=n.doc.resolve(Math.max(0,t.pos-1)).before(t.depth);if(s===void 0)return!0;const i=n.doc.nodeAt(s);return!(t.node.type===(i==null?void 0:i.type)&&_t(n.doc,t.pos))||!jd(t.node.attrs.type,i==null?void 0:i.attrs.type)||n.join(t.pos),!0},Os=(n,e)=>{const t=Hi(r=>r.type===e)(n.selection);if(!t)return!0;const s=n.doc.resolve(t.start).after(t.depth);if(s===void 0)return!0;const i=n.doc.nodeAt(s);return!(t.node.type===(i==null?void 0:i.type)&&_t(n.doc,s))||!jd(t.node.attrs.type,i==null?void 0:i.attrs.type)||n.join(s),!0};function Uk(n){const e=n.doc,t=e.firstChild;if(!t)return null;const s=e.resolve(1),i=e.resolve(t.nodeSize-1);return U.between(s,i)}const Wk=(n,e,t,s={})=>({editor:i,tr:r,state:o,dispatch:l,chain:c,commands:d,can:u})=>{const{extensions:p,splittableMarks:f}=i.extensionManager,h=ye(n,o.schema),g=ye(e,o.schema),{selection:b,storedMarks:m}=o,{$from:v,$to:S}=b,A=v.blockRange(S),N=m||b.$to.parentOffset&&b.$from.marks();if(!A)return!1;const B=Hi(le=>Ln(le.type.name,p))(b),E=b.from===0&&b.to===o.doc.content.size,M=o.doc.content.content,w=M.length===1?M[0]:null,T=E&&w&&Ln(w.type.name,p)?{node:w,pos:0}:null,O=B!=null?B:T,I=!!B&&A.depth>=1&&A.depth-B.depth<=1,Z=!!T;if((I||Z)&&O){if(O.node.type===h)return E&&Z?c().command(({tr:le,dispatch:ae})=>{const _=Uk(le);return _?(le.setSelection(_),ae&&ae(le),!0):!1}).liftListItem(g).run():d.liftListItem(g);if(Ln(O.node.type.name,p)&&h.validContent(O.node.content))return c().command(()=>(r.setNodeMarkup(O.pos,h),!0)).command(()=>As(r,h)).command(()=>Os(r,h)).run();if(Ln(O.node.type.name,p)){var Oe;const le=(Oe=O.node.firstChild)===null||Oe===void 0?void 0:Oe.type;if(le&&le!==g){const ae=zd(O.node,{listType:h,itemType:g,isListNode:fe=>Ln(fe.type.name,p)}),_=ae?$.from(ae):null;return!_||!h.validContent(_)?!1:c().command(()=>{const{$anchor:fe,$head:rt}=r.selection,yt=fe.parent,F=rt.parent,jt=fe.parentOffset,xs=rt.parentOffset;let Ft;try{Ft=h.create(s,_)}catch(cn){return!1}if(r.replaceWith(O.pos,O.pos+O.node.nodeSize,Ft),yt.inlineContent&&F.inlineContent){const cn=Zl(Ft,yt),te=Zl(Ft,F);if(cn!==null&&te!==null){const ws=O.pos+cn+2+jt,Ou=O.pos+te+2+xs;r.setSelection(U.create(r.doc,ws,Ou))}}return!0}).command(()=>As(r,h)).command(()=>Os(r,h)).run()}}}return!t||!N||!l?c().command(()=>u().wrapInList(h,s)?!0:d.clearNodes()).wrapInList(h,s).command(()=>As(r,h)).command(()=>Os(r,h)).run():c().command(()=>{const le=u().wrapInList(h,s),ae=N.filter(_=>f.includes(_.type.name));return r.ensureMarks(ae),le?!0:d.clearNodes()}).wrapInList(h,s).command(()=>As(r,h)).command(()=>Os(r,h)).run()},Kk=(n,e={},t={})=>({state:s,commands:i})=>{const{extendEmptyMarkRange:r=!1}=t,o=vt(n,s.schema);return zr(s,o,e)?i.unsetMark(o,{extendEmptyMarkRange:r}):i.setMark(o,e)},Jk=(n,e,t={})=>({state:s,commands:i})=>{const r=ye(n,s.schema),o=ye(e,s.schema),l=bt(s,r,t);let c;return s.selection.$anchor.sameParent(s.selection.$head)&&(c=s.selection.$anchor.parent.attrs),l?i.setNode(o,c):i.setNode(r,{...c,...t})},Gk=(n,e={})=>({state:t,commands:s})=>{const i=ye(n,t.schema);return bt(t,i,e)?s.lift(i):s.wrapIn(i,e)},Yk=()=>({state:n,dispatch:e})=>{const t=n.plugins;for(let s=0;s=0;c-=1)o.step(l.steps[c].invert(l.docs[c]));if(r.text){const c=o.doc.resolve(r.from).marks();o.replaceWith(r.from,r.to,n.schema.text(r.text,c))}else o.delete(r.from,r.to)}return!0}}return!1},Xk=(n={})=>({tr:e,dispatch:t,editor:s})=>{const{ignoreClearable:i=!1}=n,{selection:r}=e,{empty:o,ranges:l}=r;if(o)return!0;const{nonClearableMarks:c}=s.extensionManager;if(t){const d=Object.values(s.schema.marks).filter(u=>i||!c.includes(u.name));l.forEach(u=>{for(const p of d)e.removeMark(u.$from.pos,u.$to.pos,p)})}return!0},Zk=(n,e={})=>({tr:t,state:s,dispatch:i})=>{const{extendEmptyMarkRange:r=!1}=e,{selection:o}=t,l=vt(n,s.schema),{$from:c,empty:d,ranges:u}=o;if(!i)return!0;if(d&&r){var p;let{from:f,to:h}=o;const g=yo(c,l,(p=c.marks().find(b=>b.type===l))===null||p===void 0?void 0:p.attrs);g&&(f=g.from,h=g.to),t.removeMark(f,h,l)}else u.forEach(f=>{t.removeMark(f.$from.pos,f.$to.pos,l)});return t.removeStoredMark(l),!0},Qk=n=>({tr:e,state:t,dispatch:s})=>{const{selection:i}=t;let r,o;return typeof n=="number"?(r=n,o=n):n&&"from"in n&&"to"in n?(r=n.from,o=n.to):(r=i.from,o=i.to),s&&e.doc.nodesBetween(r,o,(l,c)=>{if(l.isText)return;const d={...l.attrs};delete d.dir,e.setNodeMarkup(c,void 0,d)}),!0},ex=(n,e={})=>({tr:t,state:s,dispatch:i})=>{let r=null,o=null;const l=Vi(typeof n=="string"?n:n.name,s.schema);if(!l)return!1;l==="node"&&(r=ye(n,s.schema)),l==="mark"&&(o=vt(n,s.schema));let c=!1;return t.selection.ranges.forEach(d=>{const u=d.$from.pos,p=d.$to.pos;let f,h,g,b;t.selection.empty?s.doc.nodesBetween(u,p,(m,v)=>{r&&r===m.type&&(c=!0,g=Math.max(v,u),b=Math.min(v+m.nodeSize,p),f=v,h=m)}):s.doc.nodesBetween(u,p,(m,v)=>{v=u&&v<=p&&(r&&r===m.type&&(c=!0,i&&t.setNodeMarkup(v,void 0,{...m.attrs,...e})),o&&m.marks.length&&m.marks.forEach(S=>{if(o===S.type&&(c=!0,i)){const A=Math.max(v,u),N=Math.min(v+m.nodeSize,p);t.addMark(A,N,o.create({...S.attrs,...e}))}}))}),h&&(f!==void 0&&i&&t.setNodeMarkup(f,void 0,{...h.attrs,...e}),o&&h.marks.length&&h.marks.forEach(m=>{o===m.type&&i&&t.addMark(g,b,o.create({...m.attrs,...e}))}))}),c},bn=new me("__tiptap_decorations__"),tx=n=>({tr:e,dispatch:t})=>(t&&e.setMeta(bn,{type:"force",name:n}),!0),nx=(n,e={})=>({state:t,dispatch:s})=>{const i=ye(n,t.schema);return ay(i,e)(t,s)},sx=(n,e={})=>({state:t,dispatch:s})=>{const i=ye(n,t.schema);return cy(i,e)(t,s)};var ix=ev({blur:()=>b1,clearContent:()=>v1,clearNodes:()=>y1,command:()=>k1,createParagraphNear:()=>x1,cut:()=>w1,deleteCurrentNode:()=>S1,deleteNode:()=>C1,deleteRange:()=>M1,deleteSelection:()=>A1,enter:()=>O1,exitCode:()=>N1,extendMarkRange:()=>I1,first:()=>D1,focus:()=>R1,forEach:()=>L1,insertContent:()=>P1,insertContentAt:()=>B1,insertDefaultBlock:()=>_1,joinBackward:()=>F1,joinDown:()=>j1,joinForward:()=>V1,joinItemBackward:()=>H1,joinItemForward:()=>q1,joinTextblockBackward:()=>U1,joinTextblockForward:()=>W1,joinUp:()=>z1,keyboardShortcut:()=>J1,lift:()=>G1,liftEmptyBlock:()=>Y1,liftListItem:()=>X1,newlineInCode:()=>Z1,resetAttributes:()=>Q1,scrollIntoView:()=>ek,selectAll:()=>tk,selectNodeBackward:()=>nk,selectNodeForward:()=>sk,selectParentNode:()=>ik,selectTextblockEnd:()=>rk,selectTextblockStart:()=>ok,setContent:()=>lk,setMark:()=>$k,setMeta:()=>Rk,setNode:()=>Lk,setNodeSelection:()=>Pk,setTextDirection:()=>Bk,setTextSelection:()=>_k,sinkListItem:()=>zk,splitBlock:()=>jk,splitListItem:()=>Fk,toggleList:()=>Wk,toggleMark:()=>Kk,toggleNode:()=>Jk,toggleWrap:()=>Gk,undoInputRule:()=>Yk,unsetAllMarks:()=>Xk,unsetMark:()=>Zk,unsetTextDirection:()=>Qk,updateAttributes:()=>ex,updateDecorations:()=>tx,wrapIn:()=>nx,wrapInList:()=>sx});const Pn=new WeakMap;function rx(n,e){var t;Pn.set(n,((t=Pn.get(n))!==null&&t!==void 0?t:0)+1);try{return e()}finally{var s;const i=((s=Pn.get(n))!==null&&s!==void 0?s:1)-1;i>0?Pn.set(n,i):Pn.delete(n)}}var ox=class{constructor(){this.callbacks={}}on(n,e){return this.callbacks[n]||(this.callbacks[n]=[]),this.callbacks[n].push(e),this}emit(n,...e){const t=this.callbacks[n];return t&&t.forEach(s=>s.apply(this,e)),this}off(n,e){const t=this.callbacks[n];return t&&(e?this.callbacks[n]=t.filter(s=>s!==e):delete this.callbacks[n]),this}once(n,e){const t=(...s)=>{this.off(n,t),e.apply(this,s)};return this.on(n,t)}removeAllListeners(){this.callbacks={}}};function lx(n){return n.kind==="widget"}function Fd(n,e){const t=[],s=new Set;for(const i of n)i.kind==="widget"&&lx(i)&&s.add(i.key),t.push(i.toPMDecoration(e));return{decorations:t,widgetKeys:s}}function ax(n,e,t){const{decorations:s,widgetKeys:i}=Fd(e,t);return{set:ne.create(n,s),widgetKeys:i}}function Vd({position:n,from:e,to:t,docSize:s}){return nVd({position:o.anchor,from:e,to:t,docSize:s})?!0:(o.anchor===t||r.has(i)||(r.add(i),console.warn(`[tiptap warn]: Extension "${i}" returned a decoration outside the requested range [${e}, ${t}). It was ignored.`)),!1))}function dx(n){var e;const t=(e=n.spec)===null||e===void 0?void 0:e.key;return typeof t=="string"?t:void 0}function Hd(n){return n.jsonID==="attr"}function ux(n){let e=!1;if(n.getMap().forEach(()=>{e=!0}),e||Hd(n))return!0;const t=n;return typeof t.from=="number"&&typeof t.to=="number"}function px(n,e){let t=null,s=0,i=0;for(let r=0;re.to);r+=1){const o=i+n.child(r).nodeSize;o>=e.from&&(t===null&&(t=i),s=o),i=o}return t===null?null:{from:t,to:s}}function fx(n,e){if(n.steps.some(r=>!ux(r)))return{type:"full"};const t=qi(n).map(({newRange:r})=>r);n.steps.forEach((r,o)=>{if(!Hd(r))return;const l=n.mapping.slice(o);t.push({from:l.map(r.pos,-1),to:l.map(r.pos+1)})});const s=[];for(const r of t){const o=px(e,r);o&&s.push(o)}s.sort((r,o)=>r.from-o.from);const i=[];for(const r of s){const o=i[i.length-1];o&&r.from<=o.to?o.to=Math.max(o.to,r.to):i.push({...r})}return{type:"ranges",ranges:i}}function qd(n,e,t,s){return n.map(e,t,{onRemove:i=>{const r=i==null?void 0:i.key;typeof r=="string"&&s.delete(r)}})}function hx(n,e,t){var s,i;const r=(s=e.decorationSetsByExtension[n])!==null&&s!==void 0?s:ne.empty,o=new Set((i=e.widgetKeysByExtension[n])!==null&&i!==void 0?i:[]);return{set:qd(r,t.mapping,t.doc,o),widgetKeys:o}}function ea(n,e){const t=Object.values(e).flatMap(s=>s.find());return ne.create(n,t)}function ta(n){const e=new Set;for(const t of Object.values(n))for(const s of t)e.add(s);return e}function mx(n,e){var t;switch((t=e.update)!==null&&t!==void 0?t:"document"){case"document":if(e.createInRange)throw new Error(`[tiptap error]: Extension "${n}" provides createInRange() but does not use the "changedRanges" decoration update strategy.`);return;case"changedRanges":if(!e.createInRange)throw new Error(`[tiptap error]: Extension "${n}" uses the "changedRanges" decoration update strategy but does not provide createInRange().`);return;case"manual":if(e.createInRange)throw new Error(`[tiptap error]: Extension "${n}" uses the "manual" decoration update strategy, which is not compatible with createInRange(). createInRange() requires the "changedRanges" strategy.`);if(e.shouldUpdate)throw new Error(`[tiptap error]: Extension "${n}" cannot combine the "manual" decoration update strategy with shouldUpdate().`);return;default:throw new Error(`[tiptap error]: Extension "${n}" uses an unknown decoration update strategy. Expected "document", "changedRanges", or "manual".`)}}function gx(n,e,t){return t?!0:n.update==="manual"?!1:n.shouldUpdate?n.shouldUpdate(e):e.tr.docChanged}const bx=new Set;var vx=class{constructor(n){this.warnedWidgetKeys=new Set,this.warnedOutOfRangeExtensions=new Set,this.handleBeforeTransaction=({nextState:e})=>{const t=bn.getState(e);t&&this.warnDuplicateWidgetKeys(t)},this.editor=n.editor,this.entries=this.resolveEntries(n.entries),this.entries.forEach(({name:e,spec:t})=>mx(e,t)),this.plugin=this.entries.length>0?this.createPlugin():null,this.editor.on("beforeTransaction",this.handleBeforeTransaction)}destroy(){this.editor.off("beforeTransaction",this.handleBeforeTransaction)}liveWidgetKeys(){var n,e;return(n=(e=bn.getState(this.editor.state))===null||e===void 0?void 0:e.widgetKeys)!==null&&n!==void 0?n:bx}get mountedView(){return this.editor.isDestroyed?null:this.editor.view}resolveEntries(n){const e=[];for(const{name:t,addDecorations:s}of n){const i=s();i&&e.push({name:t,spec:i})}return e}createPlugin(){const{editor:n,entries:e}=this;return new oe({key:bn,state:{init:(t,s)=>{const i={},r={};for(const{name:l,spec:c}of e){const{set:d,widgetKeys:u}=this.buildFullSet(l,c,s);i[l]=d,r[l]=u}const o={decorationSetsByExtension:i,widgetKeysByExtension:r,mergedDecorationSet:this.buildMergedSet(s.doc,i),widgetKeys:ta(r)};return this.warnDuplicateWidgetKeys(o),o},apply:(t,s,i,r)=>{const o=t.getMeta(bn),l=(o==null?void 0:o.type)==="force"&&!o.name,c=(o==null?void 0:o.type)==="force"?o.name:void 0,d={},u={},p=new Set;return rx(n,()=>{for(const{name:f,spec:h}of e){const g=l||c===f;if(gx(h,{editor:n,tr:t,oldState:i,newState:r},g))if(h.update==="changedRanges"&&t.docChanged&&!g){const b=this.applyChangedRangesRecompute(f,h,s,t,r);d[f]=b.set,u[f]=b.widgetKeys,p.add(f)}else{const{set:b,widgetKeys:m}=this.buildFullSet(f,h,r);d[f]=b,u[f]=m,p.add(f)}else{const b=hx(f,s,t);d[f]=b.set,u[f]=b.widgetKeys}}}),p.size===0&&!t.docChanged?s:{decorationSetsByExtension:d,widgetKeysByExtension:u,mergedDecorationSet:this.mergeAfterApply({entries:e,previous:s,tr:t,decorationSetsByExtension:d,recomputedNames:p}),widgetKeys:ta(u)}}},props:{decorations(t){var s,i;return(s=(i=bn.getState(t))===null||i===void 0?void 0:i.mergedDecorationSet)!==null&&s!==void 0?s:ne.empty}}})}applyChangedRangesRecompute(n,e,t,s,i){const r=fx(s,i.doc);return r.type==="full"?this.buildFullSet(n,e,i):this.rebuildRanges(n,e,t,s,i,r.ranges)}rebuildRanges(n,e,t,s,i,r){var o,l;const c=(o=t.decorationSetsByExtension[n])!==null&&o!==void 0?o:ne.empty,d=new Set((l=t.widgetKeysByExtension[n])!==null&&l!==void 0?l:[]);let u=qd(c,s.mapping,s.doc,d);const p=i.doc.content.size;for(const{from:f,to:h}of r){const g=u.find(f,h).filter(v=>Vd({position:v.from,from:f,to:h,docSize:p}));for(const v of g){const S=dx(v);S&&d.delete(S)}u=u.remove(g);const{decorations:b,widgetKeys:m}=Fd(cx({decorations:this.runCreate(n,"createInRange",()=>e.createInRange({editor:this.editor,state:i,view:this.mountedView,from:f,to:h})),from:f,to:h,docSize:p,extensionName:n,warnedExtensions:this.warnedOutOfRangeExtensions}),n);u=u.add(i.doc,b);for(const v of m)d.add(v)}return{set:u,widgetKeys:d}}buildFullSet(n,e,t){const s=this.runCreate(n,"create",()=>e.create({editor:this.editor,state:t,view:this.mountedView}));return ax(t.doc,s,n)}runCreate(n,e,t){try{return t()}catch(s){return console.error(`[tiptap error]: Extension "${n}" threw in \`addDecorations().${e}()\`. Its decorations were dropped for this update.`,s),[]}}warnDuplicateWidgetKeys(n){}buildMergedSet(n,e){const t=Object.keys(e);return t.length===1?e[t[0]]:ea(n,e)}mergeAfterApply({entries:n,previous:e,tr:t,decorationSetsByExtension:s,recomputedNames:i}){return n.length===1?s[n[0].name]:i.size===0?e.mergedDecorationSet.map(t.mapping,t.doc):ea(t.doc,s)}};function yx(n,e){const{selection:t}=n,{$from:s}=t;if(t instanceof W){const r=s.index();return s.parent.canReplaceWith(r,r+1,e)}let i=s.depth;for(;i>=0;){const r=s.index(i);if(s.node(i).contentMatchAt(r).matchType(e))return!0;i-=1}return!1}function kx(n,e,t){const s=document.querySelector("style[data-tiptap-style]");if(s!==null)return s;const i=document.createElement("style");return e&&i.setAttribute("nonce",e),i.setAttribute("data-tiptap-style",""),i.innerHTML=n,document.getElementsByTagName("head")[0].appendChild(i),i}function xx(n){return typeof n=="number"}function wx(n){return Object.prototype.toString.call(n).slice(8,-1)}function Ns(n){return wx(n)!=="Object"?!1:n.constructor===Object&&Object.getPrototypeOf(n)===Object.prototype}function na(n,e,t){const s=n.split(` `),i=[];let r="",o=0;const l=e.baseIndentSize||2;for(;o0)break;if(u.trim()===""){o+=1,r=`${r}${u} `;continue}else return}const f=e.extractItemData(p),{indentLevel:h,mainContent:g}=f;r=`${r}${u} -`;const b=[g];for(o+=1;oB.trim()!=="");if(O===-1)break;if((((d=s[o+1+O].match(/^(\s*)/))===null||d===void 0||(d=d[1])===null||d===void 0?void 0:d.length)||0)>h){b.push(A),r=`${r}${A} +`;const b=[g];for(o+=1;oB.trim()!=="");if(N===-1)break;if((((d=s[o+1+N].match(/^(\s*)/))===null||d===void 0||(d=d[1])===null||d===void 0?void 0:d.length)||0)>h){b.push(A),r=`${r}${A} `,o+=1;continue}else break}if((((c=A.match(/^(\s*)/))===null||c===void 0||(c=c[1])===null||c===void 0?void 0:c.length)||0)>h)b.push(A),r=`${r}${A} -`,o+=1;else break}let m;const v=b.slice(1);if(v.length>0){const A=v.map(O=>O.slice(h+l)).join(` +`,o+=1;else break}let m;const v=b.slice(1);if(v.length>0){const A=v.map(N=>N.slice(h+l)).join(` `);A.trim()&&(e.customNestedParser?m=e.customNestedParser(A):m=t.blockTokens(A))}const S=e.createToken(f,m);i.push(S)}if(i.length!==0)return{items:i,raw:r}}const sa=4;function ia(n){let e=0;for(const t of n)e=t===" "?e+sa-e%sa:e+1;return e}function Ud(n,e,t,s,i){if(!n||!Array.isArray(n.content))return"";const r=typeof t=="function"?t(s):t,[o,...l]=n.content;let c=`${r}${e.renderChildren([o])}`;return l&&l.length>0&&l.forEach((d,u)=>{var p,f;const h=(p=(f=e.renderChild)===null||f===void 0?void 0:f.call(e,d,u+1))!==null&&p!==void 0?p:e.renderChildren([d]);if(h!=null){const g=m=>{if(!(i!=null&&i.alignNestedToPrefix))return e.indent(m);const v=e.indent(""),S=ia(r);return(ia(v)>=S?v:" ".repeat(S))+m},b=h.split(` `).map(m=>g(m||"")).join(` `);c+=d.type==="paragraph"?` ${b}`:` -${b}`}}),c}function Wd(n,e){const t={...n};return Ns(n)&&Ns(e)&&Object.keys(e).forEach(s=>{Ns(e[s])&&Ns(n[s])?t[s]=Wd(n[s],e[s]):t[s]=e[s]}),t}function wx(n,e,t={}){const{state:s}=e,{doc:i,tr:r}=s,o=n;i.descendants((l,c)=>{const d=r.mapping.map(c),u=r.mapping.map(c)+l.nodeSize;let p=null;if(l.marks.forEach(h=>{if(h!==o)return!1;p=h}),!p)return;let f=!1;if(Object.keys(t).forEach(h=>{t[h]!==p.attrs[h]&&(f=!0)}),f){const h=n.type.create({...n.attrs,...t});r.removeMark(d,u,n.type),r.addMark(d,u,h)}}),r.docChanged&&e.view.dispatch(r)}var ks=class{constructor(n){var e;this.find=n.find,this.handler=n.handler,this.undoable=(e=n.undoable)!==null&&e!==void 0?e:!0}};const Sx=(n,e)=>{if(vo(e))return e.exec(n);const t=e(n);if(!t)return null;const s=[t.text];return s.index=t.index,s.input=n,s.data=t.data,t.replaceWith&&(t.text.includes(t.replaceWith)||console.warn('[tiptap warn]: "inputRuleMatch.replaceWith" must be part of "inputRuleMatch.text".'),s.push(t.replaceWith)),s};function Cx(n){const{editor:e,from:t,to:s,text:i,insertText:r}=n;if(!r)return{inputTransaction:null,tr:e.view.state.tr};const o=e.view.state.tr.insertText(i,t,s);return{inputTransaction:o,tr:pt.create({doc:o.doc,selection:o.selection,storedMarks:o.storedMarks}).tr}}function Mx(n){const{editor:e,from:t,to:s,text:i,rule:r,match:o,plugin:l,insertText:c}=n,{view:d}=e,{inputTransaction:u,tr:p}=Cx({editor:e,from:t,to:s,text:i,insertText:c}),f=u?t+i.length:s,h=Fi({state:d.state,transaction:p}),g={from:t-(o[0].length-i.length),to:f},{commands:b,chain:m,can:v}=new xn({editor:e,state:h});return r.handler({state:h,range:g,match:o,commands:b,chain:m,can:v})===null||!p.steps.length?!1:(u&&(d.dispatch(u),!d.state.doc.eq(u.doc))||(f1(p),p.setMeta("inputRule",!0),r.undoable&&p.setMeta(l,{transform:p,from:t,to:f,text:i}),d.dispatch(p)),!0)}function Tx(n,e,t){const s=e[0].length-t.length;if(s<=0)return!0;const i=n.parentOffset-s;return i>=0&&n.parent.textBetween(i,n.parentOffset)===e[0].slice(0,s)}function Is(n){var e;const{editor:t,from:s,to:i,text:r,rules:o,plugin:l,insertText:c}=n,{view:d}=t;if(d.composing)return!1;const u=d.state.doc.resolve(s);if(u.parent.type.spec.code||!((e=u.nodeBefore||u.nodeAfter)===null||e===void 0)&&e.marks.find(f=>f.type.spec.code))return!1;const p=Sk(u)+r;for(const f of o){const h=Sx(p,f.find);if(!(!h||!Tx(u,h,r))&&Mx({editor:t,from:s,to:i,text:r,rule:f,match:h,plugin:l,insertText:c}))return!0}return!1}function Ex(n){const{editor:e,rules:t}=n,s=new oe({state:{init(){return null},apply(i,r,o){const l=i.getMeta(s);if(l)return l;const c=i.getMeta("applyInputRules");return c&&setTimeout(()=>{let{text:d}=c;typeof d=="string"?d=d:d=xo($.from(d),o.schema);const{from:u}=c,p=u+d.length;Is({editor:e,from:u,to:p,text:d,rules:t,plugin:s})}),i.selectionSet||i.docChanged?null:r}},props:{handleTextInput(i,r,o,l){return Is({editor:e,from:r,to:o,text:l,rules:t,plugin:s,insertText:!0})},handleDOMEvents:{compositionend:i=>(setTimeout(()=>{const{$cursor:r}=i.state.selection;r&&Is({editor:e,from:r.pos,to:r.pos,text:"",rules:t,plugin:s})}),!1)},handleKeyDown(i,r){if(r.key!=="Enter")return!1;const{$cursor:o}=i.state.selection;return o?Is({editor:e,from:o.pos,to:o.pos,text:` -`,rules:t,plugin:s}):!1}},isInputRules:!0});return s}var Co=class{constructor(n={}){this.type="extendable",this.parent=null,this.child=null,this.name="",this.config={name:this.name},this.config={...this.config,...n},this.name=this.config.name}get options(){return{...se(V(this,"addOptions",{name:this.name}))}}get storage(){return{...se(V(this,"addStorage",{name:this.name,options:this.options}))}}configure(n={}){const e=this.extend({...this.config,addOptions:()=>Wd(this.options,n)});return e.name=this.name,e.parent=this.parent,this.child=null,e}extend(n={}){const e=new this.constructor({...this.config,...n});return e.parent=this,this.child=e,e.name="name"in n?n.name:e.parent.name,e}},an=class Kd extends Co{constructor(...e){super(...e),this.type="mark"}static create(e={}){const t=typeof e=="function"?e():e;return new Kd(t)}static handleExit({editor:e,mark:t}){const{tr:s}=e.state,i=e.state.selection.$from;if(i.pos===i.end()){const r=i.marks();if(!r.find(l=>(l==null?void 0:l.type.name)===t.name))return!1;const o=r.find(l=>(l==null?void 0:l.type.name)===t.name);return o&&s.removeStoredMark(o),s.insertText(" ",i.pos),e.view.dispatch(s),!0}return!1}configure(e){return super.configure(e)}extend(e){const t=typeof e=="function"?e():e;return super.extend(t)}},Jd=class{constructor(n){this.find=n.find,this.handler=n.handler}};const Ax=(n,e,t)=>{if(vo(e))return[...n.matchAll(e)];const s=e(n,t);return s?s.map(i=>{const r=[i.text];return r.index=i.index,r.input=n,r.data=i.data,i.replaceWith&&(i.text.includes(i.replaceWith)||console.warn('[tiptap warn]: "pasteRuleMatch.replaceWith" must be part of "pasteRuleMatch.text".'),r.push(i.replaceWith)),r}):[]};function Ox(n){const{editor:e,state:t,from:s,to:i,rule:r,pasteEvent:o,dropEvent:l}=n,{commands:c,chain:d,can:u}=new xn({editor:e,state:t}),p=[];return t.doc.nodesBetween(s,i,(f,h)=>{var g,b,m,v;if(!((g=f.type)===null||g===void 0||(g=g.spec)===null||g===void 0)&&g.code||!(f.isText||f.isTextblock||f.isInline))return;const S=(b=(m=(v=f.content)===null||v===void 0?void 0:v.size)!==null&&m!==void 0?m:f.nodeSize)!==null&&b!==void 0?b:0,A=Math.max(s,h),O=Math.min(i,h+S);if(A>=O)return;const B=f.isText?f.text||"":f.textBetween(A-h,O-h,void 0,"");Ax(B,r.find,o).forEach(E=>{if(E.index===void 0)return;const M=A+E.index+1,w=M+E[0].length,T={from:t.tr.mapping.map(M),to:t.tr.mapping.map(w)},N=r.handler({state:t,range:T,match:E,commands:c,chain:d,can:u,pasteEvent:o,dropEvent:l});p.push(N)})}),p.every(f=>f!==null)}let hn=null;const Nx=n=>{var e;const t=new ClipboardEvent("paste",{clipboardData:new DataTransfer});return(e=t.clipboardData)===null||e===void 0||e.setData("text/html",n),t};function Ix(n){const{editor:e,rules:t}=n;let s=null,i=!1,r=!1,o=typeof ClipboardEvent!="undefined"?new ClipboardEvent("paste"):null,l;try{l=typeof DragEvent!="undefined"?new DragEvent("drop"):null}catch(d){l=null}const c=({state:d,from:u,to:p,rule:f,pasteEvt:h})=>{const g=d.tr,b=Fi({state:d,transaction:g});if(!(!Ox({editor:e,state:b,from:Math.max(u-1,0),to:p.b-1,rule:f,pasteEvent:h,dropEvent:l})||!g.steps.length)){try{l=typeof DragEvent!="undefined"?new DragEvent("drop"):null}catch(m){l=null}return o=typeof ClipboardEvent!="undefined"?new ClipboardEvent("paste"):null,g}};return e.on("destroy",()=>{hn===e&&(hn=null)}),t.map(d=>new oe({view(u){const p=h=>{var g;s=!((g=u.dom.parentElement)===null||g===void 0)&&g.contains(h.target)?u.dom.parentElement:null,s&&(hn=e)},f=()=>{hn&&(hn=null)};return window.addEventListener("dragstart",p),window.addEventListener("dragend",f),{destroy(){window.removeEventListener("dragstart",p),window.removeEventListener("dragend",f)}}},props:{handleDOMEvents:{drop:(u,p)=>{if(r=s===u.dom.parentElement,l=p,!r){const f=hn;f!=null&&f.isEditable&&setTimeout(()=>{if(f.isDestroyed)return;const h=f.state.selection;h&&f.commands.deleteRange({from:h.from,to:h.to})},10)}return!1},paste:(u,p)=>{var f;const h=(f=p.clipboardData)===null||f===void 0?void 0:f.getData("text/html");return o=p,i=!!(h!=null&&h.includes("data-pm-slice")),!1}}},appendTransaction:(u,p,f)=>{const h=u[0],g=h.getMeta("uiEvent")==="paste"&&!i,b=h.getMeta("uiEvent")==="drop"&&!r,m=h.getMeta("applyPasteRules"),v=!!m;if(!g&&!b&&!v)return;if(v){let{text:O}=m;typeof O=="string"?O=O:O=xo($.from(O),f.schema);const{from:B}=m,E=B+O.length,M=Nx(O);return c({rule:d,state:f,from:B,to:{b:E},pasteEvt:M})}const S=p.doc.content.findDiffStart(f.doc.content),A=p.doc.content.findDiffEnd(f.doc.content);if(!(!kx(S)||!A||S===A.b))return c({rule:d,state:f,from:S,to:A,pasteEvt:o})}}))}var Wi=class{constructor(n,e){this.splittableMarks=[],this.nonClearableMarks=[],this.decorationManager=null,this.editor=e,this.baseExtensions=n,this.extensions=Id(n),this.hasSchemaSpec=e.options.schemaSpec!==void 0,this.schema=gk(this.extensions,e,e.options.schemaSpec),this.setupExtensions()}get commands(){return this.extensions.reduce((n,e)=>{const t=V(e,"addCommands",{name:e.name,options:e.options,storage:this.editor.extensionStorage[e.name],editor:this.editor,type:fn(e.name,this.schema)});return t?{...n,...t()}:n},{})}get plugins(){const{editor:n}=this,e=Kn([...this.extensions].reverse()).flatMap(s=>{const i={name:s.name,options:s.options,storage:this.editor.extensionStorage[s.name],editor:n,type:fn(s.name,this.schema)},r=[],o=V(s,"addKeyboardShortcuts",i);let l={};if(s.type==="mark"&&V(s,"exitable",i)&&(l.ArrowRight=()=>an.handleExit({editor:n,mark:s})),o){const f=Object.fromEntries(Object.entries(o()).map(([h,g])=>[h,()=>g({editor:n})]));l={...l,...f}}const c=r1(l);r.push(c);const d=V(s,"addInputRules",i);if(Yl(s,n.options.enableInputRules)&&d){const f=d();if(f&&f.length){const h=Ex({editor:n,rules:f}),g=Array.isArray(h)?h:[h];r.push(...g)}}const u=V(s,"addPasteRules",i);if(Yl(s,n.options.enablePasteRules)&&u){const f=u();if(f&&f.length){const h=Ix({editor:n,rules:f});r.push(...h)}}const p=V(s,"addProseMirrorPlugins",i);if(p){const f=p();r.push(...f)}return r}),t=this.createDecorationPlugin();return t&&e.push(t),e}createDecorationPlugin(){var n;const{editor:e}=this;(n=this.decorationManager)===null||n===void 0||n.destroy();const t=[];return this.extensions.forEach(s=>{const i=V(s,"addDecorations",{name:s.name,options:s.options,storage:this.editor.extensionStorage[s.name],editor:e,type:fn(s.name,this.schema)});i&&t.push({name:s.name,addDecorations:i})}),this.decorationManager=new bx({editor:e,entries:t}),this.decorationManager.plugin}get attributes(){const n=wo(this.extensions);return this.hasSchemaSpec?Od(n,this.schema):n}get nodeViews(){const{editor:n}=this,{nodeExtensions:e}=An(this.extensions);return Object.fromEntries(e.filter(t=>!!V(t,"addNodeView")).map(t=>{const s=this.attributes.filter(l=>l.type===t.name),i=V(t,"addNodeView",{name:t.name,options:t.options,storage:this.editor.extensionStorage[t.name],editor:n,type:ye(t.name,this.schema)});if(!i)return[];const r=i();if(!r)return[];const o=(l,c,d,u,p)=>{const f=ps(l,s);return r({node:l,view:c,getPos:d,decorations:u,innerDecorations:p,editor:n,extension:t,HTMLAttributes:f})};return[t.name,o]}))}dispatchTransaction(n){const{editor:e}=this;return Kn([...this.extensions].reverse()).reduceRight((t,s)=>{const i={name:s.name,options:s.options,storage:this.editor.extensionStorage[s.name],editor:e,type:fn(s.name,this.schema)},r=V(s,"dispatchTransaction",i);return r?o=>{r.call(i,{transaction:o,next:t})}:t},n)}transformPastedHTML(n){const{editor:e}=this;return Kn([...this.extensions]).reduce((t,s)=>{const i={name:s.name,options:s.options,storage:this.editor.extensionStorage[s.name],editor:e,type:fn(s.name,this.schema)},r=V(s,"transformPastedHTML",i);return r?(o,l)=>{const c=t(o,l);return r.call(i,c)}:t},n||(t=>t))}get markViews(){const{editor:n}=this,{markExtensions:e}=An(this.extensions);return Object.fromEntries(e.filter(t=>!!V(t,"addMarkView")).map(t=>{const s=this.attributes.filter(o=>o.type===t.name),i=V(t,"addMarkView",{name:t.name,options:t.options,storage:this.editor.extensionStorage[t.name],editor:n,type:vt(t.name,this.schema)});if(!i)return[];const r=(o,l,c)=>{const d=ps(o,s);return i()({mark:o,view:l,inline:c,editor:n,extension:t,HTMLAttributes:d,updateAttributes:u=>{wx(o,n,u)}})};return[t.name,r]}))}destroy(){var n;(n=this.decorationManager)===null||n===void 0||n.destroy(),this.extensions.forEach(e=>{let t=e;for(;t.parent;){const s=t.parent;s.child===t&&(s.child=null),t=s}}),this.extensions=[],this.baseExtensions=[],this.decorationManager=null,this.schema=null,this.editor=null}setupExtensions(){const n=this.extensions;this.editor.extensionStorage=Object.fromEntries(n.map(e=>[e.name,e.storage])),n.forEach(e=>{const t={name:e.name,options:e.options,storage:this.editor.extensionStorage[e.name],editor:this.editor,type:fn(e.name,this.schema)};if(e.type==="mark"){var s,i;(!((s=se(V(e,"keepOnSplit",t)))!==null&&s!==void 0)||s)&&this.splittableMarks.push(e.name),!((i=se(V(e,"clearable",t)))!==null&&i!==void 0)||i||this.nonClearableMarks.push(e.name)}const r=V(e,"onBeforeCreate",t),o=V(e,"onCreate",t),l=V(e,"onUpdate",t),c=V(e,"onSelectionUpdate",t),d=V(e,"onTransaction",t),u=V(e,"onFocus",t),p=V(e,"onBlur",t),f=V(e,"onDestroy",t);r&&this.editor.on("beforeCreate",r),o&&this.editor.on("create",o),l&&this.editor.on("update",l),c&&this.editor.on("selectionUpdate",c),d&&this.editor.on("transaction",d),u&&this.editor.on("focus",u),p&&this.editor.on("blur",p),f&&this.editor.on("destroy",f)})}};Wi.resolve=Id;Wi.sort=Kn;Wi.flatten=ko;var pe=class Gd extends Co{constructor(...e){super(...e),this.type="extension"}static create(e={}){const t=typeof e=="function"?e():e;return new Gd(t)}configure(e){return super.configure(e)}extend(e){const t=typeof e=="function"?e():e;return super.extend(t)}};const Dx=pe.create({name:"clipboardTextSerializer",addOptions(){return{blockSeparator:void 0}},addProseMirrorPlugins(){return[new oe({key:new me("clipboardTextSerializer"),props:{clipboardTextSerializer:()=>{const{editor:n}=this,{state:e,schema:t}=n,{doc:s,selection:i}=e,r=$d(t),{blockSeparator:o}=this.options,l={...o!==void 0?{blockSeparator:o}:{},textSerializers:r};return[...i.ranges].sort((c,d)=>c.$from.pos-d.$from.pos).map(({$from:c,$to:d})=>Dd(s,{from:c.pos,to:d.pos},l)).join(o!=null?o:` +${b}`}}),c}function Wd(n,e){const t={...n};return Ns(n)&&Ns(e)&&Object.keys(e).forEach(s=>{Ns(e[s])&&Ns(n[s])?t[s]=Wd(n[s],e[s]):t[s]=e[s]}),t}function Sx(n,e,t={}){const{state:s}=e,{doc:i,tr:r}=s,o=n;i.descendants((l,c)=>{const d=r.mapping.map(c),u=r.mapping.map(c)+l.nodeSize;let p=null;if(l.marks.forEach(h=>{if(h!==o)return!1;p=h}),!p)return;let f=!1;if(Object.keys(t).forEach(h=>{t[h]!==p.attrs[h]&&(f=!0)}),f){const h=n.type.create({...n.attrs,...t});r.removeMark(d,u,n.type),r.addMark(d,u,h)}}),r.docChanged&&e.view.dispatch(r)}var ks=class{constructor(n){var e;this.find=n.find,this.handler=n.handler,this.undoable=(e=n.undoable)!==null&&e!==void 0?e:!0}};const Cx=(n,e)=>{if(vo(e))return e.exec(n);const t=e(n);if(!t)return null;const s=[t.text];return s.index=t.index,s.input=n,s.data=t.data,t.replaceWith&&(t.text.includes(t.replaceWith)||console.warn('[tiptap warn]: "inputRuleMatch.replaceWith" must be part of "inputRuleMatch.text".'),s.push(t.replaceWith)),s};function Mx(n){const{editor:e,from:t,to:s,text:i,insertText:r}=n;if(!r)return{inputTransaction:null,tr:e.view.state.tr};const o=e.view.state.tr.insertText(i,t,s);return{inputTransaction:o,tr:pt.create({doc:o.doc,selection:o.selection,storedMarks:o.storedMarks}).tr}}function Tx(n){const{editor:e,from:t,to:s,text:i,rule:r,match:o,plugin:l,insertText:c}=n,{view:d}=e,{inputTransaction:u,tr:p}=Mx({editor:e,from:t,to:s,text:i,insertText:c}),f=u?t+i.length:s,h=Fi({state:d.state,transaction:p}),g={from:t-(o[0].length-i.length),to:f},{commands:b,chain:m,can:v}=new xn({editor:e,state:h});return r.handler({state:h,range:g,match:o,commands:b,chain:m,can:v})===null||!p.steps.length?!1:(u&&(d.dispatch(u),!d.state.doc.eq(u.doc))||(h1(p),p.setMeta("inputRule",!0),r.undoable&&p.setMeta(l,{transform:p,from:t,to:f,text:i}),d.dispatch(p)),!0)}function Ex(n,e,t){const s=e[0].length-t.length;if(s<=0)return!0;const i=n.parentOffset-s;return i>=0&&n.parent.textBetween(i,n.parentOffset)===e[0].slice(0,s)}function Is(n){var e;const{editor:t,from:s,to:i,text:r,rules:o,plugin:l,insertText:c}=n,{view:d}=t;if(d.composing)return!1;const u=d.state.doc.resolve(s);if(u.parent.type.spec.code||!((e=u.nodeBefore||u.nodeAfter)===null||e===void 0)&&e.marks.find(f=>f.type.spec.code))return!1;const p=Ck(u)+r;for(const f of o){const h=Cx(p,f.find);if(!(!h||!Ex(u,h,r))&&Tx({editor:t,from:s,to:i,text:r,rule:f,match:h,plugin:l,insertText:c}))return!0}return!1}function Ax(n){const{editor:e,rules:t}=n,s=new oe({state:{init(){return null},apply(i,r,o){const l=i.getMeta(s);if(l)return l;const c=i.getMeta("applyInputRules");return c&&setTimeout(()=>{let{text:d}=c;typeof d=="string"?d=d:d=xo($.from(d),o.schema);const{from:u}=c,p=u+d.length;Is({editor:e,from:u,to:p,text:d,rules:t,plugin:s})}),i.selectionSet||i.docChanged?null:r}},props:{handleTextInput(i,r,o,l){return Is({editor:e,from:r,to:o,text:l,rules:t,plugin:s,insertText:!0})},handleDOMEvents:{compositionend:i=>(setTimeout(()=>{const{$cursor:r}=i.state.selection;r&&Is({editor:e,from:r.pos,to:r.pos,text:"",rules:t,plugin:s})}),!1)},handleKeyDown(i,r){if(r.key!=="Enter")return!1;const{$cursor:o}=i.state.selection;return o?Is({editor:e,from:o.pos,to:o.pos,text:` +`,rules:t,plugin:s}):!1}},isInputRules:!0});return s}var Co=class{constructor(n={}){this.type="extendable",this.parent=null,this.child=null,this.name="",this.config={name:this.name},this.config={...this.config,...n},this.name=this.config.name}get options(){return{...se(V(this,"addOptions",{name:this.name}))}}get storage(){return{...se(V(this,"addStorage",{name:this.name,options:this.options}))}}configure(n={}){const e=this.extend({...this.config,addOptions:()=>Wd(this.options,n)});return e.name=this.name,e.parent=this.parent,this.child=null,e}extend(n={}){const e=new this.constructor({...this.config,...n});return e.parent=this,this.child=e,e.name="name"in n?n.name:e.parent.name,e}},an=class Kd extends Co{constructor(...e){super(...e),this.type="mark"}static create(e={}){const t=typeof e=="function"?e():e;return new Kd(t)}static handleExit({editor:e,mark:t}){const{tr:s}=e.state,i=e.state.selection.$from;if(i.pos===i.end()){const r=i.marks();if(!r.find(l=>(l==null?void 0:l.type.name)===t.name))return!1;const o=r.find(l=>(l==null?void 0:l.type.name)===t.name);return o&&s.removeStoredMark(o),s.insertText(" ",i.pos),e.view.dispatch(s),!0}return!1}configure(e){return super.configure(e)}extend(e){const t=typeof e=="function"?e():e;return super.extend(t)}},Jd=class{constructor(n){this.find=n.find,this.handler=n.handler}};const Ox=(n,e,t)=>{if(vo(e))return[...n.matchAll(e)];const s=e(n,t);return s?s.map(i=>{const r=[i.text];return r.index=i.index,r.input=n,r.data=i.data,i.replaceWith&&(i.text.includes(i.replaceWith)||console.warn('[tiptap warn]: "pasteRuleMatch.replaceWith" must be part of "pasteRuleMatch.text".'),r.push(i.replaceWith)),r}):[]};function Nx(n){const{editor:e,state:t,from:s,to:i,rule:r,pasteEvent:o,dropEvent:l}=n,{commands:c,chain:d,can:u}=new xn({editor:e,state:t}),p=[];return t.doc.nodesBetween(s,i,(f,h)=>{var g,b,m,v;if(!((g=f.type)===null||g===void 0||(g=g.spec)===null||g===void 0)&&g.code||!(f.isText||f.isTextblock||f.isInline))return;const S=(b=(m=(v=f.content)===null||v===void 0?void 0:v.size)!==null&&m!==void 0?m:f.nodeSize)!==null&&b!==void 0?b:0,A=Math.max(s,h),N=Math.min(i,h+S);if(A>=N)return;const B=f.isText?f.text||"":f.textBetween(A-h,N-h,void 0,"");Ox(B,r.find,o).forEach(E=>{if(E.index===void 0)return;const M=A+E.index+1,w=M+E[0].length,T={from:t.tr.mapping.map(M),to:t.tr.mapping.map(w)},O=r.handler({state:t,range:T,match:E,commands:c,chain:d,can:u,pasteEvent:o,dropEvent:l});p.push(O)})}),p.every(f=>f!==null)}let hn=null;const Ix=n=>{var e;const t=new ClipboardEvent("paste",{clipboardData:new DataTransfer});return(e=t.clipboardData)===null||e===void 0||e.setData("text/html",n),t};function Dx(n){const{editor:e,rules:t}=n;let s=null,i=!1,r=!1,o=typeof ClipboardEvent!="undefined"?new ClipboardEvent("paste"):null,l;try{l=typeof DragEvent!="undefined"?new DragEvent("drop"):null}catch(d){l=null}const c=({state:d,from:u,to:p,rule:f,pasteEvt:h})=>{const g=d.tr,b=Fi({state:d,transaction:g});if(!(!Nx({editor:e,state:b,from:Math.max(u-1,0),to:p.b-1,rule:f,pasteEvent:h,dropEvent:l})||!g.steps.length)){try{l=typeof DragEvent!="undefined"?new DragEvent("drop"):null}catch(m){l=null}return o=typeof ClipboardEvent!="undefined"?new ClipboardEvent("paste"):null,g}};return e.on("destroy",()=>{hn===e&&(hn=null)}),t.map(d=>new oe({view(u){const p=h=>{var g;s=!((g=u.dom.parentElement)===null||g===void 0)&&g.contains(h.target)?u.dom.parentElement:null,s&&(hn=e)},f=()=>{hn&&(hn=null)};return window.addEventListener("dragstart",p),window.addEventListener("dragend",f),{destroy(){window.removeEventListener("dragstart",p),window.removeEventListener("dragend",f)}}},props:{handleDOMEvents:{drop:(u,p)=>{if(r=s===u.dom.parentElement,l=p,!r){const f=hn;f!=null&&f.isEditable&&setTimeout(()=>{if(f.isDestroyed)return;const h=f.state.selection;h&&f.commands.deleteRange({from:h.from,to:h.to})},10)}return!1},paste:(u,p)=>{var f;const h=(f=p.clipboardData)===null||f===void 0?void 0:f.getData("text/html");return o=p,i=!!(h!=null&&h.includes("data-pm-slice")),!1}}},appendTransaction:(u,p,f)=>{const h=u[0],g=h.getMeta("uiEvent")==="paste"&&!i,b=h.getMeta("uiEvent")==="drop"&&!r,m=h.getMeta("applyPasteRules"),v=!!m;if(!g&&!b&&!v)return;if(v){let{text:N}=m;typeof N=="string"?N=N:N=xo($.from(N),f.schema);const{from:B}=m,E=B+N.length,M=Ix(N);return c({rule:d,state:f,from:B,to:{b:E},pasteEvt:M})}const S=p.doc.content.findDiffStart(f.doc.content),A=p.doc.content.findDiffEnd(f.doc.content);if(!(!xx(S)||!A||S===A.b))return c({rule:d,state:f,from:S,to:A,pasteEvt:o})}}))}var Wi=class{constructor(n,e){this.splittableMarks=[],this.nonClearableMarks=[],this.decorationManager=null,this.editor=e,this.baseExtensions=n,this.extensions=Id(n),this.hasSchemaSpec=e.options.schemaSpec!==void 0,this.schema=bk(this.extensions,e,e.options.schemaSpec),this.setupExtensions()}get commands(){return this.extensions.reduce((n,e)=>{const t=V(e,"addCommands",{name:e.name,options:e.options,storage:this.editor.extensionStorage[e.name],editor:this.editor,type:fn(e.name,this.schema)});return t?{...n,...t()}:n},{})}get plugins(){const{editor:n}=this,e=Kn([...this.extensions].reverse()).flatMap(s=>{const i={name:s.name,options:s.options,storage:this.editor.extensionStorage[s.name],editor:n,type:fn(s.name,this.schema)},r=[],o=V(s,"addKeyboardShortcuts",i);let l={};if(s.type==="mark"&&V(s,"exitable",i)&&(l.ArrowRight=()=>an.handleExit({editor:n,mark:s})),o){const f=Object.fromEntries(Object.entries(o()).map(([h,g])=>[h,()=>g({editor:n})]));l={...l,...f}}const c=o1(l);r.push(c);const d=V(s,"addInputRules",i);if(Yl(s,n.options.enableInputRules)&&d){const f=d();if(f&&f.length){const h=Ax({editor:n,rules:f}),g=Array.isArray(h)?h:[h];r.push(...g)}}const u=V(s,"addPasteRules",i);if(Yl(s,n.options.enablePasteRules)&&u){const f=u();if(f&&f.length){const h=Dx({editor:n,rules:f});r.push(...h)}}const p=V(s,"addProseMirrorPlugins",i);if(p){const f=p();r.push(...f)}return r}),t=this.createDecorationPlugin();return t&&e.push(t),e}createDecorationPlugin(){var n;const{editor:e}=this;(n=this.decorationManager)===null||n===void 0||n.destroy();const t=[];return this.extensions.forEach(s=>{const i=V(s,"addDecorations",{name:s.name,options:s.options,storage:this.editor.extensionStorage[s.name],editor:e,type:fn(s.name,this.schema)});i&&t.push({name:s.name,addDecorations:i})}),this.decorationManager=new vx({editor:e,entries:t}),this.decorationManager.plugin}get attributes(){const n=wo(this.extensions);return this.hasSchemaSpec?Od(n,this.schema):n}get nodeViews(){const{editor:n}=this,{nodeExtensions:e}=An(this.extensions);return Object.fromEntries(e.filter(t=>!!V(t,"addNodeView")).map(t=>{const s=this.attributes.filter(l=>l.type===t.name),i=V(t,"addNodeView",{name:t.name,options:t.options,storage:this.editor.extensionStorage[t.name],editor:n,type:ye(t.name,this.schema)});if(!i)return[];const r=i();if(!r)return[];const o=(l,c,d,u,p)=>{const f=ps(l,s);return r({node:l,view:c,getPos:d,decorations:u,innerDecorations:p,editor:n,extension:t,HTMLAttributes:f})};return[t.name,o]}))}dispatchTransaction(n){const{editor:e}=this;return Kn([...this.extensions].reverse()).reduceRight((t,s)=>{const i={name:s.name,options:s.options,storage:this.editor.extensionStorage[s.name],editor:e,type:fn(s.name,this.schema)},r=V(s,"dispatchTransaction",i);return r?o=>{r.call(i,{transaction:o,next:t})}:t},n)}transformPastedHTML(n){const{editor:e}=this;return Kn([...this.extensions]).reduce((t,s)=>{const i={name:s.name,options:s.options,storage:this.editor.extensionStorage[s.name],editor:e,type:fn(s.name,this.schema)},r=V(s,"transformPastedHTML",i);return r?(o,l)=>{const c=t(o,l);return r.call(i,c)}:t},n||(t=>t))}get markViews(){const{editor:n}=this,{markExtensions:e}=An(this.extensions);return Object.fromEntries(e.filter(t=>!!V(t,"addMarkView")).map(t=>{const s=this.attributes.filter(o=>o.type===t.name),i=V(t,"addMarkView",{name:t.name,options:t.options,storage:this.editor.extensionStorage[t.name],editor:n,type:vt(t.name,this.schema)});if(!i)return[];const r=(o,l,c)=>{const d=ps(o,s);return i()({mark:o,view:l,inline:c,editor:n,extension:t,HTMLAttributes:d,updateAttributes:u=>{Sx(o,n,u)}})};return[t.name,r]}))}destroy(){var n;(n=this.decorationManager)===null||n===void 0||n.destroy(),this.extensions.forEach(e=>{let t=e;for(;t.parent;){const s=t.parent;s.child===t&&(s.child=null),t=s}}),this.extensions=[],this.baseExtensions=[],this.decorationManager=null,this.schema=null,this.editor=null}setupExtensions(){const n=this.extensions;this.editor.extensionStorage=Object.fromEntries(n.map(e=>[e.name,e.storage])),n.forEach(e=>{const t={name:e.name,options:e.options,storage:this.editor.extensionStorage[e.name],editor:this.editor,type:fn(e.name,this.schema)};if(e.type==="mark"){var s,i;(!((s=se(V(e,"keepOnSplit",t)))!==null&&s!==void 0)||s)&&this.splittableMarks.push(e.name),!((i=se(V(e,"clearable",t)))!==null&&i!==void 0)||i||this.nonClearableMarks.push(e.name)}const r=V(e,"onBeforeCreate",t),o=V(e,"onCreate",t),l=V(e,"onUpdate",t),c=V(e,"onSelectionUpdate",t),d=V(e,"onTransaction",t),u=V(e,"onFocus",t),p=V(e,"onBlur",t),f=V(e,"onDestroy",t);r&&this.editor.on("beforeCreate",r),o&&this.editor.on("create",o),l&&this.editor.on("update",l),c&&this.editor.on("selectionUpdate",c),d&&this.editor.on("transaction",d),u&&this.editor.on("focus",u),p&&this.editor.on("blur",p),f&&this.editor.on("destroy",f)})}};Wi.resolve=Id;Wi.sort=Kn;Wi.flatten=ko;var pe=class Gd extends Co{constructor(...e){super(...e),this.type="extension"}static create(e={}){const t=typeof e=="function"?e():e;return new Gd(t)}configure(e){return super.configure(e)}extend(e){const t=typeof e=="function"?e():e;return super.extend(t)}};const $x=pe.create({name:"clipboardTextSerializer",addOptions(){return{blockSeparator:void 0}},addProseMirrorPlugins(){return[new oe({key:new me("clipboardTextSerializer"),props:{clipboardTextSerializer:()=>{const{editor:n}=this,{state:e,schema:t}=n,{doc:s,selection:i}=e,r=$d(t),{blockSeparator:o}=this.options,l={...o!==void 0?{blockSeparator:o}:{},textSerializers:r};return[...i.ranges].sort((c,d)=>c.$from.pos-d.$from.pos).map(({$from:c,$to:d})=>Dd(s,{from:c.pos,to:d.pos},l)).join(o!=null?o:` -`)}}})]}}),$x=pe.create({name:"commands",addCommands(){return{...sx}}}),Rx=pe.create({name:"delete",onUpdate({transaction:n,appendedTransactions:e}){var t,s;const i=()=>{var r,o,l;if((r=(o=this.editor.options.coreExtensionOptions)===null||o===void 0||(o=o.delete)===null||o===void 0||(l=o.filterTransaction)===null||l===void 0?void 0:l.call(o,n))!==null&&r!==void 0?r:n.getMeta("y-sync$"))return;const c=Ad(n.before,[n,...e]);qi(c).forEach(u=>{c.mapping.mapResult(u.oldRange.from).deletedAfter&&c.mapping.mapResult(u.oldRange.to).deletedBefore&&c.before.nodesBetween(u.oldRange.from,u.oldRange.to,(p,f)=>{const h=f+p.nodeSize-2,g=u.oldRange.from<=f&&h<=u.oldRange.to;this.editor.emit("delete",{type:"node",node:p,from:f,to:h,newFrom:c.mapping.map(f),newTo:c.mapping.map(h),deletedRange:u.oldRange,newRange:u.newRange,partial:!g,editor:this.editor,transaction:n,combinedTransform:c})})});const d=c.mapping;c.steps.forEach((u,p)=>{if(u instanceof Xe){var f,h;const g=d.slice(p).map(u.from,-1),b=d.slice(p).map(u.to),m=d.invert().map(g,-1),v=d.invert().map(b),S=g>0?(f=c.doc.nodeAt(g-1))===null||f===void 0?void 0:f.marks.some(O=>O.eq(u.mark)):!1,A=(h=c.doc.nodeAt(b))===null||h===void 0?void 0:h.marks.some(O=>O.eq(u.mark));this.editor.emit("delete",{type:"mark",mark:u.mark,from:u.from,to:u.to,deletedRange:{from:m,to:v},newRange:{from:g,to:b},partial:!!(A||S),editor:this.editor,transaction:n,combinedTransform:c})}})};!((t=(s=this.editor.options.coreExtensionOptions)===null||s===void 0||(s=s.delete)===null||s===void 0?void 0:s.async)!==null&&t!==void 0)||t?setTimeout(i,0):i()}}),Lx=pe.create({name:"drop",addProseMirrorPlugins(){return[new oe({key:new me("tiptapDrop"),props:{handleDrop:(n,e,t,s)=>{this.editor.emit("drop",{editor:this.editor,event:e,slice:t,moved:s})}}})]}}),Px=pe.create({name:"editable",addProseMirrorPlugins(){return[new oe({key:new me("editable"),props:{editable:()=>this.editor.options.editable}})]}}),Bx=new me("focusEvents"),_x=pe.create({name:"focusEvents",addProseMirrorPlugins(){const{editor:n}=this;return[new oe({key:Bx,props:{handleDOMEvents:{focus:(e,t)=>{n.isFocused=!0;const s=n.state.tr.setMeta("focus",{event:t}).setMeta("addToHistory",!1);return e.dispatch(s),!1},blur:(e,t)=>{n.isFocused=!1;const s=n.state.tr.setMeta("blur",{event:t}).setMeta("addToHistory",!1);return e.dispatch(s),!1}}}})]}}),zx=pe.create({name:"keymap",addKeyboardShortcuts(){const n=()=>this.editor.commands.first(({commands:o})=>[()=>o.undoInputRule(),()=>o.command(({tr:l})=>{const{selection:c,doc:d}=l,{empty:u,$anchor:p}=c,{pos:f,parent:h}=p,g=p.parent.isTextblock&&f>0?l.doc.resolve(f-1):p,b=g.parent.type.spec.isolating,m=p.pos-p.parentOffset,v=b&&g.parent.childCount===1?m===p.pos:X.atStart(d).from===f;return!u||!h.type.isTextblock||h.textContent.length||!v||v&&p.parent.type.name==="paragraph"?!1:o.clearNodes()}),()=>o.deleteSelection(),()=>o.joinBackward(),()=>o.selectNodeBackward()]),e=()=>this.editor.commands.first(({commands:o})=>[()=>o.deleteSelection(),()=>o.deleteCurrentNode(),()=>o.joinForward(),()=>o.selectNodeForward()]),s={Enter:()=>this.editor.commands.first(({commands:o})=>[()=>o.newlineInCode(),()=>o.createParagraphNear(),()=>o.liftEmptyBlock(),()=>o.splitBlock()]),"Mod-Enter":()=>this.editor.commands.exitCode(),Backspace:n,"Mod-Backspace":n,"Shift-Backspace":n,Delete:e,"Mod-Delete":e,"Mod-a":()=>this.editor.commands.selectAll()},i={...s},r={...s,"Ctrl-h":n,"Alt-Backspace":n,"Ctrl-d":e,"Ctrl-Alt-Backspace":e,"Alt-Delete":e,"Alt-d":e,"Ctrl-a":()=>this.editor.commands.selectTextblockStart(),"Ctrl-e":()=>this.editor.commands.selectTextblockEnd()};return ni()||Td()?r:i},addProseMirrorPlugins(){return[new oe({key:new me("clearDocument"),appendTransaction:(n,e,t)=>{if(n.some(h=>h.getMeta("composition")))return;const s=n.some(h=>h.docChanged)&&!e.doc.eq(t.doc),i=n.some(h=>h.getMeta("preventClearDocument"));if(!s||i)return;const{empty:r,from:o,to:l}=e.selection,c=X.atStart(e.doc).from,d=X.atEnd(e.doc).to;if(r||!(o===c&&l===d)||!ys(t.doc))return;const u=t.tr,p=Fi({state:t,transaction:u}),{commands:f}=new xn({editor:this.editor,state:p});if(f.clearNodes(),!!u.steps.length)return u}})]}}),jx=pe.create({name:"paste",addProseMirrorPlugins(){return[new oe({key:new me("tiptapPaste"),props:{handlePaste:(n,e,t)=>{this.editor.emit("paste",{editor:this.editor,event:e,slice:t})}}})]}}),Fx=pe.create({name:"tabindex",addOptions(){return{value:void 0}},addProseMirrorPlugins(){return[new oe({key:new me("tabindex"),props:{attributes:()=>{var n;return!this.editor.isEditable&&this.options.value===void 0?{}:{tabindex:(n=this.options.value)!==null&&n!==void 0?n:"0"}}}})]}}),Vx=pe.create({name:"textDirection",addOptions(){return{direction:void 0}},addGlobalAttributes(){if(!this.options.direction)return[];const{nodeExtensions:n}=An(this.extensions);return[{types:n.filter(e=>e.name!=="text").map(e=>e.name),attributes:{dir:{default:this.options.direction,parseHTML:e=>{const t=e.getAttribute("dir");return t&&(t==="ltr"||t==="rtl"||t==="auto")?t:this.options.direction},renderHTML:e=>e.dir?{dir:e.dir}:{}}}}]},addProseMirrorPlugins(){return[new oe({key:new me("textDirection"),props:{attributes:()=>{const n=this.options.direction;return n?{dir:n}:{}}}})]}});let ra=!1;function Hx(n){if(ra)return;ra=!0;let e;try{const t=de.fromJSON(n,{from:0,to:0});if(!Ak(t))return;e=t.slice.content}catch(t){return}e instanceof $||console.warn("[tiptap warn]: prosemirror-model is loaded more than once. Wrapping and splitting nodes will fail. Deduplicate it in your lock file, or alias it to a single copy in your bundler.")}var qx=class Fn{get name(){return this.node.type.name}constructor(e,t,s=!1,i=null){this.currentNode=null,this.actualDepth=null,this.isBlock=s,this.resolvedPos=e,this.editor=t,this.currentNode=i}get node(){return this.currentNode||this.resolvedPos.node()}get element(){return this.editor.view.domAtPos(this.pos).node}get depth(){var e;return(e=this.actualDepth)!==null&&e!==void 0?e:this.resolvedPos.depth}get pos(){return this.resolvedPos.pos}get content(){return this.node.content}set content(e){let t=this.from,s=this.to;if(this.isBlock){if(this.content.size===0){console.error(`You can’t set content on a block node. Tried to set content on ${this.name} at ${this.pos}`);return}t=this.from+1,s=this.to-1}this.editor.commands.insertContentAt({from:t,to:s},e)}get attributes(){return this.node.attrs}get textContent(){return this.node.textContent}get size(){return this.node.nodeSize}get from(){return this.isBlock?this.pos:this.resolvedPos.start(this.resolvedPos.depth)}get range(){return{from:this.from,to:this.to}}get to(){return this.isBlock?this.pos+this.size:this.resolvedPos.end(this.resolvedPos.depth)+(this.node.isText?0:1)}get parent(){if(this.depth===0)return null;const e=this.resolvedPos.start(this.resolvedPos.depth-1),t=this.resolvedPos.doc.resolve(e);return new Fn(t,this.editor)}get before(){let e=this.resolvedPos.doc.resolve(this.from-(this.isBlock?1:2));return e.depth!==this.depth&&(e=this.resolvedPos.doc.resolve(this.from-3)),new Fn(e,this.editor)}get after(){let e=this.resolvedPos.doc.resolve(this.to+(this.isBlock?2:1));return e.depth!==this.depth&&(e=this.resolvedPos.doc.resolve(this.to+3)),new Fn(e,this.editor)}get children(){const e=[];return this.node.content.forEach((t,s)=>{const i=t.isBlock&&!t.isTextblock,r=t.isAtom&&!t.isText,o=t.isInline,l=this.pos+s+(r?0:1);if(l<0||l>this.resolvedPos.doc.nodeSize-2)return;const c=this.resolvedPos.doc.resolve(l);if(!i&&!o&&c.depth<=this.depth)return;const d=new Fn(c,this.editor,i,i||o?t:null);i&&(d.actualDepth=this.depth+1),e.push(d)}),e}get firstChild(){return this.children[0]||null}get lastChild(){const e=this.children;return e[e.length-1]||null}closest(e,t={}){let s=null,i=this.parent;for(;i&&!s;){if(i.node.type.name===e)if(Object.keys(t).length>0){const r=i.node.attrs,o=Object.keys(t);for(let l=0;l{s&&i.length>0||(o.node.type.name===e&&r.every(l=>t[l]===o.node.attrs[l])&&i.push(o),!(s&&i.length>0)&&(i=i.concat(o.querySelectorAll(e,t,s))))}),i}setAttribute(e){const{tr:t}=this.editor.state;t.setNodeMarkup(this.from,void 0,{...this.node.attrs,...e}),this.editor.view.dispatch(t)}};const Ux=`.ProseMirror { +`)}}})]}}),Rx=pe.create({name:"commands",addCommands(){return{...ix}}}),Lx=pe.create({name:"delete",onUpdate({transaction:n,appendedTransactions:e}){var t,s;const i=()=>{var r,o,l;if((r=(o=this.editor.options.coreExtensionOptions)===null||o===void 0||(o=o.delete)===null||o===void 0||(l=o.filterTransaction)===null||l===void 0?void 0:l.call(o,n))!==null&&r!==void 0?r:n.getMeta("y-sync$"))return;const c=Ad(n.before,[n,...e]);qi(c).forEach(u=>{c.mapping.mapResult(u.oldRange.from).deletedAfter&&c.mapping.mapResult(u.oldRange.to).deletedBefore&&c.before.nodesBetween(u.oldRange.from,u.oldRange.to,(p,f)=>{const h=f+p.nodeSize-2,g=u.oldRange.from<=f&&h<=u.oldRange.to;this.editor.emit("delete",{type:"node",node:p,from:f,to:h,newFrom:c.mapping.map(f),newTo:c.mapping.map(h),deletedRange:u.oldRange,newRange:u.newRange,partial:!g,editor:this.editor,transaction:n,combinedTransform:c})})});const d=c.mapping;c.steps.forEach((u,p)=>{if(u instanceof Xe){var f,h;const g=d.slice(p).map(u.from,-1),b=d.slice(p).map(u.to),m=d.invert().map(g,-1),v=d.invert().map(b),S=g>0?(f=c.doc.nodeAt(g-1))===null||f===void 0?void 0:f.marks.some(N=>N.eq(u.mark)):!1,A=(h=c.doc.nodeAt(b))===null||h===void 0?void 0:h.marks.some(N=>N.eq(u.mark));this.editor.emit("delete",{type:"mark",mark:u.mark,from:u.from,to:u.to,deletedRange:{from:m,to:v},newRange:{from:g,to:b},partial:!!(A||S),editor:this.editor,transaction:n,combinedTransform:c})}})};!((t=(s=this.editor.options.coreExtensionOptions)===null||s===void 0||(s=s.delete)===null||s===void 0?void 0:s.async)!==null&&t!==void 0)||t?setTimeout(i,0):i()}}),Px=pe.create({name:"drop",addProseMirrorPlugins(){return[new oe({key:new me("tiptapDrop"),props:{handleDrop:(n,e,t,s)=>{this.editor.emit("drop",{editor:this.editor,event:e,slice:t,moved:s})}}})]}}),Bx=pe.create({name:"editable",addProseMirrorPlugins(){return[new oe({key:new me("editable"),props:{editable:()=>this.editor.options.editable}})]}}),_x=new me("focusEvents"),zx=pe.create({name:"focusEvents",addProseMirrorPlugins(){const{editor:n}=this;return[new oe({key:_x,props:{handleDOMEvents:{focus:(e,t)=>{n.isFocused=!0;const s=n.state.tr.setMeta("focus",{event:t}).setMeta("addToHistory",!1);return e.dispatch(s),!1},blur:(e,t)=>{n.isFocused=!1;const s=n.state.tr.setMeta("blur",{event:t}).setMeta("addToHistory",!1);return e.dispatch(s),!1}}}})]}}),jx=pe.create({name:"keymap",addKeyboardShortcuts(){const n=()=>this.editor.commands.first(({commands:o})=>[()=>o.undoInputRule(),()=>o.command(({tr:l})=>{const{selection:c,doc:d}=l,{empty:u,$anchor:p}=c,{pos:f,parent:h}=p,g=p.parent.isTextblock&&f>0?l.doc.resolve(f-1):p,b=g.parent.type.spec.isolating,m=p.pos-p.parentOffset,v=b&&g.parent.childCount===1?m===p.pos:X.atStart(d).from===f;return!u||!h.type.isTextblock||h.textContent.length||!v||v&&p.parent.type.name==="paragraph"?!1:o.clearNodes()}),()=>o.deleteSelection(),()=>o.joinBackward(),()=>o.selectNodeBackward()]),e=()=>this.editor.commands.first(({commands:o})=>[()=>o.deleteSelection(),()=>o.deleteCurrentNode(),()=>o.joinForward(),()=>o.selectNodeForward()]),s={Enter:()=>this.editor.commands.first(({commands:o})=>[()=>o.newlineInCode(),()=>o.createParagraphNear(),()=>o.liftEmptyBlock(),()=>o.splitBlock()]),"Mod-Enter":()=>this.editor.commands.exitCode(),Backspace:n,"Mod-Backspace":n,"Shift-Backspace":n,Delete:e,"Mod-Delete":e,"Mod-a":()=>this.editor.commands.selectAll()},i={...s},r={...s,"Ctrl-h":n,"Alt-Backspace":n,"Ctrl-d":e,"Ctrl-Alt-Backspace":e,"Alt-Delete":e,"Alt-d":e,"Ctrl-a":()=>this.editor.commands.selectTextblockStart(),"Ctrl-e":()=>this.editor.commands.selectTextblockEnd()};return ni()||Td()?r:i},addProseMirrorPlugins(){return[new oe({key:new me("clearDocument"),appendTransaction:(n,e,t)=>{if(n.some(h=>h.getMeta("composition")))return;const s=n.some(h=>h.docChanged)&&!e.doc.eq(t.doc),i=n.some(h=>h.getMeta("preventClearDocument"));if(!s||i)return;const{empty:r,from:o,to:l}=e.selection,c=X.atStart(e.doc).from,d=X.atEnd(e.doc).to;if(r||!(o===c&&l===d)||!ys(t.doc))return;const u=t.tr,p=Fi({state:t,transaction:u}),{commands:f}=new xn({editor:this.editor,state:p});if(f.clearNodes(),!!u.steps.length)return u}})]}}),Fx=pe.create({name:"paste",addProseMirrorPlugins(){return[new oe({key:new me("tiptapPaste"),props:{handlePaste:(n,e,t)=>{this.editor.emit("paste",{editor:this.editor,event:e,slice:t})}}})]}}),Vx=pe.create({name:"tabindex",addOptions(){return{value:void 0}},addProseMirrorPlugins(){return[new oe({key:new me("tabindex"),props:{attributes:()=>{var n;return!this.editor.isEditable&&this.options.value===void 0?{}:{tabindex:(n=this.options.value)!==null&&n!==void 0?n:"0"}}}})]}}),Hx=pe.create({name:"textDirection",addOptions(){return{direction:void 0}},addGlobalAttributes(){if(!this.options.direction)return[];const{nodeExtensions:n}=An(this.extensions);return[{types:n.filter(e=>e.name!=="text").map(e=>e.name),attributes:{dir:{default:this.options.direction,parseHTML:e=>{const t=e.getAttribute("dir");return t&&(t==="ltr"||t==="rtl"||t==="auto")?t:this.options.direction},renderHTML:e=>e.dir?{dir:e.dir}:{}}}}]},addProseMirrorPlugins(){return[new oe({key:new me("textDirection"),props:{attributes:()=>{const n=this.options.direction;return n?{dir:n}:{}}}})]}});let ra=!1;function qx(n){if(ra)return;ra=!0;let e;try{const t=de.fromJSON(n,{from:0,to:0});if(!Ok(t))return;e=t.slice.content}catch(t){return}e instanceof $||console.warn("[tiptap warn]: prosemirror-model is loaded more than once. Wrapping and splitting nodes will fail. Deduplicate it in your lock file, or alias it to a single copy in your bundler.")}var Ux=class Fn{get name(){return this.node.type.name}constructor(e,t,s=!1,i=null){this.currentNode=null,this.actualDepth=null,this.isBlock=s,this.resolvedPos=e,this.editor=t,this.currentNode=i}get node(){return this.currentNode||this.resolvedPos.node()}get element(){return this.editor.view.domAtPos(this.pos).node}get depth(){var e;return(e=this.actualDepth)!==null&&e!==void 0?e:this.resolvedPos.depth}get pos(){return this.resolvedPos.pos}get content(){return this.node.content}set content(e){let t=this.from,s=this.to;if(this.isBlock){if(this.content.size===0){console.error(`You can’t set content on a block node. Tried to set content on ${this.name} at ${this.pos}`);return}t=this.from+1,s=this.to-1}this.editor.commands.insertContentAt({from:t,to:s},e)}get attributes(){return this.node.attrs}get textContent(){return this.node.textContent}get size(){return this.node.nodeSize}get from(){return this.isBlock?this.pos:this.resolvedPos.start(this.resolvedPos.depth)}get range(){return{from:this.from,to:this.to}}get to(){return this.isBlock?this.pos+this.size:this.resolvedPos.end(this.resolvedPos.depth)+(this.node.isText?0:1)}get parent(){if(this.depth===0)return null;const e=this.resolvedPos.start(this.resolvedPos.depth-1),t=this.resolvedPos.doc.resolve(e);return new Fn(t,this.editor)}get before(){let e=this.resolvedPos.doc.resolve(this.from-(this.isBlock?1:2));return e.depth!==this.depth&&(e=this.resolvedPos.doc.resolve(this.from-3)),new Fn(e,this.editor)}get after(){let e=this.resolvedPos.doc.resolve(this.to+(this.isBlock?2:1));return e.depth!==this.depth&&(e=this.resolvedPos.doc.resolve(this.to+3)),new Fn(e,this.editor)}get children(){const e=[];return this.node.content.forEach((t,s)=>{const i=t.isBlock&&!t.isTextblock,r=t.isAtom&&!t.isText,o=t.isInline,l=this.pos+s+(r?0:1);if(l<0||l>this.resolvedPos.doc.nodeSize-2)return;const c=this.resolvedPos.doc.resolve(l);if(!i&&!o&&c.depth<=this.depth)return;const d=new Fn(c,this.editor,i,i||o?t:null);i&&(d.actualDepth=this.depth+1),e.push(d)}),e}get firstChild(){return this.children[0]||null}get lastChild(){const e=this.children;return e[e.length-1]||null}closest(e,t={}){let s=null,i=this.parent;for(;i&&!s;){if(i.node.type.name===e)if(Object.keys(t).length>0){const r=i.node.attrs,o=Object.keys(t);for(let l=0;l{s&&i.length>0||(o.node.type.name===e&&r.every(l=>t[l]===o.node.attrs[l])&&i.push(o),!(s&&i.length>0)&&(i=i.concat(o.querySelectorAll(e,t,s))))}),i}setAttribute(e){const{tr:t}=this.editor.state;t.setNodeMarkup(this.from,void 0,{...this.node.attrs,...e}),this.editor.view.dispatch(t)}};const Wx=`.ProseMirror { position: relative; } @@ -97,13 +97,13 @@ img.ProseMirror-separator { .ProseMirror-focused .ProseMirror-gapcursor { display: block; -}`;var Wx=class extends rx{constructor(e={}){super(),this.css=null,this.className="tiptap",this.editorView=null,this.isFocused=!1,this.destroyed=!1,this.isInitialized=!1,this.extensionStorage={},this.instanceId=Math.random().toString(36).slice(2,9),this.hasWarnedStaleDecorationRead=!1,this.options={element:typeof document!="undefined"?document.createElement("div"):null,content:"",injectCSS:!0,injectNonce:void 0,extensions:[],autofocus:!1,editable:!0,textDirection:void 0,editorProps:{},parseOptions:{},coreExtensionOptions:{},enableInputRules:!0,enablePasteRules:!0,enableCoreExtensions:!0,enableContentCheck:!1,emitContentError:!1,onBeforeCreate:()=>null,onCreate:()=>null,onMount:()=>null,onUnmount:()=>null,onUpdate:()=>null,onSelectionUpdate:()=>null,onTransaction:()=>null,onFocus:()=>null,onBlur:()=>null,onDestroy:()=>null,onContentError:({error:s})=>{throw s},onPaste:()=>null,onDrop:()=>null,onDelete:()=>null,enableExtensionDispatchTransaction:!0},this.isCapturingTransaction=!1,this.capturedTransaction=null,this.utils={getUpdatedPosition:Ok,createMappablePosition:Nk},this.setOptions(e),this.createExtensionManager(),this.createCommandManager(),this.createSchema(),this.on("beforeCreate",this.options.onBeforeCreate),this.emit("beforeCreate",{editor:this}),this.on("mount",this.options.onMount),this.on("unmount",this.options.onUnmount),this.on("contentError",this.options.onContentError),this.on("create",this.options.onCreate),this.on("update",this.options.onUpdate),this.on("selectionUpdate",this.options.onSelectionUpdate),this.on("transaction",this.options.onTransaction),this.on("focus",this.options.onFocus),this.on("blur",this.options.onBlur),this.on("destroy",this.options.onDestroy),this.on("drop",({event:s,slice:i,moved:r})=>this.options.onDrop(s,i,r)),this.on("paste",({event:s,slice:i})=>this.options.onPaste(s,i)),this.on("delete",this.options.onDelete);const t=this.createDoc();if(!this.editorState){const s=Pr(t,this.options.autofocus);this.editorState=pt.create({doc:t,schema:this.schema,selection:s||void 0})}Hx(this.schema),this.options.element&&this.mount(this.options.element)}mount(e){if(typeof document=="undefined")throw new Error("[tiptap error]: The editor cannot be mounted because there is no 'document' defined in this environment.");this.createView(e),this.emit("mount",{editor:this}),this.css&&!document.head.contains(this.css)&&document.head.appendChild(this.css),window.setTimeout(()=>{this.isDestroyed||(this.options.autofocus!==!1&&this.options.autofocus!==null&&this.commands.focus(this.options.autofocus),this.emit("create",{editor:this}),this.isInitialized=!0)},0)}unmount(){if(this.editorView){this.editorState=this.editorView.state;const e=this.editorView.dom;e!=null&&e.editor&&delete e.editor,this.editorView.destroy()}if(this.editorView=null,this.isInitialized=!1,this.css&&!document.querySelectorAll(`.${this.className}`).length)try{typeof this.css.remove=="function"?this.css.remove():this.css.parentNode&&this.css.parentNode.removeChild(this.css)}catch(e){console.warn("Failed to remove CSS element:",e)}this.css=null,this.emit("unmount",{editor:this})}get storage(){return this.extensionStorage}get commands(){return this.commandManager.commands}chain(){return this.commandManager?this.commandManager.chain():xn.createFakeChain()}can(){return this.commandManager?this.commandManager.can():xn.createFallbackCan()}injectCSS(){this.options.injectCSS&&typeof document!="undefined"&&(this.css=yx(Ux,this.options.injectNonce))}setOptions(e={}){this.options={...this.options,...e},!(!this.editorView||!this.state||this.isDestroyed)&&(this.options.editorProps&&this.view.setProps({...this.options.editorProps,attributes:this.getEditorViewAttributes()}),this.view.updateState(this.state))}setEditable(e,t=!0){this.setOptions({editable:e}),t&&this.emit("update",{editor:this,transaction:this.state.tr,appendedTransactions:[]})}get isEditable(){return this.options.editable&&this.view&&this.view.editable}get view(){return this.editorView?this.editorView:new Proxy({state:this.editorState,updateState:e=>{this.editorState=e},dispatch:e=>{this.dispatchTransaction(e)},composing:!1,dragging:null,editable:!0,isDestroyed:!1},{get:(e,t)=>{if(this.editorView)return this.editorView[t];if(t==="state")return this.editorState;if(t in e)return Reflect.get(e,t);throw new Error(`[tiptap error]: The editor view is not available. Cannot access view['${t}']. The editor may not be mounted yet.`)}})}get state(){return this.editorView&&(this.editorState=this.view.state),this.editorState}registerPlugin(e,t){const s=_r(t)?t(e,[...this.state.plugins]):[...this.state.plugins,e],i=this.state.reconfigure({plugins:s});return this.view.updateState(i),i}unregisterPlugin(e){if(this.isDestroyed)return;const t=this.state.plugins;let s=t;if([].concat(e).forEach(r=>{const o=typeof r=="string"?`${r}$`:r.key;s=s.filter(l=>!l.key.startsWith(o))}),t.length===s.length)return;const i=this.state.reconfigure({plugins:s});return this.view.updateState(i),i}createExtensionManager(){var e,t;const s=[...this.options.enableCoreExtensions?[Px,Dx.configure({blockSeparator:(e=this.options.coreExtensionOptions)===null||e===void 0||(e=e.clipboardTextSerializer)===null||e===void 0?void 0:e.blockSeparator}),$x,_x,zx,Fx.configure({value:(t=this.options.coreExtensionOptions)===null||t===void 0||(t=t.tabindex)===null||t===void 0?void 0:t.value}),Lx,jx,Rx,Vx.configure({direction:this.options.textDirection})].filter(i=>typeof this.options.enableCoreExtensions=="object"?this.options.enableCoreExtensions[i.name]!==!1:!0):[],...this.options.extensions].filter(i=>["extension","node","mark"].includes(i==null?void 0:i.type));this.extensionManager=new Wi(s,this)}createCommandManager(){this.commandManager=new xn({editor:this})}createSchema(){this.schema=this.extensionManager.schema}createDoc(){let e;try{e=Br(this.options.content,this.schema,this.options.parseOptions,{errorOnInvalidContent:this.options.enableContentCheck})}catch(t){if(!(t instanceof Error)||!["[tiptap error]: Invalid JSON content","[tiptap error]: Invalid HTML content"].includes(t.message))throw t;const s=Br(this.options.content,this.schema,this.options.parseOptions,{errorOnInvalidContent:!1});return this.editorState=pt.create({doc:s,schema:this.schema,selection:Pr(s,this.options.autofocus)||void 0}),this.emit("contentError",{editor:this,error:t,disableCollaboration:()=>{"collaboration"in this.storage&&typeof this.storage.collaboration=="object"&&this.storage.collaboration&&(this.storage.collaboration.isDisabled=!0),this.options.extensions=this.options.extensions.filter(i=>i.name!=="collaboration"),this.createExtensionManager()}}),this.editorState.doc}return e}getEditorViewAttributes(){var e;const t=(e=this.options.editorProps)===null||e===void 0?void 0:e.attributes;return _r(t)?s=>({role:"textbox",...t(s)}):{role:"textbox",...t}}createView(e){const{editorProps:t,enableExtensionDispatchTransaction:s}=this.options,i=t.dispatchTransaction||this.dispatchTransaction.bind(this),r=s?this.extensionManager.dispatchTransaction(i):i,o=t.transformPastedHTML,l=this.extensionManager.transformPastedHTML(o);this.editorView=new dd(e,{...t,attributes:this.getEditorViewAttributes(),dispatchTransaction:r,transformPastedHTML:l,state:this.editorState,markViews:this.extensionManager.markViews,nodeViews:this.extensionManager.nodeViews});const c=this.state.reconfigure({plugins:this.extensionManager.plugins});this.view.updateState(c),this.prependClass(),this.injectCSS();const d=this.view.dom;d.editor=this}createNodeViews(){this.view.isDestroyed||this.view.setProps({markViews:this.extensionManager.markViews,nodeViews:this.extensionManager.nodeViews})}prependClass(){this.view.dom.className=`${this.className} ${this.view.dom.className}`}captureTransaction(e){this.isCapturingTransaction=!0,e(),this.isCapturingTransaction=!1;const t=this.capturedTransaction;return this.capturedTransaction=null,t}dispatchTransaction(e){if(this.view.isDestroyed)return;if(this.isCapturingTransaction){if(!this.capturedTransaction){this.capturedTransaction=e;return}e.steps.forEach(u=>{var p;return(p=this.capturedTransaction)===null||p===void 0?void 0:p.step(u)});return}const{state:t,transactions:s}=this.state.applyTransaction(e),i=!this.state.selection.eq(t.selection),r=s.includes(e),o=this.state;if(this.emit("beforeTransaction",{editor:this,transaction:e,nextState:t}),!r)return;this.view.updateState(t),this.emit("transaction",{editor:this,transaction:e,appendedTransactions:s.slice(1)}),i&&this.emit("selectionUpdate",{editor:this,transaction:e});const l=s.findLast(u=>u.getMeta("focus")||u.getMeta("blur")),c=l==null?void 0:l.getMeta("focus"),d=l==null?void 0:l.getMeta("blur");c&&this.emit("focus",{editor:this,event:c.event,transaction:l}),d&&this.emit("blur",{editor:this,event:d.event,transaction:l}),!(e.getMeta("preventUpdate")||!s.some(u=>u.docChanged)||o.doc.eq(t.doc))&&this.emit("update",{editor:this,transaction:e,appendedTransactions:s.slice(1)})}getAttributes(e){return Rd(this.state,e)}isActive(e,t){const s=typeof e=="string"?e:null,i=typeof e=="string"?t:e;return Ck(this.state,s,i)}getJSON(){return this.state.doc.toJSON()}getHTML(){return xo(this.state.doc.content,this.schema)}getText(e){const{blockSeparator:t=` +}`;var Kx=class extends ox{constructor(e={}){super(),this.css=null,this.className="tiptap",this.editorView=null,this.isFocused=!1,this.destroyed=!1,this.isInitialized=!1,this.extensionStorage={},this.instanceId=Math.random().toString(36).slice(2,9),this.hasWarnedStaleDecorationRead=!1,this.options={element:typeof document!="undefined"?document.createElement("div"):null,content:"",injectCSS:!0,injectNonce:void 0,extensions:[],autofocus:!1,editable:!0,textDirection:void 0,editorProps:{},parseOptions:{},coreExtensionOptions:{},enableInputRules:!0,enablePasteRules:!0,enableCoreExtensions:!0,enableContentCheck:!1,emitContentError:!1,onBeforeCreate:()=>null,onCreate:()=>null,onMount:()=>null,onUnmount:()=>null,onUpdate:()=>null,onSelectionUpdate:()=>null,onTransaction:()=>null,onFocus:()=>null,onBlur:()=>null,onDestroy:()=>null,onContentError:({error:s})=>{throw s},onPaste:()=>null,onDrop:()=>null,onDelete:()=>null,enableExtensionDispatchTransaction:!0},this.isCapturingTransaction=!1,this.capturedTransaction=null,this.utils={getUpdatedPosition:Nk,createMappablePosition:Ik},this.setOptions(e),this.createExtensionManager(),this.createCommandManager(),this.createSchema(),this.on("beforeCreate",this.options.onBeforeCreate),this.emit("beforeCreate",{editor:this}),this.on("mount",this.options.onMount),this.on("unmount",this.options.onUnmount),this.on("contentError",this.options.onContentError),this.on("create",this.options.onCreate),this.on("update",this.options.onUpdate),this.on("selectionUpdate",this.options.onSelectionUpdate),this.on("transaction",this.options.onTransaction),this.on("focus",this.options.onFocus),this.on("blur",this.options.onBlur),this.on("destroy",this.options.onDestroy),this.on("drop",({event:s,slice:i,moved:r})=>this.options.onDrop(s,i,r)),this.on("paste",({event:s,slice:i})=>this.options.onPaste(s,i)),this.on("delete",this.options.onDelete);const t=this.createDoc();if(!this.editorState){const s=Pr(t,this.options.autofocus);this.editorState=pt.create({doc:t,schema:this.schema,selection:s||void 0})}qx(this.schema),this.options.element&&this.mount(this.options.element)}mount(e){if(typeof document=="undefined")throw new Error("[tiptap error]: The editor cannot be mounted because there is no 'document' defined in this environment.");this.createView(e),this.emit("mount",{editor:this}),this.css&&!document.head.contains(this.css)&&document.head.appendChild(this.css),window.setTimeout(()=>{this.isDestroyed||(this.options.autofocus!==!1&&this.options.autofocus!==null&&this.commands.focus(this.options.autofocus),this.emit("create",{editor:this}),this.isInitialized=!0)},0)}unmount(){if(this.editorView){this.editorState=this.editorView.state;const e=this.editorView.dom;e!=null&&e.editor&&delete e.editor,this.editorView.destroy()}if(this.editorView=null,this.isInitialized=!1,this.css&&!document.querySelectorAll(`.${this.className}`).length)try{typeof this.css.remove=="function"?this.css.remove():this.css.parentNode&&this.css.parentNode.removeChild(this.css)}catch(e){console.warn("Failed to remove CSS element:",e)}this.css=null,this.emit("unmount",{editor:this})}get storage(){return this.extensionStorage}get commands(){return this.commandManager.commands}chain(){return this.commandManager?this.commandManager.chain():xn.createFakeChain()}can(){return this.commandManager?this.commandManager.can():xn.createFallbackCan()}injectCSS(){this.options.injectCSS&&typeof document!="undefined"&&(this.css=kx(Wx,this.options.injectNonce))}setOptions(e={}){this.options={...this.options,...e},!(!this.editorView||!this.state||this.isDestroyed)&&(this.options.editorProps&&this.view.setProps({...this.options.editorProps,attributes:this.getEditorViewAttributes()}),this.view.updateState(this.state))}setEditable(e,t=!0){this.setOptions({editable:e}),t&&this.emit("update",{editor:this,transaction:this.state.tr,appendedTransactions:[]})}get isEditable(){return this.options.editable&&this.view&&this.view.editable}get view(){return this.editorView?this.editorView:new Proxy({state:this.editorState,updateState:e=>{this.editorState=e},dispatch:e=>{this.dispatchTransaction(e)},composing:!1,dragging:null,editable:!0,isDestroyed:!1},{get:(e,t)=>{if(this.editorView)return this.editorView[t];if(t==="state")return this.editorState;if(t in e)return Reflect.get(e,t);throw new Error(`[tiptap error]: The editor view is not available. Cannot access view['${t}']. The editor may not be mounted yet.`)}})}get state(){return this.editorView&&(this.editorState=this.view.state),this.editorState}registerPlugin(e,t){const s=_r(t)?t(e,[...this.state.plugins]):[...this.state.plugins,e],i=this.state.reconfigure({plugins:s});return this.view.updateState(i),i}unregisterPlugin(e){if(this.isDestroyed)return;const t=this.state.plugins;let s=t;if([].concat(e).forEach(r=>{const o=typeof r=="string"?`${r}$`:r.key;s=s.filter(l=>!l.key.startsWith(o))}),t.length===s.length)return;const i=this.state.reconfigure({plugins:s});return this.view.updateState(i),i}createExtensionManager(){var e,t;const s=[...this.options.enableCoreExtensions?[Bx,$x.configure({blockSeparator:(e=this.options.coreExtensionOptions)===null||e===void 0||(e=e.clipboardTextSerializer)===null||e===void 0?void 0:e.blockSeparator}),Rx,zx,jx,Vx.configure({value:(t=this.options.coreExtensionOptions)===null||t===void 0||(t=t.tabindex)===null||t===void 0?void 0:t.value}),Px,Fx,Lx,Hx.configure({direction:this.options.textDirection})].filter(i=>typeof this.options.enableCoreExtensions=="object"?this.options.enableCoreExtensions[i.name]!==!1:!0):[],...this.options.extensions].filter(i=>["extension","node","mark"].includes(i==null?void 0:i.type));this.extensionManager=new Wi(s,this)}createCommandManager(){this.commandManager=new xn({editor:this})}createSchema(){this.schema=this.extensionManager.schema}createDoc(){let e;try{e=Br(this.options.content,this.schema,this.options.parseOptions,{errorOnInvalidContent:this.options.enableContentCheck})}catch(t){if(!(t instanceof Error)||!["[tiptap error]: Invalid JSON content","[tiptap error]: Invalid HTML content"].includes(t.message))throw t;const s=Br(this.options.content,this.schema,this.options.parseOptions,{errorOnInvalidContent:!1});return this.editorState=pt.create({doc:s,schema:this.schema,selection:Pr(s,this.options.autofocus)||void 0}),this.emit("contentError",{editor:this,error:t,disableCollaboration:()=>{"collaboration"in this.storage&&typeof this.storage.collaboration=="object"&&this.storage.collaboration&&(this.storage.collaboration.isDisabled=!0),this.options.extensions=this.options.extensions.filter(i=>i.name!=="collaboration"),this.createExtensionManager()}}),this.editorState.doc}return e}getEditorViewAttributes(){var e;const t=(e=this.options.editorProps)===null||e===void 0?void 0:e.attributes;return _r(t)?s=>({role:"textbox",...t(s)}):{role:"textbox",...t}}createView(e){const{editorProps:t,enableExtensionDispatchTransaction:s}=this.options,i=t.dispatchTransaction||this.dispatchTransaction.bind(this),r=s?this.extensionManager.dispatchTransaction(i):i,o=t.transformPastedHTML,l=this.extensionManager.transformPastedHTML(o);this.editorView=new dd(e,{...t,attributes:this.getEditorViewAttributes(),dispatchTransaction:r,transformPastedHTML:l,state:this.editorState,markViews:this.extensionManager.markViews,nodeViews:this.extensionManager.nodeViews});const c=this.state.reconfigure({plugins:this.extensionManager.plugins});this.view.updateState(c),this.prependClass(),this.injectCSS();const d=this.view.dom;d.editor=this}createNodeViews(){this.view.isDestroyed||this.view.setProps({markViews:this.extensionManager.markViews,nodeViews:this.extensionManager.nodeViews})}prependClass(){this.view.dom.className=`${this.className} ${this.view.dom.className}`}captureTransaction(e){this.isCapturingTransaction=!0,e(),this.isCapturingTransaction=!1;const t=this.capturedTransaction;return this.capturedTransaction=null,t}dispatchTransaction(e){if(this.view.isDestroyed)return;if(this.isCapturingTransaction){if(!this.capturedTransaction){this.capturedTransaction=e;return}e.steps.forEach(u=>{var p;return(p=this.capturedTransaction)===null||p===void 0?void 0:p.step(u)});return}const{state:t,transactions:s}=this.state.applyTransaction(e),i=!this.state.selection.eq(t.selection),r=s.includes(e),o=this.state;if(this.emit("beforeTransaction",{editor:this,transaction:e,nextState:t}),!r)return;this.view.updateState(t),this.emit("transaction",{editor:this,transaction:e,appendedTransactions:s.slice(1)}),i&&this.emit("selectionUpdate",{editor:this,transaction:e});const l=s.findLast(u=>u.getMeta("focus")||u.getMeta("blur")),c=l==null?void 0:l.getMeta("focus"),d=l==null?void 0:l.getMeta("blur");c&&this.emit("focus",{editor:this,event:c.event,transaction:l}),d&&this.emit("blur",{editor:this,event:d.event,transaction:l}),!(e.getMeta("preventUpdate")||!s.some(u=>u.docChanged)||o.doc.eq(t.doc))&&this.emit("update",{editor:this,transaction:e,appendedTransactions:s.slice(1)})}getAttributes(e){return Rd(this.state,e)}isActive(e,t){const s=typeof e=="string"?e:null,i=typeof e=="string"?t:e;return Mk(this.state,s,i)}getJSON(){return this.state.doc.toJSON()}getHTML(){return xo(this.state.doc.content,this.schema)}getText(e){const{blockSeparator:t=` -`,textSerializers:s={}}=e||{};return bk(this.state.doc,{blockSeparator:t,textSerializers:{...$d(this.schema),...s}})}get isEmpty(){return ys(this.state.doc)}destroy(){this.destroyed||(this.destroyed=!0,this.emit("destroy"),this.unmount(),this.removeAllListeners(),this.extensionManager.destroy(),this.extensionManager=null,this.schema=null,this.commandManager=null,this.extensionStorage={})}get isDestroyed(){var e,t;return(e=(t=this.editorView)===null||t===void 0?void 0:t.isDestroyed)!==null&&e!==void 0?e:!0}$node(e,t){var s;return((s=this.$doc)===null||s===void 0?void 0:s.querySelector(e,t))||null}$nodes(e,t){var s;return((s=this.$doc)===null||s===void 0?void 0:s.querySelectorAll(e,t))||null}$pos(e){const t=this.state.doc.resolve(e),s=e>0&&t.nodeAfter&&!t.nodeAfter.isText&&t.nodeAfter.isAtom?t.nodeAfter:null;return new qx(t,this,!1,s)}get $doc(){return this.$pos(0)}};function on(n){return new ks({find:n.find,handler:({state:e,range:t,match:s})=>{const i=se(n.getAttributes,void 0,s);if(i===!1||i===null)return null;const{tr:r}=e,o=s[s.length-1],l=s[0];if(o){const c=l.search(/\S/),d=t.from+l.indexOf(o),u=d+o.length;if(Ui(t.from,t.to,e.doc).filter(f=>f.mark.type.excluded.find(h=>h===n.type&&h!==f.mark.type)).filter(f=>f.to>d).length)return null;ut.from&&r.delete(t.from+c,d);const p=t.from+c+o.length;r.addMark(t.from+c,p,n.type.create(i||{})),r.removeStoredMark(n.type)}},undoable:n.undoable})}function Kx(n){return new ks({find:n.find,handler:({state:e,range:t,match:s})=>{const i=se(n.getAttributes,void 0,s)||{},{tr:r}=e,o=t.from;let l=t.to;const c=n.type.create(i);if(s[1]){let d=o+s[0].lastIndexOf(s[1]);d>l?d=l:l=d+s[1].length;const u=s[0][s[0].length-1];r.insertText(u,o+s[0].length-1),r.replaceWith(d,l,c)}else if(s[0]){const d=n.type.isInline?o:o-1;r.insert(d,n.type.create(i)).delete(r.mapping.map(o),r.mapping.map(l))}r.scrollIntoView()},undoable:n.undoable})}function jr(n){return new ks({find:n.find,handler:({state:e,range:t,match:s})=>{const i=e.doc.resolve(t.from),r=se(n.getAttributes,void 0,s)||{};if(!i.node(-1).canReplaceWith(i.index(-1),i.indexAfter(-1),n.type))return null;e.tr.delete(t.from,t.to).setBlockType(t.from,t.from,n.type,r)},undoable:n.undoable})}function On(n){return new ks({find:n.find,handler:({state:e,range:t,match:s,chain:i})=>{const r=se(n.getAttributes,void 0,s)||{},o=e.tr.delete(t.from,t.to),l=o.doc.resolve(t.from).blockRange(),c=l&&no(l,n.type,r);if(!c)return null;if(o.wrap(l,c),n.keepMarks&&n.editor){const{selection:u,storedMarks:p}=e,{splittableMarks:f}=n.editor.extensionManager,h=p||u.$to.parentOffset&&u.$from.marks();if(h){const g=h.filter(b=>f.includes(b.type.name));o.ensureMarks(g)}}if(n.keepAttributes){const u=n.type.name==="bulletList"||n.type.name==="orderedList"?"listItem":"taskList";i().updateAttributes(u,r).run()}const d=o.doc.resolve(t.from-1).nodeBefore;d&&d.type===n.type&&_t(o.doc,t.from-1)&&(!n.joinPredicate||n.joinPredicate(s,d))&&o.join(t.from-1)},undoable:n.undoable})}var Fe=class Yd extends Co{constructor(...e){super(...e),this.type="node"}static create(e={}){const t=typeof e=="function"?e():e;return new Yd(t)}configure(e){return super.configure(e)}extend(e){const t=typeof e=="function"?e():e;return super.extend(t)}};function Pt(n){return new Jd({find:n.find,handler:({state:e,range:t,match:s,pasteEvent:i})=>{const r=se(n.getAttributes,void 0,s,i);if(r===!1||r===null)return null;const{tr:o}=e,l=s[s.length-1],c=s[0];let d=t.to;if(l){const u=c.search(/\S/),p=t.from+c.indexOf(l),f=p+l.length;if(Ui(t.from,t.to,e.doc).filter(h=>h.mark.type.excluded.find(g=>g===n.type&&g!==h.mark.type)).filter(h=>h.to>p).length)return null;ft.from&&o.delete(t.from+u,p),d=t.from+u+l.length,o.addMark(t.from+u,d,n.type.create(r||{})),s.index!==void 0&&s.input!==void 0&&s.index+s[0].length>=s.input.length||o.removeStoredMark(n.type)}}})}function oa(n){return Ru((e,t)=>({get(){return e(),n},set(s){n=s,requestAnimationFrame(()=>{requestAnimationFrame(()=>{t()})})}}))}var Jx=class extends Wx{constructor(n={}){return super(n),this.contentComponent=null,this.appContext=null,this.reactiveState=oa(this.view.state),this.reactiveExtensionStorage=oa(this.extensionStorage),this.on("beforeTransaction",({nextState:e})=>{this.reactiveState.value=e,this.reactiveExtensionStorage.value=this.extensionStorage}),$u(this)}get state(){return this.reactiveState?this.reactiveState.value:this.view.state}get storage(){return this.reactiveExtensionStorage?this.reactiveExtensionStorage.value:super.storage}registerPlugin(n,e){const t=super.registerPlugin(n,e);return this.reactiveState&&(this.reactiveState.value=t),t}unregisterPlugin(n){const e=super.unregisterPlugin(n);return this.reactiveState&&e&&(this.reactiveState.value=e),e}};const Gx=Du({name:"EditorContent",props:{editor:{default:null,type:Object}},setup(n){const e=P(),t=_u();return Pu(()=>{const s=n.editor;s&&s.options.element&&e.value&&Bu(()=>{var i;if(!e.value||!(!((i=s.view.dom)===null||i===void 0)&&i.parentNode))return;const r=j(e.value);e.value.append(...s.view.dom.parentNode.childNodes),s.contentComponent=t.ctx._,t&&(s.appContext={...t.appContext,provides:t.provides}),s.setOptions({element:r}),s.createNodeViews()})}),Bt(()=>{const s=n.editor;s&&(s.contentComponent=null,s.appContext=null)}),{rootEl:e}},render(){return Lu("div",{ref:n=>{this.rootEl=n}})}}),Xd=new WeakSet,Zd=new WeakSet;function Ht(n){const e=n;return Xd.add(e),e}function Fr(n){return Array.isArray(n)&&Xd.has(n)}function Qd(n){return n.flatMap(e=>e==null?[]:Array.isArray(e)&&Zd.has(e)&&!Fr(e)?Qd(e):[e])}function Yx(n,e){if(n==="slot")return 0;if(n instanceof Function){const i=n(e);return Array.isArray(i)&&!Fr(i)&&!Zd.has(i)?Ht(i):i}const{children:t,...s}=e!=null?e:{};if(n==="svg")throw new Error("SVG elements are not supported in the JSX syntax, use the array syntax instead");if(Array.isArray(t)){if(Fr(t))return Ht([n,s,t]);if(t.length===0)return Ht([n,s]);const i=Qd(t);return i.length===0?Ht([n,s]):Ht([n,s,...i])}return t!=null?Ht([n,s,t]):Ht([n,s])}const si=(n,e)=>Yx(n,e),Xx=(n,e)=>{var t;const{state:s}=n,{selection:i}=s;if(!i.empty)return!1;const{$from:r}=i;if(r.parentOffset!==0)return!1;const o=r.depth-1;if(o<0)return!1;const l=r.node(o),c=r.index(o);if(c===0)return!1;if(l.type===e)return n.commands.lift(e.name);const d=l.child(c-1);if(d.type!==e||!(!((t=d.lastChild)===null||t===void 0)&&t.isTextblock))return!1;const u=r.before()-1-1;return n.commands.command(({tr:p,dispatch:f})=>{if(!f)return!0;const h=r.parent.content,g=new z(h,0,0);return p.replace(u,r.after(),g),p.setSelection(U.create(p.doc,u+h.size)),p.scrollIntoView(),f(p),!0})},Zx=/^\s*>\s$/,Qx=Fe.create({name:"blockquote",addOptions(){return{HTMLAttributes:{}}},content:"block+",group:"block",defining:!0,parseHTML(){return[{tag:"blockquote"}]},renderHTML({HTMLAttributes:n}){return si("blockquote",{...ke(this.options.HTMLAttributes,n),children:si("slot",{})})},parseMarkdown:(n,e)=>{var t;const s=(t=e.parseBlockChildren)!==null&&t!==void 0?t:e.parseChildren;return e.createNode("blockquote",void 0,s(n.tokens||[]))},renderMarkdown:(n,e)=>{if(!n.content)return"";const t=">",s=[];return n.content.forEach((i,r)=>{var o,l;const c=((o=(l=e.renderChild)===null||l===void 0?void 0:l.call(e,i,r))!==null&&o!==void 0?o:e.renderChildren([i])).split(` +`,textSerializers:s={}}=e||{};return vk(this.state.doc,{blockSeparator:t,textSerializers:{...$d(this.schema),...s}})}get isEmpty(){return ys(this.state.doc)}destroy(){this.destroyed||(this.destroyed=!0,this.emit("destroy"),this.unmount(),this.removeAllListeners(),this.extensionManager.destroy(),this.extensionManager=null,this.schema=null,this.commandManager=null,this.extensionStorage={})}get isDestroyed(){var e,t;return(e=(t=this.editorView)===null||t===void 0?void 0:t.isDestroyed)!==null&&e!==void 0?e:!0}$node(e,t){var s;return((s=this.$doc)===null||s===void 0?void 0:s.querySelector(e,t))||null}$nodes(e,t){var s;return((s=this.$doc)===null||s===void 0?void 0:s.querySelectorAll(e,t))||null}$pos(e){const t=this.state.doc.resolve(e),s=e>0&&t.nodeAfter&&!t.nodeAfter.isText&&t.nodeAfter.isAtom?t.nodeAfter:null;return new Ux(t,this,!1,s)}get $doc(){return this.$pos(0)}};function on(n){return new ks({find:n.find,handler:({state:e,range:t,match:s})=>{const i=se(n.getAttributes,void 0,s);if(i===!1||i===null)return null;const{tr:r}=e,o=s[s.length-1],l=s[0];if(o){const c=l.search(/\S/),d=t.from+l.indexOf(o),u=d+o.length;if(Ui(t.from,t.to,e.doc).filter(f=>f.mark.type.excluded.find(h=>h===n.type&&h!==f.mark.type)).filter(f=>f.to>d).length)return null;ut.from&&r.delete(t.from+c,d);const p=t.from+c+o.length;r.addMark(t.from+c,p,n.type.create(i||{})),r.removeStoredMark(n.type)}},undoable:n.undoable})}function Jx(n){return new ks({find:n.find,handler:({state:e,range:t,match:s})=>{const i=se(n.getAttributes,void 0,s)||{},{tr:r}=e,o=t.from;let l=t.to;const c=n.type.create(i);if(s[1]){let d=o+s[0].lastIndexOf(s[1]);d>l?d=l:l=d+s[1].length;const u=s[0][s[0].length-1];r.insertText(u,o+s[0].length-1),r.replaceWith(d,l,c)}else if(s[0]){const d=n.type.isInline?o:o-1;r.insert(d,n.type.create(i)).delete(r.mapping.map(o),r.mapping.map(l))}r.scrollIntoView()},undoable:n.undoable})}function jr(n){return new ks({find:n.find,handler:({state:e,range:t,match:s})=>{const i=e.doc.resolve(t.from),r=se(n.getAttributes,void 0,s)||{};if(!i.node(-1).canReplaceWith(i.index(-1),i.indexAfter(-1),n.type))return null;e.tr.delete(t.from,t.to).setBlockType(t.from,t.from,n.type,r)},undoable:n.undoable})}function On(n){return new ks({find:n.find,handler:({state:e,range:t,match:s,chain:i})=>{const r=se(n.getAttributes,void 0,s)||{},o=e.tr.delete(t.from,t.to),l=o.doc.resolve(t.from).blockRange(),c=l&&no(l,n.type,r);if(!c)return null;if(o.wrap(l,c),n.keepMarks&&n.editor){const{selection:u,storedMarks:p}=e,{splittableMarks:f}=n.editor.extensionManager,h=p||u.$to.parentOffset&&u.$from.marks();if(h){const g=h.filter(b=>f.includes(b.type.name));o.ensureMarks(g)}}if(n.keepAttributes){const u=n.type.name==="bulletList"||n.type.name==="orderedList"?"listItem":"taskList";i().updateAttributes(u,r).run()}const d=o.doc.resolve(t.from-1).nodeBefore;d&&d.type===n.type&&_t(o.doc,t.from-1)&&(!n.joinPredicate||n.joinPredicate(s,d))&&o.join(t.from-1)},undoable:n.undoable})}var Fe=class Yd extends Co{constructor(...e){super(...e),this.type="node"}static create(e={}){const t=typeof e=="function"?e():e;return new Yd(t)}configure(e){return super.configure(e)}extend(e){const t=typeof e=="function"?e():e;return super.extend(t)}};function Pt(n){return new Jd({find:n.find,handler:({state:e,range:t,match:s,pasteEvent:i})=>{const r=se(n.getAttributes,void 0,s,i);if(r===!1||r===null)return null;const{tr:o}=e,l=s[s.length-1],c=s[0];let d=t.to;if(l){const u=c.search(/\S/),p=t.from+c.indexOf(l),f=p+l.length;if(Ui(t.from,t.to,e.doc).filter(h=>h.mark.type.excluded.find(g=>g===n.type&&g!==h.mark.type)).filter(h=>h.to>p).length)return null;ft.from&&o.delete(t.from+u,p),d=t.from+u+l.length,o.addMark(t.from+u,d,n.type.create(r||{})),s.index!==void 0&&s.input!==void 0&&s.index+s[0].length>=s.input.length||o.removeStoredMark(n.type)}}})}function oa(n){return Ru((e,t)=>({get(){return e(),n},set(s){n=s,requestAnimationFrame(()=>{requestAnimationFrame(()=>{t()})})}}))}var Gx=class extends Kx{constructor(n={}){return super(n),this.contentComponent=null,this.appContext=null,this.reactiveState=oa(this.view.state),this.reactiveExtensionStorage=oa(this.extensionStorage),this.on("beforeTransaction",({nextState:e})=>{this.reactiveState.value=e,this.reactiveExtensionStorage.value=this.extensionStorage}),$u(this)}get state(){return this.reactiveState?this.reactiveState.value:this.view.state}get storage(){return this.reactiveExtensionStorage?this.reactiveExtensionStorage.value:super.storage}registerPlugin(n,e){const t=super.registerPlugin(n,e);return this.reactiveState&&(this.reactiveState.value=t),t}unregisterPlugin(n){const e=super.unregisterPlugin(n);return this.reactiveState&&e&&(this.reactiveState.value=e),e}};const Yx=Du({name:"EditorContent",props:{editor:{default:null,type:Object}},setup(n){const e=P(),t=_u();return Pu(()=>{const s=n.editor;s&&s.options.element&&e.value&&Bu(()=>{var i;if(!e.value||!(!((i=s.view.dom)===null||i===void 0)&&i.parentNode))return;const r=j(e.value);e.value.append(...s.view.dom.parentNode.childNodes),s.contentComponent=t.ctx._,t&&(s.appContext={...t.appContext,provides:t.provides}),s.setOptions({element:r}),s.createNodeViews()})}),Bt(()=>{const s=n.editor;s&&(s.contentComponent=null,s.appContext=null)}),{rootEl:e}},render(){return Lu("div",{ref:n=>{this.rootEl=n}})}}),Xd=new WeakSet,Zd=new WeakSet;function Ht(n){const e=n;return Xd.add(e),e}function Fr(n){return Array.isArray(n)&&Xd.has(n)}function Qd(n){return n.flatMap(e=>e==null?[]:Array.isArray(e)&&Zd.has(e)&&!Fr(e)?Qd(e):[e])}function Xx(n,e){if(n==="slot")return 0;if(n instanceof Function){const i=n(e);return Array.isArray(i)&&!Fr(i)&&!Zd.has(i)?Ht(i):i}const{children:t,...s}=e!=null?e:{};if(n==="svg")throw new Error("SVG elements are not supported in the JSX syntax, use the array syntax instead");if(Array.isArray(t)){if(Fr(t))return Ht([n,s,t]);if(t.length===0)return Ht([n,s]);const i=Qd(t);return i.length===0?Ht([n,s]):Ht([n,s,...i])}return t!=null?Ht([n,s,t]):Ht([n,s])}const si=(n,e)=>Xx(n,e),Zx=(n,e)=>{var t;const{state:s}=n,{selection:i}=s;if(!i.empty)return!1;const{$from:r}=i;if(r.parentOffset!==0)return!1;const o=r.depth-1;if(o<0)return!1;const l=r.node(o),c=r.index(o);if(c===0)return!1;if(l.type===e)return n.commands.lift(e.name);const d=l.child(c-1);if(d.type!==e||!(!((t=d.lastChild)===null||t===void 0)&&t.isTextblock))return!1;const u=r.before()-1-1;return n.commands.command(({tr:p,dispatch:f})=>{if(!f)return!0;const h=r.parent.content,g=new z(h,0,0);return p.replace(u,r.after(),g),p.setSelection(U.create(p.doc,u+h.size)),p.scrollIntoView(),f(p),!0})},Qx=/^\s*>\s$/,ew=Fe.create({name:"blockquote",addOptions(){return{HTMLAttributes:{}}},content:"block+",group:"block",defining:!0,parseHTML(){return[{tag:"blockquote"}]},renderHTML({HTMLAttributes:n}){return si("blockquote",{...ke(this.options.HTMLAttributes,n),children:si("slot",{})})},parseMarkdown:(n,e)=>{var t;const s=(t=e.parseBlockChildren)!==null&&t!==void 0?t:e.parseChildren;return e.createNode("blockquote",void 0,s(n.tokens||[]))},renderMarkdown:(n,e)=>{if(!n.content)return"";const t=">",s=[];return n.content.forEach((i,r)=>{var o,l;const c=((o=(l=e.renderChild)===null||l===void 0?void 0:l.call(e,i,r))!==null&&o!==void 0?o:e.renderChildren([i])).split(` `).map(d=>d.trim()===""?t:`${t} ${d}`);s.push(c.join(` `))}),s.join(` ${t} -`)},addCommands(){return{setBlockquote:()=>({commands:n})=>n.wrapIn(this.name),toggleBlockquote:()=>({commands:n})=>n.toggleWrap(this.name),unsetBlockquote:()=>({commands:n})=>n.lift(this.name)}},addKeyboardShortcuts(){return{"Mod-Shift-b":()=>this.editor.commands.toggleBlockquote(),Backspace:()=>Xx(this.editor,this.type)}},addInputRules(){return[On({find:Zx,type:this.type})]}}),ew=/(?:^|\s)(\*\*(?!\s+\*\*)((?:[^*]+))\*\*(?!\s+\*\*))$/,tw=/(?:^|\s)(\*\*(?!\s+\*\*)((?:[^*]+))\*\*(?!\s+\*\*))/g,nw=/(?:^|\s)(__(?!\s+__)((?:[^_]+))__(?!\s+__))$/,sw=/(?:^|\s)(__(?!\s+__)((?:[^_]+))__(?!\s+__))/g,iw=an.create({name:"bold",addOptions(){return{HTMLAttributes:{}}},parseHTML(){return[{tag:"strong"},{tag:"b",getAttrs:n=>n.style.fontWeight!=="normal"&&null},{style:"font-weight=400",clearMark:n=>n.type.name===this.name},{style:"font-weight",getAttrs:n=>/^(bold(er)?|[5-9]\d{2,})$/.test(n)&&null}]},renderHTML({HTMLAttributes:n}){return si("strong",{...ke(this.options.HTMLAttributes,n),children:si("slot",{})})},markdownTokenName:"strong",parseMarkdown:(n,e)=>e.applyMark("bold",e.parseInline(n.tokens||[])),markdownOptions:{htmlReopen:{open:"",close:""}},renderMarkdown:(n,e)=>`**${e.renderChildren(n)}**`,addCommands(){return{setBold:()=>({commands:n})=>n.setMark(this.name),toggleBold:()=>({commands:n})=>n.toggleMark(this.name),unsetBold:()=>({commands:n})=>n.unsetMark(this.name)}},addKeyboardShortcuts(){return{"Mod-b":()=>this.editor.commands.toggleBold(),"Mod-B":()=>this.editor.commands.toggleBold()}},addInputRules(){return[on({find:ew,type:this.type}),on({find:nw,type:this.type})]},addPasteRules(){return[Pt({find:tw,type:this.type}),Pt({find:sw,type:this.type})]}}),rw=n=>{const e=/`([^`]+)`(?!`)$/.exec(n);return!e||e.index>0&&n[e.index-1]==="`"?null:{index:e.index,text:e[0],replaceWith:e[1]}},ow=n=>{const e=/`([^`]+)`(?!`)/g,t=[];let s;for(;(s=e.exec(n))!==null;)s.index>0&&n[s.index-1]==="`"||t.push({index:s.index,text:s[0],replaceWith:s[1]});return t};function lw(n){const e=new Set((n.match(/`+/g)||[]).map(s=>s.length));let t=1;for(;e.has(t);)t+=1;return t}const aw=an.create({name:"code",addOptions(){return{HTMLAttributes:{}}},excludes:"_",code:!0,exitable:!0,parseHTML(){return[{tag:"code"}]},renderHTML({HTMLAttributes:n}){return["code",ke(this.options.HTMLAttributes,n),0]},markdownTokenName:"codespan",parseMarkdown:(n,e)=>e.applyMark("code",[{type:"text",text:n.text||""}]),renderMarkdown:(n,e,t)=>{var s;if(!n.content)return"";const i=typeof(t==null||(s=t.meta)===null||s===void 0?void 0:s.markText)=="string"?t.meta.markText:"",r="`".repeat(lw(i)),o=i.startsWith("`")||i.endsWith("`")?" ":"";return`${r}${o}${e.renderChildren(n.content)}${o}${r}`},addCommands(){return{setCode:()=>({commands:n})=>n.setMark(this.name),toggleCode:()=>({commands:n})=>n.toggleMark(this.name),unsetCode:()=>({commands:n})=>n.unsetMark(this.name)}},addKeyboardShortcuts(){return{"Mod-e":()=>this.editor.commands.toggleCode()}},addInputRules(){return[on({find:rw,type:this.type})]},addPasteRules(){return[Pt({find:ow,type:this.type})]}}),ur=4,cw=/^```([a-z]+)?[\s\n]$/,dw=/^~~~([a-z]+)?[\s\n]$/,uw=Fe.create({name:"codeBlock",addOptions(){return{languageClassPrefix:"language-",exitOnTripleEnter:!0,exitOnArrowDown:!0,exitOnArrowUp:!0,defaultLanguage:null,enableTabIndentation:!1,tabSize:ur,HTMLAttributes:{}}},content:"text*",marks:"",group:"block",code:!0,defining:!0,addAttributes(){return{language:{default:this.options.defaultLanguage,parseHTML:n=>{var e;const{languageClassPrefix:t}=this.options;if(!t)return null;const s=[...((e=n.firstElementChild)===null||e===void 0?void 0:e.classList)||[]].filter(i=>i.startsWith(t)).map(i=>i.replace(t,""))[0];return s||null},rendered:!1}}},parseHTML(){return[{tag:"pre",preserveWhitespace:"full"}]},renderHTML({node:n,HTMLAttributes:e}){return["pre",ke(this.options.HTMLAttributes,e),["code",{class:n.attrs.language?this.options.languageClassPrefix+n.attrs.language:null},0]]},markdownTokenName:"code",parseMarkdown:(n,e)=>{var t,s;return((t=n.raw)===null||t===void 0?void 0:t.startsWith("```"))===!1&&((s=n.raw)===null||s===void 0?void 0:s.startsWith("~~~"))===!1&&n.codeBlockStyle!=="indented"?[]:e.createNode("codeBlock",{language:n.lang||null},n.text?[e.createTextNode(n.text)]:[])},renderMarkdown:(n,e)=>{var t;let s="";const i=((t=n.attrs)===null||t===void 0?void 0:t.language)||"";return n.content?s=[`\`\`\`${i}`,e.renderChildren(n.content),"```"].join(` +`)},addCommands(){return{setBlockquote:()=>({commands:n})=>n.wrapIn(this.name),toggleBlockquote:()=>({commands:n})=>n.toggleWrap(this.name),unsetBlockquote:()=>({commands:n})=>n.lift(this.name)}},addKeyboardShortcuts(){return{"Mod-Shift-b":()=>this.editor.commands.toggleBlockquote(),Backspace:()=>Zx(this.editor,this.type)}},addInputRules(){return[On({find:Qx,type:this.type})]}}),tw=/(?:^|\s)(\*\*(?!\s+\*\*)((?:[^*]+))\*\*(?!\s+\*\*))$/,nw=/(?:^|\s)(\*\*(?!\s+\*\*)((?:[^*]+))\*\*(?!\s+\*\*))/g,sw=/(?:^|\s)(__(?!\s+__)((?:[^_]+))__(?!\s+__))$/,iw=/(?:^|\s)(__(?!\s+__)((?:[^_]+))__(?!\s+__))/g,rw=an.create({name:"bold",addOptions(){return{HTMLAttributes:{}}},parseHTML(){return[{tag:"strong"},{tag:"b",getAttrs:n=>n.style.fontWeight!=="normal"&&null},{style:"font-weight=400",clearMark:n=>n.type.name===this.name},{style:"font-weight",getAttrs:n=>/^(bold(er)?|[5-9]\d{2,})$/.test(n)&&null}]},renderHTML({HTMLAttributes:n}){return si("strong",{...ke(this.options.HTMLAttributes,n),children:si("slot",{})})},markdownTokenName:"strong",parseMarkdown:(n,e)=>e.applyMark("bold",e.parseInline(n.tokens||[])),markdownOptions:{htmlReopen:{open:"",close:""}},renderMarkdown:(n,e)=>`**${e.renderChildren(n)}**`,addCommands(){return{setBold:()=>({commands:n})=>n.setMark(this.name),toggleBold:()=>({commands:n})=>n.toggleMark(this.name),unsetBold:()=>({commands:n})=>n.unsetMark(this.name)}},addKeyboardShortcuts(){return{"Mod-b":()=>this.editor.commands.toggleBold(),"Mod-B":()=>this.editor.commands.toggleBold()}},addInputRules(){return[on({find:tw,type:this.type}),on({find:sw,type:this.type})]},addPasteRules(){return[Pt({find:nw,type:this.type}),Pt({find:iw,type:this.type})]}}),ow=n=>{const e=/`([^`]+)`(?!`)$/.exec(n);return!e||e.index>0&&n[e.index-1]==="`"?null:{index:e.index,text:e[0],replaceWith:e[1]}},lw=n=>{const e=/`([^`]+)`(?!`)/g,t=[];let s;for(;(s=e.exec(n))!==null;)s.index>0&&n[s.index-1]==="`"||t.push({index:s.index,text:s[0],replaceWith:s[1]});return t};function aw(n){const e=new Set((n.match(/`+/g)||[]).map(s=>s.length));let t=1;for(;e.has(t);)t+=1;return t}const cw=an.create({name:"code",addOptions(){return{HTMLAttributes:{}}},excludes:"_",code:!0,exitable:!0,parseHTML(){return[{tag:"code"}]},renderHTML({HTMLAttributes:n}){return["code",ke(this.options.HTMLAttributes,n),0]},markdownTokenName:"codespan",parseMarkdown:(n,e)=>e.applyMark("code",[{type:"text",text:n.text||""}]),renderMarkdown:(n,e,t)=>{var s;if(!n.content)return"";const i=typeof(t==null||(s=t.meta)===null||s===void 0?void 0:s.markText)=="string"?t.meta.markText:"",r="`".repeat(aw(i)),o=i.startsWith("`")||i.endsWith("`")?" ":"";return`${r}${o}${e.renderChildren(n.content)}${o}${r}`},addCommands(){return{setCode:()=>({commands:n})=>n.setMark(this.name),toggleCode:()=>({commands:n})=>n.toggleMark(this.name),unsetCode:()=>({commands:n})=>n.unsetMark(this.name)}},addKeyboardShortcuts(){return{"Mod-e":()=>this.editor.commands.toggleCode()}},addInputRules(){return[on({find:ow,type:this.type})]},addPasteRules(){return[Pt({find:lw,type:this.type})]}}),ur=4,dw=/^```([a-z]+)?[\s\n]$/,uw=/^~~~([a-z]+)?[\s\n]$/,pw=Fe.create({name:"codeBlock",addOptions(){return{languageClassPrefix:"language-",exitOnTripleEnter:!0,exitOnArrowDown:!0,exitOnArrowUp:!0,defaultLanguage:null,enableTabIndentation:!1,tabSize:ur,HTMLAttributes:{}}},content:"text*",marks:"",group:"block",code:!0,defining:!0,addAttributes(){return{language:{default:this.options.defaultLanguage,parseHTML:n=>{var e;const{languageClassPrefix:t}=this.options;if(!t)return null;const s=[...((e=n.firstElementChild)===null||e===void 0?void 0:e.classList)||[]].filter(i=>i.startsWith(t)).map(i=>i.replace(t,""))[0];return s||null},rendered:!1}}},parseHTML(){return[{tag:"pre",preserveWhitespace:"full"}]},renderHTML({node:n,HTMLAttributes:e}){return["pre",ke(this.options.HTMLAttributes,e),["code",{class:n.attrs.language?this.options.languageClassPrefix+n.attrs.language:null},0]]},markdownTokenName:"code",parseMarkdown:(n,e)=>{var t,s;return((t=n.raw)===null||t===void 0?void 0:t.startsWith("```"))===!1&&((s=n.raw)===null||s===void 0?void 0:s.startsWith("~~~"))===!1&&n.codeBlockStyle!=="indented"?[]:e.createNode("codeBlock",{language:n.lang||null},n.text?[e.createTextNode(n.text)]:[])},renderMarkdown:(n,e)=>{var t;let s="";const i=((t=n.attrs)===null||t===void 0?void 0:t.language)||"";return n.content?s=[`\`\`\`${i}`,e.renderChildren(n.content),"```"].join(` `):s=`\`\`\`${i} \`\`\``,s},addCommands(){return{setCodeBlock:n=>({commands:e})=>e.setNode(this.name,n),toggleCodeBlock:n=>({commands:e})=>e.toggleNode(this.name,"paragraph",n)}},addKeyboardShortcuts(){return{"Mod-Alt-c":()=>this.editor.commands.toggleCodeBlock(),Backspace:()=>{const{empty:n,$anchor:e}=this.editor.state.selection,t=e.pos===1;return!n||e.parent.type.name!==this.name?!1:t||!e.parent.textContent.length?this.editor.commands.clearNodes():!1},Tab:({editor:n})=>{var e;if(!this.options.enableTabIndentation)return!1;const t=(e=this.options.tabSize)!==null&&e!==void 0?e:ur,{state:s}=n,{selection:i}=s,{$from:r,empty:o}=i;if(r.parent.type!==this.type)return!1;const l=" ".repeat(t);return o?n.commands.insertContent(l):n.commands.command(({tr:c})=>{const{from:d,to:u}=i,p=s.doc.textBetween(d,u,` @@ -119,28 +119,28 @@ ${t} `).map(p=>{var f;const h=((f=p.match(/^ */))===null||f===void 0?void 0:f[0])||"",g=Math.min(h.length,t);return p.slice(g)}).join(` `);return l.replaceWith(c,d,s.schema.text(u)),!0})},Enter:({editor:n})=>{if(!this.options.exitOnTripleEnter)return!1;const{state:e}=n,{selection:t}=e,{$from:s,empty:i}=t;if(!i||s.parent.type!==this.type)return!1;const r=s.parentOffset===s.parent.nodeSize-2,o=s.parent.textContent.endsWith(` -`);return!r||!o?!1:n.chain().command(({tr:l})=>(l.delete(s.pos-2,s.pos),!0)).exitCode().run()},ArrowUp:({editor:n})=>{if(!this.options.exitOnArrowUp)return!1;const{state:e}=n,{selection:t}=e,{$from:s,empty:i}=t;if(!i||s.parent.type!==this.type||s.parentOffset!==0)return!1;const r=s.before();return r>0?!1:n.commands.insertDefaultBlock({pos:r})},ArrowDown:({editor:n})=>{if(!this.options.exitOnArrowDown)return!1;const{state:e}=n,{selection:t,doc:s}=e,{$from:i,empty:r}=t;if(!r||i.parent.type!==this.type||i.parentOffset!==i.parent.nodeSize-2)return!1;const o=i.after();return o===void 0?!1:s.nodeAt(o)?n.commands.command(({tr:l})=>(l.setSelection(X.near(s.resolve(o))),!0)):n.commands.exitCode()}}},addInputRules(){return[jr({find:cw,type:this.type,getAttributes:n=>({language:n[1]})}),jr({find:dw,type:this.type,getAttributes:n=>({language:n[1]})})]},addProseMirrorPlugins(){return[new oe({key:new me("codeBlockVSCodeHandler"),props:{handlePaste:(n,e)=>{if(!e.clipboardData||this.editor.isActive(this.type.name))return!1;const t=e.clipboardData.getData("text/plain"),s=e.clipboardData.getData("vscode-editor-data"),i=s?JSON.parse(s):void 0,r=i==null?void 0:i.mode;if(!t||!r)return!1;const{tr:o,schema:l}=n.state,c=l.text(t.replace(/\r\n?/g,` -`));return o.replaceSelectionWith(this.type.create({language:r},c)),o.selection.$from.parent.type!==this.type&&o.setSelection(U.near(o.doc.resolve(Math.max(0,o.selection.from-2)))),o.setMeta("paste",!0),n.dispatch(o),!0}}})]}}),pw=Fe.create({name:"doc",topNode:!0,content:"block+",renderMarkdown:(n,e)=>n.content?e.renderChildren(n.content,` +`);return!r||!o?!1:n.chain().command(({tr:l})=>(l.delete(s.pos-2,s.pos),!0)).exitCode().run()},ArrowUp:({editor:n})=>{if(!this.options.exitOnArrowUp)return!1;const{state:e}=n,{selection:t}=e,{$from:s,empty:i}=t;if(!i||s.parent.type!==this.type||s.parentOffset!==0)return!1;const r=s.before();return r>0?!1:n.commands.insertDefaultBlock({pos:r})},ArrowDown:({editor:n})=>{if(!this.options.exitOnArrowDown)return!1;const{state:e}=n,{selection:t,doc:s}=e,{$from:i,empty:r}=t;if(!r||i.parent.type!==this.type||i.parentOffset!==i.parent.nodeSize-2)return!1;const o=i.after();return o===void 0?!1:s.nodeAt(o)?n.commands.command(({tr:l})=>(l.setSelection(X.near(s.resolve(o))),!0)):n.commands.exitCode()}}},addInputRules(){return[jr({find:dw,type:this.type,getAttributes:n=>({language:n[1]})}),jr({find:uw,type:this.type,getAttributes:n=>({language:n[1]})})]},addProseMirrorPlugins(){return[new oe({key:new me("codeBlockVSCodeHandler"),props:{handlePaste:(n,e)=>{if(!e.clipboardData||this.editor.isActive(this.type.name))return!1;const t=e.clipboardData.getData("text/plain"),s=e.clipboardData.getData("vscode-editor-data"),i=s?JSON.parse(s):void 0,r=i==null?void 0:i.mode;if(!t||!r)return!1;const{tr:o,schema:l}=n.state,c=l.text(t.replace(/\r\n?/g,` +`));return o.replaceSelectionWith(this.type.create({language:r},c)),o.selection.$from.parent.type!==this.type&&o.setSelection(U.near(o.doc.resolve(Math.max(0,o.selection.from-2)))),o.setMeta("paste",!0),n.dispatch(o),!0}}})]}}),fw=Fe.create({name:"doc",topNode:!0,content:"block+",renderMarkdown:(n,e)=>n.content?e.renderChildren(n.content,` -`):""}),fw=Fe.create({name:"hardBreak",markdownTokenName:"br",addOptions(){return{keepMarks:!0,HTMLAttributes:{}}},inline:!0,group:"inline",selectable:!1,linebreakReplacement:!0,parseHTML(){return[{tag:"br"}]},renderHTML({HTMLAttributes:n}){return["br",ke(this.options.HTMLAttributes,n)]},renderText(){return` +`):""}),hw=Fe.create({name:"hardBreak",markdownTokenName:"br",addOptions(){return{keepMarks:!0,HTMLAttributes:{}}},inline:!0,group:"inline",selectable:!1,linebreakReplacement:!0,parseHTML(){return[{tag:"br"}]},renderHTML({HTMLAttributes:n}){return["br",ke(this.options.HTMLAttributes,n)]},renderText(){return` `},renderMarkdown:()=>` -`,parseMarkdown:()=>({type:"hardBreak"}),addCommands(){return{setHardBreak:()=>({commands:n,chain:e,state:t,editor:s})=>n.first([()=>n.exitCode(),()=>n.command(()=>{const{selection:i,storedMarks:r}=t;if(i.$from.parent.type.spec.isolating)return!1;const{keepMarks:o}=this.options,{splittableMarks:l}=s.extensionManager,c=r||i.$to.parentOffset&&i.$from.marks();return e().insertContent({type:this.name}).command(({tr:d,dispatch:u})=>{if(u&&c&&o){const p=c.filter(f=>l.includes(f.type.name));d.ensureMarks(p)}return!0}).scrollIntoView().run()})])}},addKeyboardShortcuts(){return{"Mod-Enter":()=>this.editor.commands.setHardBreak(),"Shift-Enter":()=>this.editor.commands.setHardBreak()}}}),hw=Fe.create({name:"heading",addOptions(){return{levels:[1,2,3,4,5,6],HTMLAttributes:{}}},content:"inline*",group:"block",defining:!0,addAttributes(){return{level:{default:1,rendered:!1}}},parseHTML(){return this.options.levels.map(n=>({tag:`h${n}`,attrs:{level:n}}))},renderHTML({node:n,HTMLAttributes:e}){return[`h${this.options.levels.includes(n.attrs.level)?n.attrs.level:this.options.levels[0]}`,ke(this.options.HTMLAttributes,e),0]},parseMarkdown:(n,e)=>e.createNode("heading",{level:n.depth||1},e.parseInline(n.tokens||[])),renderMarkdown:(n,e)=>{var t;const s=!((t=n.attrs)===null||t===void 0)&&t.level?parseInt(n.attrs.level,10):1,i="#".repeat(s);return n.content?`${i} ${e.renderChildren(n.content)}`:""},addCommands(){return{setHeading:n=>({commands:e})=>this.options.levels.includes(n.level)?e.setNode(this.name,n):!1,toggleHeading:n=>({commands:e})=>this.options.levels.includes(n.level)?e.toggleNode(this.name,"paragraph",n):!1}},addKeyboardShortcuts(){return this.options.levels.reduce((n,e)=>({...n,[`Mod-Alt-${e}`]:()=>this.editor.commands.toggleHeading({level:e})}),{})},addInputRules(){return this.options.levels.map(n=>jr({find:new RegExp(`^(#{${Math.min(...this.options.levels)},${n}})\\s$`),type:this.type,getAttributes:{level:n}}))}}),mw=Fe.create({name:"horizontalRule",addOptions(){return{HTMLAttributes:{},nextNodeType:"paragraph"}},group:"block",parseHTML(){return[{tag:"hr"}]},renderHTML({HTMLAttributes:n}){return["hr",ke(this.options.HTMLAttributes,n)]},markdownTokenName:"hr",parseMarkdown:(n,e)=>e.createNode("horizontalRule"),renderMarkdown:()=>"---",addCommands(){return{setHorizontalRule:()=>({chain:n,state:e})=>{if(!vx(e,e.schema.nodes[this.name]))return!1;const{selection:t}=e,{$to:s}=t,i=n();return Ld(t)?i.insertContentAt(s.pos,{type:this.name}):i.insertContent({type:this.name}),i.command(({state:r,tr:o,dispatch:l})=>{if(l){const{$to:c}=o.selection,d=c.end();if(c.nodeAfter)c.nodeAfter.isTextblock?o.setSelection(U.create(o.doc,c.pos+1)):c.nodeAfter.isBlock?o.setSelection(W.create(o.doc,c.pos)):o.setSelection(U.create(o.doc,c.pos));else{const u=r.schema.nodes[this.options.nextNodeType]||c.parent.type.contentMatch.defaultType,p=u==null?void 0:u.create();p&&(o.insert(d,p),o.setSelection(U.create(o.doc,d+1)))}o.scrollIntoView()}return!0}).run()}}},addInputRules(){return[Kx({find:/^(?:---|—-|___\s|\*\*\*\s)$/,type:this.type})]}}),gw=/(?:^|\s)(\*(?!\s+\*)((?:[^*]+))\*(?!\s+\*))$/,bw=/(?:^|\s)(\*(?!\s+\*)((?:[^*]+))\*(?!\s+\*))/g,vw=/(?:^|\s)(_(?!\s+_)((?:[^_]+))_(?!\s+_))$/,yw=/(?:^|\s)(_(?!\s+_)((?:[^_]+))_(?!\s+_))/g,kw=an.create({name:"italic",addOptions(){return{HTMLAttributes:{}}},parseHTML(){return[{tag:"em"},{tag:"i",getAttrs:n=>n.style.fontStyle!=="normal"&&null},{style:"font-style=normal",clearMark:n=>n.type.name===this.name},{style:"font-style=italic"}]},renderHTML({HTMLAttributes:n}){return["em",ke(this.options.HTMLAttributes,n),0]},addCommands(){return{setItalic:()=>({commands:n})=>n.setMark(this.name),toggleItalic:()=>({commands:n})=>n.toggleMark(this.name),unsetItalic:()=>({commands:n})=>n.unsetMark(this.name)}},markdownTokenName:"em",parseMarkdown:(n,e)=>e.applyMark("italic",e.parseInline(n.tokens||[])),markdownOptions:{htmlReopen:{open:"",close:""}},renderMarkdown:(n,e)=>`*${e.renderChildren(n)}*`,addKeyboardShortcuts(){return{"Mod-i":()=>this.editor.commands.toggleItalic(),"Mod-I":()=>this.editor.commands.toggleItalic()}},addInputRules(){return[on({find:gw,type:this.type}),on({find:vw,type:this.type})]},addPasteRules(){return[Pt({find:bw,type:this.type}),Pt({find:yw,type:this.type})]}}),xw="aaa1rp3bb0ott3vie4c1le2ogado5udhabi7c0ademy5centure6ountant0s9o1tor4d0s1ult4e0g1ro2tna4f0l1rica5g0akhan5ency5i0g1rbus3force5tel5kdn3l0ibaba4pay4lfinanz6state5y2sace3tom5m0azon4ericanexpress7family11x2fam3ica3sterdam8nalytics7droid5quan4z2o0l2partments8p0le4q0uarelle8r0ab1mco4chi3my2pa2t0e3s0da2ia2sociates9t0hleta5torney7u0ction5di0ble3o3spost5thor3o0s4w0s2x0a2z0ure5ba0by2idu3namex4d1k2r0celona5laycard4s5efoot5gains6seball5ketball8uhaus5yern5b0c1t1va3cg1n2d1e0ats2uty4er2rlin4st0buy5t2f1g1h0arti5i0ble3d1ke2ng0o3o1z2j1lack0friday9ockbuster8g1omberg7ue3m0s1w2n0pparibas9o0ats3ehringer8fa2m1nd2o0k0ing5sch2tik2on4t1utique6x2r0adesco6idgestone9oadway5ker3ther5ussels7s1t1uild0ers6siness6y1zz3v1w1y1z0h3ca0b1fe2l0l1vinklein9m0era3p2non3petown5ital0one8r0avan4ds2e0er0s4s2sa1e1h1ino4t0ering5holic7ba1n1re3c1d1enter4o1rn3f0a1d2g1h0anel2nel4rity4se2t2eap3intai5ristmas6ome4urch5i0priani6rcle4sco3tadel4i0c2y3k1l0aims4eaning6ick2nic1que6othing5ud3ub0med6m1n1o0ach3des3ffee4llege4ogne5m0mbank4unity6pany2re3uter5sec4ndos3struction8ulting7tact3ractors9oking4l1p2rsica5untry4pon0s4rses6pa2r0edit0card4union9icket5own3s1uise0s6u0isinella9v1w1x1y0mru3ou3z2dad1nce3ta1e1ing3sun4y2clk3ds2e0al0er2s3gree4livery5l1oitte5ta3mocrat6ntal2ist5si0gn4v2hl2iamonds6et2gital5rect0ory7scount3ver5h2y2j1k1m1np2o0cs1tor4g1mains5t1wnload7rive4tv2ubai3pont4rban5vag2r2z2earth3t2c0o2deka3u0cation8e1g1mail3erck5nergy4gineer0ing9terprises10pson4quipment8r0icsson6ni3s0q1tate5t1u0rovision8s2vents5xchange6pert3osed4ress5traspace10fage2il1rwinds6th3mily4n0s2rm0ers5shion4t3edex3edback6rrari3ero6i0delity5o2lm2nal1nce1ial7re0stone6mdale6sh0ing5t0ness6j1k1lickr3ghts4r2orist4wers5y2m1o0o0d1tball6rd1ex2sale4um3undation8x2r0ee1senius7l1ogans4ntier7tr2ujitsu5n0d2rniture7tbol5yi3ga0l0lery3o1up4me0s3p1rden4y2b0iz3d0n2e0a1nt0ing5orge5f1g0ee3h1i0ft0s3ves2ing5l0ass3e1obal2o4m0ail3bh2o1x2n1odaddy5ld0point6f2odyear5g0le4p1t1v2p1q1r0ainger5phics5tis4een3ipe3ocery4up4s1t1u0cci3ge2ide2tars5ru3w1y2hair2mburg5ngout5us3bo2dfc0bank7ealth0care8lp1sinki6re1mes5iphop4samitsu7tachi5v2k0t2m1n1ockey4ldings5iday5medepot5goods5s0ense7nda3rse3spital5t0ing5t0els3mail5use3w2r1sbc3t1u0ghes5yatt3undai7ibm2cbc2e1u2d1e0ee3fm2kano4l1m0amat4db2mo0bilien9n0c1dustries8finiti5o2g1k1stitute6urance4e4t0ernational10uit4vestments10o1piranga7q1r0ish4s0maili5t0anbul7t0au2v3jaguar4va3cb2e0ep2tzt3welry6io2ll2m0p2nj2o0bs1urg4t1y2p0morgan6rs3uegos4niper7kaufen5ddi3e0rryhotels6properties14fh2g1h1i0a1ds2m1ndle4tchen5wi3m1n1oeln3matsu5sher5p0mg2n2r0d1ed3uokgroup8w1y0oto4z2la0caixa5mborghini8er3nd0rover6xess5salle5t0ino3robe5w0yer5b1c1ds2ease3clerc5frak4gal2o2xus4gbt3i0dl2fe0insurance9style7ghting6ke2lly3mited4o2ncoln4k2ve1ing5k1lc1p2oan0s3cker3us3l1ndon4tte1o3ve3pl0financial11r1s1t0d0a3u0ndbeck6xe1ury5v1y2ma0drid4if1son4keup4n0agement7go3p1rket0ing3s4riott5shalls7ttel5ba2c0kinsey7d1e0d0ia3et2lbourne7me1orial6n0u2rck0msd7g1h1iami3crosoft7l1ni1t2t0subishi9k1l0b1s2m0a2n1o0bi0le4da2e1i1m1nash3ey2ster5rmon3tgage6scow4to0rcycles9v0ie4p1q1r1s0d2t0n1r2u0seum3ic4v1w1x1y1z2na0b1goya4me2vy3ba2c1e0c1t0bank4flix4work5ustar5w0s2xt0direct7us4f0l2g0o2hk2i0co2ke1on3nja3ssan1y5l1o0kia3rton4w0ruz3tv4p1r0a1w2tt2u1yc2z2obi1server7ffice5kinawa6layan0group9lo3m0ega4ne1g1l0ine5oo2pen3racle3nge4g0anic5igins6saka4tsuka4t2vh3pa0ge2nasonic7ris2s1tners4s1y3y2ccw3e0t2f0izer5g1h0armacy6d1ilips5one2to0graphy6s4ysio5ics1tet2ures6d1n0g1k2oneer5zza4k1l0ace2y0station9umbing5s3m1n0c2ohl2ker3litie5rn2st3r0axi3ess3ime3o0d0uctions8f1gressive8mo2perties3y5tection8u0dential9s1t1ub2w0c2y2qa1pon3uebec3st5racing4dio4e0ad1lestate6tor2y4cipes5d0umbrella9hab3ise0n3t2liance6n0t0als5pair3ort3ublican8st0aurant8view0s5xroth6ich0ardli6oh3l1o1p2o0cks3deo3gers4om3s0vp3u0gby3hr2n2w0e2yukyu6sa0arland6fe0ty4kura4le1on3msclub4ung5ndvik0coromant12ofi4p1rl2s1ve2xo3b0i1s2c0b1haeffler7midt4olarships8ol3ule3warz5ience5ot3d1e0arch3t2cure1ity6ek2lect4ner3rvices6ven3w1x0y3fr2g1h0angrila6rp3ell3ia1ksha5oes2p0ping5uji3w3i0lk2na1gles5te3j1k0i0n2y0pe4l0ing4m0art3ile4n0cf3o0ccer3ial4ftbank4ware6hu2lar2utions7ng1y2y2pa0ce3ort2t3r0l2s1t0ada2ples4r1tebank4farm7c0group6ockholm6rage3e3ream4udio2y3yle4u0cks3pplies3y2ort5rf1gery5zuki5v1watch4iss4x1y0dney4stems6z2tab1ipei4lk2obao4rget4tamotors6r2too4x0i3c0i2d0k2eam2ch0nology8l1masek5nnis4va3f1g1h0d1eater2re6iaa2ckets5enda4ps2res2ol4j0maxx4x2k0maxx5l1m0all4n1o0day3kyo3ols3p1ray3shiba5tal3urs3wn2yota3s3r0ade1ing4ining5vel0ers0insurance16ust3v2t1ube2i1nes3shu4v0s2w1z2ua1bank3s2g1k1nicom3versity8o2ol2ps2s1y1z2va0cations7na1guard7c1e0gas3ntures6risign5mögensberater2ung14sicherung10t2g1i0ajes4deo3g1king4llas4n1p1rgin4sa1ion4va1o3laanderen9n1odka3lvo3te1ing3o2yage5u2wales2mart4ter4ng0gou5tch0es6eather0channel12bcam3er2site5d0ding5ibo2r3f1hoswho6ien2ki2lliamhill9n0dows4e1ners6me2oodside6rk0s2ld3w2s1tc1f3xbox3erox4ihuan4n2xx2yz3yachts4hoo3maxun5ndex5e1odobashi7ga2kohama6u0tube6t1un3za0ppos4ra3ero3ip2m1one3uerich6w2",ww="ελ1υ2бг1ел3дети4ею2католик6ом3мкд2он1сква6онлайн5рг3рус2ф2сайт3рб3укр3қаз3հայ3ישראל5קום3ابوظبي5رامكو5لاردن4بحرين5جزائر5سعودية6عليان5مغرب5مارات5یران5بارت2زار4يتك3ھارت5تونس4سودان3رية5شبكة4عراق2ب2مان4فلسطين6قطر3كاثوليك6وم3مصر2ليسيا5وريتانيا7قع4همراه5پاکستان7ڀارت4कॉम3नेट3भारत0म्3ोत5संगठन5বাংলা5ভারত2ৰত4ਭਾਰਤ4ભારત4ଭାରତ4இந்தியா6லங்கை6சிங்கப்பூர்11భారత్5ಭಾರತ4ഭാരതം5ලංකා4คอม3ไทย3ລາວ3გე2みんな3アマゾン4クラウド4グーグル4コム2ストア3セール3ファッション6ポイント4世界2中信1国1國1文网3亚马逊3企业2佛山2信息2健康2八卦2公司1益2台湾1灣2商城1店1标2嘉里0大酒店5在线2大拿2天主教3娱乐2家電2广东2微博2慈善2我爱你3手机2招聘2政务1府2新加坡2闻2时尚2書籍2机构2淡马锡3游戏2澳門2点看2移动2组织机构4网址1店1站1络2联通2谷歌2购物2通販2集团2電訊盈科4飞利浦3食品2餐厅2香格里拉3港2닷넷1컴2삼성2한국2",Vr="numeric",Hr="ascii",qr="alpha",Jn="asciinumeric",Vn="alphanumeric",Ur="domain",eu="emoji",Sw="scheme",Cw="slashscheme",pr="whitespace";function Mw(n,e){return n in e||(e[n]=[]),e[n]}function Jt(n,e,t){e[Vr]&&(e[Jn]=!0,e[Vn]=!0),e[Hr]&&(e[Jn]=!0,e[qr]=!0),e[Jn]&&(e[Vn]=!0),e[qr]&&(e[Vn]=!0),e[Vn]&&(e[Ur]=!0),e[eu]&&(e[Ur]=!0);for(const s in e){const i=Mw(s,t);i.indexOf(n)<0&&i.push(n)}}function Tw(n,e){const t={};for(const s in e)e[s].indexOf(n)>=0&&(t[s]=!0);return t}function _e(n=null){this.j={},this.jr=[],this.jd=null,this.t=n}_e.groups={};_e.prototype={accepts(){return!!this.t},go(n){const e=this,t=e.j[n];if(t)return t;for(let s=0;sn.ta(e,t,s,i),ce=(n,e,t,s,i)=>n.tr(e,t,s,i),la=(n,e,t,s,i)=>n.ts(e,t,s,i),L=(n,e,t,s,i)=>n.tt(e,t,s,i),dt="WORD",Wr="UWORD",tu="ASCIINUMERICAL",nu="ALPHANUMERICAL",fs="LOCALHOST",Kr="TLD",Jr="UTLD",Hs="SCHEME",vn="SLASH_SCHEME",Mo="NUM",Gr="WS",To="NL",Gn="OPENBRACE",Yn="CLOSEBRACE",ii="OPENBRACKET",ri="CLOSEBRACKET",oi="OPENPAREN",li="CLOSEPAREN",ai="OPENANGLEBRACKET",ci="CLOSEANGLEBRACKET",di="FULLWIDTHLEFTPAREN",ui="FULLWIDTHRIGHTPAREN",pi="LEFTCORNERBRACKET",fi="RIGHTCORNERBRACKET",hi="LEFTWHITECORNERBRACKET",mi="RIGHTWHITECORNERBRACKET",gi="FULLWIDTHLESSTHAN",bi="FULLWIDTHGREATERTHAN",vi="AMPERSAND",yi="APOSTROPHE",ki="ASTERISK",Ct="AT",xi="BACKSLASH",wi="BACKTICK",Si="CARET",Gt="COLON",Eo="COMMA",Ci="DOLLAR",tt="DOT",Mi="EQUALS",Ao="EXCLAMATION",Ke="HYPHEN",Xn="PERCENT",Ti="PIPE",Ei="PLUS",Ai="POUND",Zn="QUERY",Oo="QUOTE",su="FULLWIDTHMIDDLEDOT",No="SEMI",nt="SLASH",Qn="TILDE",Oi="UNDERSCORE",iu="EMOJI",Ni="SYM";var ru=Object.freeze({__proto__:null,ALPHANUMERICAL:nu,AMPERSAND:vi,APOSTROPHE:yi,ASCIINUMERICAL:tu,ASTERISK:ki,AT:Ct,BACKSLASH:xi,BACKTICK:wi,CARET:Si,CLOSEANGLEBRACKET:ci,CLOSEBRACE:Yn,CLOSEBRACKET:ri,CLOSEPAREN:li,COLON:Gt,COMMA:Eo,DOLLAR:Ci,DOT:tt,EMOJI:iu,EQUALS:Mi,EXCLAMATION:Ao,FULLWIDTHGREATERTHAN:bi,FULLWIDTHLEFTPAREN:di,FULLWIDTHLESSTHAN:gi,FULLWIDTHMIDDLEDOT:su,FULLWIDTHRIGHTPAREN:ui,HYPHEN:Ke,LEFTCORNERBRACKET:pi,LEFTWHITECORNERBRACKET:hi,LOCALHOST:fs,NL:To,NUM:Mo,OPENANGLEBRACKET:ai,OPENBRACE:Gn,OPENBRACKET:ii,OPENPAREN:oi,PERCENT:Xn,PIPE:Ti,PLUS:Ei,POUND:Ai,QUERY:Zn,QUOTE:Oo,RIGHTCORNERBRACKET:fi,RIGHTWHITECORNERBRACKET:mi,SCHEME:Hs,SEMI:No,SLASH:nt,SLASH_SCHEME:vn,SYM:Ni,TILDE:Qn,TLD:Kr,UNDERSCORE:Oi,UTLD:Jr,UWORD:Wr,WORD:dt,WS:Gr});const lt=/[a-z]/,Bn=/\p{L}/u,fr=/\p{Emoji}/u,at=/\d/,hr=/\s/,aa="\r",mr=` -`,Ew="️",Aw="‍",gr="";let Ds=null,$s=null;function Ow(n=[]){const e={};_e.groups=e;const t=new _e;Ds==null&&(Ds=ca(xw)),$s==null&&($s=ca(ww)),L(t,"'",yi),L(t,"{",Gn),L(t,"}",Yn),L(t,"[",ii),L(t,"]",ri),L(t,"(",oi),L(t,")",li),L(t,"<",ai),L(t,">",ci),L(t,"(",di),L(t,")",ui),L(t,"「",pi),L(t,"」",fi),L(t,"『",hi),L(t,"』",mi),L(t,"<",gi),L(t,">",bi),L(t,"&",vi),L(t,"*",ki),L(t,"@",Ct),L(t,"`",wi),L(t,"^",Si),L(t,":",Gt),L(t,",",Eo),L(t,"$",Ci),L(t,".",tt),L(t,"=",Mi),L(t,"!",Ao),L(t,"-",Ke),L(t,"%",Xn),L(t,"|",Ti),L(t,"+",Ei),L(t,"#",Ai),L(t,"?",Zn),L(t,'"',Oo),L(t,"/",nt),L(t,";",No),L(t,"~",Qn),L(t,"_",Oi),L(t,"\\",xi),L(t,"・",su);const s=ce(t,at,Mo,{[Vr]:!0});ce(s,at,s);const i=ce(s,lt,tu,{[Jn]:!0}),r=ce(s,Bn,nu,{[Vn]:!0}),o=ce(t,lt,dt,{[Hr]:!0});ce(o,at,i),ce(o,lt,o),ce(i,at,i),ce(i,lt,i);const l=ce(t,Bn,Wr,{[qr]:!0});ce(l,lt),ce(l,at,r),ce(l,Bn,l),ce(r,at,r),ce(r,lt),ce(r,Bn,r);const c=L(t,mr,To,{[pr]:!0}),d=L(t,aa,Gr,{[pr]:!0}),u=ce(t,hr,Gr,{[pr]:!0});L(t,gr,u),L(d,mr,c),L(d,gr,u),ce(d,hr,u),L(u,aa),L(u,mr),ce(u,hr,u),L(u,gr,u);const p=ce(t,fr,iu,{[eu]:!0});L(p,"#"),ce(p,fr,p),L(p,Ew,p);const f=L(p,Aw);L(f,"#"),ce(f,fr,p);const h=[[lt,o],[at,i]],g=[[lt,null],[Bn,l],[at,r]];for(let b=0;bb[0]>m[0]?1:-1);for(let b=0;b=0?S[Ur]=!0:lt.test(m)?at.test(m)?S[Jn]=!0:S[Hr]=!0:S[Vr]=!0,la(t,m,m,S)}return la(t,"localhost",fs,{ascii:!0}),t.jd=new _e(Ni),{start:t,tokens:Object.assign({groups:e},ru)}}function ou(n,e){const t=Nw(e.replace(/[A-Z]/g,l=>l.toLowerCase())),s=t.length,i=[];let r=0,o=0;for(;o=0&&(p+=t[o].length,f++),d+=t[o].length,r+=t[o].length,o++;r-=p,o-=f,d-=p,i.push({t:u.t,v:e.slice(r-d,r),s:r-d,e:r})}return i}function Nw(n){const e=[],t=n.length;let s=0;for(;s56319||s+1===t||(r=n.charCodeAt(s+1))<56320||r>57343?n[s]:n.slice(s,s+2);e.push(o),s+=o.length}return e}function kt(n,e,t,s,i){let r;const o=e.length;for(let l=0;l=0;)r++;if(r>0){e.push(t.join(""));for(let o=parseInt(n.substring(s,s+r),10);o>0;o--)t.pop();s+=r}else t.push(n[s]),s++}return e}const hs={defaultProtocol:"http",events:null,format:da,formatHref:da,nl2br:!1,tagName:"a",target:null,rel:null,validate:!0,truncate:1/0,className:null,attributes:null,ignoreTags:[],render:null};function Io(n,e=null){let t=Object.assign({},hs);n&&(t=Object.assign(t,n instanceof Io?n.o:n));const s=t.ignoreTags,i=[];for(let r=0;rt?s.substring(0,t)+"…":s},toFormattedHref(n){return n.get("formatHref",this.toHref(n.get("defaultProtocol")),this)},startIndex(){return this.tk[0].s},endIndex(){return this.tk[this.tk.length-1].e},toObject(n=hs.defaultProtocol){return{type:this.t,value:this.toString(),isLink:this.isLink,href:this.toHref(n),start:this.startIndex(),end:this.endIndex()}},toFormattedObject(n){return{type:this.t,value:this.toFormattedString(n),isLink:this.isLink,href:this.toFormattedHref(n),start:this.startIndex(),end:this.endIndex()}},validate(n){return n.get("validate",this.toString(),this)},render(n){const e=this,t=this.toHref(n.get("defaultProtocol")),s=n.get("formatHref",t,this),i=n.get("tagName",t,e),r=this.toFormattedString(n),o={},l=n.get("className",t,e),c=n.get("target",t,e),d=n.get("rel",t,e),u=n.getObj("attributes",t,e),p=n.getObj("events",t,e);return o.href=s,l&&(o.class=l),c&&(o.target=c),d&&(o.rel=d),u&&Object.assign(o,u),{tagName:i,attributes:o,content:r,eventListeners:p}}};function Ki(n,e){class t extends lu{constructor(i,r){super(i,r),this.t=n}}for(const s in e)t.prototype[s]=e[s];return t.t=n,t}const Iw=Ki("email",{isLink:!0,toHref(){return"mailto:"+this.toString()}}),ua=Ki("text"),Dw=Ki("nl"),Rs=Ki("url",{isLink:!0,toHref(n=hs.defaultProtocol){return this.hasProtocol()?this.v:`${n}://${this.v}`},hasProtocol(){const n=this.tk;return n.length>=2&&n[0].t!==fs&&n[1].t===Gt}}),We=n=>new _e(n);function $w({groups:n}){const e=n.domain.concat([vi,ki,Ct,xi,wi,Si,Ci,Mi,Ke,Mo,Xn,Ti,Ei,Ai,nt,Ni,Qn,Oi]),t=[yi,Gt,Eo,tt,Ao,Xn,Zn,Oo,No,ai,ci,Gn,Yn,ri,ii,oi,li,di,ui,pi,fi,hi,mi,gi,bi],s=[vi,yi,ki,xi,wi,Si,Ci,Mi,Ke,Gn,Yn,Xn,Ti,Ei,Ai,Zn,nt,Ni,Qn,Oi],i=We(),r=L(i,Qn);Q(r,s,r),Q(r,n.domain,r);const o=We(),l=We(),c=We();Q(i,n.domain,o),Q(i,n.scheme,l),Q(i,n.slashscheme,c),Q(o,s,r),Q(o,n.domain,o);const d=L(o,Ct);L(r,Ct,d),L(l,Ct,d),L(c,Ct,d);const u=L(r,tt);Q(u,s,r),Q(u,n.domain,r);const p=We();Q(d,n.domain,p),Q(p,n.domain,p);const f=L(p,tt);Q(f,n.domain,p);const h=We(Iw);Q(f,n.tld,h),Q(f,n.utld,h),L(d,fs,h);const g=L(p,Ke);L(g,Ke,g),Q(g,n.domain,p),Q(h,n.domain,p),L(h,tt,f),L(h,Ke,g);const b=L(o,Ke),m=L(o,tt);L(b,Ke,b),Q(b,n.domain,o),Q(m,s,r),Q(m,n.domain,o);const v=We(Rs);Q(m,n.tld,v),Q(m,n.utld,v),Q(v,n.domain,o),Q(v,s,r),L(v,tt,m),L(v,Ke,b),L(v,Ct,d);const S=L(v,Gt),A=We(Rs);Q(S,n.numeric,A);const O=We(Rs),B=We();Q(O,e,O),Q(O,t,B),Q(B,e,O),Q(B,t,B),L(v,nt,O),L(A,nt,O);const E=L(l,Gt),M=L(c,Gt),w=L(M,nt),T=L(w,nt);Q(l,n.domain,o),L(l,tt,m),L(l,Ke,b),Q(c,n.domain,o),L(c,tt,m),L(c,Ke,b),Q(E,n.domain,O),L(E,nt,O),L(E,Zn,O),Q(T,n.domain,O),Q(T,e,O),L(T,nt,O);const N=[[Gn,Yn],[ii,ri],[oi,li],[ai,ci],[di,ui],[pi,fi],[hi,mi],[gi,bi]];for(let I=0;I=0&&f++,i++,u++;if(f<0)i-=u,i0&&(r.push(br(ua,e,o)),o=[]),i-=f,u-=f;const h=p.t,g=t.slice(i-u,i);r.push(br(h,e,g))}}return o.length>0&&r.push(br(ua,e,o)),r}function br(n,e,t){const s=t[0].s,i=t[t.length-1].e,r=e.slice(s,i);return new n(r,t)}const Lw=typeof console!="undefined"&&console&&console.warn||(()=>{}),Pw="until manual call of linkify.init(). Register all schemes and plugins before invoking linkify the first time.",re={scanner:null,parser:null,tokenQueue:[],pluginQueue:[],customSchemes:[],initialized:!1};function Bw(){return _e.groups={},re.scanner=null,re.parser=null,re.tokenQueue=[],re.pluginQueue=[],re.customSchemes=[],re.initialized=!1,re}function pa(n,e=!1){if(re.initialized&&Lw(`linkifyjs: already initialized - will not register custom scheme "${n}" ${Pw}`),!/^[0-9a-z]+(-[0-9a-z]+)*$/.test(n))throw new Error(`linkifyjs: incorrect scheme format. +`,parseMarkdown:()=>({type:"hardBreak"}),addCommands(){return{setHardBreak:()=>({commands:n,chain:e,state:t,editor:s})=>n.first([()=>n.exitCode(),()=>n.command(()=>{const{selection:i,storedMarks:r}=t;if(i.$from.parent.type.spec.isolating)return!1;const{keepMarks:o}=this.options,{splittableMarks:l}=s.extensionManager,c=r||i.$to.parentOffset&&i.$from.marks();return e().insertContent({type:this.name}).command(({tr:d,dispatch:u})=>{if(u&&c&&o){const p=c.filter(f=>l.includes(f.type.name));d.ensureMarks(p)}return!0}).scrollIntoView().run()})])}},addKeyboardShortcuts(){return{"Mod-Enter":()=>this.editor.commands.setHardBreak(),"Shift-Enter":()=>this.editor.commands.setHardBreak()}}}),mw=Fe.create({name:"heading",addOptions(){return{levels:[1,2,3,4,5,6],HTMLAttributes:{}}},content:"inline*",group:"block",defining:!0,addAttributes(){return{level:{default:1,rendered:!1}}},parseHTML(){return this.options.levels.map(n=>({tag:`h${n}`,attrs:{level:n}}))},renderHTML({node:n,HTMLAttributes:e}){return[`h${this.options.levels.includes(n.attrs.level)?n.attrs.level:this.options.levels[0]}`,ke(this.options.HTMLAttributes,e),0]},parseMarkdown:(n,e)=>e.createNode("heading",{level:n.depth||1},e.parseInline(n.tokens||[])),renderMarkdown:(n,e)=>{var t;const s=!((t=n.attrs)===null||t===void 0)&&t.level?parseInt(n.attrs.level,10):1,i="#".repeat(s);return n.content?`${i} ${e.renderChildren(n.content)}`:""},addCommands(){return{setHeading:n=>({commands:e})=>this.options.levels.includes(n.level)?e.setNode(this.name,n):!1,toggleHeading:n=>({commands:e})=>this.options.levels.includes(n.level)?e.toggleNode(this.name,"paragraph",n):!1}},addKeyboardShortcuts(){return this.options.levels.reduce((n,e)=>({...n,[`Mod-Alt-${e}`]:()=>this.editor.commands.toggleHeading({level:e})}),{})},addInputRules(){return this.options.levels.map(n=>jr({find:new RegExp(`^(#{${Math.min(...this.options.levels)},${n}})\\s$`),type:this.type,getAttributes:{level:n}}))}}),gw=Fe.create({name:"horizontalRule",addOptions(){return{HTMLAttributes:{},nextNodeType:"paragraph"}},group:"block",parseHTML(){return[{tag:"hr"}]},renderHTML({HTMLAttributes:n}){return["hr",ke(this.options.HTMLAttributes,n)]},markdownTokenName:"hr",parseMarkdown:(n,e)=>e.createNode("horizontalRule"),renderMarkdown:()=>"---",addCommands(){return{setHorizontalRule:()=>({chain:n,state:e})=>{if(!yx(e,e.schema.nodes[this.name]))return!1;const{selection:t}=e,{$to:s}=t,i=n();return Ld(t)?i.insertContentAt(s.pos,{type:this.name}):i.insertContent({type:this.name}),i.command(({state:r,tr:o,dispatch:l})=>{if(l){const{$to:c}=o.selection,d=c.end();if(c.nodeAfter)c.nodeAfter.isTextblock?o.setSelection(U.create(o.doc,c.pos+1)):c.nodeAfter.isBlock?o.setSelection(W.create(o.doc,c.pos)):o.setSelection(U.create(o.doc,c.pos));else{const u=r.schema.nodes[this.options.nextNodeType]||c.parent.type.contentMatch.defaultType,p=u==null?void 0:u.create();p&&(o.insert(d,p),o.setSelection(U.create(o.doc,d+1)))}o.scrollIntoView()}return!0}).run()}}},addInputRules(){return[Jx({find:/^(?:---|—-|___\s|\*\*\*\s)$/,type:this.type})]}}),bw=/(?:^|\s)(\*(?!\s+\*)((?:[^*]+))\*(?!\s+\*))$/,vw=/(?:^|\s)(\*(?!\s+\*)((?:[^*]+))\*(?!\s+\*))/g,yw=/(?:^|\s)(_(?!\s+_)((?:[^_]+))_(?!\s+_))$/,kw=/(?:^|\s)(_(?!\s+_)((?:[^_]+))_(?!\s+_))/g,xw=an.create({name:"italic",addOptions(){return{HTMLAttributes:{}}},parseHTML(){return[{tag:"em"},{tag:"i",getAttrs:n=>n.style.fontStyle!=="normal"&&null},{style:"font-style=normal",clearMark:n=>n.type.name===this.name},{style:"font-style=italic"}]},renderHTML({HTMLAttributes:n}){return["em",ke(this.options.HTMLAttributes,n),0]},addCommands(){return{setItalic:()=>({commands:n})=>n.setMark(this.name),toggleItalic:()=>({commands:n})=>n.toggleMark(this.name),unsetItalic:()=>({commands:n})=>n.unsetMark(this.name)}},markdownTokenName:"em",parseMarkdown:(n,e)=>e.applyMark("italic",e.parseInline(n.tokens||[])),markdownOptions:{htmlReopen:{open:"",close:""}},renderMarkdown:(n,e)=>`*${e.renderChildren(n)}*`,addKeyboardShortcuts(){return{"Mod-i":()=>this.editor.commands.toggleItalic(),"Mod-I":()=>this.editor.commands.toggleItalic()}},addInputRules(){return[on({find:bw,type:this.type}),on({find:yw,type:this.type})]},addPasteRules(){return[Pt({find:vw,type:this.type}),Pt({find:kw,type:this.type})]}}),ww="aaa1rp3bb0ott3vie4c1le2ogado5udhabi7c0ademy5centure6ountant0s9o1tor4d0s1ult4e0g1ro2tna4f0l1rica5g0akhan5ency5i0g1rbus3force5tel5kdn3l0ibaba4pay4lfinanz6state5y2sace3tom5m0azon4ericanexpress7family11x2fam3ica3sterdam8nalytics7droid5quan4z2o0l2partments8p0le4q0uarelle8r0ab1mco4chi3my2pa2t0e3s0da2ia2sociates9t0hleta5torney7u0ction5di0ble3o3spost5thor3o0s4w0s2x0a2z0ure5ba0by2idu3namex4d1k2r0celona5laycard4s5efoot5gains6seball5ketball8uhaus5yern5b0c1t1va3cg1n2d1e0ats2uty4er2rlin4st0buy5t2f1g1h0arti5i0ble3d1ke2ng0o3o1z2j1lack0friday9ockbuster8g1omberg7ue3m0s1w2n0pparibas9o0ats3ehringer8fa2m1nd2o0k0ing5sch2tik2on4t1utique6x2r0adesco6idgestone9oadway5ker3ther5ussels7s1t1uild0ers6siness6y1zz3v1w1y1z0h3ca0b1fe2l0l1vinklein9m0era3p2non3petown5ital0one8r0avan4ds2e0er0s4s2sa1e1h1ino4t0ering5holic7ba1n1re3c1d1enter4o1rn3f0a1d2g1h0anel2nel4rity4se2t2eap3intai5ristmas6ome4urch5i0priani6rcle4sco3tadel4i0c2y3k1l0aims4eaning6ick2nic1que6othing5ud3ub0med6m1n1o0ach3des3ffee4llege4ogne5m0mbank4unity6pany2re3uter5sec4ndos3struction8ulting7tact3ractors9oking4l1p2rsica5untry4pon0s4rses6pa2r0edit0card4union9icket5own3s1uise0s6u0isinella9v1w1x1y0mru3ou3z2dad1nce3ta1e1ing3sun4y2clk3ds2e0al0er2s3gree4livery5l1oitte5ta3mocrat6ntal2ist5si0gn4v2hl2iamonds6et2gital5rect0ory7scount3ver5h2y2j1k1m1np2o0cs1tor4g1mains5t1wnload7rive4tv2ubai3pont4rban5vag2r2z2earth3t2c0o2deka3u0cation8e1g1mail3erck5nergy4gineer0ing9terprises10pson4quipment8r0icsson6ni3s0q1tate5t1u0rovision8s2vents5xchange6pert3osed4ress5traspace10fage2il1rwinds6th3mily4n0s2rm0ers5shion4t3edex3edback6rrari3ero6i0delity5o2lm2nal1nce1ial7re0stone6mdale6sh0ing5t0ness6j1k1lickr3ghts4r2orist4wers5y2m1o0o0d1tball6rd1ex2sale4um3undation8x2r0ee1senius7l1ogans4ntier7tr2ujitsu5n0d2rniture7tbol5yi3ga0l0lery3o1up4me0s3p1rden4y2b0iz3d0n2e0a1nt0ing5orge5f1g0ee3h1i0ft0s3ves2ing5l0ass3e1obal2o4m0ail3bh2o1x2n1odaddy5ld0point6f2odyear5g0le4p1t1v2p1q1r0ainger5phics5tis4een3ipe3ocery4up4s1t1u0cci3ge2ide2tars5ru3w1y2hair2mburg5ngout5us3bo2dfc0bank7ealth0care8lp1sinki6re1mes5iphop4samitsu7tachi5v2k0t2m1n1ockey4ldings5iday5medepot5goods5s0ense7nda3rse3spital5t0ing5t0els3mail5use3w2r1sbc3t1u0ghes5yatt3undai7ibm2cbc2e1u2d1e0ee3fm2kano4l1m0amat4db2mo0bilien9n0c1dustries8finiti5o2g1k1stitute6urance4e4t0ernational10uit4vestments10o1piranga7q1r0ish4s0maili5t0anbul7t0au2v3jaguar4va3cb2e0ep2tzt3welry6io2ll2m0p2nj2o0bs1urg4t1y2p0morgan6rs3uegos4niper7kaufen5ddi3e0rryhotels6properties14fh2g1h1i0a1ds2m1ndle4tchen5wi3m1n1oeln3matsu5sher5p0mg2n2r0d1ed3uokgroup8w1y0oto4z2la0caixa5mborghini8er3nd0rover6xess5salle5t0ino3robe5w0yer5b1c1ds2ease3clerc5frak4gal2o2xus4gbt3i0dl2fe0insurance9style7ghting6ke2lly3mited4o2ncoln4k2ve1ing5k1lc1p2oan0s3cker3us3l1ndon4tte1o3ve3pl0financial11r1s1t0d0a3u0ndbeck6xe1ury5v1y2ma0drid4if1son4keup4n0agement7go3p1rket0ing3s4riott5shalls7ttel5ba2c0kinsey7d1e0d0ia3et2lbourne7me1orial6n0u2rck0msd7g1h1iami3crosoft7l1ni1t2t0subishi9k1l0b1s2m0a2n1o0bi0le4da2e1i1m1nash3ey2ster5rmon3tgage6scow4to0rcycles9v0ie4p1q1r1s0d2t0n1r2u0seum3ic4v1w1x1y1z2na0b1goya4me2vy3ba2c1e0c1t0bank4flix4work5ustar5w0s2xt0direct7us4f0l2g0o2hk2i0co2ke1on3nja3ssan1y5l1o0kia3rton4w0ruz3tv4p1r0a1w2tt2u1yc2z2obi1server7ffice5kinawa6layan0group9lo3m0ega4ne1g1l0ine5oo2pen3racle3nge4g0anic5igins6saka4tsuka4t2vh3pa0ge2nasonic7ris2s1tners4s1y3y2ccw3e0t2f0izer5g1h0armacy6d1ilips5one2to0graphy6s4ysio5ics1tet2ures6d1n0g1k2oneer5zza4k1l0ace2y0station9umbing5s3m1n0c2ohl2ker3litie5rn2st3r0axi3ess3ime3o0d0uctions8f1gressive8mo2perties3y5tection8u0dential9s1t1ub2w0c2y2qa1pon3uebec3st5racing4dio4e0ad1lestate6tor2y4cipes5d0umbrella9hab3ise0n3t2liance6n0t0als5pair3ort3ublican8st0aurant8view0s5xroth6ich0ardli6oh3l1o1p2o0cks3deo3gers4om3s0vp3u0gby3hr2n2w0e2yukyu6sa0arland6fe0ty4kura4le1on3msclub4ung5ndvik0coromant12ofi4p1rl2s1ve2xo3b0i1s2c0b1haeffler7midt4olarships8ol3ule3warz5ience5ot3d1e0arch3t2cure1ity6ek2lect4ner3rvices6ven3w1x0y3fr2g1h0angrila6rp3ell3ia1ksha5oes2p0ping5uji3w3i0lk2na1gles5te3j1k0i0n2y0pe4l0ing4m0art3ile4n0cf3o0ccer3ial4ftbank4ware6hu2lar2utions7ng1y2y2pa0ce3ort2t3r0l2s1t0ada2ples4r1tebank4farm7c0group6ockholm6rage3e3ream4udio2y3yle4u0cks3pplies3y2ort5rf1gery5zuki5v1watch4iss4x1y0dney4stems6z2tab1ipei4lk2obao4rget4tamotors6r2too4x0i3c0i2d0k2eam2ch0nology8l1masek5nnis4va3f1g1h0d1eater2re6iaa2ckets5enda4ps2res2ol4j0maxx4x2k0maxx5l1m0all4n1o0day3kyo3ols3p1ray3shiba5tal3urs3wn2yota3s3r0ade1ing4ining5vel0ers0insurance16ust3v2t1ube2i1nes3shu4v0s2w1z2ua1bank3s2g1k1nicom3versity8o2ol2ps2s1y1z2va0cations7na1guard7c1e0gas3ntures6risign5mögensberater2ung14sicherung10t2g1i0ajes4deo3g1king4llas4n1p1rgin4sa1ion4va1o3laanderen9n1odka3lvo3te1ing3o2yage5u2wales2mart4ter4ng0gou5tch0es6eather0channel12bcam3er2site5d0ding5ibo2r3f1hoswho6ien2ki2lliamhill9n0dows4e1ners6me2oodside6rk0s2ld3w2s1tc1f3xbox3erox4ihuan4n2xx2yz3yachts4hoo3maxun5ndex5e1odobashi7ga2kohama6u0tube6t1un3za0ppos4ra3ero3ip2m1one3uerich6w2",Sw="ελ1υ2бг1ел3дети4ею2католик6ом3мкд2он1сква6онлайн5рг3рус2ф2сайт3рб3укр3қаз3հայ3ישראל5קום3ابوظبي5رامكو5لاردن4بحرين5جزائر5سعودية6عليان5مغرب5مارات5یران5بارت2زار4يتك3ھارت5تونس4سودان3رية5شبكة4عراق2ب2مان4فلسطين6قطر3كاثوليك6وم3مصر2ليسيا5وريتانيا7قع4همراه5پاکستان7ڀارت4कॉम3नेट3भारत0म्3ोत5संगठन5বাংলা5ভারত2ৰত4ਭਾਰਤ4ભારત4ଭାରତ4இந்தியா6லங்கை6சிங்கப்பூர்11భారత్5ಭಾರತ4ഭാരതം5ලංකා4คอม3ไทย3ລາວ3გე2みんな3アマゾン4クラウド4グーグル4コム2ストア3セール3ファッション6ポイント4世界2中信1国1國1文网3亚马逊3企业2佛山2信息2健康2八卦2公司1益2台湾1灣2商城1店1标2嘉里0大酒店5在线2大拿2天主教3娱乐2家電2广东2微博2慈善2我爱你3手机2招聘2政务1府2新加坡2闻2时尚2書籍2机构2淡马锡3游戏2澳門2点看2移动2组织机构4网址1店1站1络2联通2谷歌2购物2通販2集团2電訊盈科4飞利浦3食品2餐厅2香格里拉3港2닷넷1컴2삼성2한국2",Vr="numeric",Hr="ascii",qr="alpha",Jn="asciinumeric",Vn="alphanumeric",Ur="domain",eu="emoji",Cw="scheme",Mw="slashscheme",pr="whitespace";function Tw(n,e){return n in e||(e[n]=[]),e[n]}function Jt(n,e,t){e[Vr]&&(e[Jn]=!0,e[Vn]=!0),e[Hr]&&(e[Jn]=!0,e[qr]=!0),e[Jn]&&(e[Vn]=!0),e[qr]&&(e[Vn]=!0),e[Vn]&&(e[Ur]=!0),e[eu]&&(e[Ur]=!0);for(const s in e){const i=Tw(s,t);i.indexOf(n)<0&&i.push(n)}}function Ew(n,e){const t={};for(const s in e)e[s].indexOf(n)>=0&&(t[s]=!0);return t}function _e(n=null){this.j={},this.jr=[],this.jd=null,this.t=n}_e.groups={};_e.prototype={accepts(){return!!this.t},go(n){const e=this,t=e.j[n];if(t)return t;for(let s=0;sn.ta(e,t,s,i),ce=(n,e,t,s,i)=>n.tr(e,t,s,i),la=(n,e,t,s,i)=>n.ts(e,t,s,i),L=(n,e,t,s,i)=>n.tt(e,t,s,i),dt="WORD",Wr="UWORD",tu="ASCIINUMERICAL",nu="ALPHANUMERICAL",fs="LOCALHOST",Kr="TLD",Jr="UTLD",Hs="SCHEME",vn="SLASH_SCHEME",Mo="NUM",Gr="WS",To="NL",Gn="OPENBRACE",Yn="CLOSEBRACE",ii="OPENBRACKET",ri="CLOSEBRACKET",oi="OPENPAREN",li="CLOSEPAREN",ai="OPENANGLEBRACKET",ci="CLOSEANGLEBRACKET",di="FULLWIDTHLEFTPAREN",ui="FULLWIDTHRIGHTPAREN",pi="LEFTCORNERBRACKET",fi="RIGHTCORNERBRACKET",hi="LEFTWHITECORNERBRACKET",mi="RIGHTWHITECORNERBRACKET",gi="FULLWIDTHLESSTHAN",bi="FULLWIDTHGREATERTHAN",vi="AMPERSAND",yi="APOSTROPHE",ki="ASTERISK",Ct="AT",xi="BACKSLASH",wi="BACKTICK",Si="CARET",Gt="COLON",Eo="COMMA",Ci="DOLLAR",tt="DOT",Mi="EQUALS",Ao="EXCLAMATION",Ke="HYPHEN",Xn="PERCENT",Ti="PIPE",Ei="PLUS",Ai="POUND",Zn="QUERY",Oo="QUOTE",su="FULLWIDTHMIDDLEDOT",No="SEMI",nt="SLASH",Qn="TILDE",Oi="UNDERSCORE",iu="EMOJI",Ni="SYM";var ru=Object.freeze({__proto__:null,ALPHANUMERICAL:nu,AMPERSAND:vi,APOSTROPHE:yi,ASCIINUMERICAL:tu,ASTERISK:ki,AT:Ct,BACKSLASH:xi,BACKTICK:wi,CARET:Si,CLOSEANGLEBRACKET:ci,CLOSEBRACE:Yn,CLOSEBRACKET:ri,CLOSEPAREN:li,COLON:Gt,COMMA:Eo,DOLLAR:Ci,DOT:tt,EMOJI:iu,EQUALS:Mi,EXCLAMATION:Ao,FULLWIDTHGREATERTHAN:bi,FULLWIDTHLEFTPAREN:di,FULLWIDTHLESSTHAN:gi,FULLWIDTHMIDDLEDOT:su,FULLWIDTHRIGHTPAREN:ui,HYPHEN:Ke,LEFTCORNERBRACKET:pi,LEFTWHITECORNERBRACKET:hi,LOCALHOST:fs,NL:To,NUM:Mo,OPENANGLEBRACKET:ai,OPENBRACE:Gn,OPENBRACKET:ii,OPENPAREN:oi,PERCENT:Xn,PIPE:Ti,PLUS:Ei,POUND:Ai,QUERY:Zn,QUOTE:Oo,RIGHTCORNERBRACKET:fi,RIGHTWHITECORNERBRACKET:mi,SCHEME:Hs,SEMI:No,SLASH:nt,SLASH_SCHEME:vn,SYM:Ni,TILDE:Qn,TLD:Kr,UNDERSCORE:Oi,UTLD:Jr,UWORD:Wr,WORD:dt,WS:Gr});const lt=/[a-z]/,Bn=/\p{L}/u,fr=/\p{Emoji}/u,at=/\d/,hr=/\s/,aa="\r",mr=` +`,Aw="️",Ow="‍",gr="";let Ds=null,$s=null;function Nw(n=[]){const e={};_e.groups=e;const t=new _e;Ds==null&&(Ds=ca(ww)),$s==null&&($s=ca(Sw)),L(t,"'",yi),L(t,"{",Gn),L(t,"}",Yn),L(t,"[",ii),L(t,"]",ri),L(t,"(",oi),L(t,")",li),L(t,"<",ai),L(t,">",ci),L(t,"(",di),L(t,")",ui),L(t,"「",pi),L(t,"」",fi),L(t,"『",hi),L(t,"』",mi),L(t,"<",gi),L(t,">",bi),L(t,"&",vi),L(t,"*",ki),L(t,"@",Ct),L(t,"`",wi),L(t,"^",Si),L(t,":",Gt),L(t,",",Eo),L(t,"$",Ci),L(t,".",tt),L(t,"=",Mi),L(t,"!",Ao),L(t,"-",Ke),L(t,"%",Xn),L(t,"|",Ti),L(t,"+",Ei),L(t,"#",Ai),L(t,"?",Zn),L(t,'"',Oo),L(t,"/",nt),L(t,";",No),L(t,"~",Qn),L(t,"_",Oi),L(t,"\\",xi),L(t,"・",su);const s=ce(t,at,Mo,{[Vr]:!0});ce(s,at,s);const i=ce(s,lt,tu,{[Jn]:!0}),r=ce(s,Bn,nu,{[Vn]:!0}),o=ce(t,lt,dt,{[Hr]:!0});ce(o,at,i),ce(o,lt,o),ce(i,at,i),ce(i,lt,i);const l=ce(t,Bn,Wr,{[qr]:!0});ce(l,lt),ce(l,at,r),ce(l,Bn,l),ce(r,at,r),ce(r,lt),ce(r,Bn,r);const c=L(t,mr,To,{[pr]:!0}),d=L(t,aa,Gr,{[pr]:!0}),u=ce(t,hr,Gr,{[pr]:!0});L(t,gr,u),L(d,mr,c),L(d,gr,u),ce(d,hr,u),L(u,aa),L(u,mr),ce(u,hr,u),L(u,gr,u);const p=ce(t,fr,iu,{[eu]:!0});L(p,"#"),ce(p,fr,p),L(p,Aw,p);const f=L(p,Ow);L(f,"#"),ce(f,fr,p);const h=[[lt,o],[at,i]],g=[[lt,null],[Bn,l],[at,r]];for(let b=0;bb[0]>m[0]?1:-1);for(let b=0;b=0?S[Ur]=!0:lt.test(m)?at.test(m)?S[Jn]=!0:S[Hr]=!0:S[Vr]=!0,la(t,m,m,S)}return la(t,"localhost",fs,{ascii:!0}),t.jd=new _e(Ni),{start:t,tokens:Object.assign({groups:e},ru)}}function ou(n,e){const t=Iw(e.replace(/[A-Z]/g,l=>l.toLowerCase())),s=t.length,i=[];let r=0,o=0;for(;o=0&&(p+=t[o].length,f++),d+=t[o].length,r+=t[o].length,o++;r-=p,o-=f,d-=p,i.push({t:u.t,v:e.slice(r-d,r),s:r-d,e:r})}return i}function Iw(n){const e=[],t=n.length;let s=0;for(;s56319||s+1===t||(r=n.charCodeAt(s+1))<56320||r>57343?n[s]:n.slice(s,s+2);e.push(o),s+=o.length}return e}function kt(n,e,t,s,i){let r;const o=e.length;for(let l=0;l=0;)r++;if(r>0){e.push(t.join(""));for(let o=parseInt(n.substring(s,s+r),10);o>0;o--)t.pop();s+=r}else t.push(n[s]),s++}return e}const hs={defaultProtocol:"http",events:null,format:da,formatHref:da,nl2br:!1,tagName:"a",target:null,rel:null,validate:!0,truncate:1/0,className:null,attributes:null,ignoreTags:[],render:null};function Io(n,e=null){let t=Object.assign({},hs);n&&(t=Object.assign(t,n instanceof Io?n.o:n));const s=t.ignoreTags,i=[];for(let r=0;rt?s.substring(0,t)+"…":s},toFormattedHref(n){return n.get("formatHref",this.toHref(n.get("defaultProtocol")),this)},startIndex(){return this.tk[0].s},endIndex(){return this.tk[this.tk.length-1].e},toObject(n=hs.defaultProtocol){return{type:this.t,value:this.toString(),isLink:this.isLink,href:this.toHref(n),start:this.startIndex(),end:this.endIndex()}},toFormattedObject(n){return{type:this.t,value:this.toFormattedString(n),isLink:this.isLink,href:this.toFormattedHref(n),start:this.startIndex(),end:this.endIndex()}},validate(n){return n.get("validate",this.toString(),this)},render(n){const e=this,t=this.toHref(n.get("defaultProtocol")),s=n.get("formatHref",t,this),i=n.get("tagName",t,e),r=this.toFormattedString(n),o={},l=n.get("className",t,e),c=n.get("target",t,e),d=n.get("rel",t,e),u=n.getObj("attributes",t,e),p=n.getObj("events",t,e);return o.href=s,l&&(o.class=l),c&&(o.target=c),d&&(o.rel=d),u&&Object.assign(o,u),{tagName:i,attributes:o,content:r,eventListeners:p}}};function Ki(n,e){class t extends lu{constructor(i,r){super(i,r),this.t=n}}for(const s in e)t.prototype[s]=e[s];return t.t=n,t}const Dw=Ki("email",{isLink:!0,toHref(){return"mailto:"+this.toString()}}),ua=Ki("text"),$w=Ki("nl"),Rs=Ki("url",{isLink:!0,toHref(n=hs.defaultProtocol){return this.hasProtocol()?this.v:`${n}://${this.v}`},hasProtocol(){const n=this.tk;return n.length>=2&&n[0].t!==fs&&n[1].t===Gt}}),We=n=>new _e(n);function Rw({groups:n}){const e=n.domain.concat([vi,ki,Ct,xi,wi,Si,Ci,Mi,Ke,Mo,Xn,Ti,Ei,Ai,nt,Ni,Qn,Oi]),t=[yi,Gt,Eo,tt,Ao,Xn,Zn,Oo,No,ai,ci,Gn,Yn,ri,ii,oi,li,di,ui,pi,fi,hi,mi,gi,bi],s=[vi,yi,ki,xi,wi,Si,Ci,Mi,Ke,Gn,Yn,Xn,Ti,Ei,Ai,Zn,nt,Ni,Qn,Oi],i=We(),r=L(i,Qn);Q(r,s,r),Q(r,n.domain,r);const o=We(),l=We(),c=We();Q(i,n.domain,o),Q(i,n.scheme,l),Q(i,n.slashscheme,c),Q(o,s,r),Q(o,n.domain,o);const d=L(o,Ct);L(r,Ct,d),L(l,Ct,d),L(c,Ct,d);const u=L(r,tt);Q(u,s,r),Q(u,n.domain,r);const p=We();Q(d,n.domain,p),Q(p,n.domain,p);const f=L(p,tt);Q(f,n.domain,p);const h=We(Dw);Q(f,n.tld,h),Q(f,n.utld,h),L(d,fs,h);const g=L(p,Ke);L(g,Ke,g),Q(g,n.domain,p),Q(h,n.domain,p),L(h,tt,f),L(h,Ke,g);const b=L(o,Ke),m=L(o,tt);L(b,Ke,b),Q(b,n.domain,o),Q(m,s,r),Q(m,n.domain,o);const v=We(Rs);Q(m,n.tld,v),Q(m,n.utld,v),Q(v,n.domain,o),Q(v,s,r),L(v,tt,m),L(v,Ke,b),L(v,Ct,d);const S=L(v,Gt),A=We(Rs);Q(S,n.numeric,A);const N=We(Rs),B=We();Q(N,e,N),Q(N,t,B),Q(B,e,N),Q(B,t,B),L(v,nt,N),L(A,nt,N);const E=L(l,Gt),M=L(c,Gt),w=L(M,nt),T=L(w,nt);Q(l,n.domain,o),L(l,tt,m),L(l,Ke,b),Q(c,n.domain,o),L(c,tt,m),L(c,Ke,b),Q(E,n.domain,N),L(E,nt,N),L(E,Zn,N),Q(T,n.domain,N),Q(T,e,N),L(T,nt,N);const O=[[Gn,Yn],[ii,ri],[oi,li],[ai,ci],[di,ui],[pi,fi],[hi,mi],[gi,bi]];for(let I=0;I=0&&f++,i++,u++;if(f<0)i-=u,i0&&(r.push(br(ua,e,o)),o=[]),i-=f,u-=f;const h=p.t,g=t.slice(i-u,i);r.push(br(h,e,g))}}return o.length>0&&r.push(br(ua,e,o)),r}function br(n,e,t){const s=t[0].s,i=t[t.length-1].e,r=e.slice(s,i);return new n(r,t)}const Pw=typeof console!="undefined"&&console&&console.warn||(()=>{}),Bw="until manual call of linkify.init(). Register all schemes and plugins before invoking linkify the first time.",re={scanner:null,parser:null,tokenQueue:[],pluginQueue:[],customSchemes:[],initialized:!1};function _w(){return _e.groups={},re.scanner=null,re.parser=null,re.tokenQueue=[],re.pluginQueue=[],re.customSchemes=[],re.initialized=!1,re}function pa(n,e=!1){if(re.initialized&&Pw(`linkifyjs: already initialized - will not register custom scheme "${n}" ${Bw}`),!/^[0-9a-z]+(-[0-9a-z]+)*$/.test(n))throw new Error(`linkifyjs: incorrect scheme format. 1. Must only contain digits, lowercase ASCII letters or "-" 2. Cannot start or end with "-" -3. "-" cannot repeat`);re.customSchemes.push([n,e])}function _w(){re.scanner=Ow(re.customSchemes);for(let n=0;np.mark.type===t);if(!c.length)return;const{nodeAfter:d}=r;if(d&&c.some(p=>p.mark.isInSet(d.marks)))return;const u=n.storedMarks;n.removeMark(l,e.to,t),n.setStoredMarks(u),n.selection.empty&&n.selection.from===e.to&&n.removeStoredMark(t)}function qw(n){return n.length===1?n[0].isLink:n.length===3&&n[1].isLink?["()","[]"].includes(n[0].value+n[2].value):!1}function Uw(n){return new oe({key:new me("autolink"),appendTransaction:(e,t,s)=>{const i=e.some(c=>c.docChanged)&&!t.doc.eq(s.doc),r=e.some(c=>c.getMeta("preventAutolink"));if(!i||r)return;const{tr:o}=s,l=Ad(t.doc,[...e]);if(!e.some(m1)){const c=[];l.steps.forEach((d,u)=>{if(!(d instanceof de)||!d.slice.size)return;const p=l.mapping.slice(u+1),f=p.map(d.from,1),h=p.map(d.from+d.slice.size,-1);fu.to-d.to),c.forEach(d=>Hw(o,d,n.type))}if(qi(l).forEach(({newRange:c})=>{const d=lk(s.doc,c,f=>f.isTextblock);let u,p;if(d.length>1)u=d[0],p=s.doc.textBetween(u.pos,u.pos+u.node.nodeSize,void 0," ");else if(d.length){const f=s.doc.textBetween(c.from,c.to," "," ");if(!jw.test(f))return;u=d[0],p=s.doc.textBetween(u.pos,c.to,void 0," ")}if(u&&p){const f=p.split(zw).filter(Boolean);if(f.length<=0)return!1;const h=f[f.length-1],g=u.pos+p.lastIndexOf(h);if(!h)return!1;const b=Do(h).map(m=>m.toObject(n.defaultProtocol));if(!qw(b))return!1;b.filter(m=>m.isLink).map(m=>({...m,from:g+m.start+1,to:g+m.end+1})).filter(m=>s.schema.marks.code?!s.doc.rangeHasMark(m.from,m.to,s.schema.marks.code):!0).filter(m=>n.validate(m.value)).filter(m=>n.shouldAutoLink(m.value)).forEach(m=>{Ui(m.from,m.to,s.doc).some(v=>v.mark.type===n.type)||o.addMark(m.from,m.to,n.type.create({href:m.href}))})}}),!!o.steps.length)return o}})}function Ww(n){return new oe({key:new me("handleClickLink"),props:{handleClick:(e,t,s)=>{if(s.button!==0||!e.editable)return!1;let i=null;if(s.target instanceof HTMLAnchorElement)i=s.target;else{const c=s.target;if(!c)return!1;const d=n.editor.view.dom;i=c.closest("a"),i&&!d.contains(i)&&(i=null)}if(!i)return!1;let r=!1;if(n.enableClickSelection&&(r=n.editor.commands.extendMarkRange(n.type.name)),n.openOnClick){var o,l;const c=Rd(e.state,n.type.name),d=(o=i.href)!==null&&o!==void 0?o:c.href,u=(l=i.target)!==null&&l!==void 0?l:c.target;d&&(window.open(d,u),r=!0)}return r}}})}const Kw=/\[([^[\]]+)\]\(((?:[^\s()]|\([^\s()]*\))+)(?:\s+(?:(["'])(.*?)\3|“(.*?)”|‘(.*?)’))?\)$/,Jw=/\[([^[\]]+)\]\(((?:[^\s()]|\([^\s()]*\))+)(?:\s+(?:(["'])(.*?)\3|“(.*?)”|‘(.*?)’))?\)/g;function cu(n,e){let t=0;for(let s=e-1;s>=0&&n[s]==="\\";s-=1)t+=1;return t%2===1}function Gw(n,e){let t=0,s=0;for(;s0}function du(n,e,t){var s,i;const[,r,o]=e;return(e.index?n[e.index-1]:void 0)==="!"||cu(n,(s=e.index)!==null&&s!==void 0?s:0)||Gw(n,(i=e.index)!==null&&i!==void 0?i:0)?!1:!!r.trim()&&t(o)}function uu(n){var e,t;const[s,i,r,,o,l,c]=n,d=(e=o!=null?o:l)!==null&&e!==void 0?e:c;return{index:(t=n.index)!==null&&t!==void 0?t:0,text:s,replaceWith:i,data:{href:r,title:d||null,markdown:!0}}}function Yw(n,e){return n.index{const s=Kw.exec(t);return!s||!du(t,s,n.isAllowedHref)?null:uu(s)},type:n.type,getAttributes:pu});return new ks({find:e.find,handler:t=>{const s=e.handler(t);return s!==null&&t.state.tr.steps.length&&t.state.tr.setMeta("preventAutolink",!0),s}})}function Zw(n){const e=Pt({find:t=>{var s,i;const r=[];for(const l of t.matchAll(Jw))du(t,l,n.isAllowedHref)&&r.push(uu(l));const o=((s=(i=n.findPlainUrls)===null||i===void 0?void 0:i.call(n,t))!==null&&s!==void 0?s:[]).filter(l=>!r.some(c=>Yw(c,l)));return[...r,...o]},type:n.type,getAttributes:pu});return new Jd({find:e.find,handler:t=>{var s;const i=e.handler(t);return i!==null&&t.state.tr.steps.length&&(!((s=t.match.data)===null||s===void 0)&&s.markdown)&&t.state.tr.setMeta("preventAutolink",!0),i}})}function Qw(n){return new oe({key:new me("handlePasteLink"),props:{handlePaste:(e,t,s)=>{const{shouldAutoLink:i}=n,{state:r}=e,{selection:o}=r,{empty:l}=o;if(l)return!1;let c="";s.content.forEach(u=>{c+=u.textContent});const d=au(c,{defaultProtocol:n.defaultProtocol}).find(u=>u.isLink&&u.value===c);return!c||!d||i!==void 0&&!i(d.value)?!1:n.editor.commands.setMark(n.type,{href:d.href})}}})}function ct(n,e){const t=["http","https","ftp","ftps","mailto","tel","callto","sms","cid","xmpp"];return e&&e.forEach(s=>{const i=typeof s=="string"?s:s.scheme;i&&t.push(i)}),!n||n.replace(Vw,"").match(new RegExp(`^(?:(?:${t.map(s=>s.replace(/[-/\\^$*+?.()|[\]{}]/g,"\\$&")).join("|")}):|[^a-z]|[a-z0-9+.\\-]+(?:[^a-z+.\\-:]|$))`,"i"))}const eS=an.create({name:"link",priority:1e3,keepOnSplit:!1,exitable:!0,onCreate(){this.options.validate&&!this.options.shouldAutoLink&&(this.options.shouldAutoLink=this.options.validate,console.warn("The `validate` option is deprecated. Rename to the `shouldAutoLink` option instead.")),this.options.protocols.forEach(n=>{if(typeof n=="string"){pa(n);return}pa(n.scheme,n.optionalSlashes)})},onDestroy(){Bw()},inclusive(){return this.options.autolink},addOptions(){return{openOnClick:!0,enableClickSelection:!1,linkOnPaste:!0,markdownLinks:!1,autolink:!0,protocols:[],defaultProtocol:"http",HTMLAttributes:{target:"_blank",rel:"noopener noreferrer nofollow",class:null},isAllowedUri:(n,e)=>!!ct(n,e.protocols),validate:n=>!!n,shouldAutoLink:n=>{const e=/^[a-z][a-z0-9+.-]*:\/\//i.test(n),t=/^[a-z][a-z0-9+.-]*:/i.test(n);if(e||t&&!n.includes("@"))return!0;const s=(n.includes("@")?n.split("@").pop():n).split(/[/?#:]/)[0];return!(/^\d{1,3}(\.\d{1,3}){3}$/.test(s)||!/\./.test(s))}}},addAttributes(){var n,e,t;return{href:{default:null,parseHTML(s){return s.getAttribute("href")}},target:{default:(n=this.options.HTMLAttributes.target)!==null&&n!==void 0?n:null},rel:{default:(e=this.options.HTMLAttributes.rel)!==null&&e!==void 0?e:null},class:{default:(t=this.options.HTMLAttributes.class)!==null&&t!==void 0?t:null},title:{default:null}}},parseHTML(){return[{tag:"a[href]",getAttrs:n=>{const e=n.getAttribute("href");return!e||!this.options.isAllowedUri(e,{defaultValidate:t=>!!ct(t,this.options.protocols),protocols:this.options.protocols,defaultProtocol:this.options.defaultProtocol})?!1:null}}]},renderHTML({HTMLAttributes:n}){return this.options.isAllowedUri(n.href,{defaultValidate:e=>!!ct(e,this.options.protocols),protocols:this.options.protocols,defaultProtocol:this.options.defaultProtocol})?["a",ke(this.options.HTMLAttributes,n),0]:["a",ke(this.options.HTMLAttributes,{...n,href:""}),0]},markdownTokenName:"link",parseMarkdown:(n,e)=>e.applyMark("link",e.parseInline(n.tokens||[]),{href:n.href,title:n.title||null}),renderMarkdown:(n,e)=>{var t,s,i,r;const o=(t=(s=n.attrs)===null||s===void 0?void 0:s.href)!==null&&t!==void 0?t:"",l=(i=(r=n.attrs)===null||r===void 0?void 0:r.title)!==null&&i!==void 0?i:"",c=e.renderChildren(n);return l?`[${c}](${o} "${l}")`:`[${c}](${o})`},addCommands(){return{setLink:n=>({chain:e})=>{const{href:t}=n;return this.options.isAllowedUri(t,{defaultValidate:s=>!!ct(s,this.options.protocols),protocols:this.options.protocols,defaultProtocol:this.options.defaultProtocol})?e().setMark(this.name,n).setMeta("preventAutolink",!0).run():!1},toggleLink:n=>({chain:e})=>{const{href:t}=n||{};return t&&!this.options.isAllowedUri(t,{defaultValidate:s=>!!ct(s,this.options.protocols),protocols:this.options.protocols,defaultProtocol:this.options.defaultProtocol})?!1:e().toggleMark(this.name,n,{extendEmptyMarkRange:!0}).setMeta("preventAutolink",!0).run()},unsetLink:()=>({chain:n})=>n().unsetMark(this.name,{extendEmptyMarkRange:!0}).setMeta("preventAutolink",!0).run()}},addInputRules(){return this.options.markdownLinks?[Xw({type:this.type,isAllowedHref:n=>this.options.isAllowedUri(n,{defaultValidate:e=>!!ct(e,this.options.protocols),protocols:this.options.protocols,defaultProtocol:this.options.defaultProtocol})})]:[]},addPasteRules(){const n=e=>{const t=[];if(e){const{protocols:s,defaultProtocol:i}=this.options;au(e).filter(r=>r.isLink&&this.options.isAllowedUri(r.value,{defaultValidate:o=>!!ct(o,s),protocols:s,defaultProtocol:i})).forEach(r=>{this.options.shouldAutoLink(r.value)&&t.push({text:r.value,data:{href:r.href},index:r.start})})}return t};return this.options.markdownLinks?[Zw({type:this.type,isAllowedHref:e=>this.options.isAllowedUri(e,{defaultValidate:t=>!!ct(t,this.options.protocols),protocols:this.options.protocols,defaultProtocol:this.options.defaultProtocol}),findPlainUrls:n})]:[Pt({find:n,type:this.type,getAttributes:e=>{var t;return{href:(t=e.data)===null||t===void 0?void 0:t.href}}})]},addProseMirrorPlugins(){const n=[],{protocols:e,defaultProtocol:t}=this.options;return this.options.autolink&&n.push(Uw({type:this.type,defaultProtocol:this.options.defaultProtocol,validate:s=>this.options.isAllowedUri(s,{defaultValidate:i=>!!ct(i,e),protocols:e,defaultProtocol:t}),shouldAutoLink:this.options.shouldAutoLink})),n.push(Ww({type:this.type,editor:this.editor,openOnClick:this.options.openOnClick==="whenNotEditable"?!0:this.options.openOnClick,enableClickSelection:this.options.enableClickSelection})),this.options.linkOnPaste&&n.push(Qw({editor:this.editor,defaultProtocol:this.options.defaultProtocol,type:this.type,shouldAutoLink:this.options.shouldAutoLink})),n}}),tS="listItem",fa="textStyle",ha=/^\s*([-+*])\s$/,fu=Fe.create({name:"bulletList",addOptions(){return{itemTypeName:"listItem",HTMLAttributes:{},keepMarks:!1,keepAttributes:!1}},group:"block list",content(){return`${this.options.itemTypeName}+`},parseHTML(){return[{tag:"ul"}]},renderHTML({HTMLAttributes:n}){return["ul",ke(this.options.HTMLAttributes,n),0]},markdownTokenName:"list",parseMarkdown:(n,e)=>n.type!=="list"||n.ordered?[]:{type:"bulletList",content:n.items?e.parseChildren(n.items):[]},renderMarkdown:(n,e)=>n.content?e.renderChildren(n.content,` -`):"",markdownOptions:{indentsContent:!0},addCommands(){return{toggleBulletList:()=>({commands:n,chain:e})=>this.options.keepAttributes?e().toggleList(this.name,this.options.itemTypeName,this.options.keepMarks).updateAttributes(tS,this.editor.getAttributes(fa)).run():n.toggleList(this.name,this.options.itemTypeName,this.options.keepMarks)}},addKeyboardShortcuts(){return{"Mod-Shift-8":()=>this.editor.commands.toggleBulletList()}},addInputRules(){let n=On({find:ha,type:this.type});return(this.options.keepMarks||this.options.keepAttributes)&&(n=On({find:ha,type:this.type,keepMarks:this.options.keepMarks,keepAttributes:this.options.keepAttributes,getAttributes:()=>this.editor.getAttributes(fa),editor:this.editor})),[n]}}),nS=(n,e,t)=>{const{selection:s}=n;if(!s.empty)return null;const{$from:i}=s;if(!i.parent.isTextblock||i.parentOffset!==i.parent.content.size)return null;let r=-1;for(let h=i.depth;h>0;h-=1)if(i.node(h).type.name===e){r=h;break}if(r<0)return null;const o=i.node(r),l=i.index(r);if(l+1>=o.childCount)return null;const c=o.child(l+1);if(!t.includes(c.type.name))return null;const d=n.schema.nodes[e];let u=!1;if(c.forEach(h=>{h.type===d&&h.childCount>1&&(u=!0)}),!u)return null;const p=n.doc.resolve(i.after()).nodeAfter;if(!p||!t.includes(p.type.name))return null;const f=[];return p.forEach(h=>{f.push(h)}),f.length===0?null:{listItemDepth:r,nestedList:p,nestedListPos:i.after(),insertPos:i.after(r),items:f}},sS=(n,e,t,s)=>{const i=nS(n,t,s);if(!i)return!1;const{selection:r}=n,{nestedList:o,nestedListPos:l,insertPos:c,items:d}=i,u=n.tr;u.delete(l,l+o.nodeSize);const p=u.mapping.map(c);return u.insert(p,$.from(d)),u.setSelection(r.map(u.doc,u.mapping)),e&&e(u),!0},iS=(n,e,t)=>sS(n.state,n.view.dispatch,e,t),hu=(n,e)=>pe.create({name:`${n}BranchingDeleteKeymap`,priority:101,addKeyboardShortcuts(){const t=()=>iS(this.editor,n,e);return{Delete:t,"Mod-Delete":t}}}),mu=[[1e3,"m"],[900,"cm"],[500,"d"],[400,"cd"],[100,"c"],[90,"xc"],[50,"l"],[40,"xl"],[10,"x"],[9,"ix"],[5,"v"],[4,"iv"],[1,"i"]],Ls="abcdefghijklmnopqrstuvwxyz",gu=String.raw`\d+|[ivxlcdmIVXLCDM]+|${"[a-zA-Z]{1,2}"}`;function Gi(n){let e=n,t="";for(const[s,i]of mu)for(;e>=s;)t+=i,e-=s;return t}function $o(n){return Gi(n).toUpperCase()}function bu(n){const e=n.toLowerCase();let t=0,s=0;for(;t0?s:1}const t=parseInt(n,10);return Number.isNaN(t)?1:t}function lS(n,e){if(n==="numeric")return String(e);switch(n){case"a":return Ii(e);case"A":return Ii(e).toUpperCase();case"i":return Gi(e);case"I":return $o(e);default:return String(e)}}function aS(n){var e;if(n.length===0)return!1;const t=(e=Yi(n[0]))!==null&&e!==void 0?e:"numeric",s=Ro(n[0]);if(s<1)return!1;for(let i=0;i{var t;if(n.type!=="list_item")return[];const s=(t=e.parseBlockChildren)!==null&&t!==void 0?t:e.parseChildren;let i=[];if(n.tokens&&n.tokens.length>0){if(pS(n))return{type:"listItem",content:[{type:"paragraph",content:fS(n.text||"",e)}]};if(n.tokens.some(r=>r.type==="paragraph"))i=s(n.tokens);else{const r=n.tokens[0];if(r&&r.type==="text"&&r.tokens&&r.tokens.length>0){if(i=[{type:"paragraph",content:e.parseInline(r.tokens)}],n.tokens.length>1){const o=s(n.tokens.slice(1));i.push(...o)}}else i=s(n.tokens)}}return i.length===0&&(i=[{type:"paragraph",content:[]}]),{type:"listItem",content:i}},renderMarkdown:(n,e,t)=>Ud(n,e,s=>{if(s.parentType==="bulletList")return"- ";if(s.parentType==="orderedList"){var i,r;const o=((i=s.meta)===null||i===void 0||(i=i.parentAttrs)===null||i===void 0?void 0:i.start)||1;return uS((r=s.meta)===null||r===void 0||(r=r.parentAttrs)===null||r===void 0?void 0:r.type,o-1+(s.index||0),". ")}return"- "},t,{alignNestedToPrefix:(t==null?void 0:t.parentType)==="orderedList"}),addExtensions(){return[hu(this.name,[this.options.bulletListTypeName,this.options.orderedListTypeName])]},addKeyboardShortcuts(){return{Enter:()=>this.editor.commands.splitListItem(this.name),Tab:()=>this.editor.commands.sinkListItem(this.name),"Shift-Tab":()=>this.editor.commands.liftListItem(this.name)}}}),Lo=(n,e)=>{const{$from:t}=e.selection,s=ye(n,e.schema);let i=null,r=t.depth,o=t.pos,l=null;for(;r>0&&l===null;)i=t.node(r),i.type===s?l=r:(r-=1,o-=1);return l===null?null:{$pos:e.doc.resolve(o),depth:l}},yu=(n,e)=>{const t=Lo(n,e);if(!t)return!1;const[,s]=xk(e,n,t.$pos.pos+4);return s},hS=(n,e,t)=>{const{$anchor:s}=n.selection,i=Math.max(0,s.pos-2),r=n.doc.resolve(i).node();return!(!r||!t.includes(r.type.name))},ma=(n,e,t)=>{if(n.commands.undoInputRule())return!0;if(n.state.selection.from!==n.state.selection.to)return!1;if(!bt(n.state,e)&&hS(n.state,e,t)){const{$anchor:r}=n.state.selection,o=n.state.doc.resolve(r.before()-1),l=[];o.node().descendants((u,p)=>{u.type.name===e&&l.push({node:u,pos:p})});const c=l.at(-1);if(!c)return!1;const d=n.state.doc.resolve(o.start()+c.pos+1);return n.chain().cut({from:r.start()-1,to:r.end()+1},d.end()).joinForward().run()}if(!bt(n.state,e)||!Tk(n.state))return!1;const{$from:s}=n.state.selection,i=s.depth-1;return s.node(i).type!==n.schema.nodes[e]||s.index(i)!==0?!1:n.chain().liftListItem(e).run()},mS=(n,e)=>{const t=yu(n,e),s=Lo(n,e);return!s||!t?!1:t>s.depth},gS=(n,e)=>{const t=yu(n,e),s=Lo(n,e);return!s||!t?!1:t{if(!bt(n.state,e)||!Mk(n.state,e))return!1;const{selection:t}=n.state,{$from:s,$to:i}=t;return!t.empty&&s.sameParent(i)?!1:mS(e,n.state)?n.chain().focus(n.state.selection.from+4).lift(e).joinBackward().run():gS(e,n.state)?n.chain().joinForward().joinBackward().run():n.commands.joinItemForward()},bS=(n,e,t)=>{const{state:s}=n,{selection:i}=s;if(!i.empty)return!1;const{$from:r}=i;if(r.parentOffset!==0||!r.parent.isTextblock||bt(s,e))return!1;const o=wk(r);if(!o||!t.includes(o.type.name))return!1;const l=o.lastChild;if(!l||l.type.name!==e)return!1;const c=r.parent;if(!l.canReplace(l.childCount,l.childCount,$.from(c)))return!1;const d=r.before(),u=r.after(),p=d-2;return n.commands.command(({tr:f,dispatch:h})=>(h&&(f.delete(d,u).insert(p,$.from(c)),f.setSelection(U.create(f.doc,p+1)),f.scrollIntoView()),!0))},ku=pe.create({name:"listKeymap",addOptions(){return{listTypes:[{itemName:"listItem",wrapperNames:["bulletList","orderedList"]},{itemName:"taskItem",wrapperNames:["taskList"]}]}},addKeyboardShortcuts(){return{Delete:({editor:n})=>{let e=!1;return this.options.listTypes.forEach(({itemName:t})=>{n.state.schema.nodes[t]!==void 0&&ga(n,t)&&(e=!0)}),e},"Mod-Delete":({editor:n})=>{let e=!1;return this.options.listTypes.forEach(({itemName:t})=>{n.state.schema.nodes[t]!==void 0&&ga(n,t)&&(e=!0)}),e},Backspace:({editor:n})=>{let e=!1;return this.options.listTypes.forEach(({itemName:t,wrapperNames:s})=>{n.state.schema.nodes[t]!==void 0&&ma(n,t,s)&&(e=!0)}),e},"Mod-Backspace":({editor:n})=>{let e=!1;return this.options.listTypes.forEach(({itemName:t,wrapperNames:s})=>{n.state.schema.nodes[t]!==void 0&&ma(n,t,s)&&(e=!0)}),e},Tab:({editor:n})=>{for(const{itemName:e,wrapperNames:t}of this.options.listTypes)if(n.state.schema.nodes[e]!==void 0&&bS(n,e,t))return!0;return!1}}}}),Di=new RegExp(`^(\\s*)(${gu})([.)])\\s+(.*)$`),vS=/^\s/,yn={heading:/^#{1,6}(?:\s|$)/,bulletItem:/^[-+*]\s+/,codeFence:/^(?:```|~~~)/,blockMath:/^\$\$/,thematicBreak:/^(?:(?:-[ \t]*){3,}|(?:_[ \t]*){3,}|(?:\*[ \t]*){3,})$/};function yS(n){return Di.test(n.trimStart())}function kS(n){const e=n.trimStart();return yn.bulletItem.test(e)||yS(e)||yn.heading.test(e)||yn.thematicBreak.test(e)&&!e.startsWith("-")||/^>\s?/.test(e)||yn.codeFence.test(e)||yn.blockMath.test(e)}function xS(n){return Object.values(yn).some(e=>e.test(n))}function wS(n){const e=[],t=[];let s=!1;return n.forEach(i=>{if(s){t.push(i);return}if(i.trim()===""){s=!0,t.push(i);return}if(e.length>0&&kS(i)){s=!0,t.push(i);return}e.push(i)}),{paragraphLines:e,blockLines:t}}function ba(n){const e=[];let t=0,s=0;for(;tp.mark.type===t);if(!c.length)return;const{nodeAfter:d}=r;if(d&&c.some(p=>p.mark.isInSet(d.marks)))return;const u=n.storedMarks;n.removeMark(l,e.to,t),n.setStoredMarks(u),n.selection.empty&&n.selection.from===e.to&&n.removeStoredMark(t)}function Uw(n){return n.length===1?n[0].isLink:n.length===3&&n[1].isLink?["()","[]"].includes(n[0].value+n[2].value):!1}function Ww(n){return new oe({key:new me("autolink"),appendTransaction:(e,t,s)=>{const i=e.some(c=>c.docChanged)&&!t.doc.eq(s.doc),r=e.some(c=>c.getMeta("preventAutolink"));if(!i||r)return;const{tr:o}=s,l=Ad(t.doc,[...e]);if(!e.some(g1)){const c=[];l.steps.forEach((d,u)=>{if(!(d instanceof de)||!d.slice.size)return;const p=l.mapping.slice(u+1),f=p.map(d.from,1),h=p.map(d.from+d.slice.size,-1);fu.to-d.to),c.forEach(d=>qw(o,d,n.type))}if(qi(l).forEach(({newRange:c})=>{const d=ak(s.doc,c,f=>f.isTextblock);let u,p;if(d.length>1)u=d[0],p=s.doc.textBetween(u.pos,u.pos+u.node.nodeSize,void 0," ");else if(d.length){const f=s.doc.textBetween(c.from,c.to," "," ");if(!Fw.test(f))return;u=d[0],p=s.doc.textBetween(u.pos,c.to,void 0," ")}if(u&&p){const f=p.split(jw).filter(Boolean);if(f.length<=0)return!1;const h=f[f.length-1],g=u.pos+p.lastIndexOf(h);if(!h)return!1;const b=Do(h).map(m=>m.toObject(n.defaultProtocol));if(!Uw(b))return!1;b.filter(m=>m.isLink).map(m=>({...m,from:g+m.start+1,to:g+m.end+1})).filter(m=>s.schema.marks.code?!s.doc.rangeHasMark(m.from,m.to,s.schema.marks.code):!0).filter(m=>n.validate(m.value)).filter(m=>n.shouldAutoLink(m.value)).forEach(m=>{Ui(m.from,m.to,s.doc).some(v=>v.mark.type===n.type)||o.addMark(m.from,m.to,n.type.create({href:m.href}))})}}),!!o.steps.length)return o}})}function Kw(n){return new oe({key:new me("handleClickLink"),props:{handleClick:(e,t,s)=>{if(s.button!==0||!e.editable)return!1;let i=null;if(s.target instanceof HTMLAnchorElement)i=s.target;else{const c=s.target;if(!c)return!1;const d=n.editor.view.dom;i=c.closest("a"),i&&!d.contains(i)&&(i=null)}if(!i)return!1;let r=!1;if(n.enableClickSelection&&(r=n.editor.commands.extendMarkRange(n.type.name)),n.openOnClick){var o,l;const c=Rd(e.state,n.type.name),d=(o=i.href)!==null&&o!==void 0?o:c.href,u=(l=i.target)!==null&&l!==void 0?l:c.target;d&&(window.open(d,u),r=!0)}return r}}})}const Jw=/\[([^[\]]+)\]\(((?:[^\s()]|\([^\s()]*\))+)(?:\s+(?:(["'])(.*?)\3|“(.*?)”|‘(.*?)’))?\)$/,Gw=/\[([^[\]]+)\]\(((?:[^\s()]|\([^\s()]*\))+)(?:\s+(?:(["'])(.*?)\3|“(.*?)”|‘(.*?)’))?\)/g;function cu(n,e){let t=0;for(let s=e-1;s>=0&&n[s]==="\\";s-=1)t+=1;return t%2===1}function Yw(n,e){let t=0,s=0;for(;s0}function du(n,e,t){var s,i;const[,r,o]=e;return(e.index?n[e.index-1]:void 0)==="!"||cu(n,(s=e.index)!==null&&s!==void 0?s:0)||Yw(n,(i=e.index)!==null&&i!==void 0?i:0)?!1:!!r.trim()&&t(o)}function uu(n){var e,t;const[s,i,r,,o,l,c]=n,d=(e=o!=null?o:l)!==null&&e!==void 0?e:c;return{index:(t=n.index)!==null&&t!==void 0?t:0,text:s,replaceWith:i,data:{href:r,title:d||null,markdown:!0}}}function Xw(n,e){return n.index{const s=Jw.exec(t);return!s||!du(t,s,n.isAllowedHref)?null:uu(s)},type:n.type,getAttributes:pu});return new ks({find:e.find,handler:t=>{const s=e.handler(t);return s!==null&&t.state.tr.steps.length&&t.state.tr.setMeta("preventAutolink",!0),s}})}function Qw(n){const e=Pt({find:t=>{var s,i;const r=[];for(const l of t.matchAll(Gw))du(t,l,n.isAllowedHref)&&r.push(uu(l));const o=((s=(i=n.findPlainUrls)===null||i===void 0?void 0:i.call(n,t))!==null&&s!==void 0?s:[]).filter(l=>!r.some(c=>Xw(c,l)));return[...r,...o]},type:n.type,getAttributes:pu});return new Jd({find:e.find,handler:t=>{var s;const i=e.handler(t);return i!==null&&t.state.tr.steps.length&&(!((s=t.match.data)===null||s===void 0)&&s.markdown)&&t.state.tr.setMeta("preventAutolink",!0),i}})}function eS(n){return new oe({key:new me("handlePasteLink"),props:{handlePaste:(e,t,s)=>{const{shouldAutoLink:i}=n,{state:r}=e,{selection:o}=r,{empty:l}=o;if(l)return!1;let c="";s.content.forEach(u=>{c+=u.textContent});const d=au(c,{defaultProtocol:n.defaultProtocol}).find(u=>u.isLink&&u.value===c);return!c||!d||i!==void 0&&!i(d.value)?!1:n.editor.commands.setMark(n.type,{href:d.href})}}})}function ct(n,e){const t=["http","https","ftp","ftps","mailto","tel","callto","sms","cid","xmpp"];return e&&e.forEach(s=>{const i=typeof s=="string"?s:s.scheme;i&&t.push(i)}),!n||n.replace(Hw,"").match(new RegExp(`^(?:(?:${t.map(s=>s.replace(/[-/\\^$*+?.()|[\]{}]/g,"\\$&")).join("|")}):|[^a-z]|[a-z0-9+.\\-]+(?:[^a-z+.\\-:]|$))`,"i"))}const tS=an.create({name:"link",priority:1e3,keepOnSplit:!1,exitable:!0,onCreate(){this.options.validate&&!this.options.shouldAutoLink&&(this.options.shouldAutoLink=this.options.validate,console.warn("The `validate` option is deprecated. Rename to the `shouldAutoLink` option instead.")),this.options.protocols.forEach(n=>{if(typeof n=="string"){pa(n);return}pa(n.scheme,n.optionalSlashes)})},onDestroy(){_w()},inclusive(){return this.options.autolink},addOptions(){return{openOnClick:!0,enableClickSelection:!1,linkOnPaste:!0,markdownLinks:!1,autolink:!0,protocols:[],defaultProtocol:"http",HTMLAttributes:{target:"_blank",rel:"noopener noreferrer nofollow",class:null},isAllowedUri:(n,e)=>!!ct(n,e.protocols),validate:n=>!!n,shouldAutoLink:n=>{const e=/^[a-z][a-z0-9+.-]*:\/\//i.test(n),t=/^[a-z][a-z0-9+.-]*:/i.test(n);if(e||t&&!n.includes("@"))return!0;const s=(n.includes("@")?n.split("@").pop():n).split(/[/?#:]/)[0];return!(/^\d{1,3}(\.\d{1,3}){3}$/.test(s)||!/\./.test(s))}}},addAttributes(){var n,e,t;return{href:{default:null,parseHTML(s){return s.getAttribute("href")}},target:{default:(n=this.options.HTMLAttributes.target)!==null&&n!==void 0?n:null},rel:{default:(e=this.options.HTMLAttributes.rel)!==null&&e!==void 0?e:null},class:{default:(t=this.options.HTMLAttributes.class)!==null&&t!==void 0?t:null},title:{default:null}}},parseHTML(){return[{tag:"a[href]",getAttrs:n=>{const e=n.getAttribute("href");return!e||!this.options.isAllowedUri(e,{defaultValidate:t=>!!ct(t,this.options.protocols),protocols:this.options.protocols,defaultProtocol:this.options.defaultProtocol})?!1:null}}]},renderHTML({HTMLAttributes:n}){return this.options.isAllowedUri(n.href,{defaultValidate:e=>!!ct(e,this.options.protocols),protocols:this.options.protocols,defaultProtocol:this.options.defaultProtocol})?["a",ke(this.options.HTMLAttributes,n),0]:["a",ke(this.options.HTMLAttributes,{...n,href:""}),0]},markdownTokenName:"link",parseMarkdown:(n,e)=>e.applyMark("link",e.parseInline(n.tokens||[]),{href:n.href,title:n.title||null}),renderMarkdown:(n,e)=>{var t,s,i,r;const o=(t=(s=n.attrs)===null||s===void 0?void 0:s.href)!==null&&t!==void 0?t:"",l=(i=(r=n.attrs)===null||r===void 0?void 0:r.title)!==null&&i!==void 0?i:"",c=e.renderChildren(n);return l?`[${c}](${o} "${l}")`:`[${c}](${o})`},addCommands(){return{setLink:n=>({chain:e})=>{const{href:t}=n;return this.options.isAllowedUri(t,{defaultValidate:s=>!!ct(s,this.options.protocols),protocols:this.options.protocols,defaultProtocol:this.options.defaultProtocol})?e().setMark(this.name,n).setMeta("preventAutolink",!0).run():!1},toggleLink:n=>({chain:e})=>{const{href:t}=n||{};return t&&!this.options.isAllowedUri(t,{defaultValidate:s=>!!ct(s,this.options.protocols),protocols:this.options.protocols,defaultProtocol:this.options.defaultProtocol})?!1:e().toggleMark(this.name,n,{extendEmptyMarkRange:!0}).setMeta("preventAutolink",!0).run()},unsetLink:()=>({chain:n})=>n().unsetMark(this.name,{extendEmptyMarkRange:!0}).setMeta("preventAutolink",!0).run()}},addInputRules(){return this.options.markdownLinks?[Zw({type:this.type,isAllowedHref:n=>this.options.isAllowedUri(n,{defaultValidate:e=>!!ct(e,this.options.protocols),protocols:this.options.protocols,defaultProtocol:this.options.defaultProtocol})})]:[]},addPasteRules(){const n=e=>{const t=[];if(e){const{protocols:s,defaultProtocol:i}=this.options;au(e).filter(r=>r.isLink&&this.options.isAllowedUri(r.value,{defaultValidate:o=>!!ct(o,s),protocols:s,defaultProtocol:i})).forEach(r=>{this.options.shouldAutoLink(r.value)&&t.push({text:r.value,data:{href:r.href},index:r.start})})}return t};return this.options.markdownLinks?[Qw({type:this.type,isAllowedHref:e=>this.options.isAllowedUri(e,{defaultValidate:t=>!!ct(t,this.options.protocols),protocols:this.options.protocols,defaultProtocol:this.options.defaultProtocol}),findPlainUrls:n})]:[Pt({find:n,type:this.type,getAttributes:e=>{var t;return{href:(t=e.data)===null||t===void 0?void 0:t.href}}})]},addProseMirrorPlugins(){const n=[],{protocols:e,defaultProtocol:t}=this.options;return this.options.autolink&&n.push(Ww({type:this.type,defaultProtocol:this.options.defaultProtocol,validate:s=>this.options.isAllowedUri(s,{defaultValidate:i=>!!ct(i,e),protocols:e,defaultProtocol:t}),shouldAutoLink:this.options.shouldAutoLink})),n.push(Kw({type:this.type,editor:this.editor,openOnClick:this.options.openOnClick==="whenNotEditable"?!0:this.options.openOnClick,enableClickSelection:this.options.enableClickSelection})),this.options.linkOnPaste&&n.push(eS({editor:this.editor,defaultProtocol:this.options.defaultProtocol,type:this.type,shouldAutoLink:this.options.shouldAutoLink})),n}}),nS="listItem",fa="textStyle",ha=/^\s*([-+*])\s$/,fu=Fe.create({name:"bulletList",addOptions(){return{itemTypeName:"listItem",HTMLAttributes:{},keepMarks:!1,keepAttributes:!1}},group:"block list",content(){return`${this.options.itemTypeName}+`},parseHTML(){return[{tag:"ul"}]},renderHTML({HTMLAttributes:n}){return["ul",ke(this.options.HTMLAttributes,n),0]},markdownTokenName:"list",parseMarkdown:(n,e)=>n.type!=="list"||n.ordered?[]:{type:"bulletList",content:n.items?e.parseChildren(n.items):[]},renderMarkdown:(n,e)=>n.content?e.renderChildren(n.content,` +`):"",markdownOptions:{indentsContent:!0},addCommands(){return{toggleBulletList:()=>({commands:n,chain:e})=>this.options.keepAttributes?e().toggleList(this.name,this.options.itemTypeName,this.options.keepMarks).updateAttributes(nS,this.editor.getAttributes(fa)).run():n.toggleList(this.name,this.options.itemTypeName,this.options.keepMarks)}},addKeyboardShortcuts(){return{"Mod-Shift-8":()=>this.editor.commands.toggleBulletList()}},addInputRules(){let n=On({find:ha,type:this.type});return(this.options.keepMarks||this.options.keepAttributes)&&(n=On({find:ha,type:this.type,keepMarks:this.options.keepMarks,keepAttributes:this.options.keepAttributes,getAttributes:()=>this.editor.getAttributes(fa),editor:this.editor})),[n]}}),sS=(n,e,t)=>{const{selection:s}=n;if(!s.empty)return null;const{$from:i}=s;if(!i.parent.isTextblock||i.parentOffset!==i.parent.content.size)return null;let r=-1;for(let h=i.depth;h>0;h-=1)if(i.node(h).type.name===e){r=h;break}if(r<0)return null;const o=i.node(r),l=i.index(r);if(l+1>=o.childCount)return null;const c=o.child(l+1);if(!t.includes(c.type.name))return null;const d=n.schema.nodes[e];let u=!1;if(c.forEach(h=>{h.type===d&&h.childCount>1&&(u=!0)}),!u)return null;const p=n.doc.resolve(i.after()).nodeAfter;if(!p||!t.includes(p.type.name))return null;const f=[];return p.forEach(h=>{f.push(h)}),f.length===0?null:{listItemDepth:r,nestedList:p,nestedListPos:i.after(),insertPos:i.after(r),items:f}},iS=(n,e,t,s)=>{const i=sS(n,t,s);if(!i)return!1;const{selection:r}=n,{nestedList:o,nestedListPos:l,insertPos:c,items:d}=i,u=n.tr;u.delete(l,l+o.nodeSize);const p=u.mapping.map(c);return u.insert(p,$.from(d)),u.setSelection(r.map(u.doc,u.mapping)),e&&e(u),!0},rS=(n,e,t)=>iS(n.state,n.view.dispatch,e,t),hu=(n,e)=>pe.create({name:`${n}BranchingDeleteKeymap`,priority:101,addKeyboardShortcuts(){const t=()=>rS(this.editor,n,e);return{Delete:t,"Mod-Delete":t}}}),mu=[[1e3,"m"],[900,"cm"],[500,"d"],[400,"cd"],[100,"c"],[90,"xc"],[50,"l"],[40,"xl"],[10,"x"],[9,"ix"],[5,"v"],[4,"iv"],[1,"i"]],Ls="abcdefghijklmnopqrstuvwxyz",gu=String.raw`\d+|[ivxlcdmIVXLCDM]+|${"[a-zA-Z]{1,2}"}`;function Gi(n){let e=n,t="";for(const[s,i]of mu)for(;e>=s;)t+=i,e-=s;return t}function $o(n){return Gi(n).toUpperCase()}function bu(n){const e=n.toLowerCase();let t=0,s=0;for(;t0?s:1}const t=parseInt(n,10);return Number.isNaN(t)?1:t}function aS(n,e){if(n==="numeric")return String(e);switch(n){case"a":return Ii(e);case"A":return Ii(e).toUpperCase();case"i":return Gi(e);case"I":return $o(e);default:return String(e)}}function cS(n){var e;if(n.length===0)return!1;const t=(e=Yi(n[0]))!==null&&e!==void 0?e:"numeric",s=Ro(n[0]);if(s<1)return!1;for(let i=0;i{var t;if(n.type!=="list_item")return[];const s=(t=e.parseBlockChildren)!==null&&t!==void 0?t:e.parseChildren;let i=[];if(n.tokens&&n.tokens.length>0){if(fS(n))return{type:"listItem",content:[{type:"paragraph",content:hS(n.text||"",e)}]};if(n.tokens.some(r=>r.type==="paragraph"))i=s(n.tokens);else{const r=n.tokens[0];if(r&&r.type==="text"&&r.tokens&&r.tokens.length>0){if(i=[{type:"paragraph",content:e.parseInline(r.tokens)}],n.tokens.length>1){const o=s(n.tokens.slice(1));i.push(...o)}}else i=s(n.tokens)}}return i.length===0&&(i=[{type:"paragraph",content:[]}]),{type:"listItem",content:i}},renderMarkdown:(n,e,t)=>Ud(n,e,s=>{if(s.parentType==="bulletList")return"- ";if(s.parentType==="orderedList"){var i,r;const o=((i=s.meta)===null||i===void 0||(i=i.parentAttrs)===null||i===void 0?void 0:i.start)||1;return pS((r=s.meta)===null||r===void 0||(r=r.parentAttrs)===null||r===void 0?void 0:r.type,o-1+(s.index||0),". ")}return"- "},t,{alignNestedToPrefix:(t==null?void 0:t.parentType)==="orderedList"}),addExtensions(){return[hu(this.name,[this.options.bulletListTypeName,this.options.orderedListTypeName])]},addKeyboardShortcuts(){return{Enter:()=>this.editor.commands.splitListItem(this.name),Tab:()=>this.editor.commands.sinkListItem(this.name),"Shift-Tab":()=>this.editor.commands.liftListItem(this.name)}}}),Lo=(n,e)=>{const{$from:t}=e.selection,s=ye(n,e.schema);let i=null,r=t.depth,o=t.pos,l=null;for(;r>0&&l===null;)i=t.node(r),i.type===s?l=r:(r-=1,o-=1);return l===null?null:{$pos:e.doc.resolve(o),depth:l}},yu=(n,e)=>{const t=Lo(n,e);if(!t)return!1;const[,s]=wk(e,n,t.$pos.pos+4);return s},mS=(n,e,t)=>{const{$anchor:s}=n.selection,i=Math.max(0,s.pos-2),r=n.doc.resolve(i).node();return!(!r||!t.includes(r.type.name))},ma=(n,e,t)=>{if(n.commands.undoInputRule())return!0;if(n.state.selection.from!==n.state.selection.to)return!1;if(!bt(n.state,e)&&mS(n.state,e,t)){const{$anchor:r}=n.state.selection,o=n.state.doc.resolve(r.before()-1),l=[];o.node().descendants((u,p)=>{u.type.name===e&&l.push({node:u,pos:p})});const c=l.at(-1);if(!c)return!1;const d=n.state.doc.resolve(o.start()+c.pos+1);return n.chain().cut({from:r.start()-1,to:r.end()+1},d.end()).joinForward().run()}if(!bt(n.state,e)||!Ek(n.state))return!1;const{$from:s}=n.state.selection,i=s.depth-1;return s.node(i).type!==n.schema.nodes[e]||s.index(i)!==0?!1:n.chain().liftListItem(e).run()},gS=(n,e)=>{const t=yu(n,e),s=Lo(n,e);return!s||!t?!1:t>s.depth},bS=(n,e)=>{const t=yu(n,e),s=Lo(n,e);return!s||!t?!1:t{if(!bt(n.state,e)||!Tk(n.state,e))return!1;const{selection:t}=n.state,{$from:s,$to:i}=t;return!t.empty&&s.sameParent(i)?!1:gS(e,n.state)?n.chain().focus(n.state.selection.from+4).lift(e).joinBackward().run():bS(e,n.state)?n.chain().joinForward().joinBackward().run():n.commands.joinItemForward()},vS=(n,e,t)=>{const{state:s}=n,{selection:i}=s;if(!i.empty)return!1;const{$from:r}=i;if(r.parentOffset!==0||!r.parent.isTextblock||bt(s,e))return!1;const o=Sk(r);if(!o||!t.includes(o.type.name))return!1;const l=o.lastChild;if(!l||l.type.name!==e)return!1;const c=r.parent;if(!l.canReplace(l.childCount,l.childCount,$.from(c)))return!1;const d=r.before(),u=r.after(),p=d-2;return n.commands.command(({tr:f,dispatch:h})=>(h&&(f.delete(d,u).insert(p,$.from(c)),f.setSelection(U.create(f.doc,p+1)),f.scrollIntoView()),!0))},ku=pe.create({name:"listKeymap",addOptions(){return{listTypes:[{itemName:"listItem",wrapperNames:["bulletList","orderedList"]},{itemName:"taskItem",wrapperNames:["taskList"]}]}},addKeyboardShortcuts(){return{Delete:({editor:n})=>{let e=!1;return this.options.listTypes.forEach(({itemName:t})=>{n.state.schema.nodes[t]!==void 0&&ga(n,t)&&(e=!0)}),e},"Mod-Delete":({editor:n})=>{let e=!1;return this.options.listTypes.forEach(({itemName:t})=>{n.state.schema.nodes[t]!==void 0&&ga(n,t)&&(e=!0)}),e},Backspace:({editor:n})=>{let e=!1;return this.options.listTypes.forEach(({itemName:t,wrapperNames:s})=>{n.state.schema.nodes[t]!==void 0&&ma(n,t,s)&&(e=!0)}),e},"Mod-Backspace":({editor:n})=>{let e=!1;return this.options.listTypes.forEach(({itemName:t,wrapperNames:s})=>{n.state.schema.nodes[t]!==void 0&&ma(n,t,s)&&(e=!0)}),e},Tab:({editor:n})=>{for(const{itemName:e,wrapperNames:t}of this.options.listTypes)if(n.state.schema.nodes[e]!==void 0&&vS(n,e,t))return!0;return!1}}}}),Di=new RegExp(`^(\\s*)(${gu})([.)])\\s+(.*)$`),yS=/^\s/,yn={heading:/^#{1,6}(?:\s|$)/,bulletItem:/^[-+*]\s+/,codeFence:/^(?:```|~~~)/,blockMath:/^\$\$/,thematicBreak:/^(?:(?:-[ \t]*){3,}|(?:_[ \t]*){3,}|(?:\*[ \t]*){3,})$/};function kS(n){return Di.test(n.trimStart())}function xS(n){const e=n.trimStart();return yn.bulletItem.test(e)||kS(e)||yn.heading.test(e)||yn.thematicBreak.test(e)&&!e.startsWith("-")||/^>\s?/.test(e)||yn.codeFence.test(e)||yn.blockMath.test(e)}function wS(n){return Object.values(yn).some(e=>e.test(n))}function SS(n){const e=[],t=[];let s=!1;return n.forEach(i=>{if(s){t.push(i);return}if(i.trim()===""){s=!0,t.push(i);return}if(e.length>0&&xS(i)){s=!0,t.push(i);return}e.push(i)}),{paragraphLines:e,blockLines:t}}function ba(n){const e=[];let t=0,s=0;for(;ts.trim().length>0);if(e.length===0)return null;const t=[];for(const s of e){const i=s.trim().match(SS);if(!i)return null;t.push({marker:i[1],content:i[3]})}return aS(t.map(s=>s.marker))?{type:"orderedList",attrs:dS(t[0].marker),content:t.map(s=>({type:"listItem",content:[{type:"paragraph",content:[{type:"text",text:s.content}]}]}))}:null}function xu(n,e,t){const s=[];let i=0;for(;is.trim().length>0);if(e.length===0)return null;const t=[];for(const s of e){const i=s.trim().match(CS);if(!i)return null;t.push({marker:i[1],content:i[3]})}return cS(t.map(s=>s.marker))?{type:"orderedList",attrs:uS(t[0].marker),content:t.map(s=>({type:"listItem",content:[{type:"paragraph",content:[{type:"text",text:s.content}]}]}))}:null}function xu(n,e,t){const s=[];let i=0;for(;ie;)f.push(n[p]),p+=1;if(f.length>0){const h=xu(f,Math.min(...f.map(g=>g.indent)),t);d.push({type:"list",ordered:!0,start:f[0].number,typeMarker:f[0].type,items:h,raw:f.map(g=>g.raw).join(` -`)})}s.push({type:"list_item",raw:r.raw,tokens:d}),i=p}else i+=1}return s}function MS(n,e){return n.map(t=>{if(t.type!=="list_item")return e.parseChildren([t])[0];const s=[];return t.tokens&&t.tokens.length>0&&t.tokens.forEach(i=>{if(i.type==="paragraph"||i.type==="list"||i.type==="blockquote"||i.type==="code")s.push(...e.parseChildren([i]));else if(i.type==="text"&&i.tokens){const r=e.parseChildren([i]);s.push({type:"paragraph",content:r})}else{const r=e.parseChildren([i]);r.length>0&&s.push(...r)}}),{type:"listItem",content:s}})}const TS=64;function va(n,e){const t=[];let s=0;for(;t.lengthn.hasAttribute("start")?parseInt(n.getAttribute("start")||"",10):1},type:{default:null,parseHTML:n=>{const e=n.getAttribute("type");if(e)return e;const t=n.getAttribute("style");if(t){const i=xa(t);if(i)return i}const s=n.querySelector("li");if(s){const i=s.getAttribute("style");if(i){const r=xa(i);if(r)return r}}return null}}}},parseHTML(){return[{tag:"ol"}]},renderHTML({HTMLAttributes:n}){const{start:e,type:t,...s}=n,i=ke(this.options.HTMLAttributes,s);return e!==1&&(i.start=e),t&&t!=="1"&&(i.type=t),["ol",i,0]},markdownTokenName:"list",parseMarkdown:(n,e)=>{if(n.type!=="list"||!n.ordered)return[];const t=n.start||1,s=n.typeMarker,i=n.items?MS(n.items,e):[],r={};return t!==1&&(r.start=t),s&&(r.type=s),Object.keys(r).length>0?{type:"orderedList",attrs:r,content:i}:{type:"orderedList",content:i}},renderMarkdown:(n,e)=>n.content?e.renderChildren(n.content,` -`):"",markdownTokenizer:{name:"orderedList",level:"block",start:()=>-1,tokenize:(n,e,t)=>{var s,i;const[r,o,l]=ES(n);if(r.length===0)return;const c=xu(r,r[0].indent,t);if(c.length!==0)return{type:"list",ordered:!0,start:((s=r[0])===null||s===void 0?void 0:s.number)||1,typeMarker:(i=r[0])===null||i===void 0?void 0:i.type,items:c,raw:l.slice(0,o).join(` -`)}}},markdownOptions:{indentsContent:!0},addCommands(){return{toggleOrderedList:()=>({commands:n,chain:e})=>this.options.keepAttributes?e().toggleList(this.name,this.options.itemTypeName,this.options.keepMarks).updateAttributes(AS,this.editor.getAttributes(ya)).run():n.toggleList(this.name,this.options.itemTypeName,this.options.keepMarks)}},addKeyboardShortcuts(){return{"Mod-Shift-7":()=>this.editor.commands.toggleOrderedList()}},addProseMirrorPlugins(){return[new oe({props:{handlePaste:(n,e)=>{var t,s;const i=(t=e.clipboardData)===null||t===void 0?void 0:t.getData("text/html");if(i!=null&&i.trim())return!1;const r=(s=e.clipboardData)===null||s===void 0?void 0:s.getData("text/plain");if(!r)return!1;const o=CS(r);if(!o)return!1;try{const l=n.state.schema.nodeFromJSON(o),c=n.state.tr.replaceSelectionWith(l);return n.dispatch(c),!0}catch(l){return!1}}}})]},addInputRules(){const n=(t,s)=>(!s.attrs.type||s.attrs.type==="1")&&s.childCount+s.attrs.start===+t[1];let e=On({find:ka,type:this.type,getAttributes:t=>({start:+t[1]}),joinPredicate:n});return(this.options.keepMarks||this.options.keepAttributes)&&(e=On({find:ka,type:this.type,keepMarks:this.options.keepMarks,keepAttributes:this.options.keepAttributes,getAttributes:t=>({start:+t[1],...this.editor.getAttributes(ya)}),joinPredicate:n,editor:this.editor})),[e]}}),OS=/^\s*(\[([( |x])?\])\s$/,NS="position:absolute;width:1px;height:1px;padding:0;margin:-1px;overflow:hidden;clip:rect(0,0,0,0);white-space:nowrap;border:0",IS=(n,e,t)=>{var s;return(t==null||(s=t.checkboxLabel)===null||s===void 0?void 0:s.call(t,n,e))||`Task item checkbox for ${n.textContent||"empty task item"}`},DS=Fe.create({name:"taskItem",addOptions(){return{nested:!1,HTMLAttributes:{},taskListTypeName:"taskList",a11y:void 0}},content(){return this.options.nested?"paragraph block*":"paragraph+"},defining:!0,addAttributes(){return{checked:{default:!1,keepOnSplit:!1,parseHTML:n=>{const e=n.getAttribute("data-checked");return e===""||e==="true"},renderHTML:n=>({"data-checked":n.checked})}}},parseHTML(){return[{tag:`li[data-type="${this.name}"]`,priority:51,contentElement:n=>{var e;return(e=n.querySelector("div"))!==null&&e!==void 0?e:n}}]},renderHTML({node:n,HTMLAttributes:e}){return["li",ke(this.options.HTMLAttributes,e,{"data-type":this.name}),["label",["input",{type:"checkbox",checked:n.attrs.checked?"checked":null}],["span"]],["div",0]]},parseMarkdown:(n,e)=>{const t=[];if(n.tokens&&n.tokens.length>0?t.push(e.createNode("paragraph",{},e.parseInline(n.tokens))):n.text?t.push(e.createNode("paragraph",{},[e.createNode("text",{text:n.text})])):t.push(e.createNode("paragraph",{},[])),n.nestedTokens&&n.nestedTokens.length>0){const s=e.parseChildren(n.nestedTokens);t.push(...s)}return e.createNode("taskItem",{checked:n.checked||!1},t)},renderMarkdown:(n,e)=>{var t;const s=`- [${!((t=n.attrs)===null||t===void 0)&&t.checked?"x":" "}] `;return Ud(n,e,s)},addExtensions(){return this.options.nested?[hu(this.name,[this.options.taskListTypeName])]:[]},addKeyboardShortcuts(){const n={Enter:()=>this.editor.commands.splitListItem(this.name),"Shift-Tab":()=>this.editor.commands.liftListItem(this.name)};return this.options.nested?{...n,Tab:()=>this.editor.commands.sinkListItem(this.name)}:n},addNodeView(){return({node:n,HTMLAttributes:e,getPos:t,editor:s})=>{const i=document.createElement("li"),r=document.createElement("label"),o=document.createElement("span"),l=document.createElement("input"),c=document.createElement("div");o.style.cssText=NS;const d=p=>{const f=IS(p,p.attrs.checked,this.options.a11y);l.setAttribute("aria-label",f),o.textContent=f};d(n),r.contentEditable="false",l.type="checkbox",l.addEventListener("mousedown",p=>p.preventDefault()),l.addEventListener("change",p=>{if(!s.isEditable&&!this.options.onReadOnlyChecked){l.checked=!l.checked;return}const{checked:f}=p.target;s.isEditable&&typeof t=="function"&&s.chain().focus(void 0,{scrollIntoView:!1}).command(({tr:h})=>{const g=t();if(typeof g!="number")return!1;const b=h.doc.nodeAt(g);return h.setNodeMarkup(g,void 0,{...b==null?void 0:b.attrs,checked:f}),!0}).run(),!s.isEditable&&this.options.onReadOnlyChecked&&(this.options.onReadOnlyChecked(n,f)||(l.checked=!l.checked))}),Object.entries(this.options.HTMLAttributes).forEach(([p,f])=>{i.setAttribute(p,f)}),i.dataset.checked=n.attrs.checked,l.checked=n.attrs.checked,r.append(l,o),i.append(r,c),Object.entries(e).forEach(([p,f])=>{i.setAttribute(p,f)});let u=new Set(Object.keys(e));return{dom:i,contentDOM:c,update:p=>{if(p.type!==this.type)return!1;i.dataset.checked=p.attrs.checked,l.checked=p.attrs.checked,d(p);const f=s.extensionManager.attributes,h=ps(p,f),g=new Set(Object.keys(h)),b=this.options.HTMLAttributes;return u.forEach(m=>{g.has(m)||(m in b?i.setAttribute(m,b[m]):i.removeAttribute(m))}),Object.entries(h).forEach(([m,v])=>{v==null?m in b?i.setAttribute(m,b[m]):i.removeAttribute(m):i.setAttribute(m,v)}),u=g,!0}}}},addInputRules(){return[On({find:OS,type:this.type,getAttributes:n=>({checked:n[n.length-1]==="x"})})]}}),$S=Fe.create({name:"taskList",addOptions(){return{itemTypeName:"taskItem",HTMLAttributes:{}}},group:"block list",content(){return`${this.options.itemTypeName}+`},parseHTML(){return[{tag:`ul[data-type="${this.name}"]`,priority:51}]},renderHTML({HTMLAttributes:n}){return["ul",ke(this.options.HTMLAttributes,n,{"data-type":this.name}),0]},parseMarkdown:(n,e)=>e.createNode("taskList",{},e.parseChildren(n.items||[])),renderMarkdown:(n,e)=>n.content?e.renderChildren(n.content,` -`):"",markdownTokenizer:{name:"taskList",level:"block",start(n){var e;const t=(e=n.match(/^\s*[-+*]\s+\[([ xX])\]\s+/))===null||e===void 0?void 0:e.index;return t!==void 0?t:-1},tokenize(n,e,t){const s=r=>{const o=na(r,{itemPattern:/^(\s*)([-+*])\s+\[([ xX])\]\s+(.*)$/,extractItemData:l=>({indentLevel:l[1].length,mainContent:l[4],checked:l[3].toLowerCase()==="x"}),createToken:(l,c)=>({type:"taskItem",raw:"",mainContent:l.mainContent,indentLevel:l.indentLevel,checked:l.checked,text:l.mainContent,tokens:t.inlineTokens(l.mainContent),nestedTokens:c}),customNestedParser:s},t);if(o){const l={type:"taskList",raw:o.raw,items:o.items},c=r.slice(o.raw.length);return c.trim()?[l,...t.blockTokens(c)]:[l]}return t.blockTokens(r)},i=na(n,{itemPattern:/^(\s*)([-+*])\s+\[([ xX])\]\s+(.*)$/,extractItemData:r=>({indentLevel:r[1].length,mainContent:r[4],checked:r[3].toLowerCase()==="x"}),createToken:(r,o)=>({type:"taskItem",raw:"",mainContent:r.mainContent,indentLevel:r.indentLevel,checked:r.checked,text:r.mainContent,tokens:t.inlineTokens(r.mainContent),nestedTokens:o}),customNestedParser:s},t);if(i)return{type:"taskList",raw:i.raw,items:i.items}}},markdownOptions:{indentsContent:!0},addCommands(){return{toggleTaskList:()=>({commands:n})=>n.toggleList(this.name,this.options.itemTypeName)}},addKeyboardShortcuts(){return{"Mod-Shift-9":()=>this.editor.commands.toggleTaskList()}}});pe.create({name:"listKit",addExtensions(){const n=[];return this.options.bulletList!==!1&&n.push(fu.configure(this.options.bulletList)),this.options.listItem!==!1&&n.push(vu.configure(this.options.listItem)),this.options.listKeymap!==!1&&n.push(ku.configure(this.options.listKeymap)),this.options.orderedList!==!1&&n.push(wu.configure(this.options.orderedList)),this.options.taskItem!==!1&&n.push(DS.configure(this.options.taskItem)),this.options.taskList!==!1&&n.push($S.configure(this.options.taskList)),n}});const Ps=" ",vr=" ",RS=Fe.create({name:"paragraph",priority:1e3,addOptions(){return{HTMLAttributes:{}}},group:"block",content:"inline*",parseHTML(){return[{tag:"p"}]},renderHTML({HTMLAttributes:n}){return["p",ke(this.options.HTMLAttributes,n),0]},parseMarkdown:(n,e)=>{const t=n.tokens||[];if(t.length===1&&t[0].type==="image")return e.parseChildren([t[0]]);const s=e.parseInline(t);return t.length===1&&t[0].type==="text"&&(t[0].raw===Ps||t[0].text===Ps||t[0].raw===vr||t[0].text===vr)&&s.length===1&&s[0].type==="text"&&(s[0].text===Ps||s[0].text===vr)?e.createNode("paragraph",void 0,[]):e.createNode("paragraph",void 0,s)},renderMarkdown:(n,e,t)=>{if(!n)return"";const s=Array.isArray(n.content)?n.content:[];if(s.length===0){var i,r;const o=Array.isArray(t==null||(i=t.previousNode)===null||i===void 0?void 0:i.content)?t.previousNode.content:[];return(t==null||(r=t.previousNode)===null||r===void 0?void 0:r.type)==="paragraph"&&o.length===0?Ps:""}return e.renderChildren(s)},addCommands(){return{setParagraph:()=>({commands:n})=>n.setNode(this.name)}},addKeyboardShortcuts(){return{"Mod-Alt-0":()=>this.editor.commands.setParagraph()}}}),LS=/(?:^|\s)(~~(?!\s+~~)((?:[^~]+))~~(?!\s+~~))$/,PS=/(?:^|\s)(~~(?!\s+~~)((?:[^~]+))~~(?!\s+~~))/g,BS=an.create({name:"strike",addOptions(){return{HTMLAttributes:{}}},parseHTML(){return[{tag:"s"},{tag:"del"},{tag:"strike"},{style:"text-decoration",consuming:!1,getAttrs:n=>n.includes("line-through")?{}:!1}]},renderHTML({HTMLAttributes:n}){return["s",ke(this.options.HTMLAttributes,n),0]},markdownTokenName:"del",parseMarkdown:(n,e)=>e.applyMark("strike",e.parseInline(n.tokens||[])),renderMarkdown:(n,e)=>`~~${e.renderChildren(n)}~~`,addCommands(){return{setStrike:()=>({commands:n})=>n.setMark(this.name),toggleStrike:()=>({commands:n})=>n.toggleMark(this.name),unsetStrike:()=>({commands:n})=>n.unsetMark(this.name)}},addKeyboardShortcuts(){return{"Mod-Shift-s":()=>this.editor.commands.toggleStrike()}},addInputRules(){return[on({find:LS,type:this.type})]},addPasteRules(){return[Pt({find:PS,type:this.type})]}}),_S=Fe.create({name:"text",group:"inline",parseMarkdown:n=>({type:"text",text:n.text||""}),renderMarkdown:n=>n.text||""}),zS=an.create({name:"underline",addOptions(){return{HTMLAttributes:{}}},parseHTML(){return[{tag:"u"},{style:"text-decoration",consuming:!1,getAttrs:n=>n.includes("underline")?{}:!1}]},renderHTML({HTMLAttributes:n}){return["u",ke(this.options.HTMLAttributes,n),0]},parseMarkdown(n,e){return e.applyMark(this.name||"underline",e.parseInline(n.tokens||[]))},renderMarkdown(n,e){return`++${e.renderChildren(n)}++`},markdownTokenizer:{name:"underline",level:"inline",start(n){return n.indexOf("++")},tokenize(n,e,t){const s=/^(\+\+)([\s\S]+?)(\+\+)/.exec(n);if(!s)return;const i=s[2].trim();return{type:"underline",raw:s[0],text:i,tokens:t.inlineTokens(i)}}},addCommands(){return{setUnderline:()=>({commands:n})=>n.setMark(this.name),toggleUnderline:()=>({commands:n})=>n.toggleMark(this.name),unsetUnderline:()=>({commands:n})=>n.unsetMark(this.name)}},addKeyboardShortcuts(){return{"Mod-u":()=>this.editor.commands.toggleUnderline(),"Mod-U":()=>this.editor.commands.toggleUnderline()}}});function jS(n={}){return new oe({view(e){return new FS(e,n)}})}class FS{constructor(e,t){var s;this.editorView=e,this.cursorPos=null,this.element=null,this.timeout=-1,this.lastDragEvent=null,this.width=(s=t.width)!==null&&s!==void 0?s:1,this.color=t.color===!1?void 0:t.color||"black",this.class=t.class,this.handlers=["dragover","dragend","drop","dragleave"].map(i=>{let r=o=>{this[i](o)};return e.dom.addEventListener(i,r),{name:i,handler:r}})}destroy(){this.setCursor(null),this.handlers.forEach(({name:e,handler:t})=>this.editorView.dom.removeEventListener(e,t))}update(e,t){if(this.cursorPos!=null&&t.doc!=e.state.doc)if(this.lastDragEvent){let s=this.computeTarget(this.lastDragEvent);s==this.cursorPos?this.updateOverlay():this.setCursor(s)}else this.updateOverlay()}setCursor(e){e!=this.cursorPos&&(this.cursorPos=e,e==null?(this.element.parentNode.removeChild(this.element),this.element=null):this.updateOverlay())}updateOverlay(){let e=this.editorView.state.doc.resolve(this.cursorPos),t=!e.parent.inlineContent,s,i=this.editorView.dom,r=i.getBoundingClientRect(),o=r.width/i.offsetWidth,l=r.height/i.offsetHeight;if(t){let p=e.nodeBefore,f=e.nodeAfter;if(p||f){let h=this.editorView.nodeDOM(this.cursorPos-(p?p.nodeSize:0));if(h){let g=h.getBoundingClientRect(),b=p?g.bottom:g.top;p&&f&&(b=(b+this.editorView.nodeDOM(this.cursorPos).getBoundingClientRect().top)/2);let m=this.width/2*l;s={left:g.left,right:g.right,top:b-m,bottom:b+m}}}}if(!s){let p=this.editorView.coordsAtPos(this.cursorPos),f=this.width/2*o;s={left:p.left-f,right:p.left+f,top:p.top,bottom:p.bottom}}let c=this.editorView.dom.offsetParent;this.element||(this.element=c.appendChild(document.createElement("div")),this.class&&(this.element.className=this.class),this.element.style.cssText="position: absolute; z-index: 50; pointer-events: none;",this.color&&(this.element.style.backgroundColor=this.color)),this.element.classList.toggle("prosemirror-dropcursor-block",t),this.element.classList.toggle("prosemirror-dropcursor-inline",!t);let d,u;if(!c||c==document.body&&getComputedStyle(c).position=="static")d=-pageXOffset,u=-pageYOffset;else{let p=c.getBoundingClientRect(),f=p.width/c.offsetWidth,h=p.height/c.offsetHeight;d=p.left-c.scrollLeft*f,u=p.top-c.scrollTop*h}this.element.style.left=(s.left-d)/o+"px",this.element.style.top=(s.top-u)/l+"px",this.element.style.width=(s.right-s.left)/o+"px",this.element.style.height=(s.bottom-s.top)/l+"px"}scheduleRemoval(e){clearTimeout(this.timeout),this.timeout=setTimeout(()=>this.setCursor(null),e)}computeTarget(e){let t=this.editorView.posAtCoords({left:e.clientX,top:e.clientY}),s=t&&t.inside>=0&&this.editorView.state.doc.nodeAt(t.inside),i=s&&s.type.spec.disableDropCursor,r=typeof i=="function"?i(this.editorView,t,e):i;if(!t||r)return null;let o=t.pos;if(this.editorView.dragging&&this.editorView.dragging.slice){let l=lc(this.editorView.state.doc,o,this.editorView.dragging.slice);l!=null&&(o=l)}return o}dragover(e){if(!this.editorView.editable)return;this.lastDragEvent=e;let t=this.computeTarget(e);t!=null&&(this.setCursor(t),this.scheduleRemoval(5e3))}dragend(){this.scheduleRemoval(20)}drop(){this.scheduleRemoval(20)}dragleave(e){this.editorView.dom.contains(e.relatedTarget)||this.setCursor(null)}}class ue extends X{constructor(e){super(e,e)}map(e,t){let s=e.resolve(t.map(this.head));return ue.valid(s)?new ue(s):X.near(s)}content(){return z.empty}eq(e){return e instanceof ue&&e.head==this.head}toJSON(){return{type:"gapcursor",pos:this.head}}static fromJSON(e,t){if(typeof t.pos!="number")throw new RangeError("Invalid input for GapCursor.fromJSON");return new ue(e.resolve(t.pos))}getBookmark(){return new Po(this.anchor)}static valid(e){let t=e.parent;if(t.inlineContent||!VS(e)||!HS(e))return!1;let s=t.type.spec.allowGapCursor;if(s!=null)return s;let i=t.contentMatchAt(e.index()).defaultType;return i&&i.isTextblock}static findGapCursorFrom(e,t,s=!1){e:for(;;){if(!s&&ue.valid(e))return e;let i=e.pos,r=null;for(let o=e.depth;;o--){let l=e.node(o);if(t>0?e.indexAfter(o)0){r=l.child(t>0?e.indexAfter(o):e.index(o)-1);break}else if(o==0)return null;i+=t;let c=e.doc.resolve(i);if(ue.valid(c))return c}for(;;){let o=t>0?r.firstChild:r.lastChild;if(!o){if(r.isAtom&&!r.isText&&!W.isSelectable(r)){e=e.doc.resolve(i+r.nodeSize*t),s=!1;continue e}break}r=o,i+=t;let l=e.doc.resolve(i);if(ue.valid(l))return l}return null}}}ue.prototype.visible=!1;ue.findFrom=ue.findGapCursorFrom;X.jsonID("gapcursor",ue);class Po{constructor(e){this.pos=e}map(e){return new Po(e.map(this.pos))}resolve(e){let t=e.resolve(this.pos);return ue.valid(t)?new ue(t):X.near(t)}}function Su(n){return n.isAtom||n.spec.isolating||n.spec.createGapCursor}function VS(n){for(let e=n.depth;e>=0;e--){let t=n.index(e),s=n.node(e);if(t==0){if(s.type.spec.isolating)return!0;continue}for(let i=s.child(t-1);;i=i.lastChild){if(i.childCount==0&&!i.inlineContent||Su(i.type))return!0;if(i.inlineContent)return!1}}return!0}function HS(n){for(let e=n.depth;e>=0;e--){let t=n.indexAfter(e),s=n.node(e);if(t==s.childCount){if(s.type.spec.isolating)return!0;continue}for(let i=s.child(t);;i=i.firstChild){if(i.childCount==0&&!i.inlineContent||Su(i.type))return!0;if(i.inlineContent)return!1}}return!0}function qS(){return new oe({props:{decorations:JS,createSelectionBetween(n,e,t){return e.pos==t.pos&&ue.valid(t)?new ue(t):null},handleClick:WS,handleKeyDown:US,handleDOMEvents:{beforeinput:KS}}})}const US=ud({ArrowLeft:Bs("horiz",-1),ArrowRight:Bs("horiz",1),ArrowUp:Bs("vert",-1),ArrowDown:Bs("vert",1)});function Bs(n,e){const t=n=="vert"?e>0?"down":"up":e>0?"right":"left";return function(s,i,r){let o=s.selection,l=e>0?o.$to:o.$from,c=o.empty;if(o instanceof U){if(!r.endOfTextblock(t)||l.depth==0)return!1;c=!1,l=s.doc.resolve(e>0?l.after():l.before())}let d=ue.findGapCursorFrom(l,e,c);return d?(i&&i(s.tr.setSelection(new ue(d))),!0):!1}}function WS(n,e,t){if(!n||!n.editable)return!1;let s=n.state.doc.resolve(e);if(!ue.valid(s))return!1;let i=n.posAtCoords({left:t.clientX,top:t.clientY});return i&&i.inside>-1&&W.isSelectable(n.state.doc.nodeAt(i.inside))?!1:(n.dispatch(n.state.tr.setSelection(new ue(s))),!0)}function KS(n,e){if(e.inputType!="insertCompositionText"||!(n.state.selection instanceof ue))return!1;let{$from:t}=n.state.selection,s=t.parent.contentMatchAt(t.index()).findWrapping(n.state.schema.nodes.text);if(!s)return!1;let i=$.empty;for(let o=s.length-1;o>=0;o--)i=$.from(s[o].createAndFill(null,i));let r=n.state.tr.replace(t.pos,t.pos,new z(i,0,0));return r.setSelection(U.near(r.doc.resolve(t.pos+1))),n.dispatch(r),!1}function JS(n){if(!(n.selection instanceof ue))return null;let e=document.createElement("div");return e.className="ProseMirror-gapcursor",ne.create(n.doc,[Le.widget(n.selection.head,e,{key:"gapcursor"})])}pe.create({name:"characterCount",addOptions(){return{limit:null,autoTrim:!0,mode:"textSize",textCounter:n=>n.length,wordCounter:n=>n.split(" ").filter(e=>e!=="").length}},addStorage(){return{characters:()=>0,words:()=>0}},onBeforeCreate(){this.storage.characters=n=>{const e=(n==null?void 0:n.node)||this.editor.state.doc;if(((n==null?void 0:n.mode)||this.options.mode)==="textSize"){const t=e.textBetween(0,e.content.size,void 0," ");return this.options.textCounter(t)}return e.nodeSize},this.storage.words=n=>{const e=(n==null?void 0:n.node)||this.editor.state.doc,t=e.textBetween(0,e.content.size," "," ");return this.options.wordCounter(t)}},addProseMirrorPlugins(){let n=!1;return[new oe({key:new me("characterCount"),appendTransaction:(e,t,s)=>{if(n)return;const i=this.options.limit,r=this.options.autoTrim;if(i==null||i===0||r===!1){n=!0;return}const o=this.storage.characters({node:s.doc});if(o>i){const l=o-i,c=0,d=l;console.warn(`[CharacterCount] Initial content exceeded limit of ${i} characters. Content was automatically trimmed.`);const u=s.tr.deleteRange(c,d);return n=!0,u}n=!0},filterTransaction:(e,t)=>{const s=this.options.limit;if(!e.docChanged||s===0||s===null||s===void 0)return!0;const i=this.storage.characters({node:t.doc}),r=this.storage.characters({node:e.doc});if(r<=s||i>s&&r>s&&r<=i)return!0;if(i>s&&r>s&&r>i||!e.getMeta("paste"))return!1;const o=e.selection.$head.pos,l=o-(r-s),c=o;return e.deleteRange(l,c),!(this.storage.characters({node:e.doc})>s)}})]}});const GS=pe.create({name:"dropCursor",addOptions(){return{color:"currentColor",width:1,class:void 0}},addProseMirrorPlugins(){return[jS(this.options)]}});pe.create({name:"focus",addOptions(){return{className:"has-focus",mode:"all"}},addProseMirrorPlugins(){return[new oe({key:new me("focus"),props:{decorations:({doc:n,selection:e})=>{const{isEditable:t,isFocused:s}=this.editor,{anchor:i}=e,r=[];if(!t||!s)return ne.create(n,[]);let o=0;this.options.mode==="deepest"&&n.descendants((c,d)=>{if(!c.isText){if(!(i>=d&&i<=d+c.nodeSize-1))return!1;o+=1}});let l=0;return n.descendants((c,d)=>{if(c.isText||!(i>=d&&i<=d+c.nodeSize-1))return!1;if(l+=1,this.options.mode==="deepest"&&o-l>0||this.options.mode==="shallowest"&&l>1)return this.options.mode==="deepest";r.push(Le.node(d,d+c.nodeSize,{class:this.options.className}))}),ne.create(n,r)}}})]}});const YS=pe.create({name:"gapCursor",addProseMirrorPlugins(){return[qS()]},extendNodeSchema(n){var e;const t={name:n.name,options:n.options,storage:n.storage};return{allowGapCursor:(e=se(V(n,"allowGapCursor",t)))!==null&&e!==void 0?e:null}}}),Cu="placeholder",wa=new me("tiptap__placeholder");function Mu(n){const{editor:e,placeholder:t,dataAttribute:s,pos:i,node:r,isEmptyDoc:o,hasAnchor:l,classes:{emptyNode:c,emptyEditor:d}}=n,u=[c];return o&&u.push(d),Le.node(i,i+r.nodeSize,{class:u.join(" "),[s]:typeof t=="function"?t({editor:e,node:r,pos:i,hasAnchor:l}):t})}function Tu(n,e){return typeof n=="function"?n(e):n}function Eu({editor:n,options:e,dataAttribute:t,doc:s,selection:i,from:r,to:o}){const{anchor:l}=i,c=[],d=n.isEmpty;return s.nodesBetween(r,o,(u,p)=>{const f=l>=p&&l<=p+u.nodeSize,h=!u.isLeaf&&ys(u);return u.type.isTextblock&&(f||!e.showOnlyCurrent)&&h&&c.push(Mu({editor:n,isEmptyDoc:d,dataAttribute:t,hasAnchor:f,placeholder:e.placeholder,classes:{emptyEditor:e.emptyEditorClass,emptyNode:Tu(e.emptyNodeClass,{editor:n,node:u,pos:p,hasAnchor:f})},node:u,pos:p})),e.includeChildren}),c}function Au({editor:n,options:e,dataAttribute:t,doc:s,selection:i}){if(!(n.isEditable||!e.showOnlyWhenEditable))return null;const{anchor:r}=i,o=[],l=n.isEmpty;if(e.showOnlyCurrent&&!e.includeChildren){const c=s.resolve(r),d=c.depth>0?c.node(1):c.nodeAfter,u=c.depth>0?c.before(1):r;if(d&&d.type.isTextblock&&ys(d)){const p=r>=u&&r<=u+d.nodeSize;o.push(Mu({editor:n,isEmptyDoc:l,dataAttribute:t,hasAnchor:p,placeholder:e.placeholder,classes:{emptyEditor:e.emptyEditorClass,emptyNode:Tu(e.emptyNodeClass,{editor:n,node:d,pos:u,hasAnchor:p})},node:d,pos:u}))}}else o.push(...Eu({editor:n,options:e,dataAttribute:t,doc:s,selection:i,from:0,to:s.content.size}));return ne.create(s,o)}function es(n,e){const t=n.resolve(e);if(t.depth===0){var s;const r=(s=t.nodeAfter)!==null&&s!==void 0?s:t.nodeBefore;if(!r)return{from:e,to:e};const o=t.nodeAfter?e:e-r.nodeSize;return{from:o,to:o+r.nodeSize}}const i=t.before(1);return{from:i,to:i+t.node(1).nodeSize}}function ts(n,e){return{from:Math.max(0,e.from-1),to:Math.min(n.content.size,e.to-1)}}function XS(n,e,t){const s=[];return n.forEach((i,r)=>{const o=r,l=o+i.nodeSize,c=o+1,d=l+1;ce&&s.push({from:o,to:l})}),s}function ZS(n){if(n.length===0)return[];const e=[...n].sort((s,i)=>s.from-i.from),t=[{...e[0]}];for(let s=1;se.from?t.push(ts(n,es(n,Math.min(e.to,n.content.size+1)-1))):e.fromh.from>=d&&h.to<=u);p.length&&(l=l.remove(p));const f=Eu({editor:t,options:s,dataAttribute:i,doc:r,selection:o,from:d,to:u});f.length&&(l=l.add(r,f))}return l}function sC({editor:n,options:e,dataAttribute:t}){return{init(s,i){const r=Au({editor:n,options:e,dataAttribute:t,doc:i.doc,selection:i.selection});return r!=null?r:ne.empty},apply(s,i,r,o){return!s.docChanged&&!s.selectionSet?i:nC({decorations:i.map(s.mapping,s.doc),ranges:eC(s,r,o),editor:n,options:e,dataAttribute:t,doc:o.doc,selection:o.selection})}}}function iC(n){return n.replace(/\s+/g,"-").replace(/[^a-zA-Z0-9-]/g,"").replace(/^[0-9-]+/,"").replace(/^-+/,"").toLowerCase()}function rC({editor:n,options:e}){const t=e.dataAttribute?`data-${iC(e.dataAttribute)}`:`data-${Cu}`,s=e.showOnlyCurrent&&!e.includeChildren;return new oe({key:wa,...s?{}:{state:sC({editor:n,options:e,dataAttribute:t})},props:{decorations:s?({doc:i,selection:r})=>Au({editor:n,options:e,dataAttribute:t,doc:i,selection:r}):i=>{var r;return e.showOnlyWhenEditable&&!n.isEditable?ne.empty:(r=wa.getState(i))!==null&&r!==void 0?r:ne.empty}}})}pe.create({name:"placeholder",addOptions(){return{emptyEditorClass:"is-editor-empty",emptyNodeClass:"is-empty",dataAttribute:Cu,placeholder:"Write something …",showOnlyWhenEditable:!0,showOnlyCurrent:!0,includeChildren:!1}},addProseMirrorPlugins(){return[rC({editor:this.editor,options:this.options})]}});function Yr(n,e){return!n.selection.empty&&!Ld(n.selection)&&e.isEditable}function oC(n,e){return Yr(n,e)&&!e.isFocused&&!e.view.dragging}function lC(){var n;(n=window.getSelection())===null||n===void 0||n.removeAllRanges()}function aC(n){n.focus()}pe.create({name:"selection",addOptions(){return{className:"selection"}},addProseMirrorPlugins(){const{editor:n,options:e}=this;return[new oe({key:new me("selection"),props:{decorations(t){return oC(t,n)?ne.create(t.doc,[Le.inline(t.selection.from,t.selection.to,{class:e.className})]):null},handleDOMEvents:{blur(t){return Yr(t.state,n)&&lC(),!1},focus(t){return Yr(t.state,n)&&requestAnimationFrame(()=>{!n.isDestroyed&&t.hasFocus()&&aC(t)}),!1}}}})]}});function Sa({types:n,node:e}){return e&&Array.isArray(n)&&n.includes(e.type)||(e==null?void 0:e.type)===n}const cC=pe.create({name:"trailingNode",addOptions(){return{node:void 0,notAfter:[]}},addProseMirrorPlugins(){var n;const e=new me(this.name),t=this.options.node||((n=this.editor.schema.topNodeType.contentMatch.defaultType)===null||n===void 0?void 0:n.name)||"paragraph",s=Object.entries(this.editor.schema.nodes).map(([,i])=>i).filter(i=>(this.options.notAfter||[]).concat(t).includes(i.name));return[new oe({key:e,appendTransaction:(i,r,o)=>{const{doc:l,tr:c,schema:d}=o,u=e.getState(o),p=l.content.size,f=d.nodes[t];if(!i.some(h=>h.getMeta("skipTrailingNode"))&&u)return c.insert(p,f.create())},state:{init:(i,r)=>{const o=r.tr.doc.lastChild;return!Sa({node:o,types:s})},apply:(i,r)=>{if(!i.docChanged||i.getMeta("__uniqueIDTransaction"))return r;const o=i.doc.lastChild;return!Sa({node:o,types:s})}}})]}}),dC=pe.create({name:"undoRedo",addOptions(){return{depth:100,newGroupDelay:500}},addCommands(){return{undo:()=>({state:n,dispatch:e})=>md(n,e),redo:()=>({state:n,dispatch:e})=>gd(n,e)}},addProseMirrorPlugins(){return[h1(this.options)]},addKeyboardShortcuts(){return{"Mod-z":()=>this.editor.commands.undo(),"Shift-Mod-z":()=>this.editor.commands.redo(),"Mod-y":()=>this.editor.commands.redo(),"Mod-я":()=>this.editor.commands.undo(),"Shift-Mod-я":()=>this.editor.commands.redo()}}}),uC=pe.create({name:"starterKit",addExtensions(){const n=[];if(this.options.bold!==!1&&n.push(iw.configure(this.options.bold)),this.options.blockquote!==!1&&n.push(Qx.configure(this.options.blockquote)),this.options.bulletList!==!1&&n.push(fu.configure(this.options.bulletList)),this.options.code!==!1&&n.push(aw.configure(this.options.code)),this.options.codeBlock!==!1&&n.push(uw.configure(this.options.codeBlock)),this.options.document!==!1&&n.push(pw.configure(this.options.document)),this.options.dropcursor!==!1&&n.push(GS.configure(this.options.dropcursor)),this.options.gapcursor!==!1&&n.push(YS.configure(this.options.gapcursor)),this.options.hardBreak!==!1&&n.push(fw.configure(this.options.hardBreak)),this.options.heading!==!1&&n.push(hw.configure(this.options.heading)),this.options.undoRedo!==!1&&n.push(dC.configure(this.options.undoRedo)),this.options.horizontalRule!==!1&&n.push(mw.configure(this.options.horizontalRule)),this.options.italic!==!1&&n.push(kw.configure(this.options.italic)),this.options.listItem!==!1&&n.push(vu.configure(this.options.listItem)),this.options.listKeymap!==!1){var e;n.push(ku.configure((e=this.options)===null||e===void 0?void 0:e.listKeymap))}if(this.options.link!==!1){var t;n.push(eS.configure((t=this.options)===null||t===void 0?void 0:t.link))}if(this.options.orderedList!==!1&&n.push(wu.configure(this.options.orderedList)),this.options.paragraph!==!1&&n.push(RS.configure(this.options.paragraph)),this.options.strike!==!1&&n.push(BS.configure(this.options.strike)),this.options.text!==!1&&n.push(_S.configure(this.options.text)),this.options.underline!==!1){var s;n.push(zS.configure((s=this.options)===null||s===void 0?void 0:s.underline))}if(this.options.trailingNode!==!1){var i;n.push(cC.configure((i=this.options)===null||i===void 0?void 0:i.trailingNode))}return n}});var pC=uC;const fC=()=>({type:"doc",content:[{type:"paragraph"}]});function Ca(n={}){var t;if(((t=n.content)==null?void 0:t.type)==="doc")return n.content;const e=String(n.text||"").split(` +`)})}s.push({type:"list_item",raw:r.raw,tokens:d}),i=p}else i+=1}return s}function TS(n,e){return n.map(t=>{if(t.type!=="list_item")return e.parseChildren([t])[0];const s=[];return t.tokens&&t.tokens.length>0&&t.tokens.forEach(i=>{if(i.type==="paragraph"||i.type==="list"||i.type==="blockquote"||i.type==="code")s.push(...e.parseChildren([i]));else if(i.type==="text"&&i.tokens){const r=e.parseChildren([i]);s.push({type:"paragraph",content:r})}else{const r=e.parseChildren([i]);r.length>0&&s.push(...r)}}),{type:"listItem",content:s}})}const ES=64;function va(n,e){const t=[];let s=0;for(;t.lengthn.hasAttribute("start")?parseInt(n.getAttribute("start")||"",10):1},type:{default:null,parseHTML:n=>{const e=n.getAttribute("type");if(e)return e;const t=n.getAttribute("style");if(t){const i=xa(t);if(i)return i}const s=n.querySelector("li");if(s){const i=s.getAttribute("style");if(i){const r=xa(i);if(r)return r}}return null}}}},parseHTML(){return[{tag:"ol"}]},renderHTML({HTMLAttributes:n}){const{start:e,type:t,...s}=n,i=ke(this.options.HTMLAttributes,s);return e!==1&&(i.start=e),t&&t!=="1"&&(i.type=t),["ol",i,0]},markdownTokenName:"list",parseMarkdown:(n,e)=>{if(n.type!=="list"||!n.ordered)return[];const t=n.start||1,s=n.typeMarker,i=n.items?TS(n.items,e):[],r={};return t!==1&&(r.start=t),s&&(r.type=s),Object.keys(r).length>0?{type:"orderedList",attrs:r,content:i}:{type:"orderedList",content:i}},renderMarkdown:(n,e)=>n.content?e.renderChildren(n.content,` +`):"",markdownTokenizer:{name:"orderedList",level:"block",start:()=>-1,tokenize:(n,e,t)=>{var s,i;const[r,o,l]=AS(n);if(r.length===0)return;const c=xu(r,r[0].indent,t);if(c.length!==0)return{type:"list",ordered:!0,start:((s=r[0])===null||s===void 0?void 0:s.number)||1,typeMarker:(i=r[0])===null||i===void 0?void 0:i.type,items:c,raw:l.slice(0,o).join(` +`)}}},markdownOptions:{indentsContent:!0},addCommands(){return{toggleOrderedList:()=>({commands:n,chain:e})=>this.options.keepAttributes?e().toggleList(this.name,this.options.itemTypeName,this.options.keepMarks).updateAttributes(OS,this.editor.getAttributes(ya)).run():n.toggleList(this.name,this.options.itemTypeName,this.options.keepMarks)}},addKeyboardShortcuts(){return{"Mod-Shift-7":()=>this.editor.commands.toggleOrderedList()}},addProseMirrorPlugins(){return[new oe({props:{handlePaste:(n,e)=>{var t,s;const i=(t=e.clipboardData)===null||t===void 0?void 0:t.getData("text/html");if(i!=null&&i.trim())return!1;const r=(s=e.clipboardData)===null||s===void 0?void 0:s.getData("text/plain");if(!r)return!1;const o=MS(r);if(!o)return!1;try{const l=n.state.schema.nodeFromJSON(o),c=n.state.tr.replaceSelectionWith(l);return n.dispatch(c),!0}catch(l){return!1}}}})]},addInputRules(){const n=(t,s)=>(!s.attrs.type||s.attrs.type==="1")&&s.childCount+s.attrs.start===+t[1];let e=On({find:ka,type:this.type,getAttributes:t=>({start:+t[1]}),joinPredicate:n});return(this.options.keepMarks||this.options.keepAttributes)&&(e=On({find:ka,type:this.type,keepMarks:this.options.keepMarks,keepAttributes:this.options.keepAttributes,getAttributes:t=>({start:+t[1],...this.editor.getAttributes(ya)}),joinPredicate:n,editor:this.editor})),[e]}}),NS=/^\s*(\[([( |x])?\])\s$/,IS="position:absolute;width:1px;height:1px;padding:0;margin:-1px;overflow:hidden;clip:rect(0,0,0,0);white-space:nowrap;border:0",DS=(n,e,t)=>{var s;return(t==null||(s=t.checkboxLabel)===null||s===void 0?void 0:s.call(t,n,e))||`Task item checkbox for ${n.textContent||"empty task item"}`},$S=Fe.create({name:"taskItem",addOptions(){return{nested:!1,HTMLAttributes:{},taskListTypeName:"taskList",a11y:void 0}},content(){return this.options.nested?"paragraph block*":"paragraph+"},defining:!0,addAttributes(){return{checked:{default:!1,keepOnSplit:!1,parseHTML:n=>{const e=n.getAttribute("data-checked");return e===""||e==="true"},renderHTML:n=>({"data-checked":n.checked})}}},parseHTML(){return[{tag:`li[data-type="${this.name}"]`,priority:51,contentElement:n=>{var e;return(e=n.querySelector("div"))!==null&&e!==void 0?e:n}}]},renderHTML({node:n,HTMLAttributes:e}){return["li",ke(this.options.HTMLAttributes,e,{"data-type":this.name}),["label",["input",{type:"checkbox",checked:n.attrs.checked?"checked":null}],["span"]],["div",0]]},parseMarkdown:(n,e)=>{const t=[];if(n.tokens&&n.tokens.length>0?t.push(e.createNode("paragraph",{},e.parseInline(n.tokens))):n.text?t.push(e.createNode("paragraph",{},[e.createNode("text",{text:n.text})])):t.push(e.createNode("paragraph",{},[])),n.nestedTokens&&n.nestedTokens.length>0){const s=e.parseChildren(n.nestedTokens);t.push(...s)}return e.createNode("taskItem",{checked:n.checked||!1},t)},renderMarkdown:(n,e)=>{var t;const s=`- [${!((t=n.attrs)===null||t===void 0)&&t.checked?"x":" "}] `;return Ud(n,e,s)},addExtensions(){return this.options.nested?[hu(this.name,[this.options.taskListTypeName])]:[]},addKeyboardShortcuts(){const n={Enter:()=>this.editor.commands.splitListItem(this.name),"Shift-Tab":()=>this.editor.commands.liftListItem(this.name)};return this.options.nested?{...n,Tab:()=>this.editor.commands.sinkListItem(this.name)}:n},addNodeView(){return({node:n,HTMLAttributes:e,getPos:t,editor:s})=>{const i=document.createElement("li"),r=document.createElement("label"),o=document.createElement("span"),l=document.createElement("input"),c=document.createElement("div");o.style.cssText=IS;const d=p=>{const f=DS(p,p.attrs.checked,this.options.a11y);l.setAttribute("aria-label",f),o.textContent=f};d(n),r.contentEditable="false",l.type="checkbox",l.addEventListener("mousedown",p=>p.preventDefault()),l.addEventListener("change",p=>{if(!s.isEditable&&!this.options.onReadOnlyChecked){l.checked=!l.checked;return}const{checked:f}=p.target;s.isEditable&&typeof t=="function"&&s.chain().focus(void 0,{scrollIntoView:!1}).command(({tr:h})=>{const g=t();if(typeof g!="number")return!1;const b=h.doc.nodeAt(g);return h.setNodeMarkup(g,void 0,{...b==null?void 0:b.attrs,checked:f}),!0}).run(),!s.isEditable&&this.options.onReadOnlyChecked&&(this.options.onReadOnlyChecked(n,f)||(l.checked=!l.checked))}),Object.entries(this.options.HTMLAttributes).forEach(([p,f])=>{i.setAttribute(p,f)}),i.dataset.checked=n.attrs.checked,l.checked=n.attrs.checked,r.append(l,o),i.append(r,c),Object.entries(e).forEach(([p,f])=>{i.setAttribute(p,f)});let u=new Set(Object.keys(e));return{dom:i,contentDOM:c,update:p=>{if(p.type!==this.type)return!1;i.dataset.checked=p.attrs.checked,l.checked=p.attrs.checked,d(p);const f=s.extensionManager.attributes,h=ps(p,f),g=new Set(Object.keys(h)),b=this.options.HTMLAttributes;return u.forEach(m=>{g.has(m)||(m in b?i.setAttribute(m,b[m]):i.removeAttribute(m))}),Object.entries(h).forEach(([m,v])=>{v==null?m in b?i.setAttribute(m,b[m]):i.removeAttribute(m):i.setAttribute(m,v)}),u=g,!0}}}},addInputRules(){return[On({find:NS,type:this.type,getAttributes:n=>({checked:n[n.length-1]==="x"})})]}}),RS=Fe.create({name:"taskList",addOptions(){return{itemTypeName:"taskItem",HTMLAttributes:{}}},group:"block list",content(){return`${this.options.itemTypeName}+`},parseHTML(){return[{tag:`ul[data-type="${this.name}"]`,priority:51}]},renderHTML({HTMLAttributes:n}){return["ul",ke(this.options.HTMLAttributes,n,{"data-type":this.name}),0]},parseMarkdown:(n,e)=>e.createNode("taskList",{},e.parseChildren(n.items||[])),renderMarkdown:(n,e)=>n.content?e.renderChildren(n.content,` +`):"",markdownTokenizer:{name:"taskList",level:"block",start(n){var e;const t=(e=n.match(/^\s*[-+*]\s+\[([ xX])\]\s+/))===null||e===void 0?void 0:e.index;return t!==void 0?t:-1},tokenize(n,e,t){const s=r=>{const o=na(r,{itemPattern:/^(\s*)([-+*])\s+\[([ xX])\]\s+(.*)$/,extractItemData:l=>({indentLevel:l[1].length,mainContent:l[4],checked:l[3].toLowerCase()==="x"}),createToken:(l,c)=>({type:"taskItem",raw:"",mainContent:l.mainContent,indentLevel:l.indentLevel,checked:l.checked,text:l.mainContent,tokens:t.inlineTokens(l.mainContent),nestedTokens:c}),customNestedParser:s},t);if(o){const l={type:"taskList",raw:o.raw,items:o.items},c=r.slice(o.raw.length);return c.trim()?[l,...t.blockTokens(c)]:[l]}return t.blockTokens(r)},i=na(n,{itemPattern:/^(\s*)([-+*])\s+\[([ xX])\]\s+(.*)$/,extractItemData:r=>({indentLevel:r[1].length,mainContent:r[4],checked:r[3].toLowerCase()==="x"}),createToken:(r,o)=>({type:"taskItem",raw:"",mainContent:r.mainContent,indentLevel:r.indentLevel,checked:r.checked,text:r.mainContent,tokens:t.inlineTokens(r.mainContent),nestedTokens:o}),customNestedParser:s},t);if(i)return{type:"taskList",raw:i.raw,items:i.items}}},markdownOptions:{indentsContent:!0},addCommands(){return{toggleTaskList:()=>({commands:n})=>n.toggleList(this.name,this.options.itemTypeName)}},addKeyboardShortcuts(){return{"Mod-Shift-9":()=>this.editor.commands.toggleTaskList()}}});pe.create({name:"listKit",addExtensions(){const n=[];return this.options.bulletList!==!1&&n.push(fu.configure(this.options.bulletList)),this.options.listItem!==!1&&n.push(vu.configure(this.options.listItem)),this.options.listKeymap!==!1&&n.push(ku.configure(this.options.listKeymap)),this.options.orderedList!==!1&&n.push(wu.configure(this.options.orderedList)),this.options.taskItem!==!1&&n.push($S.configure(this.options.taskItem)),this.options.taskList!==!1&&n.push(RS.configure(this.options.taskList)),n}});const Ps=" ",vr=" ",LS=Fe.create({name:"paragraph",priority:1e3,addOptions(){return{HTMLAttributes:{}}},group:"block",content:"inline*",parseHTML(){return[{tag:"p"}]},renderHTML({HTMLAttributes:n}){return["p",ke(this.options.HTMLAttributes,n),0]},parseMarkdown:(n,e)=>{const t=n.tokens||[];if(t.length===1&&t[0].type==="image")return e.parseChildren([t[0]]);const s=e.parseInline(t);return t.length===1&&t[0].type==="text"&&(t[0].raw===Ps||t[0].text===Ps||t[0].raw===vr||t[0].text===vr)&&s.length===1&&s[0].type==="text"&&(s[0].text===Ps||s[0].text===vr)?e.createNode("paragraph",void 0,[]):e.createNode("paragraph",void 0,s)},renderMarkdown:(n,e,t)=>{if(!n)return"";const s=Array.isArray(n.content)?n.content:[];if(s.length===0){var i,r;const o=Array.isArray(t==null||(i=t.previousNode)===null||i===void 0?void 0:i.content)?t.previousNode.content:[];return(t==null||(r=t.previousNode)===null||r===void 0?void 0:r.type)==="paragraph"&&o.length===0?Ps:""}return e.renderChildren(s)},addCommands(){return{setParagraph:()=>({commands:n})=>n.setNode(this.name)}},addKeyboardShortcuts(){return{"Mod-Alt-0":()=>this.editor.commands.setParagraph()}}}),PS=/(?:^|\s)(~~(?!\s+~~)((?:[^~]+))~~(?!\s+~~))$/,BS=/(?:^|\s)(~~(?!\s+~~)((?:[^~]+))~~(?!\s+~~))/g,_S=an.create({name:"strike",addOptions(){return{HTMLAttributes:{}}},parseHTML(){return[{tag:"s"},{tag:"del"},{tag:"strike"},{style:"text-decoration",consuming:!1,getAttrs:n=>n.includes("line-through")?{}:!1}]},renderHTML({HTMLAttributes:n}){return["s",ke(this.options.HTMLAttributes,n),0]},markdownTokenName:"del",parseMarkdown:(n,e)=>e.applyMark("strike",e.parseInline(n.tokens||[])),renderMarkdown:(n,e)=>`~~${e.renderChildren(n)}~~`,addCommands(){return{setStrike:()=>({commands:n})=>n.setMark(this.name),toggleStrike:()=>({commands:n})=>n.toggleMark(this.name),unsetStrike:()=>({commands:n})=>n.unsetMark(this.name)}},addKeyboardShortcuts(){return{"Mod-Shift-s":()=>this.editor.commands.toggleStrike()}},addInputRules(){return[on({find:PS,type:this.type})]},addPasteRules(){return[Pt({find:BS,type:this.type})]}}),zS=Fe.create({name:"text",group:"inline",parseMarkdown:n=>({type:"text",text:n.text||""}),renderMarkdown:n=>n.text||""}),jS=an.create({name:"underline",addOptions(){return{HTMLAttributes:{}}},parseHTML(){return[{tag:"u"},{style:"text-decoration",consuming:!1,getAttrs:n=>n.includes("underline")?{}:!1}]},renderHTML({HTMLAttributes:n}){return["u",ke(this.options.HTMLAttributes,n),0]},parseMarkdown(n,e){return e.applyMark(this.name||"underline",e.parseInline(n.tokens||[]))},renderMarkdown(n,e){return`++${e.renderChildren(n)}++`},markdownTokenizer:{name:"underline",level:"inline",start(n){return n.indexOf("++")},tokenize(n,e,t){const s=/^(\+\+)([\s\S]+?)(\+\+)/.exec(n);if(!s)return;const i=s[2].trim();return{type:"underline",raw:s[0],text:i,tokens:t.inlineTokens(i)}}},addCommands(){return{setUnderline:()=>({commands:n})=>n.setMark(this.name),toggleUnderline:()=>({commands:n})=>n.toggleMark(this.name),unsetUnderline:()=>({commands:n})=>n.unsetMark(this.name)}},addKeyboardShortcuts(){return{"Mod-u":()=>this.editor.commands.toggleUnderline(),"Mod-U":()=>this.editor.commands.toggleUnderline()}}});function FS(n={}){return new oe({view(e){return new VS(e,n)}})}class VS{constructor(e,t){var s;this.editorView=e,this.cursorPos=null,this.element=null,this.timeout=-1,this.lastDragEvent=null,this.width=(s=t.width)!==null&&s!==void 0?s:1,this.color=t.color===!1?void 0:t.color||"black",this.class=t.class,this.handlers=["dragover","dragend","drop","dragleave"].map(i=>{let r=o=>{this[i](o)};return e.dom.addEventListener(i,r),{name:i,handler:r}})}destroy(){this.setCursor(null),this.handlers.forEach(({name:e,handler:t})=>this.editorView.dom.removeEventListener(e,t))}update(e,t){if(this.cursorPos!=null&&t.doc!=e.state.doc)if(this.lastDragEvent){let s=this.computeTarget(this.lastDragEvent);s==this.cursorPos?this.updateOverlay():this.setCursor(s)}else this.updateOverlay()}setCursor(e){e!=this.cursorPos&&(this.cursorPos=e,e==null?(this.element.parentNode.removeChild(this.element),this.element=null):this.updateOverlay())}updateOverlay(){let e=this.editorView.state.doc.resolve(this.cursorPos),t=!e.parent.inlineContent,s,i=this.editorView.dom,r=i.getBoundingClientRect(),o=r.width/i.offsetWidth,l=r.height/i.offsetHeight;if(t){let p=e.nodeBefore,f=e.nodeAfter;if(p||f){let h=this.editorView.nodeDOM(this.cursorPos-(p?p.nodeSize:0));if(h){let g=h.getBoundingClientRect(),b=p?g.bottom:g.top;p&&f&&(b=(b+this.editorView.nodeDOM(this.cursorPos).getBoundingClientRect().top)/2);let m=this.width/2*l;s={left:g.left,right:g.right,top:b-m,bottom:b+m}}}}if(!s){let p=this.editorView.coordsAtPos(this.cursorPos),f=this.width/2*o;s={left:p.left-f,right:p.left+f,top:p.top,bottom:p.bottom}}let c=this.editorView.dom.offsetParent;this.element||(this.element=c.appendChild(document.createElement("div")),this.class&&(this.element.className=this.class),this.element.style.cssText="position: absolute; z-index: 50; pointer-events: none;",this.color&&(this.element.style.backgroundColor=this.color)),this.element.classList.toggle("prosemirror-dropcursor-block",t),this.element.classList.toggle("prosemirror-dropcursor-inline",!t);let d,u;if(!c||c==document.body&&getComputedStyle(c).position=="static")d=-pageXOffset,u=-pageYOffset;else{let p=c.getBoundingClientRect(),f=p.width/c.offsetWidth,h=p.height/c.offsetHeight;d=p.left-c.scrollLeft*f,u=p.top-c.scrollTop*h}this.element.style.left=(s.left-d)/o+"px",this.element.style.top=(s.top-u)/l+"px",this.element.style.width=(s.right-s.left)/o+"px",this.element.style.height=(s.bottom-s.top)/l+"px"}scheduleRemoval(e){clearTimeout(this.timeout),this.timeout=setTimeout(()=>this.setCursor(null),e)}computeTarget(e){let t=this.editorView.posAtCoords({left:e.clientX,top:e.clientY}),s=t&&t.inside>=0&&this.editorView.state.doc.nodeAt(t.inside),i=s&&s.type.spec.disableDropCursor,r=typeof i=="function"?i(this.editorView,t,e):i;if(!t||r)return null;let o=t.pos;if(this.editorView.dragging&&this.editorView.dragging.slice){let l=lc(this.editorView.state.doc,o,this.editorView.dragging.slice);l!=null&&(o=l)}return o}dragover(e){if(!this.editorView.editable)return;this.lastDragEvent=e;let t=this.computeTarget(e);t!=null&&(this.setCursor(t),this.scheduleRemoval(5e3))}dragend(){this.scheduleRemoval(20)}drop(){this.scheduleRemoval(20)}dragleave(e){this.editorView.dom.contains(e.relatedTarget)||this.setCursor(null)}}class ue extends X{constructor(e){super(e,e)}map(e,t){let s=e.resolve(t.map(this.head));return ue.valid(s)?new ue(s):X.near(s)}content(){return z.empty}eq(e){return e instanceof ue&&e.head==this.head}toJSON(){return{type:"gapcursor",pos:this.head}}static fromJSON(e,t){if(typeof t.pos!="number")throw new RangeError("Invalid input for GapCursor.fromJSON");return new ue(e.resolve(t.pos))}getBookmark(){return new Po(this.anchor)}static valid(e){let t=e.parent;if(t.inlineContent||!HS(e)||!qS(e))return!1;let s=t.type.spec.allowGapCursor;if(s!=null)return s;let i=t.contentMatchAt(e.index()).defaultType;return i&&i.isTextblock}static findGapCursorFrom(e,t,s=!1){e:for(;;){if(!s&&ue.valid(e))return e;let i=e.pos,r=null;for(let o=e.depth;;o--){let l=e.node(o);if(t>0?e.indexAfter(o)0){r=l.child(t>0?e.indexAfter(o):e.index(o)-1);break}else if(o==0)return null;i+=t;let c=e.doc.resolve(i);if(ue.valid(c))return c}for(;;){let o=t>0?r.firstChild:r.lastChild;if(!o){if(r.isAtom&&!r.isText&&!W.isSelectable(r)){e=e.doc.resolve(i+r.nodeSize*t),s=!1;continue e}break}r=o,i+=t;let l=e.doc.resolve(i);if(ue.valid(l))return l}return null}}}ue.prototype.visible=!1;ue.findFrom=ue.findGapCursorFrom;X.jsonID("gapcursor",ue);class Po{constructor(e){this.pos=e}map(e){return new Po(e.map(this.pos))}resolve(e){let t=e.resolve(this.pos);return ue.valid(t)?new ue(t):X.near(t)}}function Su(n){return n.isAtom||n.spec.isolating||n.spec.createGapCursor}function HS(n){for(let e=n.depth;e>=0;e--){let t=n.index(e),s=n.node(e);if(t==0){if(s.type.spec.isolating)return!0;continue}for(let i=s.child(t-1);;i=i.lastChild){if(i.childCount==0&&!i.inlineContent||Su(i.type))return!0;if(i.inlineContent)return!1}}return!0}function qS(n){for(let e=n.depth;e>=0;e--){let t=n.indexAfter(e),s=n.node(e);if(t==s.childCount){if(s.type.spec.isolating)return!0;continue}for(let i=s.child(t);;i=i.firstChild){if(i.childCount==0&&!i.inlineContent||Su(i.type))return!0;if(i.inlineContent)return!1}}return!0}function US(){return new oe({props:{decorations:GS,createSelectionBetween(n,e,t){return e.pos==t.pos&&ue.valid(t)?new ue(t):null},handleClick:KS,handleKeyDown:WS,handleDOMEvents:{beforeinput:JS}}})}const WS=ud({ArrowLeft:Bs("horiz",-1),ArrowRight:Bs("horiz",1),ArrowUp:Bs("vert",-1),ArrowDown:Bs("vert",1)});function Bs(n,e){const t=n=="vert"?e>0?"down":"up":e>0?"right":"left";return function(s,i,r){let o=s.selection,l=e>0?o.$to:o.$from,c=o.empty;if(o instanceof U){if(!r.endOfTextblock(t)||l.depth==0)return!1;c=!1,l=s.doc.resolve(e>0?l.after():l.before())}let d=ue.findGapCursorFrom(l,e,c);return d?(i&&i(s.tr.setSelection(new ue(d))),!0):!1}}function KS(n,e,t){if(!n||!n.editable)return!1;let s=n.state.doc.resolve(e);if(!ue.valid(s))return!1;let i=n.posAtCoords({left:t.clientX,top:t.clientY});return i&&i.inside>-1&&W.isSelectable(n.state.doc.nodeAt(i.inside))?!1:(n.dispatch(n.state.tr.setSelection(new ue(s))),!0)}function JS(n,e){if(e.inputType!="insertCompositionText"||!(n.state.selection instanceof ue))return!1;let{$from:t}=n.state.selection,s=t.parent.contentMatchAt(t.index()).findWrapping(n.state.schema.nodes.text);if(!s)return!1;let i=$.empty;for(let o=s.length-1;o>=0;o--)i=$.from(s[o].createAndFill(null,i));let r=n.state.tr.replace(t.pos,t.pos,new z(i,0,0));return r.setSelection(U.near(r.doc.resolve(t.pos+1))),n.dispatch(r),!1}function GS(n){if(!(n.selection instanceof ue))return null;let e=document.createElement("div");return e.className="ProseMirror-gapcursor",ne.create(n.doc,[Le.widget(n.selection.head,e,{key:"gapcursor"})])}pe.create({name:"characterCount",addOptions(){return{limit:null,autoTrim:!0,mode:"textSize",textCounter:n=>n.length,wordCounter:n=>n.split(" ").filter(e=>e!=="").length}},addStorage(){return{characters:()=>0,words:()=>0}},onBeforeCreate(){this.storage.characters=n=>{const e=(n==null?void 0:n.node)||this.editor.state.doc;if(((n==null?void 0:n.mode)||this.options.mode)==="textSize"){const t=e.textBetween(0,e.content.size,void 0," ");return this.options.textCounter(t)}return e.nodeSize},this.storage.words=n=>{const e=(n==null?void 0:n.node)||this.editor.state.doc,t=e.textBetween(0,e.content.size," "," ");return this.options.wordCounter(t)}},addProseMirrorPlugins(){let n=!1;return[new oe({key:new me("characterCount"),appendTransaction:(e,t,s)=>{if(n)return;const i=this.options.limit,r=this.options.autoTrim;if(i==null||i===0||r===!1){n=!0;return}const o=this.storage.characters({node:s.doc});if(o>i){const l=o-i,c=0,d=l;console.warn(`[CharacterCount] Initial content exceeded limit of ${i} characters. Content was automatically trimmed.`);const u=s.tr.deleteRange(c,d);return n=!0,u}n=!0},filterTransaction:(e,t)=>{const s=this.options.limit;if(!e.docChanged||s===0||s===null||s===void 0)return!0;const i=this.storage.characters({node:t.doc}),r=this.storage.characters({node:e.doc});if(r<=s||i>s&&r>s&&r<=i)return!0;if(i>s&&r>s&&r>i||!e.getMeta("paste"))return!1;const o=e.selection.$head.pos,l=o-(r-s),c=o;return e.deleteRange(l,c),!(this.storage.characters({node:e.doc})>s)}})]}});const YS=pe.create({name:"dropCursor",addOptions(){return{color:"currentColor",width:1,class:void 0}},addProseMirrorPlugins(){return[FS(this.options)]}});pe.create({name:"focus",addOptions(){return{className:"has-focus",mode:"all"}},addProseMirrorPlugins(){return[new oe({key:new me("focus"),props:{decorations:({doc:n,selection:e})=>{const{isEditable:t,isFocused:s}=this.editor,{anchor:i}=e,r=[];if(!t||!s)return ne.create(n,[]);let o=0;this.options.mode==="deepest"&&n.descendants((c,d)=>{if(!c.isText){if(!(i>=d&&i<=d+c.nodeSize-1))return!1;o+=1}});let l=0;return n.descendants((c,d)=>{if(c.isText||!(i>=d&&i<=d+c.nodeSize-1))return!1;if(l+=1,this.options.mode==="deepest"&&o-l>0||this.options.mode==="shallowest"&&l>1)return this.options.mode==="deepest";r.push(Le.node(d,d+c.nodeSize,{class:this.options.className}))}),ne.create(n,r)}}})]}});const XS=pe.create({name:"gapCursor",addProseMirrorPlugins(){return[US()]},extendNodeSchema(n){var e;const t={name:n.name,options:n.options,storage:n.storage};return{allowGapCursor:(e=se(V(n,"allowGapCursor",t)))!==null&&e!==void 0?e:null}}}),Cu="placeholder",wa=new me("tiptap__placeholder");function Mu(n){const{editor:e,placeholder:t,dataAttribute:s,pos:i,node:r,isEmptyDoc:o,hasAnchor:l,classes:{emptyNode:c,emptyEditor:d}}=n,u=[c];return o&&u.push(d),Le.node(i,i+r.nodeSize,{class:u.join(" "),[s]:typeof t=="function"?t({editor:e,node:r,pos:i,hasAnchor:l}):t})}function Tu(n,e){return typeof n=="function"?n(e):n}function Eu({editor:n,options:e,dataAttribute:t,doc:s,selection:i,from:r,to:o}){const{anchor:l}=i,c=[],d=n.isEmpty;return s.nodesBetween(r,o,(u,p)=>{const f=l>=p&&l<=p+u.nodeSize,h=!u.isLeaf&&ys(u);return u.type.isTextblock&&(f||!e.showOnlyCurrent)&&h&&c.push(Mu({editor:n,isEmptyDoc:d,dataAttribute:t,hasAnchor:f,placeholder:e.placeholder,classes:{emptyEditor:e.emptyEditorClass,emptyNode:Tu(e.emptyNodeClass,{editor:n,node:u,pos:p,hasAnchor:f})},node:u,pos:p})),e.includeChildren}),c}function Au({editor:n,options:e,dataAttribute:t,doc:s,selection:i}){if(!(n.isEditable||!e.showOnlyWhenEditable))return null;const{anchor:r}=i,o=[],l=n.isEmpty;if(e.showOnlyCurrent&&!e.includeChildren){const c=s.resolve(r),d=c.depth>0?c.node(1):c.nodeAfter,u=c.depth>0?c.before(1):r;if(d&&d.type.isTextblock&&ys(d)){const p=r>=u&&r<=u+d.nodeSize;o.push(Mu({editor:n,isEmptyDoc:l,dataAttribute:t,hasAnchor:p,placeholder:e.placeholder,classes:{emptyEditor:e.emptyEditorClass,emptyNode:Tu(e.emptyNodeClass,{editor:n,node:d,pos:u,hasAnchor:p})},node:d,pos:u}))}}else o.push(...Eu({editor:n,options:e,dataAttribute:t,doc:s,selection:i,from:0,to:s.content.size}));return ne.create(s,o)}function es(n,e){const t=n.resolve(e);if(t.depth===0){var s;const r=(s=t.nodeAfter)!==null&&s!==void 0?s:t.nodeBefore;if(!r)return{from:e,to:e};const o=t.nodeAfter?e:e-r.nodeSize;return{from:o,to:o+r.nodeSize}}const i=t.before(1);return{from:i,to:i+t.node(1).nodeSize}}function ts(n,e){return{from:Math.max(0,e.from-1),to:Math.min(n.content.size,e.to-1)}}function ZS(n,e,t){const s=[];return n.forEach((i,r)=>{const o=r,l=o+i.nodeSize,c=o+1,d=l+1;ce&&s.push({from:o,to:l})}),s}function QS(n){if(n.length===0)return[];const e=[...n].sort((s,i)=>s.from-i.from),t=[{...e[0]}];for(let s=1;se.from?t.push(ts(n,es(n,Math.min(e.to,n.content.size+1)-1))):e.fromh.from>=d&&h.to<=u);p.length&&(l=l.remove(p));const f=Eu({editor:t,options:s,dataAttribute:i,doc:r,selection:o,from:d,to:u});f.length&&(l=l.add(r,f))}return l}function iC({editor:n,options:e,dataAttribute:t}){return{init(s,i){const r=Au({editor:n,options:e,dataAttribute:t,doc:i.doc,selection:i.selection});return r!=null?r:ne.empty},apply(s,i,r,o){return!s.docChanged&&!s.selectionSet?i:sC({decorations:i.map(s.mapping,s.doc),ranges:tC(s,r,o),editor:n,options:e,dataAttribute:t,doc:o.doc,selection:o.selection})}}}function rC(n){return n.replace(/\s+/g,"-").replace(/[^a-zA-Z0-9-]/g,"").replace(/^[0-9-]+/,"").replace(/^-+/,"").toLowerCase()}function oC({editor:n,options:e}){const t=e.dataAttribute?`data-${rC(e.dataAttribute)}`:`data-${Cu}`,s=e.showOnlyCurrent&&!e.includeChildren;return new oe({key:wa,...s?{}:{state:iC({editor:n,options:e,dataAttribute:t})},props:{decorations:s?({doc:i,selection:r})=>Au({editor:n,options:e,dataAttribute:t,doc:i,selection:r}):i=>{var r;return e.showOnlyWhenEditable&&!n.isEditable?ne.empty:(r=wa.getState(i))!==null&&r!==void 0?r:ne.empty}}})}pe.create({name:"placeholder",addOptions(){return{emptyEditorClass:"is-editor-empty",emptyNodeClass:"is-empty",dataAttribute:Cu,placeholder:"Write something …",showOnlyWhenEditable:!0,showOnlyCurrent:!0,includeChildren:!1}},addProseMirrorPlugins(){return[oC({editor:this.editor,options:this.options})]}});function Yr(n,e){return!n.selection.empty&&!Ld(n.selection)&&e.isEditable}function lC(n,e){return Yr(n,e)&&!e.isFocused&&!e.view.dragging}function aC(){var n;(n=window.getSelection())===null||n===void 0||n.removeAllRanges()}function cC(n){n.focus()}pe.create({name:"selection",addOptions(){return{className:"selection"}},addProseMirrorPlugins(){const{editor:n,options:e}=this;return[new oe({key:new me("selection"),props:{decorations(t){return lC(t,n)?ne.create(t.doc,[Le.inline(t.selection.from,t.selection.to,{class:e.className})]):null},handleDOMEvents:{blur(t){return Yr(t.state,n)&&aC(),!1},focus(t){return Yr(t.state,n)&&requestAnimationFrame(()=>{!n.isDestroyed&&t.hasFocus()&&cC(t)}),!1}}}})]}});function Sa({types:n,node:e}){return e&&Array.isArray(n)&&n.includes(e.type)||(e==null?void 0:e.type)===n}const dC=pe.create({name:"trailingNode",addOptions(){return{node:void 0,notAfter:[]}},addProseMirrorPlugins(){var n;const e=new me(this.name),t=this.options.node||((n=this.editor.schema.topNodeType.contentMatch.defaultType)===null||n===void 0?void 0:n.name)||"paragraph",s=Object.entries(this.editor.schema.nodes).map(([,i])=>i).filter(i=>(this.options.notAfter||[]).concat(t).includes(i.name));return[new oe({key:e,appendTransaction:(i,r,o)=>{const{doc:l,tr:c,schema:d}=o,u=e.getState(o),p=l.content.size,f=d.nodes[t];if(!i.some(h=>h.getMeta("skipTrailingNode"))&&u)return c.insert(p,f.create())},state:{init:(i,r)=>{const o=r.tr.doc.lastChild;return!Sa({node:o,types:s})},apply:(i,r)=>{if(!i.docChanged||i.getMeta("__uniqueIDTransaction"))return r;const o=i.doc.lastChild;return!Sa({node:o,types:s})}}})]}}),uC=pe.create({name:"undoRedo",addOptions(){return{depth:100,newGroupDelay:500}},addCommands(){return{undo:()=>({state:n,dispatch:e})=>md(n,e),redo:()=>({state:n,dispatch:e})=>gd(n,e)}},addProseMirrorPlugins(){return[m1(this.options)]},addKeyboardShortcuts(){return{"Mod-z":()=>this.editor.commands.undo(),"Shift-Mod-z":()=>this.editor.commands.redo(),"Mod-y":()=>this.editor.commands.redo(),"Mod-я":()=>this.editor.commands.undo(),"Shift-Mod-я":()=>this.editor.commands.redo()}}}),pC=pe.create({name:"starterKit",addExtensions(){const n=[];if(this.options.bold!==!1&&n.push(rw.configure(this.options.bold)),this.options.blockquote!==!1&&n.push(ew.configure(this.options.blockquote)),this.options.bulletList!==!1&&n.push(fu.configure(this.options.bulletList)),this.options.code!==!1&&n.push(cw.configure(this.options.code)),this.options.codeBlock!==!1&&n.push(pw.configure(this.options.codeBlock)),this.options.document!==!1&&n.push(fw.configure(this.options.document)),this.options.dropcursor!==!1&&n.push(YS.configure(this.options.dropcursor)),this.options.gapcursor!==!1&&n.push(XS.configure(this.options.gapcursor)),this.options.hardBreak!==!1&&n.push(hw.configure(this.options.hardBreak)),this.options.heading!==!1&&n.push(mw.configure(this.options.heading)),this.options.undoRedo!==!1&&n.push(uC.configure(this.options.undoRedo)),this.options.horizontalRule!==!1&&n.push(gw.configure(this.options.horizontalRule)),this.options.italic!==!1&&n.push(xw.configure(this.options.italic)),this.options.listItem!==!1&&n.push(vu.configure(this.options.listItem)),this.options.listKeymap!==!1){var e;n.push(ku.configure((e=this.options)===null||e===void 0?void 0:e.listKeymap))}if(this.options.link!==!1){var t;n.push(tS.configure((t=this.options)===null||t===void 0?void 0:t.link))}if(this.options.orderedList!==!1&&n.push(wu.configure(this.options.orderedList)),this.options.paragraph!==!1&&n.push(LS.configure(this.options.paragraph)),this.options.strike!==!1&&n.push(_S.configure(this.options.strike)),this.options.text!==!1&&n.push(zS.configure(this.options.text)),this.options.underline!==!1){var s;n.push(jS.configure((s=this.options)===null||s===void 0?void 0:s.underline))}if(this.options.trailingNode!==!1){var i;n.push(dC.configure((i=this.options)===null||i===void 0?void 0:i.trailingNode))}return n}});var fC=pC;const hC=()=>({type:"doc",content:[{type:"paragraph"}]});function Ca(n={}){var t;if(((t=n.content)==null?void 0:t.type)==="doc")return n.content;const e=String(n.text||"").split(` `).map(s=>({type:"paragraph",...s?{content:[{type:"text",text:s}]}:{}}));for(const s of n.mediaIds||[])e.push({type:"media",attrs:{mediaId:s}});return{type:"doc",content:e}}function Ma(n){const e=[],t=s=>{s.type==="media"&&s.attrs.mediaId&&e.push(s.attrs.mediaId);for(const i of s.content||[])t(i)};return t(n),[...new Set(e)]}function Ta(n){const e=t=>t.type==="text"?t.text:t.type==="hardBreak"?` `:(t.content||[]).map(e).join("")+(["paragraph","heading"].includes(t.type)?` -`:"");return e(n).trim()}function hC(n,e){const t=i=>String(i!=null?i:"").replace(/[&<>"']/g,r=>({"&":"&","<":"<",">":">",'"':""","'":"'"})[r]),s=i=>{var l,c,d;if(i.type==="text")return(i.marks||[]).reduce((u,p)=>{const f={bold:"strong",italic:"em",strike:"s",underline:"u"}[p.type];return f?`<${f}>${u}`:u},t(i.text));if(i.type==="hardBreak")return"
";if(i.type==="media")return/^[a-f0-9]{16}$/.test(((l=i.attrs)==null?void 0:l.mediaId)||"")?e(i.attrs.mediaId):"";const r=(i.content||[]).map(s).join("");if(i.type==="doc")return r;const o={paragraph:"p",heading:((c=i.attrs)==null?void 0:c.level)===3?"h3":"h2",blockquote:"blockquote",bulletList:"ul",orderedList:"ol",listItem:"li"}[i.type];return o?`<${o}${o==="ol"&&Number.isInteger((d=i.attrs)==null?void 0:d.start)?` start="${Math.max(1,Math.min(9999,i.attrs.start))}"`:""}>${r||"
"}`:""};return s(n)}const mC={class:"journal-rich-editor"},gC={class:"journal-editor-toolbar",role:"toolbar","aria-label":"正文格式"},bC=["aria-pressed"],vC=["aria-pressed"],yC=["aria-pressed"],kC=["aria-pressed"],xC=["value"],wC={class:"journal-editor-foot"},SC={__name:"RichJournalEditor",setup(n){const e=Xr(null),t=P(0),s=P("");let i=new Map,r=new Map,o=new Set,l;const c=Fe.create({name:"media",group:"block",atom:!0,draggable:!0,selectable:!0,addAttributes(){return{mediaId:{default:null},uploadClient:{default:null}}},parseHTML(){return[{tag:"figure[data-media-id]",getAttrs:b=>i.has(b.dataset.mediaId)?{mediaId:b.dataset.mediaId}:!1}]},renderHTML({node:b}){return["figure",{"data-media-id":b.attrs.mediaId}]},addNodeView(){return({node:b,getPos:m,editor:v})=>{const S=document.createElement("figure");S.className="journal-inline-media",S.contentEditable="false";let A="";const O=()=>{const B=r.get(b.attrs.uploadClient),E=i.get(b.attrs.mediaId),M=JSON.stringify([E&&[E.name,E.mime,E.src],B&&[B.name,B.status,B.progress,B.error]]);if(A===M)return;A=M,S.querySelectorAll("audio,video").forEach(N=>{N.pause(),N.removeAttribute("src"),N.load()}),S.replaceChildren();const w=document.createElement("figcaption");if(w.textContent=(E==null?void 0:E.name)||(B==null?void 0:B.name)||"云端素材引用",S.append(w),!(E!=null&&E.src)){const N=document.createElement("p");N.textContent=B?B.error||"正在上传 "+Math.round(B.progress||0)+"%":"素材暂不可用",S.append(N)}if(E!=null&&E.src){const N=document.createElement(E.mime.startsWith("image/")?"img":E.mime.startsWith("audio/")?"audio":"video");N.src=E.src,N.tagName==="IMG"?(N.alt=E.name,N.loading="lazy"):(N.controls=!0,N.preload="metadata",N.playsInline=!0,N.addEventListener("play",()=>document.querySelectorAll("#page-journal audio,#page-journal video").forEach(I=>{I!==N&&I.pause()}))),S.append(N)}const T=document.createElement("button");T.type="button",T.className="quiet",T.textContent="移除正文引用",T.setAttribute("aria-label","移除正文引用 "+((E==null?void 0:E.name)||"")),T.addEventListener("click",()=>{if(!v.isEditable)return;const N=m();typeof N=="number"&&v.chain().focus().deleteRange({from:N,to:N+b.nodeSize}).run()}),S.append(T)};return o.add(O),O(),{dom:S,update(B){return B.type!==b.type?!1:(b=B,O(),!0)},stopEvent:B=>B.target.closest("button,audio,video")!==null,ignoreMutation:()=>!0,destroy(){o.delete(O),S.querySelectorAll("audio,video").forEach(B=>{B.pause(),B.removeAttribute("src"),B.load()})}}}}});function d(b,m=!0){var v;s.value=Ta(b.getJSON()),t.value++,m&&((v=document.getElementById("journal-form"))==null||v.dispatchEvent(new Event("input",{bubbles:!0})))}function u(b){var m;(m=e.value)==null||m.destroy(),o.clear(),e.value=new Jx({extensions:[pC.configure({heading:{levels:[2,3]},link:!1,code:!1,codeBlock:!1,horizontalRule:!1}),c],content:b?Ca(b):fC(),editorProps:{attributes:{class:"journal-rich-input",role:"textbox","aria-label":"记事正文","aria-multiline":"true"},handlePaste(v,S){var O;const A=(O=S.clipboardData)==null?void 0:O.getData("text/plain");return A?(S.preventDefault(),v.dispatch(v.state.tr.insertText(A)),!0):!1}},onUpdate:({editor:v})=>d(v),onSelectionUpdate:()=>t.value++,onTransaction:()=>t.value++}),d(e.value,!1)}function p(b,m){var v;(v=e.value)==null||v.chain().focus()[b](m).run()}function f(b){var O;const m=e.value,v=m.state.selection,S=[{type:"media",attrs:b},{type:"paragraph"}],A=m.chain().focus();return((O=v.node)==null?void 0:O.type.name)==="media"?A.insertContentAt(v.to,S):A.insertContent(S),A.run()}function h(b){var m;return t.value,!!((m=e.value)!=null&&m.isActive(b))}function g(){const b=document.getElementById("journal-library");b&&(b.open=!0,b.scrollIntoView({behavior:"smooth",block:"start"}))}return $i(()=>{u(),l={reset:()=>u(),set:u,focus:()=>{var b;return(b=e.value)==null?void 0:b.commands.focus()},document:()=>e.value.getJSON(),ids:()=>Ma(e.value.getJSON()),plainText:()=>Ta(e.value.getJSON()),setEditable:b=>{var m;return(m=e.value)==null?void 0:m.setEditable(b)},insertMedia(b){if(!e.value.isEditable||!i.has(b))return!1;const m=Ma(e.value.getJSON());return!m.includes(b)&&m.length>=9?(window.alert("每条记事最多引用 9 个不同素材"),!1):f({mediaId:b})},clients(){const b=[];return e.value.state.doc.descendants(m=>{m.type.name==="media"&&m.attrs.uploadClient&&b.push(m.attrs.uploadClient)}),[...new Set(b)]},pending(){let b=!1;return e.value.state.doc.descendants(m=>{m.type.name==="media"&&!m.attrs.mediaId&&(b=!0)}),b},insertUpload(b){let m=0;return e.value.state.doc.descendants(v=>{v.type.name==="media"&&m++}),m>=9?(window.alert("本条最多添加 9 个媒体,请先保存记事"),!1):f({uploadClient:b})},removeUpload(b){const m=[];e.value.state.doc.descendants((S,A)=>{S.type.name==="media"&&S.attrs.uploadClient===b&&m.push([A,S.nodeSize])});const v=e.value.state.tr;for(const[S,A]of m.reverse())v.delete(S,S+A);v.docChanged&&e.value.view.dispatch(v)},resolveUpload(b,m){i.set(m.id,m);const v=e.value.state.tr;e.value.state.doc.descendants((S,A)=>{S.type.name==="media"&&S.attrs.uploadClient===b&&v.setNodeMarkup(A,void 0,{...S.attrs,mediaId:m.id})}),v.docChanged&&e.value.view.dispatch(v)},setTasks(b){r=new Map(b.map(m=>[m.clientId,m]));for(const m of o)m()},setMedia(b){i=new Map(b.map(m=>[m.id,m]));for(const m of o)m()},render:(b,m)=>hC(Ca(b),m),clearMedia(){i.clear(),r.clear();for(const b of o)b()}},window.ZhaoJournalEditor=l}),Bt(()=>{var b;(b=e.value)==null||b.destroy(),window.ZhaoJournalEditor===l&&delete window.ZhaoJournalEditor}),(b,m)=>(y(),x("div",mC,[a("div",gC,[a("button",{type:"button",class:"quiet","aria-pressed":h("bold"),onMousedown:m[0]||(m[0]=Ve(()=>{},["prevent"])),onClick:m[1]||(m[1]=v=>p("toggleBold"))},[...m[13]||(m[13]=[a("b",null,"加粗",-1)])],40,bC),a("button",{type:"button",class:"quiet","aria-pressed":h("italic"),onMousedown:m[2]||(m[2]=Ve(()=>{},["prevent"])),onClick:m[3]||(m[3]=v=>p("toggleItalic"))},[...m[14]||(m[14]=[a("i",null,"斜体",-1)])],40,vC),a("button",{type:"button",class:"quiet","aria-pressed":h("heading"),onMousedown:m[4]||(m[4]=Ve(()=>{},["prevent"])),onClick:m[5]||(m[5]=v=>p("toggleHeading",{level:2}))},"标题",40,yC),a("button",{type:"button",class:"quiet","aria-pressed":h("bulletList"),onMousedown:m[6]||(m[6]=Ve(()=>{},["prevent"])),onClick:m[7]||(m[7]=v=>p("toggleBulletList"))},"列表",40,kC),a("button",{type:"button",class:"quiet",onMousedown:m[8]||(m[8]=Ve(()=>{},["prevent"])),onClick:m[9]||(m[9]=v=>p("undo"))},"撤销",32),a("button",{type:"button",class:"quiet",onMousedown:m[10]||(m[10]=Ve(()=>{},["prevent"])),onClick:m[11]||(m[11]=v=>p("redo"))},"重做",32),a("button",{type:"button",class:"journal-insert-button",onMousedown:m[12]||(m[12]=Ve(()=>{},["prevent"])),onClick:g},"+ 插入云端素材",32)]),G(j(Gx),{editor:e.value},null,8,["editor"]),a("input",{type:"hidden",name:"text",value:s.value},null,8,xC),a("div",wC,[m[15]||(m[15]=a("span",null,"在光标处插入照片、视频、语音;可拖动媒体调整位置。",-1)),a("span",{class:De({"text-danger":s.value.length>5e3})},k(s.value.length)+" / 5000 字",3)])]))}},CC={key:0,class:"panel"},MC={class:"d-flex justify-content-between flex-wrap gap-3"},TC={key:0,class:"alert alert-danger",role:"alert"},EC={class:"fs-5"},AC={key:0,class:"d-block mb-3"},OC=["value"],NC={key:1,class:"d-block mb-3"},IC={key:2},DC={class:"row g-3"},$C={class:"col-md-6"},RC={class:"col-md-6"},LC={class:"d-flex gap-2"},PC=["disabled"],BC=["disabled"],_C={class:"row g-3"},zC={class:"card-body"},jC={class:"fs-5"},FC={key:0,class:"badge text-bg-success"},VC={class:"small text-secondary"},HC={class:"d-flex flex-wrap gap-2"},qC=["disabled","onClick"],UC=["disabled","onClick"],WC=["disabled","onClick"],KC={key:2,class:"alert alert-info mt-3"},JC={key:3,class:"border-top pt-3 mt-4"},GC=["value"],YC={class:"d-flex gap-2 my-3"},XC=["disabled"],ZC={__name:"FamilyMembers",setup(n){const e=P(null),t=P(""),s=P(!1),i=P(null),r=P(""),o=P(!1),l=ee(()=>R.value.loggedIn&&R.value.page==="members"),c=ee(()=>(R.value.state.households||[]).filter(b=>b.id!==R.value.state.familyId));let d=0;async function u(){const b=++d;try{const m=await K().api("/api/members");b===d&&(e.value=m)}catch(m){b===d&&(t.value=m.message)}}Ae([l,()=>R.value.state.familyId,()=>R.value.session],()=>{d++,e.value=null,i.value=null,t.value="",r.value="",o.value=!1,s.value=!1,l.value&&u()},{immediate:!0});function p(b){i.value=b?{id:b.id,revision:b.revision,personId:b.personId,name:b.name,label:b.label,status:b.status}:{name:"",personId:"",label:"",status:"active",revision:0}}async function f(){if(s.value)return;s.value=!0,t.value="";const b=d;try{if(await K().api("/api/members",i.value),b!==d)return;i.value=null,await u(),await K().refresh()}catch(m){b===d&&(t.value=m.message)}finally{s.value=!1}}async function h(){if(s.value)return;s.value=!0,t.value="";const b=d;try{if(await K().api("/api/genealogy/share",{targetFamilyId:r.value,confirm:o.value}),b!==d)return;o.value=!1,r.value="",await u(),await K().refresh()}catch(m){b===d&&(t.value=m.message)}finally{s.value=!1}}async function g(b,m=!1){if(s.value)return;const v=d;s.value=!0,t.value="";try{m?await K().viewMemberHistory(b.personId,b.name,R.value.state.familyId):await K().viewPerson(b.personId,R.value.state.familyId)}catch(S){v===d&&!S.stale&&(t.value=S.message)}finally{v===d&&(s.value=!1)}}return(b,m)=>{var v,S,A,O,B;return l.value?(y(),x("section",CC,[a("div",MC,[m[8]||(m[8]=a("div",null,[a("h2",null,"家庭成员"),a("p",{class:"text-secondary"},"登记真实家人。老人、孩子无需账号;亲属关系与登录权限分别管理。")],-1)),(v=e.value)!=null&&v.canManage?(y(),x("button",{key:0,class:"btn btn-primary align-self-start",onClick:m[0]||(m[0]=E=>p())},"+ 登记成员")):D("",!0)]),t.value?(y(),x("p",TC,k(t.value),1)):D("",!0),i.value?(y(),x("form",{key:1,class:"border rounded p-3 mb-4",onSubmit:Ve(f,["prevent"])},[a("h3",EC,k(i.value.id?"编辑成员关系":"登记家庭成员"),1),i.value.id?D("",!0):(y(),x("label",AC,[m[10]||(m[10]=C("关联已有族谱人物",-1)),Y(a("select",{class:"form-select","onUpdate:modelValue":m[1]||(m[1]=E=>i.value.personId=E)},[m[9]||(m[9]=a("option",{value:""},"新建人物(尚未录入族谱)",-1)),(y(!0),x(H,null,J(((S=e.value)==null?void 0:S.candidates)||[],E=>(y(),x("option",{key:E.id,value:E.id},k(E.name),9,OC))),128))],512),[[Te,i.value.personId]])])),i.value.personId?i.value.id?(y(),x("p",IC,"人物:"+k(i.value.name)+"。姓名、生平及亲属关系在族谱中维护,仍遵守五代限制。",1)):D("",!0):(y(),x("label",NC,[m[11]||(m[11]=C("姓名",-1)),Y(a("input",{"onUpdate:modelValue":m[2]||(m[2]=E=>i.value.name=E),class:"form-control",maxlength:"80",required:""},null,512),[[At,i.value.name]])])),a("div",DC,[a("label",$C,[m[12]||(m[12]=C("家庭称呼/身份备注",-1)),Y(a("input",{"onUpdate:modelValue":m[3]||(m[3]=E=>i.value.label=E),class:"form-control",maxlength:"60",placeholder:"例如:妈妈、长子、亲友"},null,512),[[At,i.value.label]])]),a("label",RC,[m[14]||(m[14]=C("成员状态",-1)),Y(a("select",{"onUpdate:modelValue":m[4]||(m[4]=E=>i.value.status=E),class:"form-select"},[...m[13]||(m[13]=[a("option",{value:"active"},"当前成员",-1),a("option",{value:"away"},"暂住外地",-1),a("option",{value:"historical"},"历史成员",-1)])],512),[[Te,i.value.status]])])]),m[15]||(m[15]=a("p",{class:"small text-secondary mt-2"},"称呼是本家庭的备注,不自动建立父母、配偶关系或授予管理权限。成员状态不会删除人物和经历;住在外地也可以是家人。",-1)),a("div",LC,[a("button",{class:"btn btn-primary",disabled:s.value},"保存成员",8,PC),a("button",{type:"button",class:"btn btn-outline-secondary",disabled:s.value,onClick:m[5]||(m[5]=E=>i.value=null)},"取消",8,BC)])],32)):D("",!0),a("div",_C,[(y(!0),x(H,null,J(((A=e.value)==null?void 0:A.items)||[],E=>(y(),x("article",{key:E.id,class:"col-md-6 col-xl-4"},[a("div",{class:De(["card h-100",{"border-primary bg-primary-subtle":E.self}])},[a("div",zC,[a("h3",jC,[C(k(E.name)+" ",1),E.self?(y(),x("span",FC,"本人")):D("",!0)]),a("p",null,k(E.label||"家庭身份待补充")+" · "+k({active:"当前成员",away:"暂住外地",historical:"历史成员"}[E.status]),1),a("p",VC,k(E.hasAccount?"已有关联账号":"无需注册账号")+k(E.lifeStatus==="deceased"?" · 已故":""),1),a("div",HC,[e.value.canViewGenealogy?(y(),x("button",{key:0,class:"btn btn-sm btn-outline-primary",disabled:s.value,onClick:M=>g(E)},"人物与亲属",8,qC)):D("",!0),a("button",{class:"btn btn-sm btn-outline-primary",disabled:s.value,onClick:M=>g(E,!0)},"个人阅历",8,UC),e.value.canManage?(y(),x("button",{key:1,class:"btn btn-sm btn-outline-secondary",disabled:s.value,onClick:M=>p(E)},"编辑成员关系",8,WC)):D("",!0)])])],2)]))),128))]),e.value&&!e.value.items.length?(y(),x("p",KC,"还没有登记成员。已有族谱人物可直接关联,避免重复建人。")):D("",!0),j(R).platformAdmin?(y(),x("details",JC,[m[19]||(m[19]=a("summary",null,"与相关家庭共用族谱",-1)),m[20]||(m[20]=a("p",{class:"small text-secondary mt-2"},"相关家庭共用人物与亲属关系;活动、设备、位置授权继续独立。现有同名人物不会自动合并,需核对身份。世代范围限制继续有效。",-1)),a("p",null,"当前已关联:"+k((B=(O=e.value)==null?void 0:O.genealogyHomes)==null?void 0:B.map(E=>E.name).join("、")),1),a("form",{onSubmit:Ve(h,["prevent"])},[a("label",null,[m[17]||(m[17]=C("关联家庭",-1)),Y(a("select",{"onUpdate:modelValue":m[6]||(m[6]=E=>r.value=E),class:"form-select",required:""},[m[16]||(m[16]=a("option",{value:""},"请选择",-1)),(y(!0),x(H,null,J(c.value,E=>(y(),x("option",{value:E.id,key:E.id},k(E.name),9,GC))),128))],512),[[Te,r.value]])]),a("label",YC,[Y(a("input",{"onUpdate:modelValue":m[7]||(m[7]=E=>o.value=E),type:"checkbox",required:""},null,512),[[st,o.value]]),m[18]||(m[18]=C("确认双方族谱人物与关系共用,有族谱查看权限的账号可以查看合并后的族谱",-1))]),a("button",{class:"btn btn-outline-primary",disabled:s.value||!o.value||!r.value},"确认共用族谱",8,XC)],32)])):D("",!0)])):D("",!0)}}},QC={key:0,class:"panel"},eM={class:"d-flex flex-wrap justify-content-between gap-2"},tM={key:0,class:"alert alert-danger",role:"alert"},nM={class:"table-responsive"},sM={class:"table align-middle"},iM={key:0},rM=["onClick"],oM={class:"row g-3"},lM={class:"col-md-6"},aM=["value"],cM={class:"col-md-6"},dM=["value"],uM={class:"col-md-6"},pM={class:"col-md-6"},fM=["disabled"],hM={__name:"AccountAccess",setup(n){const e=P([]),t=P(""),s=P(!1),i=P(""),r=P(""),o=P("member"),l=P("none"),c=ee(()=>R.value.loggedIn&&R.value.page==="accounts"&&R.value.platformAdmin),d=ee(()=>R.value.state.households||[]),u=ee(()=>e.value.find(m=>m.id===i.value));let p=0;async function f(){const m=++p;try{const v=await K().api("/api/platform/users");m===p&&(e.value=v.users)}catch(v){m===p&&(t.value=v.message)}}Ae([c,()=>R.value.session],()=>{p++,e.value=[],i.value="",r.value="",t.value="",s.value=!1,c.value&&f()},{immediate:!0}),Ae([i,r],()=>{var v,S;const m=(S=(v=u.value)==null?void 0:v.familyGrants)==null?void 0:S[r.value];o.value=(m==null?void 0:m.role)||"member",l.value=(m==null?void 0:m.familyAccess)||"none"});async function h(){if(s.value)return;s.value=!0,t.value="";const m=p;try{await K().api("/api/users/grant",{userId:i.value,familyId:r.value,role:o.value,familyAccess:l.value}),m===p&&(await f(),await K().refresh())}catch(v){m===p&&(t.value=v.message)}finally{s.value=!1}}async function g(m){await K().editAccount(m.id,m.familyId)}const b=m=>{var v;return((v=d.value.find(S=>S.id===m))==null?void 0:v.name)||"未知家庭"};return(m,v)=>c.value?(y(),x("section",QC,[a("div",eM,[v[5]||(v[5]=a("div",null,[a("h2",null,"系统用户"),a("p",{class:"text-secondary"},"一个账号可访问多个家庭,分别授权。账号与家庭成员档案独立。")],-1)),a("button",{class:"btn btn-outline-primary align-self-start",onClick:v[0]||(v[0]=S=>j(K)().showPage("users"))},"账号建档与密码管理")]),t.value?(y(),x("p",tM,k(t.value),1)):D("",!0),a("div",nM,[a("table",sM,[v[7]||(v[7]=a("thead",null,[a("tr",null,[a("th",null,"登录账号"),a("th",null,"主要授权家庭"),a("th",null,"其他家庭权限"),a("th",null,"状态"),a("th")])],-1)),a("tbody",null,[(y(!0),x(H,null,J(e.value,S=>(y(),x("tr",{key:S.id},[a("td",null,[a("strong",null,k(S.name),1),v[6]||(v[6]=a("br",null,null,-1)),C(k(S.username),1)]),a("td",null,k(S.role==="admin"?"平台管理员":b(S.familyId)),1),a("td",null,[S.role==="admin"?(y(),x("span",iM,"可管理全部家庭;查看位置仍须本人单独授权")):D("",!0),(y(!0),x(H,null,J(S.familyGrants||{},(A,O)=>(y(),x("div",{key:O},k(b(O))+" · "+k(A.role==="family_admin"?"家庭管理员":"访问账号"),1))),128))]),a("td",null,k(S.disabled?"已停用":"启用"),1),a("td",null,[a("button",{class:"btn btn-sm btn-outline-secondary",onClick:A=>g(S)},"编辑账号",8,rM)])]))),128))])])]),a("form",{class:"border-top pt-3",onSubmit:Ve(h,["prevent"])},[v[16]||(v[16]=a("h3",{class:"fs-5"},"设置账号的其他家庭访问权限",-1)),a("div",oM,[a("label",lM,[v[9]||(v[9]=C("系统账号",-1)),Y(a("select",{"onUpdate:modelValue":v[1]||(v[1]=S=>i.value=S),class:"form-select",required:""},[v[8]||(v[8]=a("option",{value:""},"请选择",-1)),(y(!0),x(H,null,J(e.value.filter(S=>S.role!=="admin"),S=>(y(),x("option",{key:S.id,value:S.id},k(S.name)+" · "+k(S.username),9,aM))),128))],512),[[Te,i.value]])]),a("label",cM,[v[11]||(v[11]=C("家庭",-1)),Y(a("select",{"onUpdate:modelValue":v[2]||(v[2]=S=>r.value=S),class:"form-select",required:""},[v[10]||(v[10]=a("option",{value:""},"请选择",-1)),(y(!0),x(H,null,J(d.value.filter(S=>{var A;return S.id!==((A=u.value)==null?void 0:A.familyId)}),S=>(y(),x("option",{key:S.id,value:S.id},k(S.name),9,dM))),128))],512),[[Te,r.value]])]),a("label",uM,[v[13]||(v[13]=C("家庭权限",-1)),Y(a("select",{"onUpdate:modelValue":v[3]||(v[3]=S=>o.value=S),class:"form-select"},[...v[12]||(v[12]=[a("option",{value:"member"},"允许进入(不含设备控制)",-1),a("option",{value:"family_admin"},"管理本家庭及其设备",-1),a("option",{value:"none"},"取消此家庭访问",-1)])],512),[[Te,o.value]])]),a("label",pM,[v[15]||(v[15]=C("族谱权限",-1)),Y(a("select",{"onUpdate:modelValue":v[4]||(v[4]=S=>l.value=S),class:"form-select"},[...v[14]||(v[14]=[a("option",{value:"none"},"不授权",-1),a("option",{value:"read"},"查看",-1),a("option",{value:"edit"},"维护本人上下五代",-1)])],512),[[Te,l.value]])])]),v[17]||(v[17]=a("p",{class:"small text-secondary mt-3"},"授权不会自动登记为家庭成员,也不会自动获得任何人的位置。修改权限后该账号需重新登录。",-1)),a("button",{class:"btn btn-primary",disabled:s.value||!i.value||!r.value},"保存访问权限",8,fM)],32)])):D("",!0)}},mM={key:0,class:"panel mb-4"},gM={key:0},bM={class:"table-responsive"},vM={class:"table align-middle"},yM={key:0,class:"d-block text-danger"},kM=["onClick"],xM={key:1,class:"text-danger"},wM={__name:"MapStorage",setup(n){const e=P(null),t=P(""),s=ee(()=>R.value.loggedIn&&R.value.page==="storage"&&R.value.platformAdmin);let i,r=0;const o=u=>((u||0)/1024/1024).toFixed(1)+" MB",l={queued:"等待下载",downloading:"下载底图",restoring:"从网盘恢复",uploading:"上传网盘",verifying:"核对云端文件",ready:"可使用",cloud:"已归档 · 本地已释放",retry:"等待重试"};async function c(){const u=r;try{const p=await K().api("/api/maps");u===r&&(e.value=p,t.value="")}catch(p){u===r&&(t.value=p.message)}finally{u===r&&s.value&&(i=setTimeout(c,15e3))}}async function d(u){try{await K().api("/api/maps",{action:"retry",id:u}),clearTimeout(i),c()}catch(p){t.value=p.message}}return Ae(s,u=>{r++,clearTimeout(i),u&&c()},{immediate:!0}),Bt(()=>{r++,clearTimeout(i)}),(u,p)=>{var f,h;return s.value?(y(),x("section",mM,[p[1]||(p[1]=a("div",{class:"d-flex justify-content-between"},[a("h2",{class:"fs-5"},"内置地图 · 网盘归档与本机缓存"),a("span",{class:"badge text-bg-light"},"全国概览常驻")],-1)),p[2]||(p[2]=a("p",{class:"text-secondary small"},"家人开启位置共享、进入某个省份后,自动准备该省详细地图。同一省份共用一份。上传并核对成功的省份缓存可回收,需要时从百度网盘取回。",-1)),e.value?(y(),x("p",gM,"本机 "+k(o(e.value.usedBytes))+" / "+k(o(e.value.cacheLimitBytes))+" · 为其他服务至少预留 "+k(o(e.value.reserveBytes)),1)):D("",!0),a("div",bM,[a("table",vM,[p[0]||(p[0]=a("thead",null,[a("tr",null,[a("th",null,"地图"),a("th",null,"状态"),a("th",null,"本机"),a("th",null,"百度网盘"),a("th")])],-1)),a("tbody",null,[(y(!0),x(H,null,J((f=e.value)==null?void 0:f.items,g=>(y(),x("tr",{key:g.id},[a("td",null,k(g.name),1),a("td",null,[C(k(l[g.state]||g.state),1),g.error?(y(),x("small",yM,k(g.error),1)):D("",!0)]),a("td",null,k(o(g.localBytes)),1),a("td",null,k(g.cloud?"已校验归档":g.progress?g.progress+"%":"待归档"),1),a("td",null,[g.state==="retry"?(y(),x("button",{key:0,class:"btn btn-sm btn-outline-primary",onClick:b=>d(g.id)},"重试",8,kM)):D("",!0)])]))),128))])])]),t.value||(h=e.value)!=null&&h.error?(y(),x("p",xM,k(t.value||e.value.error),1)):D("",!0)])):D("",!0)}}},SM={id:"page-members",class:"page",hidden:""},CM={id:"page-accounts",class:"page",hidden:""},MM={id:"page-journal",class:"page",hidden:""},TM={id:"journal-editor-surface"},EM={id:"journal-form",class:"panel journal-compose"},AM={id:"page-overview",class:"page",hidden:""},OM={id:"page-device",class:"page",hidden:""},NM={id:"page-objects",class:"page",hidden:""},IM={id:"page-storage",class:"page",hidden:""},DM={__name:"Workspace",setup(n){return(e,t)=>(y(),x(H,null,[G(wM),a("section",SM,[G(ZC)]),a("section",CM,[G(hM)]),t[16]||(t[16]=a("div",{id:"household-context",class:"household-context",hidden:""},[a("label",null,[C("当前归属 "),a("select",{id:"household-filter","aria-label":"当前归属"})]),a("span",{id:"household-context-note"}),a("button",{id:"scope-back",class:"quiet"},"返回场所")],-1)),t[17]||(t[17]=a("div",{id:"device-context",class:"device-context",hidden:""},[a("p",{id:"device-breadcrumb"}),a("div",{role:"group","aria-label":"设备功能"},[a("button",{class:"quiet","data-device-tab":"device"},"设备档案"),a("button",{class:"quiet","data-device-tab":"live"},"实时画面"),a("button",{class:"quiet","data-device-tab":"playback"},"录像回放"),a("button",{class:"quiet","data-device-tab":"cameras"},"镜头与设置")])],-1)),t[18]||(t[18]=ge('
设备—
已接通码流—
录像占用—
空间档案—
可选择任意区域,包含其下级区域
',3)),t[19]||(t[19]=a("section",{id:"page-settings",class:"page",hidden:""},[a("div",{class:"section-head"},[a("h2",null,"把这里布置成你习惯的样子"),a("button",{id:"settings-reload",class:"quiet"},"重新读取设置")]),a("p",{id:"settings-error",role:"status"}),a("div",{class:"settings-sections",role:"group","aria-label":"设置分类"},[a("button",{class:"quiet","data-settings-section":"preferences","aria-pressed":"true"},"我的偏好"),a("button",{class:"quiet","data-settings-section":"baidu","data-platform-setting":"",hidden:""},"网盘连接"),a("button",{class:"quiet","data-settings-section":"brand","data-platform-setting":"",hidden:""},"品牌与外观"),a("button",{class:"quiet","data-settings-section":"backup","data-platform-setting":"",hidden:""},"数据库备份")]),a("form",{id:"preferences-form",class:"panel"},[a("h3",null,"我的偏好"),a("p",{class:"description"},"只影响当前账号,保存后换电脑或手机登录也会沿用。切换选项可以预览,离开未保存的预览会撤销。"),a("div",{id:"personal-choices",class:"form-grid"}),a("p",{id:"preferences-status",role:"status"}),a("div",{class:"device-actions"},[a("button",{type:"submit"},"保存我的偏好"),a("button",{type:"button",id:"personal-follow",class:"quiet"},"全部跟随平台"),a("button",{type:"button",id:"personal-cancel",class:"quiet"},"撤销预览")])]),a("section",{id:"baidu-admin",class:"panel",hidden:""},[a("div",{class:"section-head"},[a("h3",null,"百度网盘 · 统一存储"),a("span",{class:"badge"},"仅超级管理员配置")]),a("p",{class:"description"},"连接一个网盘账号,统一保存封面、Logo、图标及各用户上传的照片、视频和语音。系统按用户、家庭和记事可见范围授权;网盘账号持有人本身可以管理网盘中的文件。服务器仅转发分片,不保存媒体原文件。"),a("details",{id:"baidu-storage-guide"},[a("summary",null,"文件存在哪里?"),a("ul",null,[a("li",null,"家庭与场所:按家庭或场所保存封面。"),a("li",null,"平台外观:保存 Logo 和图标。"),a("li",null,"个人记事:按家庭、用户分组,再分照片、视频、语音。"),a("li",null,"数据库备份:单独存放;新备份上传并校验成功后,清理超过一个自然月的旧云备份。")]),a("p",{class:"description"},"文字、权限和文件引用保存在本机数据库;个人媒体原文件保存在百度网盘。封面和品牌图片仅做有限的内存缓存。更换封面、移除附件或删除记事不会删除网盘原文件。")]),a("form",{id:"baidu-config"},[a("div",{class:"form-grid"},[a("label",null,[C("AppKey"),a("input",{name:"appKey",autocomplete:"off",maxlength:"150",required:""})]),a("label",null,[C("SecretKey"),a("input",{name:"secretKey",type:"password",autocomplete:"new-password",maxlength:"150"})]),a("label",null,[C("百度后台应用名称"),a("input",{name:"appFolder",value:"智家",required:"",maxlength:"40"})]),a("label",null,[C("OAuth 回调地址"),a("input",{name:"redirectUri",type:"url",placeholder:"https://你的域名/api/baidu/callback",required:"",maxlength:"400"})])]),a("p",{class:"description"},"回调地址须与百度后台完全一致。SecretKey 留空保持已保存值,SignKey 不需要填写。当前开发者应用仅限个人场景,适用范围以百度后台为准。"),a("p",{id:"baidu-config-status",role:"status"}),a("button",{type:"submit"},"保存网盘应用配置")]),a("hr"),a("p",{id:"baidu-status",role:"status"}),a("div",{class:"device-actions"},[a("button",{id:"baidu-connect"},"连接/重新授权百度网盘"),a("button",{id:"baidu-disconnect",class:"quiet"},"解除本机连接")]),a("p",{class:"description"},"解除连接不会删除云端文件。临时媒体地址由后台按需获取,令牌不发送给浏览器。网盘授权凭据单独保存在服务器受限目录,不包含在数据库备份或公开源码中。")]),a("div",{id:"settings-private",hidden:""},[a("form",{id:"brand-form",class:"panel"},[a("h3",null,"发布与品牌配置"),a("p",{class:"description"},"仅超级管理员可修改。名称、Logo、浏览器图标及登录文案会公开显示;适用于整套系统。已有个人偏好优先于平台默认。"),a("div",{class:"form-grid"},[a("label",null,[C("系统名称"),a("input",{name:"name",required:"",maxlength:"40"})]),a("label",null,[C("系统副标题"),a("input",{name:"subtitle",required:"",maxlength:"60"})]),a("label",{class:"full"},[C("页首题词"),a("input",{name:"motto",maxlength:"100"})]),a("label",null,[C("登录标题"),a("input",{name:"loginTitle",required:"",maxlength:"40"})]),a("label",null,[C("登录说明"),a("input",{name:"loginNote",maxlength:"160"})]),a("label",{class:"full"},[C("页脚说明"),a("input",{name:"footer",maxlength:"120"})])]),a("div",{class:"brand-image-grid"},[a("div",null,[a("img",{id:"brand-logo-preview",alt:"Logo 预览",src:"/zhao-icon.png"}),a("label",null,[C("更换系统 Logo"),a("input",{id:"brand-logo-file",type:"file",accept:"image/png,image/jpeg,image/webp"})]),a("button",{type:"button",id:"brand-logo-reset",class:"quiet"},"使用默认 Logo")]),a("div",null,[a("img",{id:"brand-icon-preview",alt:"浏览器图标预览",src:"/zhao-icon.png"}),a("label",null,[C("更换浏览器图标"),a("input",{id:"brand-icon-file",type:"file",accept:"image/png,image/jpeg,image/webp"})]),a("button",{type:"button",id:"brand-icon-reset",class:"quiet"},"使用默认图标")])]),a("p",{class:"description"},"支持 PNG、JPEG、WebP,原图最多 5 MB;上传时自动缩小,图片随系统数据库保存。"),a("h3",null,"新账号与跟随平台账号的默认外观"),a("div",{id:"brand-defaults",class:"form-grid"}),a("p",{id:"brand-status",role:"status"}),a("div",{class:"device-actions"},[a("button",{type:"submit"},"保存发布配置"),a("button",{type:"button",id:"brand-export",class:"quiet"},"导出发布配置"),a("label",{class:"config-import"},[C("导入配置到表单"),a("input",{id:"brand-import",type:"file",accept:"application/json,.json"})])]),a("p",{class:"description"},"导入后先核对再保存。导出的配置只含品牌与默认外观,不含账号、设备凭据、家庭资料和网络备份目录。")]),a("section",{id:"backup-panel",class:"panel"},[a("h3",null,"数据库备份"),a("p",{class:"description"},"整台服务的数据库包含所有家庭、账号、设备连接配置和网盘文件引用,因此仅超级管理员可操作。网盘中的照片、视频、语音及录像文件不包含在新数据库副本中;旧版备份可能仍含历史内嵌图片。恢复后所有账号需要重新登录。"),a("form",{id:"backup-form"},[a("div",{class:"form-grid"},[a("label",{class:"check full"},[a("input",{name:"enabled",type:"checkbox"}),C("启用每日定时备份")]),a("label",{class:"check full"},[a("input",{name:"baidu",type:"checkbox"}),C("同时上传到已连接的百度网盘")]),a("label",null,[C("每日时间(北京时间)"),a("input",{name:"time",type:"time",required:"",value:"03:00"})]),a("label",null,[C("本机/挂载目录保留份数"),a("input",{name:"keep",type:"number",min:"1",max:"90",required:"",value:"14"})]),a("label",{class:"full"},[C("网络备份目录(可留空)"),a("input",{name:"networkPath",maxlength:"500",placeholder:"/var/lib/zhaovision/network-backup"})])]),a("p",{class:"description"},"填写本服务器已挂载的网络盘目录。使用百度接口备份只需勾选上方选项;此路径用于其他已挂载的网络存储,不能填网页地址或分享链接。写入网络目录成功不等于已确认百度云端同步完成。"),a("p",{class:"description"},"默认部署允许写入 /var/lib/zhaovision 下的目录。挂载和目录权限须由主机管理员配置;本页不会保存网盘登录密码。保留份数只清理本机和挂载目录中本系统生成的旧备份,百度网盘保留最近一个自然月;新备份上传并校验成功后才清理本应用的过期副本。"),a("p",{id:"backup-local-path",class:"description"}),a("p",{id:"backup-save-status",role:"status"}),a("button",{type:"submit"},"保存备份设置")]),a("div",{class:"section-head"},[a("h3",null,"备份记录"),a("button",{id:"backup-run"},"立即备份数据库")]),a("p",{id:"backup-result",role:"status"}),a("div",{id:"backup-history"})])])],-1)),a("section",MM,[t[6]||(t[6]=a("div",{class:"scope-intro"},[a("span",{class:"eyebrow"},"岁月有迹 · 日常成章"),a("h2",null,"把生活,写成自己的来时路"),a("p",null,"与家人分享近况,也为自己留下一份阅历。")],-1)),a("div",TM,[t[4]||(t[4]=a("div",{class:"journal-editor-heading"},[a("strong",null,"记下此刻 · 留住声音"),a("button",{id:"journal-record",disabled:"",type:"button"},"● 开始录音"),a("button",{id:"journal-stop-record",type:"button",hidden:""},"■ 结束录音并插入"),a("button",{id:"journal-discard-record",type:"button",class:"quiet",hidden:""},"取消录音"),a("span",{id:"journal-record-elapsed",role:"status"}),a("button",{id:"journal-pick-media",disabled:"",type:"button",class:"quiet"},"插入照片/视频"),a("button",{type:"submit",form:"journal-form"},"保存"),a("button",{id:"journal-expand",type:"button",class:"quiet"},"全屏编辑"),a("button",{id:"journal-close-editor",type:"button",class:"quiet",hidden:""},"关闭编辑 · Esc")],-1)),a("form",EM,[t[0]||(t[0]=ge('

写一条记事

文字和媒体按正文顺序呈现。先将光标放在想插入的位置,再选择云端素材。

',6)),G(SC),t[1]||(t[1]=ge('
参与/相关家人(可多选)
录入账号与经历中的人物分别记录;未注册的老人和孩子也可关联。关联人物不会扩大可见范围。
',1)),t[2]||(t[2]=a("p",{id:"journal-status",role:"status","aria-live":"polite"},null,-1)),t[3]||(t[3]=a("div",{class:"device-actions"},[a("button",{id:"journal-save",type:"submit"},"保存记事"),a("button",{id:"journal-new",type:"button",class:"quiet"},"另写一条")],-1))]),t[5]||(t[5]=a("section",{class:"panel journal-materials","aria-label":"云端素材"},[a("div",{class:"section-head"},[a("div",null,[a("h3",null,"云端素材"),a("p",{class:"description"},"上传即插入正文,在原位置显示进度。上传期间可以继续写文字。")])]),a("div",{class:"journal-add-media"},[a("label",{class:"quiet"},[C("+ 上传照片、视频、语音"),a("input",{id:"journal-files",disabled:"",type:"file",multiple:"",accept:"image/jpeg,image/png,image/webp,video/mp4,video/quicktime,video/webm,audio/mpeg,audio/mp4,audio/aac,audio/wav,audio/ogg,audio/webm,.m4a"})]),a("button",{id:"journal-cancel-upload",type:"button",class:"quiet",hidden:""},"暂停全部上传")]),a("p",{id:"journal-cloud-note",class:"description"}),a("p",{class:"description"},"可混合选择文件,同时上传 3 个;单个最多 256 MB。每条正文可引用 9 个不同素材。录音最长 5 分钟。"),a("p",{id:"journal-upload-status",role:"status","aria-live":"polite"}),a("div",{id:"journal-upload-list"}),a("details",{id:"journal-library",class:"journal-library"},[a("summary",null,[C("我的云端素材("),a("span",{id:"journal-library-count"},"0"),C(")")]),a("div",{class:"journal-library-list-tools"},[a("span",{class:"description"},"已保存正文使用的素材,可在其他记事中再次引用。"),a("label",null,[C("筛选"),a("select",{id:"journal-media-filter"},[a("option",{value:""},"全部素材"),a("option",{value:"image/"},"照片"),a("option",{value:"video/"},"视频"),a("option",{value:"audio/"},"语音"),a("option",{value:"unused"},"草稿临时素材")])])]),a("div",{id:"journal-library-list",class:"journal-upload-grid"})]),a("details",{id:"journal-trash",class:"journal-trash",hidden:""},[a("summary",null,[C("已移除素材("),a("span",{id:"journal-trash-count"},"0"),C(")")]),a("p",{class:"description"},"仍被正文引用的素材可以恢复;最后一个引用删除后,网盘原文件自动删除。"),a("div",{id:"journal-trash-list"})]),a("details",{id:"journal-cleanup",hidden:""},[a("summary",null,"网盘清理记录"),a("button",{id:"journal-cleanup-refresh",type:"button",class:"quiet"},"刷新清理状态"),a("div",{id:"journal-cleanup-list"})]),a("p",{class:"description"},"放弃草稿或关闭页面会取消本次上传,并删除无其他引用的文件。意外断网退出时,服务器在草稿失联 10 分钟后自动清理。删除最后一处正文引用,也会删除网盘文件。")],-1))]),t[7]||(t[7]=ge('

个人阅历保留同一条记事的正文、媒体和互动;查看他人时只展示其分享给当前家庭/场所的内容。删除正文中的媒体或整条记事,会解除对应引用;最后一个引用删除后,网盘原文件自动清理。

',2)),t[8]||(t[8]=a("div",{class:"section-head"},[a("p",{id:"journal-query-status",role:"status"}),a("div",null,[a("button",{id:"journal-prev",class:"quiet"},"上一页"),a("button",{id:"journal-next",class:"quiet"},"下一页")])],-1)),t[9]||(t[9]=a("div",{id:"journal-list",class:"journal-feed"},null,-1))]),a("section",AM,[G(ib),t[10]||(t[10]=a("div",{id:"scope-overview"},null,-1))]),a("section",OM,[G(eg),t[11]||(t[11]=a("div",{id:"device-detail"},null,-1))]),t[20]||(t[20]=a("section",{id:"page-heritage",class:"page",hidden:""},[a("div",{id:"heritage-home"})],-1)),t[21]||(t[21]=a("section",{id:"page-live",class:"page"},[a("div",{class:"section-head"},[a("h2",{id:"live-heading"},"本场所监控墙"),a("div",null,[a("label",null,[C("清晰度 "),a("select",{id:"quality"},[a("option",{value:"hd"},"主码流"),a("option",{value:"compat"},"子码流")])])])]),a("details",{class:"live-help"},[a("summary",null,"画面与清晰度说明"),a("p",{id:"wall-context",class:"description"},"这里汇总当前场所内已授权的镜头;点击摄像头详情可进入单台设备。"),a("p",{class:"description",id:"quality-note"},"主码流画面更清晰,最高 1920×1080;子码流更流畅,最高 768×432,适合网络较慢时使用。")]),a("div",{class:"wall-toolbar"},[a("label",null,[C("分屏 "),a("select",{id:"wall-layout"},[a("option",{value:"auto"},"自适应"),a("option",{value:"1"},"1 画面"),a("option",{value:"2"},"2 画面"),a("option",{value:"4"},"4 画面"),a("option",{value:"6"},"6 画面"),a("option",{value:"9"},"9 画面"),a("option",{value:"16"},"16 画面")])]),a("label",{class:"check"},[a("input",{id:"wall-arrange",type:"checkbox"}),C("调整顺序")]),a("div",{class:"wall-paging"},[a("button",{id:"wall-prev",class:"quiet","aria-label":"上一组画面"},"‹"),a("span",{id:"wall-page"}),a("button",{id:"wall-next",class:"quiet","aria-label":"下一组画面"},"›")]),a("span",{id:"wall-clock"}),a("button",{id:"wall-fullscreen"},"全屏监控")]),a("div",{id:"live-grid",class:"live-grid"}),a("section",{id:"ptz-panel",class:"ptz-panel",hidden:""},[a("div",null,[a("strong",{id:"ptz-title"},"云台"),a("p",{id:"ptz-status",role:"status"})]),a("div",{class:"ptz-pad"},[a("button",{"data-ptz-action":"up","aria-label":"云台向上"},"↑"),a("button",{"data-ptz-action":"left","aria-label":"云台向左"},"←"),a("button",{"data-ptz-action":"stop"},"停止"),a("button",{"data-ptz-action":"right","aria-label":"云台向右"},"→"),a("button",{"data-ptz-action":"down","aria-label":"云台向下"},"↓")]),a("div",{id:"ptz-presets"},[a("div",{class:"section-head"},[a("strong",null,[C("常用位置 "),a("small",{id:"preset-count"})]),a("button",{id:"preset-reload",class:"quiet"},"重新读取")]),a("p",{id:"preset-status",role:"status"}),a("div",{id:"preset-list"}),a("p",{class:"description"},"调整位置后可另存为新预置位。本版不覆盖已有位置,避免设备固件拒绝或误改。"),a("form",{id:"preset-form",hidden:""},[a("label",null,[C("当前位置名称"),a("input",{id:"preset-name",required:"",maxlength:"40",placeholder:"例如:大门、院子"})]),a("button",{type:"submit"},"保存当前位置")]),a("div",{id:"preset-confirmation",hidden:""},[a("p",{id:"preset-confirm-text"}),a("button",{id:"preset-confirm-yes"},"确认"),a("button",{id:"preset-confirm-cancel",class:"quiet"},"取消")])]),a("button",{id:"ptz-close",class:"quiet"},"收起云台")])],-1)),t[22]||(t[22]=a("section",{id:"page-playback",class:"page",hidden:""},[a("div",{class:"section-head"},[a("h2",null,[C("回到那一刻 "),a("small",null,"光阴")])]),a("div",{class:"panel playback-controls"},[a("label",null,[C("镜头 / 通道"),a("select",{id:"play-camera"})]),a("label",null,[C("录像来源"),a("select",{id:"archive-source"},[a("option",{value:"recorder"},"录像机原有录像(待接入)"),a("option",{value:"baidu"},"百度网盘录像"),a("option",{value:"local"},"本机待上传录像")])]),a("label",null,[C("日期"),a("input",{id:"play-date",type:"date"})]),a("button",{id:"query-recordings"},"查找录像"),a("span",{id:"play-info"},"选择日期,查看实际录像时段")]),a("aside",{id:"recording-health",class:"panel","aria-label":"本机录像状态",hidden:""},[a("div",{class:"section-head"},[a("strong",{id:"recording-health-text",role:"status"}),a("button",{id:"recording-configure",class:"quiet",hidden:""},"录像设置")]),a("p",{id:"recording-policy-note",class:"description"}),a("p",{id:"recording-start-note",class:"description"})]),a("div",{class:"video-panel"},[a("video",{id:"play-video",controls:"",playsinline:""}),a("div",{id:"play-empty",class:"video-empty"},"选择一个有录像的时间段")]),a("div",{class:"panel"},[a("div",{class:"timeline-head"},[a("strong",null,"当日时间轴"),a("span",null,[a("i",{class:"legend"}),C(" 有录像的时段 · 点击定位")])]),a("canvas",{id:"timeline",height:"76","aria-label":"录像时间轴"}),a("div",{class:"time-labels"},[a("span",null,"00:00"),a("span",null,"06:00"),a("span",null,"12:00"),a("span",null,"18:00"),a("span",null,"24:00")]),a("div",{class:"seek-row"},[a("label",null,[C("定位时间 "),a("input",{id:"seek-time",type:"time",step:"1",value:"12:00:00"})]),a("button",{id:"seek-button",class:"secondary"},"定位播放"),a("a",{id:"download",class:"button secondary",hidden:""},"下载原始片段")])]),a("div",{class:"panel"},[a("div",{class:"playback-tools"},[a("label",{class:"check"},[a("input",{id:"play-autonext",type:"checkbox",checked:""}),C("自动续播下一时段(跳过空档)")]),a("button",{id:"play-snapshot",class:"quiet"},"回放截图"),a("span",{id:"play-position",role:"status"})]),a("details",{class:"clip-editor"},[a("summary",null,"选取并下载指定片段"),a("form",{id:"clip-form"},[a("div",{class:"form-grid"},[a("label",null,[C("开始时间"),a("input",{id:"clip-start",type:"datetime-local",step:"1",required:""})]),a("label",null,[C("结束时间"),a("input",{id:"clip-end",type:"datetime-local",step:"1",required:""})])]),a("div",{class:"playback-tools"},[a("button",{type:"button",class:"quiet","data-clip-mark":"start"},"当前位置作起点"),a("button",{type:"button",class:"quiet","data-clip-mark":"end"},"当前位置作终点"),a("button",{type:"submit"},"生成下载链接"),a("a",{id:"clip-download",class:"button secondary",hidden:""},"下载所选片段")]),a("p",{id:"clip-status",role:"status",class:"description"}),a("p",{class:"description"},"每段最多一小时,不可跨越无录像时段。下载保留原始编码,剪辑边界可能受设备关键帧影响。")])])]),a("div",{id:"recording-list",class:"recording-list"})],-1)),t[23]||(t[23]=ge('',1)),a("section",NM,[t[12]||(t[12]=ge('

一物一档 设备 · 归属

同一设备可同时记录类型、区域、所有人、负责人和标签。分组顺序可自由组合,例如“灯 → 卧室”或“负责人 → 类型 → 区域”。人员归属不自动授予访问权限。

',2)),t[13]||(t[13]=a("div",{class:"panel device-view-controls"},[a("div",{class:"device-search-row"},[a("label",null,[C("设备类型"),a("select",{id:"device-type"},[a("option",{value:""},"所有类型")])]),a("label",null,[C("搜索设备或人员"),a("input",{id:"device-search",type:"search",placeholder:"例如:卧室 灯;也可查 IP、品牌、型号、人员"})]),a("button",{id:"device-clear",type:"button",class:"quiet",hidden:""},"清除设备筛选")]),a("div",{class:"device-actions view-presets",role:"group","aria-label":"设备分组方式"},[a("button",{type:"button",class:"quiet","data-group-preset":"space,type"},"按区域查看"),a("button",{type:"button",class:"quiet","data-group-preset":"type,space"},"按类型查看"),a("button",{type:"button",class:"quiet","data-group-preset":"manager,type,space"},"按负责人查看")]),a("details",{class:"group-custom"},[a("summary",null,"自定义分组顺序"),a("p",{class:"description"},"依次分组(前面的维度优先,区域按你定义的完整层级展示)"),a("div",{id:"device-group-order",class:"device-group-order"}),a("div",{class:"device-actions"},[a("button",{id:"device-group-add",class:"quiet"},"+ 增加分组维度"),a("button",{"data-admin":"",id:"device-view-save",class:"secondary"},"保存为本归属的默认视图")])]),a("p",{id:"device-count",class:"description"})],-1)),t[14]||(t[14]=a("div",{class:"device-actions",role:"group","aria-label":"设备展示方式"},[a("button",{id:"devices-card-view",class:"quiet","aria-pressed":"true"},"设备卡片"),a("button",{id:"devices-topology-view",class:"quiet","aria-pressed":"false"},"网络拓扑")],-1)),G(Om),G(Zm),G(dg)]),t[24]||(t[24]=ge('',2)),a("section",IM,[G(Zb),t[15]||(t[15]=ge('

录像与存储 留存

录像上传与保留策略

网盘录像默认每段 5 分钟,按录制时间上传;云端大小及 SHA-256 校验成功后删除本地片段。上传失败会保留并自动重试,未上传片段不会按天数清理。云端默认保留 30 天。容量上限由全部摄像头共用;临时录像分区另有硬容量限制,空间不足时暂停并在释放后恢复。

运行状态

每台摄像头可选择录像机或百度网盘。网盘方式临时保存原始主码流,上传并校验后腾出本机空间。预览默认使用主码流高清画面(最高 1920×1080、15 帧/秒),也可切换子码流流畅画面(最高 768×432、10 帧/秒)。本机录像保留设备原始编码。

最近操作

',2))]),t[25]||(t[25]=a("section",{id:"page-heritage-records",class:"page",hidden:""},[a("div",{class:"section-head"},[a("h2",{id:"heritage-records-title"},"文化与家风"),a("div",null,[a("button",{class:"quiet","data-page":"heritage"},"返回家庭传承"),a("button",{id:"heritage-new"},"+ 新建档案")])]),a("div",{class:"panel heritage-controls"},[a("label",null,[C("查找档案"),a("input",{id:"heritage-search",type:"search",placeholder:"名称、内容、相关人员"})]),a("label",{class:"check"},[a("input",{id:"heritage-archived",type:"checkbox"}),C("包含归档资料")]),a("button",{id:"heritage-reload",class:"quiet"},"重新载入")]),a("p",{id:"heritage-error",class:"form-error",role:"status"}),a("div",{id:"heritage-list",class:"site-grid"}),a("aside",{id:"heritage-detail",class:"panel",hidden:""})],-1)),t[26]||(t[26]=a("section",{id:"page-family",class:"page",hidden:""},[a("div",{class:"section-head"},[a("h2",null,[C("家族的来处与延续 "),a("small",null,"世系 · 传承")]),a("div",null,[a("button",{id:"family-reload",class:"quiet"},"重新载入"),a("button",{id:"family-export",class:"quiet"},"导出家谱"),a("button",{id:"new-person"},"+ 录入人物")])]),a("p",{class:"description"},"从祖辈到后辈,一张图看全家。点击人物查看档案,暖金色卡片是当前账号关联的本人。"),a("p",{id:"family-edit-note",class:"alert alert-info",role:"status"}),a("div",{class:"panel family-toolbar"},[a("label",null,[C("关系参照人物"),a("select",{id:"family-reference"})]),a("label",null,[C("查找人物"),a("input",{id:"family-search",type:"search",placeholder:"姓名、别名或籍贯"})]),a("button",{id:"family-find",class:"quiet",hidden:""},"定位搜索结果"),a("label",{class:"check"},[a("input",{id:"family-archived",type:"checkbox"}),C("显示归档人物")]),a("span",{id:"family-count"})]),a("div",{id:"family-error",class:"form-error",role:"status"}),a("div",{id:"family-workspace",class:"family-workspace"},[a("section",{id:"family-canvas-panel",class:"family-canvas-panel","aria-label":"全家关系图"},[a("div",{class:"family-map-heading"},[a("div",null,[a("span",{class:"eyebrow"},"枝叶相连 · 世代相承"),a("h2",{id:"family-view-title"},"全家关系图")]),a("div",{class:"family-view-tabs",role:"group","aria-label":"家谱显示方式"},[a("button",{id:"family-view-tree",class:"quiet","aria-pressed":"true"},"关系图"),a("button",{id:"family-view-list",class:"quiet","aria-pressed":"false"},"人物名册"),a("button",{id:"family-view-timeline",class:"quiet","aria-pressed":"false"},"家族时间线")])]),a("div",{id:"family-map-controls",class:"family-map-controls"},[a("div",{class:"family-zoom-controls"},[a("button",{id:"family-zoom-out",class:"quiet","aria-label":"缩小家谱"},"−"),a("output",{id:"family-zoom-value","aria-live":"polite"},"100%"),a("button",{id:"family-zoom-in",class:"quiet","aria-label":"放大家谱"},"+"),a("button",{id:"family-fit",class:"quiet"},"查看全谱")]),a("button",{id:"family-locate-self",class:"quiet"},"◎ 定位本人"),a("button",{id:"family-fullscreen",class:"quiet"},"全屏家谱")]),a("div",{id:"family-tree",class:"family-map-viewport",tabindex:"0",role:"region","aria-label":"家谱关系图,可拖动空白处或使用滚动条浏览"}),a("div",{id:"family-people",class:"family-people family-register",hidden:""}),a("section",{id:"family-events",hidden:"","aria-label":"家族重大记事"},[a("div",{class:"family-event-intro"},[a("div",null,[a("h3",null,"把值得记住的事,留给后来的人"),a("p",{class:"description"},"按事情发生的日期排列,可关联多位亲人,并附上详细记载或报道链接。")]),a("button",{id:"family-new-event"},"+ 写一则记事")]),a("div",{class:"family-event-filters"},[a("label",null,[C("关联人物"),a("select",{id:"family-event-person"},[a("option",{value:""},"全家")])]),a("label",null,[C("年份"),a("select",{id:"family-event-year"},[a("option",{value:""},"所有年份")])]),a("label",null,[C("排列"),a("select",{id:"family-event-order"},[a("option",{value:"desc"},"从近到远"),a("option",{value:"asc"},"从远到近")])]),a("label",null,[C("搜索记事"),a("input",{id:"family-event-search",type:"search",placeholder:"标题、摘要或正文"})]),a("label",{class:"check"},[a("input",{id:"family-event-relatives",type:"checkbox"}),C("包括此人的父母、配偶和子女")]),a("label",{id:"family-event-state-label"},[C("状态"),a("select",{id:"family-event-state"},[a("option",{value:"published"},"已发布"),a("option",{value:"draft"},"草稿箱"),a("option",{value:"archived"},"已归档"),a("option",{value:"all"},"全部")])]),a("button",{id:"family-event-clear",class:"quiet"},"清除筛选")]),a("p",{id:"family-event-count",class:"description",role:"status"}),a("div",{id:"family-timeline",class:"family-timeline"})]),a("div",{id:"family-map-footer",class:"family-map-footer"},[a("div",{class:"family-map-legend"},[a("span",null,[a("i",{class:"legend-self"}),C("本人")]),a("span",null,[a("i",{class:"legend-selected"}),C("正在查看")]),a("span",null,[a("i",{class:"legend-parent"}),C("父母 → 子女")]),a("span",null,[a("i",{class:"legend-spouse"}),C("配偶")]),a("span",null,[a("i",{class:"legend-adoptive"}),C("收养 / 继亲")])]),a("p",{id:"family-map-note",class:"description",role:"status"}),a("span",{class:"description"},"拖动空白处移动 · 点击人物查看档案 · 关系称谓按参照人物计算")])]),a("aside",{id:"family-detail",class:"panel family-inspector","aria-label":"人物档案"})])],-1)),G(ih),t[27]||(t[27]=ge('
赵府 · 智能数字管家独立部署 / 数据自有
',2))],64))}},$M={};function RM(n,e){return y(),x(H,null,[e[0]||(e[0]=ge('
灯火可亲 · 归家有时

欢迎回来

使用自己的账号,进入家庭空间。

设备档案

网络与连接

保存后自动更新拓扑。网络信息用于设备档案;摄像机实际取流地址在“配置镜头”内设置。选择人员不改变账号访问权限。

手机、灯、冰箱等当前支持设备档案、分类和责任归属。自动控制需另行接入对应协议,登记不代表已连接设备。

传承资料

这里只保存资料和意愿;不会据此转移财产或授予任何账号权限。链接内容保存在原位置,本系统保存链接和文字记录。

空间档案

镜头通道配置

直接接入摄像头时,可读取设备实际提供的媒体配置。端口请按设备填写:通常为 80,部分 TP-Link 设备为 2020。服务器需要能够访问该设备所在网络。

选择录像机时,本平台不重复录制,须在录像机上开启录像计划;设备是否实际录制需在原厂后台核对。选择百度网盘时,请勾选启用网盘录像。账号和密码只保存在本机受限数据目录。RTSP 服务响应代表设备可达,实际码流接通后才显示在线。路径预设需要与设备型号、通道一致。

摄像头对象

网络与连接

保存后自动更新拓扑。网络信息用于设备档案;摄像机实际取流地址在“配置镜头”内设置。选择人员不改变账号访问权限。

录像机配置

网络与连接

保存后自动更新拓扑。网络信息用于设备档案;摄像机实际取流地址在“配置镜头”内设置。选择人员不改变账号访问权限。

驱动在当前版本提供路径模板。录像机历史录像检索、回放及通道自动导入,需要型号确认后接入,当前尚未实现。

',7)),e[1]||(e[1]=a("dialog",{id:"leadership-dialog"},[a("form",{id:"leadership-form"},[a("div",{class:"dialog-heading"},[a("h2",null,"负责人安排与交接"),a("button",{type:"button",class:"quiet","data-close":"leadership-dialog"},"关闭")]),a("input",{name:"id",type:"hidden"}),a("input",{name:"revision",type:"hidden"}),a("p",{class:"description"},"从已获本家庭访问权限的系统账号中,指定主要和备用负责人。主要负责人即一家之主;普通账号需明确确认授予本家庭管理权限。真实家庭成员可以没有登录账号。"),a("p",{id:"leadership-scope",class:"fw-semibold"}),a("div",{id:"leadership-empty",class:"alert alert-info",role:"status",hidden:""},"本家庭还没有可选账号。请由平台管理员在系统用户中授予家庭访问权限,再指定负责人。"),a("div",{class:"leadership-member-actions d-flex flex-wrap gap-2 mb-3"},[a("button",{type:"button",id:"leadership-new",class:"secondary"},"+ 添加本家庭管理员"),a("button",{type:"button",id:"leadership-members",class:"quiet"},"管理授权账号")]),a("div",{class:"form-grid"},[a("label",null,[C("主要负责人 *"),a("select",{name:"ownerId",required:""})]),a("label",null,[C("备用负责人"),a("select",{name:"successorId"})]),a("label",{id:"leadership-grant",class:"check full alert alert-warning",hidden:""},[a("input",{type:"checkbox",name:"grantManagement"}),a("span",{id:"leadership-grant-note"})]),a("label",{class:"full"},[C("安排 / 交接说明 *"),a("textarea",{name:"reason",required:"",maxlength:"300",rows:"3",placeholder:"说明负责人安排或本次交接原因"})])]),a("p",{class:"description"},"交接后原负责人仍保留本归属的管理员权限。系统不会依据未登录或家谱去世日期自动转移权限;交接记录可追溯。"),a("p",{class:"form-error",role:"status"}),a("div",{class:"dialog-footer"},[a("button",{type:"submit"},"确认保存负责人安排")])])],-1)),e[2]||(e[2]=a("dialog",{id:"household-dialog"},[a("form",{id:"household-form"},[a("div",{class:"dialog-heading"},[a("h2",null,"家庭 / 场所档案"),a("button",{type:"button",class:"quiet","data-close":"household-dialog"},"关闭")]),a("input",{name:"id",type:"hidden"}),a("input",{name:"profileRevision",type:"hidden",value:"0"}),a("div",{class:"form-grid"},[a("label",{class:"full"},[C("归属名称 *"),a("input",{name:"name",maxlength:"80",required:"",placeholder:"例如:赵府、济南办公室、莱阳工厂"})]),a("label",{class:"full"},[C("归属类型"),a("select",{name:"kind"},[a("option",{value:"home"},"家庭"),a("option",{value:"office"},"办公场所"),a("option",{value:"factory"},"工厂")])]),a("fieldset",{class:"full geo-picker","data-geography":"","data-geo-title":"所在地"}),a("div",{class:"full cover-editor"},[a("img",{id:"household-cover-preview",alt:"场所封面预览",hidden:""}),a("label",null,[C("卡片封面照片"),a("input",{id:"household-cover-file",type:"file",accept:"image/png,image/jpeg,image/webp"})]),a("button",{type:"button",id:"household-cover-cancel",class:"quiet"},"取消本次图片选择"),a("button",{type:"button",id:"household-cover-reset",class:"quiet"},"使用默认封面"),a("p",{id:"household-cover-status",class:"description",role:"status","aria-live":"polite"},"照片仅向有权进入该家庭或场所的账号开放。")]),a("label",{class:"full"},[C("备注"),a("textarea",{name:"note",maxlength:"300",rows:"3"})])]),a("p",{class:"description"},"创建后进入该归属,建立管理员,再自行划分区域和登记设备。"),a("p",{class:"form-error"}),a("div",{class:"dialog-footer"},[a("button",{type:"submit"},"保存家庭")])])],-1)),e[3]||(e[3]=ge('

账号档案

亲属关系在家庭成员对应的族谱人物之间建立;登录账号仅关联本人身份和访问权限。

允许查看摄像头的空间

普通成员只访问本归属内已授权的区域。默认仅授权所选区域;勾选“包含下级区域”后同时包含其所有后代。管理员可管理本归属全部区域。

',2)),e[4]||(e[4]=a("dialog",{id:"person-dialog"},[a("form",{id:"person-form"},[a("div",{class:"dialog-heading"},[a("h2",null,"家谱人物"),a("button",{type:"button",class:"quiet","data-close":"person-dialog"},"关闭")]),a("input",{name:"id",type:"hidden"}),a("input",{name:"revision",type:"hidden"}),a("p",{id:"person-self-note",class:"alert alert-info",hidden:""},"这将建立并固定关联为您本人,用于确定上下五代维护范围。如族谱已有您的人物,请关闭此窗口并请管理员关联,避免重复建档。"),a("fieldset",{id:"person-relative-fields"},[a("legend",null,"新人物与已有亲属的关系"),a("div",{class:"form-grid"},[a("label",null,[C("已有亲属"),a("select",{name:"relativeId"})]),a("label",null,[C("新人物是其"),a("select",{name:"relativeKind"},[a("option",{value:"parent"},"父母一方(上一代)"),a("option",{value:"child"},"子女(下一代)"),a("option",{value:"spouse"},"配偶(同代)")])])]),a("p",{class:"description"},"人物与关系一起保存,无需为亲属开设登录账号;超出五代时不会写入。")]),a("div",{class:"form-grid"},[a("label",null,[C("姓名 / 称呼 *"),a("input",{name:"name",required:"",maxlength:"80",placeholder:"姓名暂不知时可先填称呼"})]),a("label",null,[C("别名 / 字 / 号"),a("input",{name:"alias",maxlength:"120"})]),a("label",null,[C("性别"),a("select",{name:"gender"},[a("option",{value:"unknown"},"待确认"),a("option",{value:"male"},"男"),a("option",{value:"female"},"女")])]),a("label",null,[C("在世情况"),a("select",{name:"lifeStatus"},[a("option",{value:"alive"},"在世"),a("option",{value:"deceased"},"不在世"),a("option",{value:"unknown"},"待确认")])]),a("fieldset",{class:"family-date","data-date-field":"birthDate"},[a("legend",null,"出生日期"),a("input",{name:"birthDate",type:"hidden"}),a("label",null,[C("历法"),a("select",{"data-calendar":"","aria-label":"出生日期历法"},[a("option",{value:"solar"},"公历"),a("option",{value:"lunar"},"农历")])]),a("label",null,[C("日期"),a("input",{"data-date-value":"","aria-label":"出生日期",type:"text",inputmode:"numeric",placeholder:"YYYY-MM-DD",maxlength:"10"})]),a("label",{"data-leap-label":"",class:"check",hidden:""},[a("input",{"data-date-leap":"",type:"checkbox"}),C("闰月")]),a("output",{"data-date-hint":"","aria-live":"polite"},"日期不详可留空")]),a("fieldset",{class:"family-date","data-date-field":"deathDate",hidden:""},[a("legend",null,"去世日期"),a("input",{name:"deathDate",type:"hidden"}),a("label",null,[C("历法"),a("select",{"data-calendar":"","aria-label":"去世日期历法"},[a("option",{value:"solar"},"公历"),a("option",{value:"lunar"},"农历")])]),a("label",null,[C("日期"),a("input",{"data-date-value":"","aria-label":"去世日期",type:"text",inputmode:"numeric",placeholder:"YYYY-MM-DD",maxlength:"10"})]),a("label",{"data-leap-label":"",class:"check",hidden:""},[a("input",{"data-date-leap":"",type:"checkbox"}),C("闰月")]),a("output",{"data-date-hint":"","aria-live":"polite"},"日期不详可留空")]),a("label",{class:"full",id:"person-legacy-place"},[C("原籍贯/出生地记录"),a("input",{name:"birthplace",maxlength:"160"}),a("small",null,"历史填写内容保留,可在下方分别补充。")]),a("fieldset",{class:"full person-location"},[a("legend",null,"籍贯(祖籍)"),a("div",{class:"form-grid"},[a("fieldset",{class:"full geo-picker","data-geography":"native","data-geo-title":"籍贯(祖籍)"}),a("label",null,[C("乡镇/街道"),a("input",{name:"nativeTown",maxlength:"80",placeholder:"","aria-label":"籍贯(祖籍) · 乡镇/街道"})]),a("label",null,[C("村/社区"),a("input",{name:"nativeCommunity",maxlength:"80",placeholder:"","aria-label":"籍贯(祖籍) · 村/社区"})]),a("label",{class:"full"},[C("详细地址/历史地名"),a("input",{name:"nativeAddress",maxlength:"200",placeholder:"楼栋、门牌或旧称,可按已知信息填写","aria-label":"籍贯(祖籍) · 详细地址/历史地名"})])])]),a("fieldset",{class:"full person-location"},[a("legend",null,"出生地"),a("div",{class:"form-grid"},[a("fieldset",{class:"full geo-picker","data-geography":"birth","data-geo-title":"出生地"}),a("label",null,[C("乡镇/街道"),a("input",{name:"birthTown",maxlength:"80",placeholder:"","aria-label":"出生地 · 乡镇/街道"})]),a("label",null,[C("村/社区"),a("input",{name:"birthCommunity",maxlength:"80",placeholder:"","aria-label":"出生地 · 村/社区"})]),a("label",{class:"full"},[C("详细地址/历史地名"),a("input",{name:"birthAddress",maxlength:"200",placeholder:"楼栋、门牌或旧称,可按已知信息填写","aria-label":"出生地 · 详细地址/历史地名"})])])]),a("p",{class:"description full"},"籍贯与出生地可不同;选择中国、世界或自定义地域,不详的层级可留空。"),a("label",{class:"full"},[C("生平简介"),a("textarea",{name:"biography",rows:"4",maxlength:"2000"})]),a("label",{class:"full"},[C("备注 / 信息来源"),a("textarea",{name:"note",rows:"3",maxlength:"500",placeholder:"例如:长辈口述、族谱记载、待考证信息"})]),a("label",{class:"check"},[a("input",{name:"archived",type:"checkbox"}),C("归档人物(保留关系,可恢复)")])]),a("p",{class:"form-error"}),a("div",{class:"dialog-footer"},[a("button",{type:"submit"},"保存人物")])])],-1)),e[5]||(e[5]=ge('

连接人物关系

每条亲子关系连接一位父母与一位子女。双方需在本人上下五代内;不能通过移动或断开已确认世系来改变维护范围。

',1)),e[6]||(e[6]=a("dialog",{id:"event-dialog","aria-labelledby":"event-editor-title"},[a("form",{id:"event-form"},[a("div",{class:"dialog-heading"},[a("h2",{id:"event-editor-title"},"写一则家族记事"),a("button",{type:"button",class:"quiet","data-close":"event-dialog"},"关闭")]),a("input",{name:"id",type:"hidden"}),a("input",{name:"revision",type:"hidden"}),a("div",{class:"form-grid"},[a("label",{class:"full"},[C("记事标题 *"),a("input",{name:"title",required:"",maxlength:"160",placeholder:"用一句话概括这件事"})]),a("fieldset",{class:"family-date full","data-date-field":"eventDate"},[a("legend",null,"事情发生的日期 *"),a("input",{name:"eventDate",type:"hidden"}),a("label",null,[C("历法"),a("select",{"data-calendar":"","aria-label":"记事日期历法"},[a("option",{value:"solar"},"公历"),a("option",{value:"lunar"},"农历")])]),a("label",null,[C("日期"),a("input",{"data-date-value":"","aria-label":"记事日期",required:"",type:"text",inputmode:"numeric",placeholder:"YYYY-MM-DD",maxlength:"10"})]),a("label",{"data-leap-label":"",class:"check",hidden:""},[a("input",{"data-date-leap":"",type:"checkbox"}),C("闰月")]),a("output",{"data-date-hint":"","aria-live":"polite"})]),a("fieldset",{class:"full"},[a("legend",null,"关联人物(可多选)"),a("input",{id:"event-person-search",type:"search",placeholder:"查找要关联的亲人","aria-label":"查找关联人物"}),a("div",{id:"event-person-choices"}),a("p",{class:"description"},"未选择人物时记为全家记事。每位关联人物的档案都可以追溯到这条记事。")]),a("label",{class:"full"},[C("摘要"),a("textarea",{name:"summary",maxlength:"400",rows:"2",placeholder:"简要说明这件事"})]),a("label",{class:"full"},[C("详细记载"),a("textarea",{name:"body",maxlength:"12000",rows:"7",placeholder:"记录经过、意义、长辈口述或资料出处。可分段书写。"})]),a("label",null,[C("报道 / 资料来源"),a("input",{name:"sourceName",maxlength:"160",placeholder:"例如:报刊名称、个人博客"})]),a("label",null,[C("原始报道链接"),a("input",{name:"sourceUrl",type:"url",maxlength:"2000",placeholder:"https://…"})]),a("label",{class:"check full"},[a("input",{name:"archived",type:"checkbox"}),C("归档记事(保留内容,可恢复)")])]),a("p",{class:"description"},"正式发布后,有家谱查看权限的账号即可在时间线看到;草稿只对有编辑权限的人可见。"),a("p",{class:"form-error",role:"status"}),a("div",{class:"dialog-footer event-editor-actions"},[a("button",{type:"submit","data-save-event":"",value:"draft",class:"secondary"},"保存草稿"),a("button",{type:"submit","data-publish-event":"",value:"published"},"发布记事"),a("button",{type:"submit","data-withdraw-event":"",value:"draft",class:"secondary",hidden:""},"撤回为草稿")])])],-1)),e[7]||(e[7]=ge('
家事 · 家声
',1)),e[8]||(e[8]=a("dialog",{id:"history-dialog","aria-labelledby":"history-title"},[a("div",{class:"dialog-heading"},[a("h2",{id:"history-title"},"修改记录"),a("button",{type:"button",class:"quiet","data-close":"history-dialog"},"关闭")]),a("p",{class:"description"},"人物、关系与记事每次保存都会留存版本。仅有家谱编辑权限的账号可查阅和恢复。"),a("p",{id:"history-error",class:"form-error",role:"status"}),a("div",{id:"history-list"}),a("button",{id:"history-more",class:"quiet",hidden:""},"加载更早记录"),a("article",{id:"history-detail"})],-1)),e[9]||(e[9]=a("dialog",{id:"password-dialog","aria-labelledby":"password-title"},[a("form",{id:"password-form"},[a("div",{class:"dialog-heading"},[a("h2",{id:"password-title"},"修改我的密码"),a("button",{type:"button",class:"quiet","data-close":"password-dialog"},"关闭")]),a("p",{id:"password-account",class:"description"}),a("label",null,[C("当前密码"),a("input",{name:"currentPassword",type:"password",required:"",maxlength:"128",autocomplete:"current-password"})]),a("label",null,[C("新密码"),a("input",{name:"newPassword",type:"password",required:"",minlength:"8",maxlength:"128",autocomplete:"new-password"})]),a("label",null,[C("再次输入新密码"),a("input",{name:"confirmPassword",type:"password",required:"",minlength:"8",maxlength:"128",autocomplete:"new-password"})]),a("p",{class:"description"},"保存后,这个账号在所有设备上都需要用新密码重新登录。"),a("p",{class:"form-error",role:"status"}),a("div",{class:"dialog-footer"},[a("button",{type:"submit"},"保存新密码")])])],-1)),e[10]||(e[10]=a("dialog",{id:"camera-settings-dialog","aria-labelledby":"camera-settings-title"},[a("div",{class:"dialog-heading"},[a("h2",{id:"camera-settings-title"},"摄像机参数"),a("button",{class:"quiet","data-close":"camera-settings-dialog"},"关闭")]),a("div",{class:"section-head"},[a("label",null,[C("设置码流"),a("select",{id:"camera-settings-quality"},[a("option",{value:"main"},"主码流"),a("option",{value:"sub"},"子码流")])]),a("button",{id:"camera-settings-reload",class:"quiet"},"重新读取")]),a("div",{id:"camera-settings-info"}),a("p",{id:"camera-settings-status",class:"form-error",role:"status"}),a("form",{id:"camera-image-form"},[a("h3",null,"图像与日夜模式"),a("p",{class:"description"},"作用于当前物理镜头,主、子码流共用这些图像参数。"),a("div",{id:"camera-image-fields",class:"form-grid"}),a("div",{class:"dialog-footer"},[a("button",{type:"submit",disabled:""},"保存图像参数")])]),a("form",{id:"camera-video-form"},[a("h3",null,"码流与清晰度"),a("p",{class:"description"},"作用于上方选定的码流。保存后画面可能短暂重连,录像机也会使用调整后的码流。本页保留原有视频编码。"),a("div",{id:"camera-video-fields",class:"form-grid"}),a("div",{class:"dialog-footer"},[a("button",{type:"submit",disabled:""},"保存码流参数")])]),a("details",null,[a("summary",null,"其他萤石功能的接入情况"),a("ul",null,[a("li",null,"云台方向微调与预置位:在实时画面的“云台”中使用,按设备能力启用。"),a("li",null,"实时声音与全屏:通过画面播放器控制。"),a("li",null,"双向对讲、智能追踪、声光告警、隐私遮蔽、设备翻转、云录像和消息推送:当前尚未接入,请使用萤石 App。"),a("li",null,"录像机原有录像:仍通过录像机或原厂 App 查看;本系统已支持本机额外录像的回放。")]),a("p",{class:"description"},"功能按设备实际开放能力逐项接入,型号与固件不同可能有差异。")])],-1)),e[11]||(e[11]=a("div",{id:"toast",role:"status",hidden:""},null,-1)),e[12]||(e[12]=ge('

画面截图

当前视频画面截图

下载 PNG 图片

附件预览

',2))],64)}const LM=In($M,[["render",RM]]),PM=["/vendor/hls.min.js","/live-player.js","/kinship.js","/family-graph.js","/calendar.js","/device-model.js","/data/geography-data.js","/geography.js","/app.js","/monitor.js","/date-fields.js","/family-map.js","/family.js","/family-events.js","/family-history.js","/camera-settings.js","/recording-ranges.js","/recording-ui.js","/snapshot.js","/households.js","/devices.js","/steward.js","/heritage.js","/personalization.js","/file-hash.js","/journal-queue.js","/journal.js"];function Ea(n){if(!(n instanceof Element))return;const e=[n,...n.querySelectorAll("button,input,select,textarea,table")];for(const t of e)t.matches("button")&&!t.closest(".family-map-viewport")&&!t.classList.contains("btn")&&t.classList.add("btn",t.matches(".quiet,.secondary")?"btn-outline-secondary":"btn-primary"),t.matches("select")&&t.classList.add("form-select"),t.matches("textarea,input:not([type=checkbox]):not([type=radio]):not([type=range]):not([type=hidden])")&&t.classList.add("form-control"),t.matches("input[type=checkbox],input[type=radio]")&&t.classList.add("form-check-input"),t.matches("table")&&t.classList.add("table","align-middle")}async function BM(){Ea(document.getElementById("app")),new MutationObserver(n=>{for(const e of n)for(const t of e.addedNodes)Ea(t)}).observe(document.getElementById("app"),{childList:!0,subtree:!0});for(const n of[...PM,"/vue-bridge.js"])await new Promise((e,t)=>{const s=document.createElement("script");s.src=n+"?ui=cf1dd21672863b5d",s.onload=e,s.onerror=()=>t(new Error("Could not load "+n)),document.head.append(s)});await window.ZhaoVue.boot()}const _M=["data-page"],zM={key:0,class:"alert alert-danger",role:"alert"},jM={__name:"App",setup(n){const e=P(!1);return $i(async()=>{try{await BM()}catch(t){console.error("Application startup failed",t),e.value=!0}}),(t,s)=>(y(),x(H,null,[G(ep),a("main",{"data-page":j(R).page},[G(sp),e.value?(y(),x("div",zM,"页面组件加载失败,请检查网络后重新打开页面。")):D("",!0),G(DM)],8,_M),G(LM)],64))}};zu(jM).mount("#app"); +`:"");return e(n).trim()}function mC(n,e){const t=i=>String(i!=null?i:"").replace(/[&<>"']/g,r=>({"&":"&","<":"<",">":">",'"':""","'":"'"})[r]),s=i=>{var l,c,d;if(i.type==="text")return(i.marks||[]).reduce((u,p)=>{const f={bold:"strong",italic:"em",strike:"s",underline:"u"}[p.type];return f?`<${f}>${u}`:u},t(i.text));if(i.type==="hardBreak")return"
";if(i.type==="media")return/^[a-f0-9]{16}$/.test(((l=i.attrs)==null?void 0:l.mediaId)||"")?e(i.attrs.mediaId):"";const r=(i.content||[]).map(s).join("");if(i.type==="doc")return r;const o={paragraph:"p",heading:((c=i.attrs)==null?void 0:c.level)===3?"h3":"h2",blockquote:"blockquote",bulletList:"ul",orderedList:"ol",listItem:"li"}[i.type];return o?`<${o}${o==="ol"&&Number.isInteger((d=i.attrs)==null?void 0:d.start)?` start="${Math.max(1,Math.min(9999,i.attrs.start))}"`:""}>${r||"
"}`:""};return s(n)}const gC={class:"journal-rich-editor"},bC={class:"journal-editor-toolbar",role:"toolbar","aria-label":"正文格式"},vC=["aria-pressed"],yC=["aria-pressed"],kC=["aria-pressed"],xC=["aria-pressed"],wC=["value"],SC={class:"journal-editor-foot"},CC={__name:"RichJournalEditor",setup(n){const e=Xr(null),t=P(0),s=P("");let i=new Map,r=new Map,o=new Set,l;const c=Fe.create({name:"media",group:"block",atom:!0,draggable:!0,selectable:!0,addAttributes(){return{mediaId:{default:null},uploadClient:{default:null}}},parseHTML(){return[{tag:"figure[data-media-id]",getAttrs:b=>i.has(b.dataset.mediaId)?{mediaId:b.dataset.mediaId}:!1}]},renderHTML({node:b}){return["figure",{"data-media-id":b.attrs.mediaId}]},addNodeView(){return({node:b,getPos:m,editor:v})=>{const S=document.createElement("figure");S.className="journal-inline-media",S.contentEditable="false";let A="";const N=()=>{const B=r.get(b.attrs.uploadClient),E=i.get(b.attrs.mediaId),M=JSON.stringify([E&&[E.name,E.mime,E.src],B&&[B.name,B.status,B.progress,B.error]]);if(A===M)return;A=M,S.querySelectorAll("audio,video").forEach(O=>{O.pause(),O.removeAttribute("src"),O.load()}),S.replaceChildren();const w=document.createElement("figcaption");if(w.textContent=(E==null?void 0:E.name)||(B==null?void 0:B.name)||"云端素材引用",S.append(w),!(E!=null&&E.src)){const O=document.createElement("p");O.textContent=B?B.error||"正在上传 "+Math.round(B.progress||0)+"%":"素材暂不可用",S.append(O)}if(E!=null&&E.src){const O=document.createElement(E.mime.startsWith("image/")?"img":E.mime.startsWith("audio/")?"audio":"video");O.src=E.src,O.tagName==="IMG"?(O.alt=E.name,O.loading="lazy"):(O.controls=!0,O.preload="metadata",O.playsInline=!0,O.addEventListener("play",()=>document.querySelectorAll("#page-journal audio,#page-journal video").forEach(I=>{I!==O&&I.pause()}))),S.append(O)}const T=document.createElement("button");T.type="button",T.className="quiet",T.textContent="移除正文引用",T.setAttribute("aria-label","移除正文引用 "+((E==null?void 0:E.name)||"")),T.addEventListener("click",()=>{if(!v.isEditable)return;const O=m();typeof O=="number"&&v.chain().focus().deleteRange({from:O,to:O+b.nodeSize}).run()}),S.append(T)};return o.add(N),N(),{dom:S,update(B){return B.type!==b.type?!1:(b=B,N(),!0)},stopEvent:B=>B.target.closest("button,audio,video")!==null,ignoreMutation:()=>!0,destroy(){o.delete(N),S.querySelectorAll("audio,video").forEach(B=>{B.pause(),B.removeAttribute("src"),B.load()})}}}}});function d(b,m=!0){var v;s.value=Ta(b.getJSON()),t.value++,m&&((v=document.getElementById("journal-form"))==null||v.dispatchEvent(new Event("input",{bubbles:!0})))}function u(b){var m;(m=e.value)==null||m.destroy(),o.clear(),e.value=new Gx({extensions:[fC.configure({heading:{levels:[2,3]},link:!1,code:!1,codeBlock:!1,horizontalRule:!1}),c],content:b?Ca(b):hC(),editorProps:{attributes:{class:"journal-rich-input",role:"textbox","aria-label":"记事正文","aria-multiline":"true"},handlePaste(v,S){var N;const A=(N=S.clipboardData)==null?void 0:N.getData("text/plain");return A?(S.preventDefault(),v.dispatch(v.state.tr.insertText(A)),!0):!1}},onUpdate:({editor:v})=>d(v),onSelectionUpdate:()=>t.value++,onTransaction:()=>t.value++}),d(e.value,!1)}function p(b,m){var v;(v=e.value)==null||v.chain().focus()[b](m).run()}function f(b){var N;const m=e.value,v=m.state.selection,S=[{type:"media",attrs:b},{type:"paragraph"}],A=m.chain().focus();return((N=v.node)==null?void 0:N.type.name)==="media"?A.insertContentAt(v.to,S):A.insertContent(S),A.run()}function h(b){var m;return t.value,!!((m=e.value)!=null&&m.isActive(b))}function g(){const b=document.getElementById("journal-library");b&&(b.open=!0,b.scrollIntoView({behavior:"smooth",block:"start"}))}return $i(()=>{u(),l={reset:()=>u(),set:u,focus:()=>{var b;return(b=e.value)==null?void 0:b.commands.focus()},document:()=>e.value.getJSON(),ids:()=>Ma(e.value.getJSON()),plainText:()=>Ta(e.value.getJSON()),setEditable:b=>{var m;return(m=e.value)==null?void 0:m.setEditable(b)},insertMedia(b){if(!e.value.isEditable||!i.has(b))return!1;const m=Ma(e.value.getJSON());return!m.includes(b)&&m.length>=9?(window.alert("每条记事最多引用 9 个不同素材"),!1):f({mediaId:b})},clients(){const b=[];return e.value.state.doc.descendants(m=>{m.type.name==="media"&&m.attrs.uploadClient&&b.push(m.attrs.uploadClient)}),[...new Set(b)]},pending(){let b=!1;return e.value.state.doc.descendants(m=>{m.type.name==="media"&&!m.attrs.mediaId&&(b=!0)}),b},insertUpload(b){let m=0;return e.value.state.doc.descendants(v=>{v.type.name==="media"&&m++}),m>=9?(window.alert("本条最多添加 9 个媒体,请先保存记事"),!1):f({uploadClient:b})},removeUpload(b){const m=[];e.value.state.doc.descendants((S,A)=>{S.type.name==="media"&&S.attrs.uploadClient===b&&m.push([A,S.nodeSize])});const v=e.value.state.tr;for(const[S,A]of m.reverse())v.delete(S,S+A);v.docChanged&&e.value.view.dispatch(v)},resolveUpload(b,m){i.set(m.id,m);const v=e.value.state.tr;e.value.state.doc.descendants((S,A)=>{S.type.name==="media"&&S.attrs.uploadClient===b&&v.setNodeMarkup(A,void 0,{...S.attrs,mediaId:m.id})}),v.docChanged&&e.value.view.dispatch(v)},setTasks(b){r=new Map(b.map(m=>[m.clientId,m]));for(const m of o)m()},setMedia(b){i=new Map(b.map(m=>[m.id,m]));for(const m of o)m()},render:(b,m)=>mC(Ca(b),m),clearMedia(){i.clear(),r.clear();for(const b of o)b()}},window.ZhaoJournalEditor=l}),Bt(()=>{var b;(b=e.value)==null||b.destroy(),window.ZhaoJournalEditor===l&&delete window.ZhaoJournalEditor}),(b,m)=>(y(),x("div",gC,[a("div",bC,[a("button",{type:"button",class:"quiet","aria-pressed":h("bold"),onMousedown:m[0]||(m[0]=Ve(()=>{},["prevent"])),onClick:m[1]||(m[1]=v=>p("toggleBold"))},[...m[13]||(m[13]=[a("b",null,"加粗",-1)])],40,vC),a("button",{type:"button",class:"quiet","aria-pressed":h("italic"),onMousedown:m[2]||(m[2]=Ve(()=>{},["prevent"])),onClick:m[3]||(m[3]=v=>p("toggleItalic"))},[...m[14]||(m[14]=[a("i",null,"斜体",-1)])],40,yC),a("button",{type:"button",class:"quiet","aria-pressed":h("heading"),onMousedown:m[4]||(m[4]=Ve(()=>{},["prevent"])),onClick:m[5]||(m[5]=v=>p("toggleHeading",{level:2}))},"标题",40,kC),a("button",{type:"button",class:"quiet","aria-pressed":h("bulletList"),onMousedown:m[6]||(m[6]=Ve(()=>{},["prevent"])),onClick:m[7]||(m[7]=v=>p("toggleBulletList"))},"列表",40,xC),a("button",{type:"button",class:"quiet",onMousedown:m[8]||(m[8]=Ve(()=>{},["prevent"])),onClick:m[9]||(m[9]=v=>p("undo"))},"撤销",32),a("button",{type:"button",class:"quiet",onMousedown:m[10]||(m[10]=Ve(()=>{},["prevent"])),onClick:m[11]||(m[11]=v=>p("redo"))},"重做",32),a("button",{type:"button",class:"journal-insert-button",onMousedown:m[12]||(m[12]=Ve(()=>{},["prevent"])),onClick:g},"+ 插入云端素材",32)]),G(j(Yx),{editor:e.value},null,8,["editor"]),a("input",{type:"hidden",name:"text",value:s.value},null,8,wC),a("div",SC,[m[15]||(m[15]=a("span",null,"在光标处插入照片、视频、语音;可拖动媒体调整位置。",-1)),a("span",{class:De({"text-danger":s.value.length>5e3})},k(s.value.length)+" / 5000 字",3)])]))}},MC={key:0,class:"panel"},TC={class:"d-flex justify-content-between flex-wrap gap-3"},EC={key:0,class:"alert alert-danger",role:"alert"},AC={class:"fs-5"},OC={key:0,class:"d-block mb-3"},NC=["value"],IC={key:1,class:"d-block mb-3"},DC={key:2},$C={class:"row g-3"},RC={class:"col-md-6"},LC={class:"col-md-6"},PC={class:"d-flex gap-2"},BC=["disabled"],_C=["disabled"],zC={class:"row g-3"},jC={class:"card-body"},FC={class:"fs-5"},VC={key:0,class:"badge text-bg-success"},HC={class:"small text-secondary"},qC={class:"d-flex flex-wrap gap-2"},UC=["disabled","onClick"],WC=["disabled","onClick"],KC=["disabled","onClick"],JC={key:2,class:"alert alert-info mt-3"},GC={key:3,class:"border-top pt-3 mt-4"},YC=["value"],XC={class:"d-flex gap-2 my-3"},ZC=["disabled"],QC={__name:"FamilyMembers",setup(n){const e=P(null),t=P(""),s=P(!1),i=P(null),r=P(""),o=P(!1),l=ee(()=>R.value.loggedIn&&R.value.page==="members"),c=ee(()=>(R.value.state.households||[]).filter(b=>b.id!==R.value.state.familyId));let d=0;async function u(){const b=++d;try{const m=await K().api("/api/members");b===d&&(e.value=m)}catch(m){b===d&&(t.value=m.message)}}Ae([l,()=>R.value.state.familyId,()=>R.value.session],()=>{d++,e.value=null,i.value=null,t.value="",r.value="",o.value=!1,s.value=!1,l.value&&u()},{immediate:!0});function p(b){i.value=b?{id:b.id,revision:b.revision,personId:b.personId,name:b.name,label:b.label,status:b.status}:{name:"",personId:"",label:"",status:"active",revision:0}}async function f(){if(s.value)return;s.value=!0,t.value="";const b=d;try{if(await K().api("/api/members",i.value),b!==d)return;i.value=null,await u(),await K().refresh()}catch(m){b===d&&(t.value=m.message)}finally{s.value=!1}}async function h(){if(s.value)return;s.value=!0,t.value="";const b=d;try{if(await K().api("/api/genealogy/share",{targetFamilyId:r.value,confirm:o.value}),b!==d)return;o.value=!1,r.value="",await u(),await K().refresh()}catch(m){b===d&&(t.value=m.message)}finally{s.value=!1}}async function g(b,m=!1){if(s.value)return;const v=d;s.value=!0,t.value="";try{m?await K().viewMemberHistory(b.personId,b.name,R.value.state.familyId):await K().viewPerson(b.personId,R.value.state.familyId)}catch(S){v===d&&!S.stale&&(t.value=S.message)}finally{v===d&&(s.value=!1)}}return(b,m)=>{var v,S,A,N,B;return l.value?(y(),x("section",MC,[a("div",TC,[m[8]||(m[8]=a("div",null,[a("h2",null,"家庭成员"),a("p",{class:"text-secondary"},"登记真实家人。老人、孩子无需账号;亲属关系与登录权限分别管理。")],-1)),(v=e.value)!=null&&v.canManage?(y(),x("button",{key:0,class:"btn btn-primary align-self-start",onClick:m[0]||(m[0]=E=>p())},"+ 登记成员")):D("",!0)]),t.value?(y(),x("p",EC,k(t.value),1)):D("",!0),i.value?(y(),x("form",{key:1,class:"border rounded p-3 mb-4",onSubmit:Ve(f,["prevent"])},[a("h3",AC,k(i.value.id?"编辑成员关系":"登记家庭成员"),1),i.value.id?D("",!0):(y(),x("label",OC,[m[10]||(m[10]=C("关联已有族谱人物",-1)),Y(a("select",{class:"form-select","onUpdate:modelValue":m[1]||(m[1]=E=>i.value.personId=E)},[m[9]||(m[9]=a("option",{value:""},"新建人物(尚未录入族谱)",-1)),(y(!0),x(H,null,J(((S=e.value)==null?void 0:S.candidates)||[],E=>(y(),x("option",{key:E.id,value:E.id},k(E.name),9,NC))),128))],512),[[Te,i.value.personId]])])),i.value.personId?i.value.id?(y(),x("p",DC,"人物:"+k(i.value.name)+"。姓名、生平及亲属关系在族谱中维护,仍遵守五代限制。",1)):D("",!0):(y(),x("label",IC,[m[11]||(m[11]=C("姓名",-1)),Y(a("input",{"onUpdate:modelValue":m[2]||(m[2]=E=>i.value.name=E),class:"form-control",maxlength:"80",required:""},null,512),[[At,i.value.name]])])),a("div",$C,[a("label",RC,[m[12]||(m[12]=C("家庭称呼/身份备注",-1)),Y(a("input",{"onUpdate:modelValue":m[3]||(m[3]=E=>i.value.label=E),class:"form-control",maxlength:"60",placeholder:"例如:妈妈、长子、亲友"},null,512),[[At,i.value.label]])]),a("label",LC,[m[14]||(m[14]=C("成员状态",-1)),Y(a("select",{"onUpdate:modelValue":m[4]||(m[4]=E=>i.value.status=E),class:"form-select"},[...m[13]||(m[13]=[a("option",{value:"active"},"当前成员",-1),a("option",{value:"away"},"暂住外地",-1),a("option",{value:"historical"},"历史成员",-1)])],512),[[Te,i.value.status]])])]),m[15]||(m[15]=a("p",{class:"small text-secondary mt-2"},"称呼是本家庭的备注,不自动建立父母、配偶关系或授予管理权限。成员状态不会删除人物和经历;住在外地也可以是家人。",-1)),a("div",PC,[a("button",{class:"btn btn-primary",disabled:s.value},"保存成员",8,BC),a("button",{type:"button",class:"btn btn-outline-secondary",disabled:s.value,onClick:m[5]||(m[5]=E=>i.value=null)},"取消",8,_C)])],32)):D("",!0),a("div",zC,[(y(!0),x(H,null,J(((A=e.value)==null?void 0:A.items)||[],E=>(y(),x("article",{key:E.id,class:"col-md-6 col-xl-4"},[a("div",{class:De(["card h-100",{"border-primary bg-primary-subtle":E.self}])},[a("div",jC,[a("h3",FC,[C(k(E.name)+" ",1),E.self?(y(),x("span",VC,"本人")):D("",!0)]),a("p",null,k(E.label||"家庭身份待补充")+" · "+k({active:"当前成员",away:"暂住外地",historical:"历史成员"}[E.status]),1),a("p",HC,k(E.hasAccount?"已有关联账号":"无需注册账号")+k(E.lifeStatus==="deceased"?" · 已故":""),1),a("div",qC,[e.value.canViewGenealogy?(y(),x("button",{key:0,class:"btn btn-sm btn-outline-primary",disabled:s.value,onClick:M=>g(E)},"人物与亲属",8,UC)):D("",!0),a("button",{class:"btn btn-sm btn-outline-primary",disabled:s.value,onClick:M=>g(E,!0)},"个人阅历",8,WC),e.value.canManage?(y(),x("button",{key:1,class:"btn btn-sm btn-outline-secondary",disabled:s.value,onClick:M=>p(E)},"编辑成员关系",8,KC)):D("",!0)])])],2)]))),128))]),e.value&&!e.value.items.length?(y(),x("p",JC,"还没有登记成员。已有族谱人物可直接关联,避免重复建人。")):D("",!0),j(R).platformAdmin?(y(),x("details",GC,[m[19]||(m[19]=a("summary",null,"与相关家庭共用族谱",-1)),m[20]||(m[20]=a("p",{class:"small text-secondary mt-2"},"相关家庭共用人物与亲属关系;活动、设备、位置授权继续独立。现有同名人物不会自动合并,需核对身份。世代范围限制继续有效。",-1)),a("p",null,"当前已关联:"+k((B=(N=e.value)==null?void 0:N.genealogyHomes)==null?void 0:B.map(E=>E.name).join("、")),1),a("form",{onSubmit:Ve(h,["prevent"])},[a("label",null,[m[17]||(m[17]=C("关联家庭",-1)),Y(a("select",{"onUpdate:modelValue":m[6]||(m[6]=E=>r.value=E),class:"form-select",required:""},[m[16]||(m[16]=a("option",{value:""},"请选择",-1)),(y(!0),x(H,null,J(c.value,E=>(y(),x("option",{value:E.id,key:E.id},k(E.name),9,YC))),128))],512),[[Te,r.value]])]),a("label",XC,[Y(a("input",{"onUpdate:modelValue":m[7]||(m[7]=E=>o.value=E),type:"checkbox",required:""},null,512),[[st,o.value]]),m[18]||(m[18]=C("确认双方族谱人物与关系共用,有族谱查看权限的账号可以查看合并后的族谱",-1))]),a("button",{class:"btn btn-outline-primary",disabled:s.value||!o.value||!r.value},"确认共用族谱",8,ZC)],32)])):D("",!0)])):D("",!0)}}},eM={key:0,class:"panel"},tM={class:"d-flex flex-wrap justify-content-between gap-2"},nM={key:0,class:"alert alert-danger",role:"alert"},sM={class:"table-responsive"},iM={class:"table align-middle"},rM={key:0},oM=["onClick"],lM={class:"row g-3"},aM={class:"col-md-6"},cM=["value"],dM={class:"col-md-6"},uM=["value"],pM={class:"col-md-6"},fM={class:"col-md-6"},hM=["disabled"],mM={__name:"AccountAccess",setup(n){const e=P([]),t=P(""),s=P(!1),i=P(""),r=P(""),o=P("member"),l=P("none"),c=ee(()=>R.value.loggedIn&&R.value.page==="accounts"&&R.value.platformAdmin),d=ee(()=>R.value.state.households||[]),u=ee(()=>e.value.find(m=>m.id===i.value));let p=0;async function f(){const m=++p;try{const v=await K().api("/api/platform/users");m===p&&(e.value=v.users)}catch(v){m===p&&(t.value=v.message)}}Ae([c,()=>R.value.session],()=>{p++,e.value=[],i.value="",r.value="",t.value="",s.value=!1,c.value&&f()},{immediate:!0}),Ae([i,r],()=>{var v,S;const m=(S=(v=u.value)==null?void 0:v.familyGrants)==null?void 0:S[r.value];o.value=(m==null?void 0:m.role)||"member",l.value=(m==null?void 0:m.familyAccess)||"none"});async function h(){if(s.value)return;s.value=!0,t.value="";const m=p;try{await K().api("/api/users/grant",{userId:i.value,familyId:r.value,role:o.value,familyAccess:l.value}),m===p&&(await f(),await K().refresh())}catch(v){m===p&&(t.value=v.message)}finally{s.value=!1}}async function g(m){await K().editAccount(m.id,m.familyId)}const b=m=>{var v;return((v=d.value.find(S=>S.id===m))==null?void 0:v.name)||"未知家庭"};return(m,v)=>c.value?(y(),x("section",eM,[a("div",tM,[v[5]||(v[5]=a("div",null,[a("h2",null,"系统用户"),a("p",{class:"text-secondary"},"一个账号可访问多个家庭,分别授权。账号与家庭成员档案独立。")],-1)),a("button",{class:"btn btn-outline-primary align-self-start",onClick:v[0]||(v[0]=S=>j(K)().showPage("users"))},"账号建档与密码管理")]),t.value?(y(),x("p",nM,k(t.value),1)):D("",!0),a("div",sM,[a("table",iM,[v[7]||(v[7]=a("thead",null,[a("tr",null,[a("th",null,"登录账号"),a("th",null,"主要授权家庭"),a("th",null,"其他家庭权限"),a("th",null,"状态"),a("th")])],-1)),a("tbody",null,[(y(!0),x(H,null,J(e.value,S=>(y(),x("tr",{key:S.id},[a("td",null,[a("strong",null,k(S.name),1),v[6]||(v[6]=a("br",null,null,-1)),C(k(S.username),1)]),a("td",null,k(S.role==="admin"?"平台管理员":b(S.familyId)),1),a("td",null,[S.role==="admin"?(y(),x("span",rM,"可管理全部家庭;查看位置仍须本人单独授权")):D("",!0),(y(!0),x(H,null,J(S.familyGrants||{},(A,N)=>(y(),x("div",{key:N},k(b(N))+" · "+k(A.role==="family_admin"?"家庭管理员":"访问账号"),1))),128))]),a("td",null,k(S.disabled?"已停用":"启用"),1),a("td",null,[a("button",{class:"btn btn-sm btn-outline-secondary",onClick:A=>g(S)},"编辑账号",8,oM)])]))),128))])])]),a("form",{class:"border-top pt-3",onSubmit:Ve(h,["prevent"])},[v[16]||(v[16]=a("h3",{class:"fs-5"},"设置账号的其他家庭访问权限",-1)),a("div",lM,[a("label",aM,[v[9]||(v[9]=C("系统账号",-1)),Y(a("select",{"onUpdate:modelValue":v[1]||(v[1]=S=>i.value=S),class:"form-select",required:""},[v[8]||(v[8]=a("option",{value:""},"请选择",-1)),(y(!0),x(H,null,J(e.value.filter(S=>S.role!=="admin"),S=>(y(),x("option",{key:S.id,value:S.id},k(S.name)+" · "+k(S.username),9,cM))),128))],512),[[Te,i.value]])]),a("label",dM,[v[11]||(v[11]=C("家庭",-1)),Y(a("select",{"onUpdate:modelValue":v[2]||(v[2]=S=>r.value=S),class:"form-select",required:""},[v[10]||(v[10]=a("option",{value:""},"请选择",-1)),(y(!0),x(H,null,J(d.value.filter(S=>{var A;return S.id!==((A=u.value)==null?void 0:A.familyId)}),S=>(y(),x("option",{key:S.id,value:S.id},k(S.name),9,uM))),128))],512),[[Te,r.value]])]),a("label",pM,[v[13]||(v[13]=C("家庭权限",-1)),Y(a("select",{"onUpdate:modelValue":v[3]||(v[3]=S=>o.value=S),class:"form-select"},[...v[12]||(v[12]=[a("option",{value:"member"},"允许进入(不含设备控制)",-1),a("option",{value:"family_admin"},"管理本家庭及其设备",-1),a("option",{value:"none"},"取消此家庭访问",-1)])],512),[[Te,o.value]])]),a("label",fM,[v[15]||(v[15]=C("族谱权限",-1)),Y(a("select",{"onUpdate:modelValue":v[4]||(v[4]=S=>l.value=S),class:"form-select"},[...v[14]||(v[14]=[a("option",{value:"none"},"不授权",-1),a("option",{value:"read"},"查看",-1),a("option",{value:"edit"},"维护本人上下五代",-1)])],512),[[Te,l.value]])])]),v[17]||(v[17]=a("p",{class:"small text-secondary mt-3"},"授权不会自动登记为家庭成员,也不会自动获得任何人的位置。修改权限后该账号需重新登录。",-1)),a("button",{class:"btn btn-primary",disabled:s.value||!i.value||!r.value},"保存访问权限",8,hM)],32)])):D("",!0)}},gM={key:0,class:"panel mb-4"},bM={key:0},vM={class:"table-responsive"},yM={class:"table align-middle"},kM={key:0,class:"d-block text-danger"},xM=["onClick"],wM={key:1,class:"text-danger"},SM={__name:"MapStorage",setup(n){const e=P(null),t=P(""),s=ee(()=>R.value.loggedIn&&R.value.page==="storage"&&R.value.platformAdmin);let i,r=0;const o=u=>((u||0)/1024/1024).toFixed(1)+" MB",l={queued:"等待下载",downloading:"下载底图",restoring:"从网盘恢复",uploading:"上传网盘",verifying:"核对云端文件",ready:"可使用",cloud:"已归档 · 本地已释放",retry:"等待重试"};async function c(){const u=r;try{const p=await K().api("/api/maps");u===r&&(e.value=p,t.value="")}catch(p){u===r&&(t.value=p.message)}finally{u===r&&s.value&&(i=setTimeout(c,15e3))}}async function d(u){try{await K().api("/api/maps",{action:"retry",id:u}),clearTimeout(i),c()}catch(p){t.value=p.message}}return Ae(s,u=>{r++,clearTimeout(i),u&&c()},{immediate:!0}),Bt(()=>{r++,clearTimeout(i)}),(u,p)=>{var f,h;return s.value?(y(),x("section",gM,[p[1]||(p[1]=a("div",{class:"d-flex justify-content-between"},[a("h2",{class:"fs-5"},"内置地图 · 网盘归档与本机缓存"),a("span",{class:"badge text-bg-light"},"全国概览常驻")],-1)),p[2]||(p[2]=a("p",{class:"text-secondary small"},"家人开启位置共享、进入某个省份后,自动准备该省详细地图。同一省份共用一份。上传并核对成功的省份缓存可回收,需要时从百度网盘取回。",-1)),e.value?(y(),x("p",bM,"本机 "+k(o(e.value.usedBytes))+" / "+k(o(e.value.cacheLimitBytes))+" · 为其他服务至少预留 "+k(o(e.value.reserveBytes)),1)):D("",!0),a("div",vM,[a("table",yM,[p[0]||(p[0]=a("thead",null,[a("tr",null,[a("th",null,"地图"),a("th",null,"状态"),a("th",null,"本机"),a("th",null,"百度网盘"),a("th")])],-1)),a("tbody",null,[(y(!0),x(H,null,J((f=e.value)==null?void 0:f.items,g=>(y(),x("tr",{key:g.id},[a("td",null,k(g.name),1),a("td",null,[C(k(l[g.state]||g.state),1),g.error?(y(),x("small",kM,k(g.error),1)):D("",!0)]),a("td",null,k(o(g.localBytes)),1),a("td",null,k(g.cloud?"已校验归档":g.progress?g.progress+"%":"待归档"),1),a("td",null,[g.state==="retry"?(y(),x("button",{key:0,class:"btn btn-sm btn-outline-primary",onClick:b=>d(g.id)},"重试",8,xM)):D("",!0)])]))),128))])])]),t.value||(h=e.value)!=null&&h.error?(y(),x("p",wM,k(t.value||e.value.error),1)):D("",!0)])):D("",!0)}}},CM={id:"page-members",class:"page",hidden:""},MM={id:"page-accounts",class:"page",hidden:""},TM={id:"page-journal",class:"page",hidden:""},EM={id:"journal-editor-surface"},AM={id:"journal-form",class:"panel journal-compose"},OM={id:"page-overview",class:"page",hidden:""},NM={id:"page-device",class:"page",hidden:""},IM={id:"page-objects",class:"page",hidden:""},DM={id:"page-storage",class:"page",hidden:""},$M={__name:"Workspace",setup(n){return(e,t)=>(y(),x(H,null,[G(SM),a("section",CM,[G(QC)]),a("section",MM,[G(mM)]),t[16]||(t[16]=a("div",{id:"household-context",class:"household-context",hidden:""},[a("label",null,[C("当前归属 "),a("select",{id:"household-filter","aria-label":"当前归属"})]),a("span",{id:"household-context-note"}),a("button",{id:"scope-back",class:"quiet"},"返回场所")],-1)),t[17]||(t[17]=a("div",{id:"device-context",class:"device-context",hidden:""},[a("p",{id:"device-breadcrumb"}),a("div",{role:"group","aria-label":"设备功能"},[a("button",{class:"quiet","data-device-tab":"device"},"设备档案"),a("button",{class:"quiet","data-device-tab":"live"},"实时画面"),a("button",{class:"quiet","data-device-tab":"playback"},"录像回放"),a("button",{class:"quiet","data-device-tab":"cameras"},"镜头与设置")])],-1)),t[18]||(t[18]=ge('
设备—
已接通码流—
录像占用—
空间档案—
可选择任意区域,包含其下级区域
',3)),t[19]||(t[19]=a("section",{id:"page-settings",class:"page",hidden:""},[a("div",{class:"section-head"},[a("h2",null,"把这里布置成你习惯的样子"),a("button",{id:"settings-reload",class:"quiet"},"重新读取设置")]),a("p",{id:"settings-error",role:"status"}),a("div",{class:"settings-sections",role:"group","aria-label":"设置分类"},[a("button",{class:"quiet","data-settings-section":"preferences","aria-pressed":"true"},"我的偏好"),a("button",{class:"quiet","data-settings-section":"baidu","data-platform-setting":"",hidden:""},"网盘连接"),a("button",{class:"quiet","data-settings-section":"brand","data-platform-setting":"",hidden:""},"品牌与外观"),a("button",{class:"quiet","data-settings-section":"backup","data-platform-setting":"",hidden:""},"数据库备份")]),a("form",{id:"preferences-form",class:"panel"},[a("h3",null,"我的偏好"),a("p",{class:"description"},"只影响当前账号,保存后换电脑或手机登录也会沿用。切换选项可以预览,离开未保存的预览会撤销。"),a("div",{id:"personal-choices",class:"form-grid"}),a("p",{id:"preferences-status",role:"status"}),a("div",{class:"device-actions"},[a("button",{type:"submit"},"保存我的偏好"),a("button",{type:"button",id:"personal-follow",class:"quiet"},"全部跟随平台"),a("button",{type:"button",id:"personal-cancel",class:"quiet"},"撤销预览")])]),a("section",{id:"baidu-admin",class:"panel",hidden:""},[a("div",{class:"section-head"},[a("h3",null,"百度网盘 · 统一存储"),a("span",{class:"badge"},"仅超级管理员配置")]),a("p",{class:"description"},"连接一个网盘账号,统一保存封面、Logo、图标及各用户上传的照片、视频和语音。系统按用户、家庭和记事可见范围授权;网盘账号持有人本身可以管理网盘中的文件。服务器仅转发分片,不保存媒体原文件。"),a("details",{id:"baidu-storage-guide"},[a("summary",null,"文件存在哪里?"),a("ul",null,[a("li",null,"家庭与场所:按家庭或场所保存封面。"),a("li",null,"平台外观:保存 Logo 和图标。"),a("li",null,"个人记事:按家庭、用户分组,再分照片、视频、语音。"),a("li",null,"数据库备份:单独存放;新备份上传并校验成功后,清理超过一个自然月的旧云备份。")]),a("p",{class:"description"},"文字、权限和文件引用保存在本机数据库;个人媒体原文件保存在百度网盘。封面和品牌图片仅做有限的内存缓存。更换封面、移除附件或删除记事不会删除网盘原文件。")]),a("form",{id:"baidu-config"},[a("div",{class:"form-grid"},[a("label",null,[C("AppKey"),a("input",{name:"appKey",autocomplete:"off",maxlength:"150",required:""})]),a("label",null,[C("SecretKey"),a("input",{name:"secretKey",type:"password",autocomplete:"new-password",maxlength:"150"})]),a("label",null,[C("百度后台应用名称"),a("input",{name:"appFolder",value:"智家",required:"",maxlength:"40"})]),a("label",null,[C("OAuth 回调地址"),a("input",{name:"redirectUri",type:"url",placeholder:"https://你的域名/api/baidu/callback",required:"",maxlength:"400"})])]),a("p",{class:"description"},"回调地址须与百度后台完全一致。SecretKey 留空保持已保存值,SignKey 不需要填写。当前开发者应用仅限个人场景,适用范围以百度后台为准。"),a("p",{id:"baidu-config-status",role:"status"}),a("button",{type:"submit"},"保存网盘应用配置")]),a("hr"),a("p",{id:"baidu-status",role:"status"}),a("div",{class:"device-actions"},[a("button",{id:"baidu-connect"},"连接/重新授权百度网盘"),a("button",{id:"baidu-disconnect",class:"quiet"},"解除本机连接")]),a("p",{class:"description"},"解除连接不会删除云端文件。临时媒体地址由后台按需获取,令牌不发送给浏览器。网盘授权凭据单独保存在服务器受限目录,不包含在数据库备份或公开源码中。")]),a("div",{id:"settings-private",hidden:""},[a("form",{id:"brand-form",class:"panel"},[a("h3",null,"发布与品牌配置"),a("p",{class:"description"},"仅超级管理员可修改。名称、Logo、浏览器图标及登录文案会公开显示;适用于整套系统。已有个人偏好优先于平台默认。"),a("div",{class:"form-grid"},[a("label",null,[C("系统名称"),a("input",{name:"name",required:"",maxlength:"40"})]),a("label",null,[C("系统副标题"),a("input",{name:"subtitle",required:"",maxlength:"60"})]),a("label",{class:"full"},[C("页首题词"),a("input",{name:"motto",maxlength:"100"})]),a("label",null,[C("登录标题"),a("input",{name:"loginTitle",required:"",maxlength:"40"})]),a("label",null,[C("登录说明"),a("input",{name:"loginNote",maxlength:"160"})]),a("label",{class:"full"},[C("页脚说明"),a("input",{name:"footer",maxlength:"120"})])]),a("div",{class:"brand-image-grid"},[a("div",null,[a("img",{id:"brand-logo-preview",alt:"Logo 预览",src:"/zhao-icon.png"}),a("label",null,[C("更换系统 Logo"),a("input",{id:"brand-logo-file",type:"file",accept:"image/png,image/jpeg,image/webp"})]),a("button",{type:"button",id:"brand-logo-reset",class:"quiet"},"使用默认 Logo")]),a("div",null,[a("img",{id:"brand-icon-preview",alt:"浏览器图标预览",src:"/zhao-icon.png"}),a("label",null,[C("更换浏览器图标"),a("input",{id:"brand-icon-file",type:"file",accept:"image/png,image/jpeg,image/webp"})]),a("button",{type:"button",id:"brand-icon-reset",class:"quiet"},"使用默认图标")])]),a("p",{class:"description"},"支持 PNG、JPEG、WebP,原图最多 5 MB;上传时自动缩小,图片随系统数据库保存。"),a("h3",null,"新账号与跟随平台账号的默认外观"),a("div",{id:"brand-defaults",class:"form-grid"}),a("p",{id:"brand-status",role:"status"}),a("div",{class:"device-actions"},[a("button",{type:"submit"},"保存发布配置"),a("button",{type:"button",id:"brand-export",class:"quiet"},"导出发布配置"),a("label",{class:"config-import"},[C("导入配置到表单"),a("input",{id:"brand-import",type:"file",accept:"application/json,.json"})])]),a("p",{class:"description"},"导入后先核对再保存。导出的配置只含品牌与默认外观,不含账号、设备凭据、家庭资料和网络备份目录。")]),a("section",{id:"backup-panel",class:"panel"},[a("h3",null,"数据库备份"),a("p",{class:"description"},"整台服务的数据库包含所有家庭、账号、设备连接配置和网盘文件引用,因此仅超级管理员可操作。网盘中的照片、视频、语音及录像文件不包含在新数据库副本中;旧版备份可能仍含历史内嵌图片。恢复后所有账号需要重新登录。"),a("form",{id:"backup-form"},[a("div",{class:"form-grid"},[a("label",{class:"check full"},[a("input",{name:"enabled",type:"checkbox"}),C("启用每日定时备份")]),a("label",{class:"check full"},[a("input",{name:"baidu",type:"checkbox"}),C("同时上传到已连接的百度网盘")]),a("label",null,[C("每日时间(北京时间)"),a("input",{name:"time",type:"time",required:"",value:"03:00"})]),a("label",null,[C("本机/挂载目录保留份数"),a("input",{name:"keep",type:"number",min:"1",max:"90",required:"",value:"14"})]),a("label",{class:"full"},[C("网络备份目录(可留空)"),a("input",{name:"networkPath",maxlength:"500",placeholder:"/var/lib/zhaovision/network-backup"})])]),a("p",{class:"description"},"填写本服务器已挂载的网络盘目录。使用百度接口备份只需勾选上方选项;此路径用于其他已挂载的网络存储,不能填网页地址或分享链接。写入网络目录成功不等于已确认百度云端同步完成。"),a("p",{class:"description"},"默认部署允许写入 /var/lib/zhaovision 下的目录。挂载和目录权限须由主机管理员配置;本页不会保存网盘登录密码。保留份数只清理本机和挂载目录中本系统生成的旧备份,百度网盘保留最近一个自然月;新备份上传并校验成功后才清理本应用的过期副本。"),a("p",{id:"backup-local-path",class:"description"}),a("p",{id:"backup-save-status",role:"status"}),a("button",{type:"submit"},"保存备份设置")]),a("div",{class:"section-head"},[a("h3",null,"备份记录"),a("button",{id:"backup-run"},"立即备份数据库")]),a("p",{id:"backup-result",role:"status"}),a("div",{id:"backup-history"})])])],-1)),a("section",TM,[t[6]||(t[6]=a("div",{class:"scope-intro"},[a("span",{class:"eyebrow"},"岁月有迹 · 日常成章"),a("h2",null,"把生活,写成自己的来时路"),a("p",null,"与家人分享近况,也为自己留下一份阅历。")],-1)),a("div",EM,[t[4]||(t[4]=a("div",{class:"journal-editor-heading"},[a("strong",null,"记下此刻 · 留住声音"),a("button",{id:"journal-record",disabled:"",type:"button"},"● 开始录音"),a("button",{id:"journal-stop-record",type:"button",hidden:""},"■ 结束录音并插入"),a("button",{id:"journal-discard-record",type:"button",class:"quiet",hidden:""},"取消录音"),a("span",{id:"journal-record-elapsed",role:"status"}),a("button",{id:"journal-pick-media",disabled:"",type:"button",class:"quiet"},"插入照片/视频"),a("button",{type:"submit",form:"journal-form"},"保存"),a("button",{id:"journal-expand",type:"button",class:"quiet"},"全屏编辑"),a("button",{id:"journal-close-editor",type:"button",class:"quiet",hidden:""},"关闭编辑 · Esc")],-1)),a("form",AM,[t[0]||(t[0]=ge('

写一条记事

文字和媒体按正文顺序呈现。先将光标放在想插入的位置,再选择云端素材。

',6)),G(CC),t[1]||(t[1]=ge('
参与/相关家人(可多选)
录入账号与经历中的人物分别记录;未注册的老人和孩子也可关联。关联人物不会扩大可见范围。
',1)),t[2]||(t[2]=a("p",{id:"journal-status",role:"status","aria-live":"polite"},null,-1)),t[3]||(t[3]=a("div",{class:"device-actions"},[a("button",{id:"journal-save",type:"submit"},"保存记事"),a("button",{id:"journal-new",type:"button",class:"quiet"},"另写一条")],-1))]),t[5]||(t[5]=a("section",{class:"panel journal-materials","aria-label":"云端素材"},[a("div",{class:"section-head"},[a("div",null,[a("h3",null,"云端素材"),a("p",{class:"description"},"上传即插入正文,在原位置显示进度。上传期间可以继续写文字。")])]),a("div",{class:"journal-add-media"},[a("label",{class:"quiet"},[C("+ 上传照片、视频、语音"),a("input",{id:"journal-files",disabled:"",type:"file",multiple:"",accept:"image/jpeg,image/png,image/webp,video/mp4,video/quicktime,video/webm,audio/mpeg,audio/mp4,audio/aac,audio/wav,audio/ogg,audio/webm,.m4a"})]),a("button",{id:"journal-cancel-upload",type:"button",class:"quiet",hidden:""},"暂停全部上传")]),a("p",{id:"journal-cloud-note",class:"description"}),a("p",{class:"description"},"可混合选择文件,同时上传 3 个;单个最多 256 MB。每条正文可引用 9 个不同素材。录音最长 5 分钟。"),a("p",{id:"journal-upload-status",role:"status","aria-live":"polite"}),a("div",{id:"journal-upload-list"}),a("details",{id:"journal-library",class:"journal-library"},[a("summary",null,[C("我的云端素材("),a("span",{id:"journal-library-count"},"0"),C(")")]),a("div",{class:"journal-library-list-tools"},[a("span",{class:"description"},"已保存正文使用的素材,可在其他记事中再次引用。"),a("label",null,[C("筛选"),a("select",{id:"journal-media-filter"},[a("option",{value:""},"全部素材"),a("option",{value:"image/"},"照片"),a("option",{value:"video/"},"视频"),a("option",{value:"audio/"},"语音"),a("option",{value:"unused"},"草稿临时素材")])])]),a("div",{id:"journal-library-list",class:"journal-upload-grid"})]),a("details",{id:"journal-trash",class:"journal-trash",hidden:""},[a("summary",null,[C("已移除素材("),a("span",{id:"journal-trash-count"},"0"),C(")")]),a("p",{class:"description"},"仍被正文引用的素材可以恢复;最后一个引用删除后,网盘原文件自动删除。"),a("div",{id:"journal-trash-list"})]),a("details",{id:"journal-cleanup",hidden:""},[a("summary",null,"网盘清理记录"),a("button",{id:"journal-cleanup-refresh",type:"button",class:"quiet"},"刷新清理状态"),a("div",{id:"journal-cleanup-list"})]),a("p",{class:"description"},"放弃草稿或关闭页面会取消本次上传,并删除无其他引用的文件。意外断网退出时,服务器在草稿失联 10 分钟后自动清理。删除最后一处正文引用,也会删除网盘文件。")],-1))]),t[7]||(t[7]=ge('

个人阅历保留同一条记事的正文、媒体和互动;查看他人时只展示其分享给当前家庭/场所的内容。删除正文中的媒体或整条记事,会解除对应引用;最后一个引用删除后,网盘原文件自动清理。

',2)),t[8]||(t[8]=a("div",{class:"section-head"},[a("p",{id:"journal-query-status",role:"status"}),a("div",null,[a("button",{id:"journal-prev",class:"quiet"},"上一页"),a("button",{id:"journal-next",class:"quiet"},"下一页")])],-1)),t[9]||(t[9]=a("div",{id:"journal-list",class:"journal-feed"},null,-1))]),a("section",OM,[G(rb),t[10]||(t[10]=a("div",{id:"scope-overview"},null,-1))]),a("section",NM,[G(eg),t[11]||(t[11]=a("div",{id:"device-detail"},null,-1))]),t[20]||(t[20]=a("section",{id:"page-heritage",class:"page",hidden:""},[a("div",{id:"heritage-home"})],-1)),t[21]||(t[21]=a("section",{id:"page-live",class:"page"},[a("div",{class:"section-head"},[a("h2",{id:"live-heading"},"本场所监控墙"),a("div",null,[a("label",null,[C("清晰度 "),a("select",{id:"quality"},[a("option",{value:"hd"},"主码流"),a("option",{value:"compat"},"子码流")])])])]),a("details",{class:"live-help"},[a("summary",null,"画面与清晰度说明"),a("p",{id:"wall-context",class:"description"},"这里汇总当前场所内已授权的镜头;点击摄像头详情可进入单台设备。"),a("p",{class:"description",id:"quality-note"},"主码流画面更清晰,最高 1920×1080;子码流更流畅,最高 768×432,适合网络较慢时使用。")]),a("div",{class:"wall-toolbar"},[a("label",null,[C("分屏 "),a("select",{id:"wall-layout"},[a("option",{value:"auto"},"自适应"),a("option",{value:"1"},"1 画面"),a("option",{value:"2"},"2 画面"),a("option",{value:"4"},"4 画面"),a("option",{value:"6"},"6 画面"),a("option",{value:"9"},"9 画面"),a("option",{value:"16"},"16 画面")])]),a("label",{class:"check"},[a("input",{id:"wall-arrange",type:"checkbox"}),C("调整顺序")]),a("div",{class:"wall-paging"},[a("button",{id:"wall-prev",class:"quiet","aria-label":"上一组画面"},"‹"),a("span",{id:"wall-page"}),a("button",{id:"wall-next",class:"quiet","aria-label":"下一组画面"},"›")]),a("span",{id:"wall-clock"}),a("button",{id:"wall-fullscreen"},"全屏监控")]),a("div",{id:"live-grid",class:"live-grid"}),a("section",{id:"ptz-panel",class:"ptz-panel",hidden:""},[a("div",null,[a("strong",{id:"ptz-title"},"云台"),a("p",{id:"ptz-status",role:"status"})]),a("div",{class:"ptz-pad"},[a("button",{"data-ptz-action":"up","aria-label":"云台向上"},"↑"),a("button",{"data-ptz-action":"left","aria-label":"云台向左"},"←"),a("button",{"data-ptz-action":"stop"},"停止"),a("button",{"data-ptz-action":"right","aria-label":"云台向右"},"→"),a("button",{"data-ptz-action":"down","aria-label":"云台向下"},"↓")]),a("div",{id:"ptz-presets"},[a("div",{class:"section-head"},[a("strong",null,[C("常用位置 "),a("small",{id:"preset-count"})]),a("button",{id:"preset-reload",class:"quiet"},"重新读取")]),a("p",{id:"preset-status",role:"status"}),a("div",{id:"preset-list"}),a("p",{class:"description"},"调整位置后可另存为新预置位。本版不覆盖已有位置,避免设备固件拒绝或误改。"),a("form",{id:"preset-form",hidden:""},[a("label",null,[C("当前位置名称"),a("input",{id:"preset-name",required:"",maxlength:"40",placeholder:"例如:大门、院子"})]),a("button",{type:"submit"},"保存当前位置")]),a("div",{id:"preset-confirmation",hidden:""},[a("p",{id:"preset-confirm-text"}),a("button",{id:"preset-confirm-yes"},"确认"),a("button",{id:"preset-confirm-cancel",class:"quiet"},"取消")])]),a("button",{id:"ptz-close",class:"quiet"},"收起云台")])],-1)),t[22]||(t[22]=a("section",{id:"page-playback",class:"page",hidden:""},[a("div",{class:"section-head"},[a("h2",null,[C("回到那一刻 "),a("small",null,"光阴")])]),a("div",{class:"panel playback-controls"},[a("label",null,[C("镜头 / 通道"),a("select",{id:"play-camera"})]),a("label",null,[C("录像来源"),a("select",{id:"archive-source"},[a("option",{value:"recorder"},"录像机原有录像(待接入)"),a("option",{value:"baidu"},"百度网盘录像"),a("option",{value:"local"},"本机待上传录像")])]),a("label",null,[C("日期"),a("input",{id:"play-date",type:"date"})]),a("button",{id:"query-recordings"},"查找录像"),a("span",{id:"play-info"},"选择日期,查看实际录像时段")]),a("aside",{id:"recording-health",class:"panel","aria-label":"本机录像状态",hidden:""},[a("div",{class:"section-head"},[a("strong",{id:"recording-health-text",role:"status"}),a("button",{id:"recording-configure",class:"quiet",hidden:""},"录像设置")]),a("p",{id:"recording-policy-note",class:"description"}),a("p",{id:"recording-start-note",class:"description"})]),a("div",{class:"video-panel"},[a("video",{id:"play-video",controls:"",playsinline:""}),a("div",{id:"play-empty",class:"video-empty"},"选择一个有录像的时间段")]),a("div",{class:"panel"},[a("div",{class:"timeline-head"},[a("strong",null,"当日时间轴"),a("span",null,[a("i",{class:"legend"}),C(" 有录像的时段 · 点击定位")])]),a("canvas",{id:"timeline",height:"76","aria-label":"录像时间轴"}),a("div",{class:"time-labels"},[a("span",null,"00:00"),a("span",null,"06:00"),a("span",null,"12:00"),a("span",null,"18:00"),a("span",null,"24:00")]),a("div",{class:"seek-row"},[a("label",null,[C("定位时间 "),a("input",{id:"seek-time",type:"time",step:"1",value:"12:00:00"})]),a("button",{id:"seek-button",class:"secondary"},"定位播放"),a("a",{id:"download",class:"button secondary",hidden:""},"下载原始片段")])]),a("div",{class:"panel"},[a("div",{class:"playback-tools"},[a("label",{class:"check"},[a("input",{id:"play-autonext",type:"checkbox",checked:""}),C("自动续播下一时段(跳过空档)")]),a("button",{id:"play-snapshot",class:"quiet"},"回放截图"),a("span",{id:"play-position",role:"status"})]),a("details",{class:"clip-editor"},[a("summary",null,"选取并下载指定片段"),a("form",{id:"clip-form"},[a("div",{class:"form-grid"},[a("label",null,[C("开始时间"),a("input",{id:"clip-start",type:"datetime-local",step:"1",required:""})]),a("label",null,[C("结束时间"),a("input",{id:"clip-end",type:"datetime-local",step:"1",required:""})])]),a("div",{class:"playback-tools"},[a("button",{type:"button",class:"quiet","data-clip-mark":"start"},"当前位置作起点"),a("button",{type:"button",class:"quiet","data-clip-mark":"end"},"当前位置作终点"),a("button",{type:"submit"},"生成下载链接"),a("a",{id:"clip-download",class:"button secondary",hidden:""},"下载所选片段")]),a("p",{id:"clip-status",role:"status",class:"description"}),a("p",{class:"description"},"每段最多一小时,不可跨越无录像时段。下载保留原始编码,剪辑边界可能受设备关键帧影响。")])])]),a("div",{id:"recording-list",class:"recording-list"})],-1)),t[23]||(t[23]=ge('',1)),a("section",IM,[t[12]||(t[12]=ge('

一物一档 设备 · 归属

同一设备可同时记录类型、区域、所有人、负责人和标签。分组顺序可自由组合,例如“灯 → 卧室”或“负责人 → 类型 → 区域”。人员归属不自动授予访问权限。

',2)),t[13]||(t[13]=a("div",{class:"panel device-view-controls"},[a("div",{class:"device-search-row"},[a("label",null,[C("设备类型"),a("select",{id:"device-type"},[a("option",{value:""},"所有类型")])]),a("label",null,[C("搜索设备或人员"),a("input",{id:"device-search",type:"search",placeholder:"例如:卧室 灯;也可查 IP、品牌、型号、人员"})]),a("button",{id:"device-clear",type:"button",class:"quiet",hidden:""},"清除设备筛选")]),a("div",{class:"device-actions view-presets",role:"group","aria-label":"设备分组方式"},[a("button",{type:"button",class:"quiet","data-group-preset":"space,type"},"按区域查看"),a("button",{type:"button",class:"quiet","data-group-preset":"type,space"},"按类型查看"),a("button",{type:"button",class:"quiet","data-group-preset":"manager,type,space"},"按负责人查看")]),a("details",{class:"group-custom"},[a("summary",null,"自定义分组顺序"),a("p",{class:"description"},"依次分组(前面的维度优先,区域按你定义的完整层级展示)"),a("div",{id:"device-group-order",class:"device-group-order"}),a("div",{class:"device-actions"},[a("button",{id:"device-group-add",class:"quiet"},"+ 增加分组维度"),a("button",{"data-admin":"",id:"device-view-save",class:"secondary"},"保存为本归属的默认视图")])]),a("p",{id:"device-count",class:"description"})],-1)),t[14]||(t[14]=a("div",{class:"device-actions",role:"group","aria-label":"设备展示方式"},[a("button",{id:"devices-card-view",class:"quiet","aria-pressed":"true"},"设备卡片"),a("button",{id:"devices-topology-view",class:"quiet","aria-pressed":"false"},"网络拓扑")],-1)),G(Om),G(Zm),G(dg)]),t[24]||(t[24]=ge('',2)),a("section",DM,[G(Qb),t[15]||(t[15]=ge('

录像与存储 留存

录像上传与保留策略

网盘录像默认每段 5 分钟,按录制时间上传;云端大小及 SHA-256 校验成功后删除本地片段。上传失败会保留并自动重试,未上传片段不会按天数清理。云端默认保留 30 天。容量上限由全部摄像头共用;临时录像分区另有硬容量限制,空间不足时暂停并在释放后恢复。

运行状态

每台摄像头可选择录像机或百度网盘。网盘方式临时保存原始主码流,上传并校验后腾出本机空间。预览默认使用主码流高清画面(最高 1920×1080、15 帧/秒),也可切换子码流流畅画面(最高 768×432、10 帧/秒)。本机录像保留设备原始编码。

最近操作

',2))]),t[25]||(t[25]=a("section",{id:"page-heritage-records",class:"page",hidden:""},[a("div",{class:"section-head"},[a("h2",{id:"heritage-records-title"},"文化与家风"),a("div",null,[a("button",{class:"quiet","data-page":"heritage"},"返回家庭传承"),a("button",{id:"heritage-new"},"+ 新建档案")])]),a("div",{class:"panel heritage-controls"},[a("label",null,[C("查找档案"),a("input",{id:"heritage-search",type:"search",placeholder:"名称、内容、相关人员"})]),a("label",{class:"check"},[a("input",{id:"heritage-archived",type:"checkbox"}),C("包含归档资料")]),a("button",{id:"heritage-reload",class:"quiet"},"重新载入")]),a("p",{id:"heritage-error",class:"form-error",role:"status"}),a("div",{id:"heritage-list",class:"site-grid"}),a("aside",{id:"heritage-detail",class:"panel",hidden:""})],-1)),t[26]||(t[26]=a("section",{id:"page-family",class:"page",hidden:""},[a("div",{class:"section-head"},[a("h2",null,[C("家族的来处与延续 "),a("small",null,"世系 · 传承")]),a("div",null,[a("button",{id:"family-reload",class:"quiet"},"重新载入"),a("button",{id:"family-export",class:"quiet"},"导出家谱"),a("button",{id:"new-person"},"+ 录入人物")])]),a("p",{class:"description"},"从祖辈到后辈,一张图看全家。点击人物查看档案,暖金色卡片是当前账号关联的本人。"),a("p",{id:"family-edit-note",class:"alert alert-info",role:"status"}),a("div",{class:"panel family-toolbar"},[a("label",null,[C("关系参照人物"),a("select",{id:"family-reference"})]),a("label",null,[C("查找人物"),a("input",{id:"family-search",type:"search",placeholder:"姓名、别名或籍贯"})]),a("button",{id:"family-find",class:"quiet",hidden:""},"定位搜索结果"),a("label",{class:"check"},[a("input",{id:"family-archived",type:"checkbox"}),C("显示归档人物")]),a("span",{id:"family-count"})]),a("div",{id:"family-error",class:"form-error",role:"status"}),a("div",{id:"family-workspace",class:"family-workspace"},[a("section",{id:"family-canvas-panel",class:"family-canvas-panel","aria-label":"全家关系图"},[a("div",{class:"family-map-heading"},[a("div",null,[a("span",{class:"eyebrow"},"枝叶相连 · 世代相承"),a("h2",{id:"family-view-title"},"全家关系图")]),a("div",{class:"family-view-tabs",role:"group","aria-label":"家谱显示方式"},[a("button",{id:"family-view-tree",class:"quiet","aria-pressed":"true"},"关系图"),a("button",{id:"family-view-list",class:"quiet","aria-pressed":"false"},"人物名册"),a("button",{id:"family-view-timeline",class:"quiet","aria-pressed":"false"},"家族时间线")])]),a("div",{id:"family-map-controls",class:"family-map-controls"},[a("div",{class:"family-zoom-controls"},[a("button",{id:"family-zoom-out",class:"quiet","aria-label":"缩小家谱"},"−"),a("output",{id:"family-zoom-value","aria-live":"polite"},"100%"),a("button",{id:"family-zoom-in",class:"quiet","aria-label":"放大家谱"},"+"),a("button",{id:"family-fit",class:"quiet"},"查看全谱")]),a("button",{id:"family-locate-self",class:"quiet"},"◎ 定位本人"),a("button",{id:"family-fullscreen",class:"quiet"},"全屏家谱")]),a("div",{id:"family-tree",class:"family-map-viewport",tabindex:"0",role:"region","aria-label":"家谱关系图,可拖动空白处或使用滚动条浏览"}),a("div",{id:"family-people",class:"family-people family-register",hidden:""}),a("section",{id:"family-events",hidden:"","aria-label":"家族重大记事"},[a("div",{class:"family-event-intro"},[a("div",null,[a("h3",null,"把值得记住的事,留给后来的人"),a("p",{class:"description"},"按事情发生的日期排列,可关联多位亲人,并附上详细记载或报道链接。")]),a("button",{id:"family-new-event"},"+ 写一则记事")]),a("div",{class:"family-event-filters"},[a("label",null,[C("关联人物"),a("select",{id:"family-event-person"},[a("option",{value:""},"全家")])]),a("label",null,[C("年份"),a("select",{id:"family-event-year"},[a("option",{value:""},"所有年份")])]),a("label",null,[C("排列"),a("select",{id:"family-event-order"},[a("option",{value:"desc"},"从近到远"),a("option",{value:"asc"},"从远到近")])]),a("label",null,[C("搜索记事"),a("input",{id:"family-event-search",type:"search",placeholder:"标题、摘要或正文"})]),a("label",{class:"check"},[a("input",{id:"family-event-relatives",type:"checkbox"}),C("包括此人的父母、配偶和子女")]),a("label",{id:"family-event-state-label"},[C("状态"),a("select",{id:"family-event-state"},[a("option",{value:"published"},"已发布"),a("option",{value:"draft"},"草稿箱"),a("option",{value:"archived"},"已归档"),a("option",{value:"all"},"全部")])]),a("button",{id:"family-event-clear",class:"quiet"},"清除筛选")]),a("p",{id:"family-event-count",class:"description",role:"status"}),a("div",{id:"family-timeline",class:"family-timeline"})]),a("div",{id:"family-map-footer",class:"family-map-footer"},[a("div",{class:"family-map-legend"},[a("span",null,[a("i",{class:"legend-self"}),C("本人")]),a("span",null,[a("i",{class:"legend-selected"}),C("正在查看")]),a("span",null,[a("i",{class:"legend-parent"}),C("父母 → 子女")]),a("span",null,[a("i",{class:"legend-spouse"}),C("配偶")]),a("span",null,[a("i",{class:"legend-adoptive"}),C("收养 / 继亲")])]),a("p",{id:"family-map-note",class:"description",role:"status"}),a("span",{class:"description"},"拖动空白处移动 · 点击人物查看档案 · 关系称谓按参照人物计算")])]),a("aside",{id:"family-detail",class:"panel family-inspector","aria-label":"人物档案"})])],-1)),G(ih),t[27]||(t[27]=ge('
赵府 · 智能数字管家独立部署 / 数据自有
',2))],64))}},RM={};function LM(n,e){return y(),x(H,null,[e[0]||(e[0]=ge('
灯火可亲 · 归家有时

欢迎回来

使用自己的账号,进入家庭空间。

设备档案

网络与连接

保存后自动更新拓扑。网络信息用于设备档案;摄像机实际取流地址在“配置镜头”内设置。选择人员不改变账号访问权限。

手机、灯、冰箱等当前支持设备档案、分类和责任归属。自动控制需另行接入对应协议,登记不代表已连接设备。

传承资料

这里只保存资料和意愿;不会据此转移财产或授予任何账号权限。链接内容保存在原位置,本系统保存链接和文字记录。

空间档案

镜头通道配置

直接接入摄像头时,可读取设备实际提供的媒体配置。端口请按设备填写:通常为 80,部分 TP-Link 设备为 2020。服务器需要能够访问该设备所在网络。

选择录像机时,本平台不重复录制,须在录像机上开启录像计划;设备是否实际录制需在原厂后台核对。选择百度网盘时,请勾选启用网盘录像。账号和密码只保存在本机受限数据目录。RTSP 服务响应代表设备可达,实际码流接通后才显示在线。路径预设需要与设备型号、通道一致。

摄像头对象

网络与连接

保存后自动更新拓扑。网络信息用于设备档案;摄像机实际取流地址在“配置镜头”内设置。选择人员不改变账号访问权限。

录像机配置

网络与连接

保存后自动更新拓扑。网络信息用于设备档案;摄像机实际取流地址在“配置镜头”内设置。选择人员不改变账号访问权限。

驱动在当前版本提供路径模板。录像机历史录像检索、回放及通道自动导入,需要型号确认后接入,当前尚未实现。

',7)),e[1]||(e[1]=a("dialog",{id:"leadership-dialog"},[a("form",{id:"leadership-form"},[a("div",{class:"dialog-heading"},[a("h2",null,"负责人安排与交接"),a("button",{type:"button",class:"quiet","data-close":"leadership-dialog"},"关闭")]),a("input",{name:"id",type:"hidden"}),a("input",{name:"revision",type:"hidden"}),a("p",{class:"description"},"从已获本家庭访问权限的系统账号中,指定主要和备用负责人。主要负责人即一家之主;普通账号需明确确认授予本家庭管理权限。真实家庭成员可以没有登录账号。"),a("p",{id:"leadership-scope",class:"fw-semibold"}),a("div",{id:"leadership-empty",class:"alert alert-info",role:"status",hidden:""},"本家庭还没有可选账号。请由平台管理员在系统用户中授予家庭访问权限,再指定负责人。"),a("div",{class:"leadership-member-actions d-flex flex-wrap gap-2 mb-3"},[a("button",{type:"button",id:"leadership-new",class:"secondary"},"+ 添加本家庭管理员"),a("button",{type:"button",id:"leadership-members",class:"quiet"},"管理授权账号")]),a("div",{class:"form-grid"},[a("label",null,[C("主要负责人 *"),a("select",{name:"ownerId",required:""})]),a("label",null,[C("备用负责人"),a("select",{name:"successorId"})]),a("label",{id:"leadership-grant",class:"check full alert alert-warning",hidden:""},[a("input",{type:"checkbox",name:"grantManagement"}),a("span",{id:"leadership-grant-note"})]),a("label",{class:"full"},[C("安排 / 交接说明 *"),a("textarea",{name:"reason",required:"",maxlength:"300",rows:"3",placeholder:"说明负责人安排或本次交接原因"})])]),a("p",{class:"description"},"交接后原负责人仍保留本归属的管理员权限。系统不会依据未登录或家谱去世日期自动转移权限;交接记录可追溯。"),a("p",{class:"form-error",role:"status"}),a("div",{class:"dialog-footer"},[a("button",{type:"submit"},"确认保存负责人安排")])])],-1)),e[2]||(e[2]=a("dialog",{id:"household-dialog"},[a("form",{id:"household-form"},[a("div",{class:"dialog-heading"},[a("h2",null,"家庭 / 场所档案"),a("button",{type:"button",class:"quiet","data-close":"household-dialog"},"关闭")]),a("input",{name:"id",type:"hidden"}),a("input",{name:"profileRevision",type:"hidden",value:"0"}),a("div",{class:"form-grid"},[a("label",{class:"full"},[C("归属名称 *"),a("input",{name:"name",maxlength:"80",required:"",placeholder:"例如:赵府、济南办公室、莱阳工厂"})]),a("label",{class:"full"},[C("归属类型"),a("select",{name:"kind"},[a("option",{value:"home"},"家庭"),a("option",{value:"office"},"办公场所"),a("option",{value:"factory"},"工厂")])]),a("fieldset",{class:"full geo-picker","data-geography":"","data-geo-title":"所在地"}),a("div",{class:"full cover-editor"},[a("img",{id:"household-cover-preview",alt:"场所封面预览",hidden:""}),a("label",null,[C("卡片封面照片"),a("input",{id:"household-cover-file",type:"file",accept:"image/png,image/jpeg,image/webp"})]),a("button",{type:"button",id:"household-cover-cancel",class:"quiet"},"取消本次图片选择"),a("button",{type:"button",id:"household-cover-reset",class:"quiet"},"使用默认封面"),a("p",{id:"household-cover-status",class:"description",role:"status","aria-live":"polite"},"照片仅向有权进入该家庭或场所的账号开放。")]),a("label",{class:"full"},[C("备注"),a("textarea",{name:"note",maxlength:"300",rows:"3"})])]),a("p",{class:"description"},"创建后进入该归属,建立管理员,再自行划分区域和登记设备。"),a("p",{class:"form-error"}),a("div",{class:"dialog-footer"},[a("button",{type:"submit"},"保存家庭")])])],-1)),e[3]||(e[3]=ge('

账号档案

亲属关系在家庭成员对应的族谱人物之间建立;登录账号仅关联本人身份和访问权限。

允许查看摄像头的空间

普通成员只访问本归属内已授权的区域。默认仅授权所选区域;勾选“包含下级区域”后同时包含其所有后代。管理员可管理本归属全部区域。

',2)),e[4]||(e[4]=a("dialog",{id:"person-dialog"},[a("form",{id:"person-form"},[a("div",{class:"dialog-heading"},[a("h2",null,"家谱人物"),a("button",{type:"button",class:"quiet","data-close":"person-dialog"},"关闭")]),a("input",{name:"id",type:"hidden"}),a("input",{name:"revision",type:"hidden"}),a("p",{id:"person-self-note",class:"alert alert-info",hidden:""},"这将建立并固定关联为您本人,用于确定上下五代维护范围。如族谱已有您的人物,请关闭此窗口并请管理员关联,避免重复建档。"),a("fieldset",{id:"person-relative-fields"},[a("legend",null,"新人物与已有亲属的关系"),a("div",{class:"form-grid"},[a("label",null,[C("已有亲属"),a("select",{name:"relativeId"})]),a("label",null,[C("新人物是其"),a("select",{name:"relativeKind"},[a("option",{value:"parent"},"父母一方(上一代)"),a("option",{value:"child"},"子女(下一代)"),a("option",{value:"spouse"},"配偶(同代)")])])]),a("p",{class:"description"},"人物与关系一起保存,无需为亲属开设登录账号;超出五代时不会写入。")]),a("div",{class:"form-grid"},[a("label",null,[C("姓名 / 称呼 *"),a("input",{name:"name",required:"",maxlength:"80",placeholder:"姓名暂不知时可先填称呼"})]),a("label",null,[C("别名 / 字 / 号"),a("input",{name:"alias",maxlength:"120"})]),a("label",null,[C("性别"),a("select",{name:"gender"},[a("option",{value:"unknown"},"待确认"),a("option",{value:"male"},"男"),a("option",{value:"female"},"女")])]),a("label",null,[C("在世情况"),a("select",{name:"lifeStatus"},[a("option",{value:"alive"},"在世"),a("option",{value:"deceased"},"不在世"),a("option",{value:"unknown"},"待确认")])]),a("fieldset",{class:"family-date","data-date-field":"birthDate"},[a("legend",null,"出生日期"),a("input",{name:"birthDate",type:"hidden"}),a("label",null,[C("历法"),a("select",{"data-calendar":"","aria-label":"出生日期历法"},[a("option",{value:"solar"},"公历"),a("option",{value:"lunar"},"农历")])]),a("label",null,[C("日期"),a("input",{"data-date-value":"","aria-label":"出生日期",type:"text",inputmode:"numeric",placeholder:"YYYY-MM-DD",maxlength:"10"})]),a("label",{"data-leap-label":"",class:"check",hidden:""},[a("input",{"data-date-leap":"",type:"checkbox"}),C("闰月")]),a("output",{"data-date-hint":"","aria-live":"polite"},"日期不详可留空")]),a("fieldset",{class:"family-date","data-date-field":"deathDate",hidden:""},[a("legend",null,"去世日期"),a("input",{name:"deathDate",type:"hidden"}),a("label",null,[C("历法"),a("select",{"data-calendar":"","aria-label":"去世日期历法"},[a("option",{value:"solar"},"公历"),a("option",{value:"lunar"},"农历")])]),a("label",null,[C("日期"),a("input",{"data-date-value":"","aria-label":"去世日期",type:"text",inputmode:"numeric",placeholder:"YYYY-MM-DD",maxlength:"10"})]),a("label",{"data-leap-label":"",class:"check",hidden:""},[a("input",{"data-date-leap":"",type:"checkbox"}),C("闰月")]),a("output",{"data-date-hint":"","aria-live":"polite"},"日期不详可留空")]),a("label",{class:"full",id:"person-legacy-place"},[C("原籍贯/出生地记录"),a("input",{name:"birthplace",maxlength:"160"}),a("small",null,"历史填写内容保留,可在下方分别补充。")]),a("fieldset",{class:"full person-location"},[a("legend",null,"籍贯(祖籍)"),a("div",{class:"form-grid"},[a("fieldset",{class:"full geo-picker","data-geography":"native","data-geo-title":"籍贯(祖籍)"}),a("label",null,[C("乡镇/街道"),a("input",{name:"nativeTown",maxlength:"80",placeholder:"","aria-label":"籍贯(祖籍) · 乡镇/街道"})]),a("label",null,[C("村/社区"),a("input",{name:"nativeCommunity",maxlength:"80",placeholder:"","aria-label":"籍贯(祖籍) · 村/社区"})]),a("label",{class:"full"},[C("详细地址/历史地名"),a("input",{name:"nativeAddress",maxlength:"200",placeholder:"楼栋、门牌或旧称,可按已知信息填写","aria-label":"籍贯(祖籍) · 详细地址/历史地名"})])])]),a("fieldset",{class:"full person-location"},[a("legend",null,"出生地"),a("div",{class:"form-grid"},[a("fieldset",{class:"full geo-picker","data-geography":"birth","data-geo-title":"出生地"}),a("label",null,[C("乡镇/街道"),a("input",{name:"birthTown",maxlength:"80",placeholder:"","aria-label":"出生地 · 乡镇/街道"})]),a("label",null,[C("村/社区"),a("input",{name:"birthCommunity",maxlength:"80",placeholder:"","aria-label":"出生地 · 村/社区"})]),a("label",{class:"full"},[C("详细地址/历史地名"),a("input",{name:"birthAddress",maxlength:"200",placeholder:"楼栋、门牌或旧称,可按已知信息填写","aria-label":"出生地 · 详细地址/历史地名"})])])]),a("p",{class:"description full"},"籍贯与出生地可不同;选择中国、世界或自定义地域,不详的层级可留空。"),a("label",{class:"full"},[C("生平简介"),a("textarea",{name:"biography",rows:"4",maxlength:"2000"})]),a("label",{class:"full"},[C("备注 / 信息来源"),a("textarea",{name:"note",rows:"3",maxlength:"500",placeholder:"例如:长辈口述、族谱记载、待考证信息"})]),a("label",{class:"check"},[a("input",{name:"archived",type:"checkbox"}),C("归档人物(保留关系,可恢复)")])]),a("p",{class:"form-error"}),a("div",{class:"dialog-footer"},[a("button",{type:"submit"},"保存人物")])])],-1)),e[5]||(e[5]=ge('

连接人物关系

每条亲子关系连接一位父母与一位子女。双方需在本人上下五代内;不能通过移动或断开已确认世系来改变维护范围。

',1)),e[6]||(e[6]=a("dialog",{id:"event-dialog","aria-labelledby":"event-editor-title"},[a("form",{id:"event-form"},[a("div",{class:"dialog-heading"},[a("h2",{id:"event-editor-title"},"写一则家族记事"),a("button",{type:"button",class:"quiet","data-close":"event-dialog"},"关闭")]),a("input",{name:"id",type:"hidden"}),a("input",{name:"revision",type:"hidden"}),a("div",{class:"form-grid"},[a("label",{class:"full"},[C("记事标题 *"),a("input",{name:"title",required:"",maxlength:"160",placeholder:"用一句话概括这件事"})]),a("fieldset",{class:"family-date full","data-date-field":"eventDate"},[a("legend",null,"事情发生的日期 *"),a("input",{name:"eventDate",type:"hidden"}),a("label",null,[C("历法"),a("select",{"data-calendar":"","aria-label":"记事日期历法"},[a("option",{value:"solar"},"公历"),a("option",{value:"lunar"},"农历")])]),a("label",null,[C("日期"),a("input",{"data-date-value":"","aria-label":"记事日期",required:"",type:"text",inputmode:"numeric",placeholder:"YYYY-MM-DD",maxlength:"10"})]),a("label",{"data-leap-label":"",class:"check",hidden:""},[a("input",{"data-date-leap":"",type:"checkbox"}),C("闰月")]),a("output",{"data-date-hint":"","aria-live":"polite"})]),a("fieldset",{class:"full"},[a("legend",null,"关联人物(可多选)"),a("input",{id:"event-person-search",type:"search",placeholder:"查找要关联的亲人","aria-label":"查找关联人物"}),a("div",{id:"event-person-choices"}),a("p",{class:"description"},"未选择人物时记为全家记事。每位关联人物的档案都可以追溯到这条记事。")]),a("label",{class:"full"},[C("摘要"),a("textarea",{name:"summary",maxlength:"400",rows:"2",placeholder:"简要说明这件事"})]),a("label",{class:"full"},[C("详细记载"),a("textarea",{name:"body",maxlength:"12000",rows:"7",placeholder:"记录经过、意义、长辈口述或资料出处。可分段书写。"})]),a("label",null,[C("报道 / 资料来源"),a("input",{name:"sourceName",maxlength:"160",placeholder:"例如:报刊名称、个人博客"})]),a("label",null,[C("原始报道链接"),a("input",{name:"sourceUrl",type:"url",maxlength:"2000",placeholder:"https://…"})]),a("label",{class:"check full"},[a("input",{name:"archived",type:"checkbox"}),C("归档记事(保留内容,可恢复)")])]),a("p",{class:"description"},"正式发布后,有家谱查看权限的账号即可在时间线看到;草稿只对有编辑权限的人可见。"),a("p",{class:"form-error",role:"status"}),a("div",{class:"dialog-footer event-editor-actions"},[a("button",{type:"submit","data-save-event":"",value:"draft",class:"secondary"},"保存草稿"),a("button",{type:"submit","data-publish-event":"",value:"published"},"发布记事"),a("button",{type:"submit","data-withdraw-event":"",value:"draft",class:"secondary",hidden:""},"撤回为草稿")])])],-1)),e[7]||(e[7]=ge('
家事 · 家声
',1)),e[8]||(e[8]=a("dialog",{id:"history-dialog","aria-labelledby":"history-title"},[a("div",{class:"dialog-heading"},[a("h2",{id:"history-title"},"修改记录"),a("button",{type:"button",class:"quiet","data-close":"history-dialog"},"关闭")]),a("p",{class:"description"},"人物、关系与记事每次保存都会留存版本。仅有家谱编辑权限的账号可查阅和恢复。"),a("p",{id:"history-error",class:"form-error",role:"status"}),a("div",{id:"history-list"}),a("button",{id:"history-more",class:"quiet",hidden:""},"加载更早记录"),a("article",{id:"history-detail"})],-1)),e[9]||(e[9]=a("dialog",{id:"password-dialog","aria-labelledby":"password-title"},[a("form",{id:"password-form"},[a("div",{class:"dialog-heading"},[a("h2",{id:"password-title"},"修改我的密码"),a("button",{type:"button",class:"quiet","data-close":"password-dialog"},"关闭")]),a("p",{id:"password-account",class:"description"}),a("label",null,[C("当前密码"),a("input",{name:"currentPassword",type:"password",required:"",maxlength:"128",autocomplete:"current-password"})]),a("label",null,[C("新密码"),a("input",{name:"newPassword",type:"password",required:"",minlength:"8",maxlength:"128",autocomplete:"new-password"})]),a("label",null,[C("再次输入新密码"),a("input",{name:"confirmPassword",type:"password",required:"",minlength:"8",maxlength:"128",autocomplete:"new-password"})]),a("p",{class:"description"},"保存后,这个账号在所有设备上都需要用新密码重新登录。"),a("p",{class:"form-error",role:"status"}),a("div",{class:"dialog-footer"},[a("button",{type:"submit"},"保存新密码")])])],-1)),e[10]||(e[10]=a("dialog",{id:"camera-settings-dialog","aria-labelledby":"camera-settings-title"},[a("div",{class:"dialog-heading"},[a("h2",{id:"camera-settings-title"},"摄像机参数"),a("button",{class:"quiet","data-close":"camera-settings-dialog"},"关闭")]),a("div",{class:"section-head"},[a("label",null,[C("设置码流"),a("select",{id:"camera-settings-quality"},[a("option",{value:"main"},"主码流"),a("option",{value:"sub"},"子码流")])]),a("button",{id:"camera-settings-reload",class:"quiet"},"重新读取")]),a("div",{id:"camera-settings-info"}),a("p",{id:"camera-settings-status",class:"form-error",role:"status"}),a("form",{id:"camera-image-form"},[a("h3",null,"图像与日夜模式"),a("p",{class:"description"},"作用于当前物理镜头,主、子码流共用这些图像参数。"),a("div",{id:"camera-image-fields",class:"form-grid"}),a("div",{class:"dialog-footer"},[a("button",{type:"submit",disabled:""},"保存图像参数")])]),a("form",{id:"camera-video-form"},[a("h3",null,"码流与清晰度"),a("p",{class:"description"},"作用于上方选定的码流。保存后画面可能短暂重连,录像机也会使用调整后的码流。本页保留原有视频编码。"),a("div",{id:"camera-video-fields",class:"form-grid"}),a("div",{class:"dialog-footer"},[a("button",{type:"submit",disabled:""},"保存码流参数")])]),a("details",null,[a("summary",null,"其他萤石功能的接入情况"),a("ul",null,[a("li",null,"云台方向微调与预置位:在实时画面的“云台”中使用,按设备能力启用。"),a("li",null,"实时声音与全屏:通过画面播放器控制。"),a("li",null,"双向对讲、智能追踪、声光告警、隐私遮蔽、设备翻转、云录像和消息推送:当前尚未接入,请使用萤石 App。"),a("li",null,"录像机原有录像:仍通过录像机或原厂 App 查看;本系统已支持本机额外录像的回放。")]),a("p",{class:"description"},"功能按设备实际开放能力逐项接入,型号与固件不同可能有差异。")])],-1)),e[11]||(e[11]=a("div",{id:"toast",role:"status",hidden:""},null,-1)),e[12]||(e[12]=ge('

画面截图

当前视频画面截图

下载 PNG 图片

附件预览

',2))],64)}const PM=In(RM,[["render",LM]]),BM=["/vendor/hls.min.js","/live-player.js","/kinship.js","/family-graph.js","/calendar.js","/device-model.js","/data/geography-data.js","/geography.js","/app.js","/monitor.js","/date-fields.js","/family-map.js","/family.js","/family-events.js","/family-history.js","/camera-settings.js","/recording-ranges.js","/recording-ui.js","/snapshot.js","/households.js","/devices.js","/steward.js","/heritage.js","/personalization.js","/file-hash.js","/journal-queue.js","/journal.js"];function Ea(n){if(!(n instanceof Element))return;const e=[n,...n.querySelectorAll("button,input,select,textarea,table")];for(const t of e)t.matches("button")&&!t.closest(".family-map-viewport")&&!t.classList.contains("btn")&&t.classList.add("btn",t.matches(".quiet,.secondary")?"btn-outline-secondary":"btn-primary"),t.matches("select")&&t.classList.add("form-select"),t.matches("textarea,input:not([type=checkbox]):not([type=radio]):not([type=range]):not([type=hidden])")&&t.classList.add("form-control"),t.matches("input[type=checkbox],input[type=radio]")&&t.classList.add("form-check-input"),t.matches("table")&&t.classList.add("table","align-middle")}async function _M(){Ea(document.getElementById("app")),new MutationObserver(n=>{for(const e of n)for(const t of e.addedNodes)Ea(t)}).observe(document.getElementById("app"),{childList:!0,subtree:!0});for(const n of[...BM,"/vue-bridge.js"])await new Promise((e,t)=>{const s=document.createElement("script");s.src=n+"?ui=cf1dd21672863b5d",s.onload=e,s.onerror=()=>t(new Error("Could not load "+n)),document.head.append(s)});await window.ZhaoVue.boot()}const zM=["data-page"],jM={key:0,class:"alert alert-danger",role:"alert"},FM={__name:"App",setup(n){const e=P(!1);return $i(async()=>{try{await _M()}catch(t){console.error("Application startup failed",t),e.value=!0}}),(t,s)=>(y(),x(H,null,[G(ep),a("main",{"data-page":j(R).page},[G(sp),e.value?(y(),x("div",jM,"页面组件加载失败,请检查网络后重新打开页面。")):D("",!0),G($M)],8,zM),G(PM)],64))}};zu(FM).mount("#app"); diff --git a/web/ui/assets/tv-8KQFA1ao.js b/web/ui/assets/tv-8KQFA1ao.js new file mode 100644 index 0000000..9a36ec5 --- /dev/null +++ b/web/ui/assets/tv-8KQFA1ao.js @@ -0,0 +1 @@ +import"./modulepreload-polyfill-B5Qt9EMX.js";import{w as ve,f as de,g as he,o as i,c,a as e,e as B,t as n,u as V,h as _,F as U,j as R,i as me,B as ye,k as Y,l as C,r as S,n as ie,K as ge}from"./FamilyMap-CiWCoS6Z.js";function pe(v){const r=Object.fromEntries(new Intl.DateTimeFormat("en-GB",{timeZone:"Asia/Shanghai",year:"numeric",month:"2-digit",day:"2-digit",hour:"2-digit",minute:"2-digit",second:"2-digit",hourCycle:"h23"}).formatToParts(v).map(k=>[k.type,k.value])),h=new Date(Date.UTC(+r.year,+r.month-1,+r.day)),m=h.getUTCDay(),g=new Date(h);g.setUTCDate(h.getUTCDate()+4-(m||7));const T=new Date(Date.UTC(g.getUTCFullYear(),0,1));return{...r,weekday:"星期"+"日一二三四五六"[m],week:Math.ceil(((g-T)/864e5+1)/7),weekYear:g.getUTCFullYear(),date:`${r.year}-${r.month}-${r.day}`}}const ue=v=>v===0?"晴":v<=3?"多云":v<=48?"有雾":v<=67?"有雨":v<=77?"有雪":v<=82?"阵雨":v<=86?"阵雪":v>=95?"雷雨":"天气更新中",j="zhao.display",Z=v=>typeof v=="string"&&/^[A-Za-z0-9_-]{43}$/.test(v);function fe({fetcher:v=fetch,storage:r=localStorage,url:h=location,historyApi:m=history,onChange:g,later:T=setTimeout,cancel:k=clearTimeout,now:P=Date.now}={}){let d="",D=0,$,w,p=!1,f=0,o={data:null,error:"",authRequired:!1,loading:!1,lastSync:0};const b=l=>{o={...o,...l},g({...o})},L=()=>{try{return r.getItem(j)||""}catch(l){return""}},I=l=>{try{l?r.setItem(j,l):r.removeItem(j)}catch(M){}};function N(){D++,k($),w==null||w.abort()}function x(l){if(!p&&(N(),d=Z(l)?l:"",I(d),f=0,b({data:null,lastSync:0,error:d?"":"请在家庭的显示终端管理中获取配对码,完成绑定。",authRequired:!d,loading:!!d}),d))return E()}function F(){const l=new URLSearchParams(h.hash.slice(1));if(!l.has("display"))return!1;const M=l.get("display");l.delete("display");try{m.replaceState(null,"",h.pathname+h.search+(l.toString()?"#"+l.toString():""))}catch(u){}return x(M),!0}async function E(){if(p||!d)return;k($);const l=++D,M=d;w==null||w.abort();const u=new AbortController;w=u;const O=T(()=>u.abort(),12e3);b({loading:!0});try{const y=await v("/api/display/snapshot",{headers:{Authorization:"Bearer "+M},signal:u.signal,cache:"no-store"}),A=await y.json();if(p||l!==D)return;if(y.status===401||y.status===403){const q=L();if(Z(q)&&q!==M){x(q);return}d="",I(""),b({data:null,lastSync:0,error:A.error||"展示授权已失效,请重新连接显示终端。",authRequired:!0});return}if(!y.ok)throw Error(A.error||"暂时无法同步家庭资料");f=0,b({data:A,error:"",authRequired:!1,lastSync:P()})}catch(y){!p&&l===D&&(f++,b({error:y.name==="AbortError"?"家庭连接暂时超时":y.message||"家庭连接暂时中断"}))}finally{k(O),!p&&l===D&&(b({loading:!1}),d&&($=T(E,Math.min(12e4,3e4*Math.max(1,f)))))}}return{start(){if(!F())return x(L())},hashChanged:F,storageChanged(l){if(l.key===j||l.key===null)return x(L())},retry(){if(F())return;const l=L();return Z(l)&&l!==d?x(l):d?E():x("")},stop(){p=!0,N()}}}const _e={class:"tv-shell"},ke={class:"tv-top"},we={key:0,class:"tv-reconnect",role:"alert"},be=["disabled"],xe={class:"tv-upper"},Ce={class:"square-clock","aria-label":"北京时间时钟"},Te=["aria-label"],De=["transform"],Se=["y1","y2"],Ee=["x","y"],Le=["transform"],Me=["transform"],$e=["transform"],Fe={x:"220",y:"303",class:"digital-time"},qe={class:"tv-home"},Ie={class:"tv-greeting"},Ae={class:"tv-date"},ze={class:"tv-date-extra"},Be={key:0},Ue={class:"tv-weather tv-card","aria-label":"天气"},Re={class:"weather-current"},Pe={class:"section-label"},Ne={class:"weather-big"},Ye={class:"weather-symbol"},je={key:0},Oe={class:"weather-note"},Ve={key:0,class:"weather-forecast"},Ze={class:"tv-bottom"},Ge={class:"tv-card tv-devices"},Ke={class:"tv-section-heading"},He={class:"tv-device-grid"},Je={class:"device-emblem"},Qe={key:0,class:"tv-empty"},We={key:0,class:"tv-page-count"},Xe={class:"tv-family-presence tv-card"},et={key:0},tt={key:2,class:"tv-positions"},at={key:0},st={key:0},nt={class:"tv-footer"},lt={key:0,class:"sync-error"},ot={__name:"Television",setup(v){const r=S(null),h=S(Date.now()),m=S(""),g=S(0),T=S(0),k=S(0),P=S(!1),d=S(!1),D=S(!1);let $,w,p;const f=fe({onChange:t=>{if(r.value=t.data,m.value=t.error,g.value=t.lastSync,d.value=t.authRequired,D.value=t.loading,t.data){const a=new Date(t.data.serverTime).getTime();Number.isFinite(a)&&(k.value=a-t.lastSync)}}}),o=C(()=>pe(new Date(h.value+k.value))),b=C(()=>+o.value.hour>=20||+o.value.hour<7),L=t=>(b.value?["#978469","#739486","#8299aa","#ab8278"]:["#ee8a25","#148a7e","#2585cb","#d44e6b"])[t%4];ve(b,t=>document.documentElement.dataset.theme=t?"night":"day",{immediate:!0});const I=C(()=>{try{return new Intl.DateTimeFormat("zh-CN-u-ca-chinese",{timeZone:"Asia/Shanghai",month:"long",day:"numeric"}).format(new Date(h.value+k.value))}catch(t){return""}}),N=C(()=>+o.value.hour<6?"夜深了,愿你好梦":+o.value.hour<11?"早安,新的一天":+o.value.hour<14?"午安,慢慢生活":+o.value.hour<18?"午后,家有暖意":"晚安时光,灯火可亲"),x=C(()=>({hour:+o.value.hour%12*30+ +o.value.minute/2,minute:+o.value.minute*6,second:+o.value.second*6})),F=C(()=>{var z;const t=((z=r.value)==null?void 0:z.devices)||[],a=T.value%Math.max(1,Math.ceil(t.length/3))*3;return t.slice(a,a+3)}),E=C(()=>{var a;if(h.value-g.value>9e4||m.value)return[];const t=((a=r.value)==null?void 0:a.locations)||[];return t.slice(T.value%Math.max(1,Math.ceil(t.length/3))*3,T.value%Math.max(1,Math.ceil(t.length/3))*3+3)}),l=C(()=>{var t;return h.value-g.value>9e4||m.value?[]:((t=r.value)==null?void 0:t.locations)||[]}),M=t=>t.status==="scheduled"?"按设定周期上传 · 等待下次更新":t.status==="stale"?"位置更新中断 · 请检查手机":t.position?`${t.position.latitude.toFixed(3)}°, ${t.position.longitude.toFixed(3)}°`:"等待手机定位",u=C(()=>{var t;return(t=r.value)==null?void 0:t.weather}),O=C(()=>d.value?"等待重新连接":g.value?m.value||h.value-g.value>9e4?"网络暂时中断 · 显示上次资料":"家庭资料已同步":"正在连接家庭"),y=t=>typeof t=="number"?Math.round(t):"—";async function A(){try{document.fullscreenElement?await document.exitFullscreen():await document.documentElement.requestFullscreen(),P.value=!!document.fullscreenElement,navigator.wakeLock&&(p=await navigator.wakeLock.request("screen"))}catch(t){}}const q=()=>{!document.hidden&&navigator.wakeLock&&navigator.wakeLock.request("screen").then(t=>p=t).catch(()=>{})};return de(()=>{f.start(),$=setInterval(()=>h.value=Date.now(),1e3),w=setInterval(()=>T.value++,15e3),document.addEventListener("visibilitychange",q),window.addEventListener("hashchange",f.hashChanged),window.addEventListener("storage",f.storageChanged)}),he(()=>{f.stop(),clearInterval($),clearInterval(w),p==null||p.release(),document.removeEventListener("visibilitychange",q),window.removeEventListener("hashchange",f.hashChanged),window.removeEventListener("storage",f.storageChanged)}),(t,a)=>{var z,G,K,H,J,Q,W,X,ee,te,ae,se,ne,le,oe,re;return i(),c("div",_e,[e("header",ke,[a[1]||(a[1]=e("span",{class:"tv-brand"},[e("img",{src:"/zhao-icon.png",alt:"赵"}),B("赵府 "),e("span",null,"家庭时光")],-1)),e("button",{class:"tv-fullscreen",onClick:A,"aria-label":"切换全屏"},n(P.value?"退出全屏":"全屏展示")+" ⛶",1)]),d.value?(i(),c("section",we,[a[2]||(a[2]=e("strong",null,"显示终端需要重新连接",-1)),e("p",null,n(m.value),1),a[3]||(a[3]=e("p",null,"若刚完成配对,请退出并重新打开 App。需要更换配对时,点击下方「绑定家庭」,输入管理员生成的 8 位显示终端配对码。",-1)),e("button",{onClick:a[0]||(a[0]=s=>V(f).retry()),disabled:D.value},n(D.value?"正在连接…":"重试连接"),9,be)])):_("",!0),e("div",xe,[e("section",Ce,[(i(),c("svg",{viewBox:"0 0 440 440",role:"img","aria-label":`${o.value.hour}:${o.value.minute}:${o.value.second}`},[(i(),c(U,null,R(60,s=>e("g",{key:s,transform:`rotate(${s*6} 220 220)`},[e("line",{x1:"220",y1:s%5===0?29:32,x2:"220",y2:s%5===0?46:39,style:ie(s%5===0?{stroke:L(s/5)}:{}),class:Y(s%5===0?"hour-mark":"minute-mark")},null,14,Se)],8,De)),64)),(i(),c(U,null,R(12,s=>e("text",{key:"n"+s,x:220+148*Math.sin(s*Math.PI/6),y:220-148*Math.cos(s*Math.PI/6)+10,style:ie({fill:L(s)}),class:"clock-number"},n(s),13,Ee)),64)),a[4]||(a[4]=e("text",{x:"220",y:"140",class:"clock-word"},"家 · 在 此 刻",-1)),e("line",{x1:"220",y1:"231",x2:"220",y2:"127",class:"clock-hour",transform:`rotate(${x.value.hour} 220 220)`},null,8,Le),e("line",{x1:"220",y1:"234",x2:"220",y2:"91",class:"clock-minute",transform:`rotate(${x.value.minute} 220 220)`},null,8,Me),e("line",{x1:"220",y1:"247",x2:"220",y2:"65",class:"clock-second",transform:`rotate(${x.value.second} 220 220)`},null,8,$e),a[5]||(a[5]=e("circle",{cx:"220",cy:"220",r:"8",fill:"#a66645"},null,-1)),a[6]||(a[6]=e("circle",{cx:"220",cy:"220",r:"3",fill:"#fffaf0"},null,-1)),e("text",Fe,n(o.value.hour)+":"+n(o.value.minute),1),a[7]||(a[7]=e("text",{x:"220",y:"329",class:"clock-zone"},"北京时间",-1))],8,Te))]),e("section",qe,[e("div",Ie,n(N.value),1),e("h1",null,n(((z=r.value)==null?void 0:z.home.name)||"欢迎回家"),1),e("div",Ae,[B(n(o.value.year)+" 年 "+n(+o.value.month)+" 月 "+n(+o.value.day)+" 日 ",1),e("b",null,n(o.value.weekday),1)]),e("div",ze,[I.value?(i(),c("span",Be,"农历 "+n(I.value),1)):_("",!0),e("span",null,n(o.value.weekYear)+" 年 · 第 "+n(o.value.week)+" 周",1)])])]),e("section",Ue,[e("div",Re,[e("div",Pe,n(((G=u.value)==null?void 0:G.city)||((K=r.value)==null?void 0:K.home.city)||"本地")+" · 天气",1),e("div",Ne,[e("span",Ye,n((H=u.value)!=null&&H.available&&u.value.current.weather_code<3?"☀":"☁"),1),e("strong",null,[B(n((J=u.value)!=null&&J.available?y(u.value.current.temperature_2m):"—"),1),a[8]||(a[8]=e("small",null,"°",-1))]),e("div",null,[e("b",null,n((Q=u.value)!=null&&Q.available?V(ue)(u.value.current.weather_code):"天气更新中"),1),(W=u.value)!=null&&W.available?(i(),c("span",je,"体感 "+n(y(u.value.current.apparent_temperature))+"° · 湿度 "+n(y(u.value.current.relative_humidity_2m))+"%",1)):_("",!0)])]),e("div",Oe,n((X=u.value)!=null&&X.stale?"上次天气 · 待更新":(ee=u.value)!=null&&ee.available?"室外天气 · "+(u.value.current.time||"").slice(11,16)+" 更新":((te=u.value)==null?void 0:te.message)||"正在连接天气服务"),1)]),(ae=u.value)!=null&&ae.available?(i(),c("div",Ve,[(i(!0),c(U,null,R(u.value.days,(s,ce)=>(i(),c("div",{key:s.date},[e("span",null,n(["今天","明天","后天"][ce]),1),e("b",null,n(V(ue)(s.code)),1),e("span",null,n(y(s.low))+"° / "+n(y(s.high))+"°",1)]))),128))])):_("",!0)]),e("div",Ze,[e("section",Ge,[e("div",Ke,[a[9]||(a[9]=e("h2",null,"家中设备",-1)),e("span",null,n((ne=(se=r.value)==null?void 0:se.home.deviceCount)!=null?ne:"—")+" 台 · "+n((oe=(le=r.value)==null?void 0:le.home.spaces)!=null?oe:"—")+" 处区域",1)]),e("div",He,[(i(!0),c(U,null,R(F.value,s=>(i(),c("article",{key:s.id,class:"tv-device"},[e("div",Je,n(/电视|显示/.test(s.type)?"▣":/摄像/.test(s.type)?"◉":/路由|网关/.test(s.type)?"⌁":"◇"),1),e("div",null,[e("h3",null,n(s.name),1),e("p",null,n(s.location),1),e("span",{class:Y(["tv-status",s.status])},[a[10]||(a[10]=e("i",null,null,-1)),B(n(s.statusLabel),1)],2)])]))),128)),F.value.length?_("",!0):(i(),c("div",Qe,"设备接入后,会在这里与你见面。"))]),(((re=r.value)==null?void 0:re.devices.length)||0)>3?(i(),c("div",We,"设备分组自动轮换 · 每 15 秒")):_("",!0)]),e("section",Xe,[e("div",null,[a[11]||(a[11]=e("h2",null,"家人位置",-1)),E.value.length?_("",!0):(i(),c("p",et,"等待家人主动开启位置共享")),l.value.some(s=>s.position)?(i(),me(ye,{key:1,items:l.value,night:b.value,height:220},null,8,["items","night"])):_("",!0),E.value.length?(i(),c("div",tt,[(i(!0),c(U,null,R(E.value,s=>(i(),c("div",{key:s.id},[e("b",null,n(s.name),1),e("span",{class:Y({warning:s.status==="stale"})},n(M(s)),3),s.position?(i(),c("small",at,n(new Date(s.position.at*1e3).toLocaleTimeString("zh-CN",{hour:"2-digit",minute:"2-digit"}))+" 更新",1)):_("",!0)]))),128))])):_("",!0)]),E.value.length?_("",!0):(i(),c("span",st,"暂无共享位置"))])]),e("footer",nt,[e("span",{class:Y({warning:!!m.value})},[a[12]||(a[12]=e("i",null,null,-1)),B(n(O.value),1)],2),m.value?(i(),c("span",lt,n(m.value),1)):_("",!0),a[13]||(a[13]=e("span",null,"愿每个平常日,都有家的温度",-1)),a[14]||(a[14]=e("a",{href:"https://open-meteo.com/",target:"_blank",rel:"noreferrer"},"天气 Open-Meteo",-1))])])}}};ge(ot).mount("#app"); diff --git a/web/ui/assets/tv-Dxkdq4LJ.js b/web/ui/assets/tv-Dxkdq4LJ.js deleted file mode 100644 index c85a7fd..0000000 --- a/web/ui/assets/tv-Dxkdq4LJ.js +++ /dev/null @@ -1 +0,0 @@ -import"./modulepreload-polyfill-B5Qt9EMX.js";import{w as ve,f as de,g as he,o as i,c,a as e,e as B,t as n,u as V,h as _,F as U,j as R,i as me,B as ye,k as Y,l as C,r as S,n as ie,K as ge}from"./FamilyMap-CiWCoS6Z.js";function pe(v){const r=Object.fromEntries(new Intl.DateTimeFormat("en-GB",{timeZone:"Asia/Shanghai",year:"numeric",month:"2-digit",day:"2-digit",hour:"2-digit",minute:"2-digit",second:"2-digit",hourCycle:"h23"}).formatToParts(v).map(k=>[k.type,k.value])),h=new Date(Date.UTC(+r.year,+r.month-1,+r.day)),m=h.getUTCDay(),g=new Date(h);g.setUTCDate(h.getUTCDate()+4-(m||7));const T=new Date(Date.UTC(g.getUTCFullYear(),0,1));return{...r,weekday:"星期"+"日一二三四五六"[m],week:Math.ceil(((g-T)/864e5+1)/7),weekYear:g.getUTCFullYear(),date:`${r.year}-${r.month}-${r.day}`}}const ue=v=>v===0?"晴":v<=3?"多云":v<=48?"有雾":v<=67?"有雨":v<=77?"有雪":v<=82?"阵雨":v<=86?"阵雪":v>=95?"雷雨":"天气更新中",j="zhao.display",Z=v=>typeof v=="string"&&/^[A-Za-z0-9_-]{43}$/.test(v);function fe({fetcher:v=fetch,storage:r=localStorage,url:h=location,historyApi:m=history,onChange:g,later:T=setTimeout,cancel:k=clearTimeout,now:P=Date.now}={}){let d="",D=0,$,w,p=!1,f=0,o={data:null,error:"",authRequired:!1,loading:!1,lastSync:0};const b=l=>{o={...o,...l},g({...o})},L=()=>{try{return r.getItem(j)||""}catch(l){return""}},I=l=>{try{l?r.setItem(j,l):r.removeItem(j)}catch(M){}};function N(){D++,k($),w==null||w.abort()}function x(l){if(!p&&(N(),d=Z(l)?l:"",I(d),f=0,b({data:null,lastSync:0,error:d?"":"请在家庭的显示终端管理中获取配对码,完成绑定。",authRequired:!d,loading:!!d}),d))return E()}function F(){const l=new URLSearchParams(h.hash.slice(1));if(!l.has("display"))return!1;const M=l.get("display");l.delete("display");try{m.replaceState(null,"",h.pathname+h.search+(l.toString()?"#"+l.toString():""))}catch(u){}return x(M),!0}async function E(){if(p||!d)return;k($);const l=++D,M=d;w==null||w.abort();const u=new AbortController;w=u;const O=T(()=>u.abort(),12e3);b({loading:!0});try{const y=await v("/api/display/snapshot",{headers:{Authorization:"Bearer "+M},signal:u.signal,cache:"no-store"}),A=await y.json();if(p||l!==D)return;if(y.status===401||y.status===403){const q=L();if(Z(q)&&q!==M){x(q);return}d="",I(""),b({data:null,lastSync:0,error:A.error||"展示授权已失效,请重新连接显示终端。",authRequired:!0});return}if(!y.ok)throw Error(A.error||"暂时无法同步家庭资料");f=0,b({data:A,error:"",authRequired:!1,lastSync:P()})}catch(y){!p&&l===D&&(f++,b({error:y.name==="AbortError"?"家庭连接暂时超时":y.message||"家庭连接暂时中断"}))}finally{k(O),!p&&l===D&&(b({loading:!1}),d&&($=T(E,Math.min(12e4,3e4*Math.max(1,f)))))}}return{start(){if(!F())return x(L())},hashChanged:F,storageChanged(l){if(l.key===j||l.key===null)return x(L())},retry(){if(F())return;const l=L();return Z(l)&&l!==d?x(l):d?E():x("")},stop(){p=!0,N()}}}const _e={class:"tv-shell"},ke={class:"tv-top"},we={key:0,class:"tv-reconnect",role:"alert"},be=["disabled"],xe={class:"tv-upper"},Ce={class:"square-clock","aria-label":"北京时间时钟"},Te=["aria-label"],De=["transform"],Se=["y1","y2"],Ee=["x","y"],Le=["transform"],Me=["transform"],$e=["transform"],Fe={x:"220",y:"303",class:"digital-time"},qe={class:"tv-home"},Ie={class:"tv-greeting"},Ae={class:"tv-date"},ze={class:"tv-date-extra"},Be={key:0},Ue={class:"tv-weather tv-card","aria-label":"天气"},Re={class:"weather-current"},Pe={class:"section-label"},Ne={class:"weather-big"},Ye={class:"weather-symbol"},je={key:0},Oe={class:"weather-note"},Ve={key:0,class:"weather-forecast"},Ze={class:"tv-bottom"},Ge={class:"tv-card tv-devices"},Ke={class:"tv-section-heading"},He={class:"tv-device-grid"},Je={class:"device-emblem"},Qe={key:0,class:"tv-empty"},We={key:0,class:"tv-page-count"},Xe={class:"tv-family-presence tv-card"},et={key:0},tt={key:2,class:"tv-positions"},at={key:0},st={key:0},nt={class:"tv-footer"},lt={key:0,class:"sync-error"},ot={__name:"Television",setup(v){const r=S(null),h=S(Date.now()),m=S(""),g=S(0),T=S(0),k=S(0),P=S(!1),d=S(!1),D=S(!1);let $,w,p;const f=fe({onChange:a=>{if(r.value=a.data,m.value=a.error,g.value=a.lastSync,d.value=a.authRequired,D.value=a.loading,a.data){const t=new Date(a.data.serverTime).getTime();Number.isFinite(t)&&(k.value=t-a.lastSync)}}}),o=C(()=>pe(new Date(h.value+k.value))),b=C(()=>+o.value.hour>=20||+o.value.hour<7),L=a=>(b.value?["#978469","#739486","#8299aa","#ab8278"]:["#ee8a25","#148a7e","#2585cb","#d44e6b"])[a%4];ve(b,a=>document.documentElement.dataset.theme=a?"night":"day",{immediate:!0});const I=C(()=>{try{return new Intl.DateTimeFormat("zh-CN-u-ca-chinese",{timeZone:"Asia/Shanghai",month:"long",day:"numeric"}).format(new Date(h.value+k.value))}catch(a){return""}}),N=C(()=>+o.value.hour<6?"夜深了,愿你好梦":+o.value.hour<11?"早安,新的一天":+o.value.hour<14?"午安,慢慢生活":+o.value.hour<18?"午后,家有暖意":"晚安时光,灯火可亲"),x=C(()=>({hour:+o.value.hour%12*30+ +o.value.minute/2,minute:+o.value.minute*6,second:+o.value.second*6})),F=C(()=>{var z;const a=((z=r.value)==null?void 0:z.devices)||[],t=T.value%Math.max(1,Math.ceil(a.length/3))*3;return a.slice(t,t+3)}),E=C(()=>{var t;if(h.value-g.value>9e4||m.value)return[];const a=((t=r.value)==null?void 0:t.locations)||[];return a.slice(T.value%Math.max(1,Math.ceil(a.length/3))*3,T.value%Math.max(1,Math.ceil(a.length/3))*3+3)}),l=C(()=>{var a;return h.value-g.value>9e4||m.value?[]:((a=r.value)==null?void 0:a.locations)||[]}),M=a=>a.status==="stale"?"位置更新中断 · 请检查手机":a.position?`${a.position.latitude.toFixed(3)}°, ${a.position.longitude.toFixed(3)}°`:"等待手机定位",u=C(()=>{var a;return(a=r.value)==null?void 0:a.weather}),O=C(()=>d.value?"等待重新连接":g.value?m.value||h.value-g.value>9e4?"网络暂时中断 · 显示上次资料":"家庭资料已同步":"正在连接家庭"),y=a=>typeof a=="number"?Math.round(a):"—";async function A(){try{document.fullscreenElement?await document.exitFullscreen():await document.documentElement.requestFullscreen(),P.value=!!document.fullscreenElement,navigator.wakeLock&&(p=await navigator.wakeLock.request("screen"))}catch(a){}}const q=()=>{!document.hidden&&navigator.wakeLock&&navigator.wakeLock.request("screen").then(a=>p=a).catch(()=>{})};return de(()=>{f.start(),$=setInterval(()=>h.value=Date.now(),1e3),w=setInterval(()=>T.value++,15e3),document.addEventListener("visibilitychange",q),window.addEventListener("hashchange",f.hashChanged),window.addEventListener("storage",f.storageChanged)}),he(()=>{f.stop(),clearInterval($),clearInterval(w),p==null||p.release(),document.removeEventListener("visibilitychange",q),window.removeEventListener("hashchange",f.hashChanged),window.removeEventListener("storage",f.storageChanged)}),(a,t)=>{var z,G,K,H,J,Q,W,X,ee,te,ae,se,ne,le,oe,re;return i(),c("div",_e,[e("header",ke,[t[1]||(t[1]=e("span",{class:"tv-brand"},[e("img",{src:"/zhao-icon.png",alt:"赵"}),B("赵府 "),e("span",null,"家庭时光")],-1)),e("button",{class:"tv-fullscreen",onClick:A,"aria-label":"切换全屏"},n(P.value?"退出全屏":"全屏展示")+" ⛶",1)]),d.value?(i(),c("section",we,[t[2]||(t[2]=e("strong",null,"显示终端需要重新连接",-1)),e("p",null,n(m.value),1),t[3]||(t[3]=e("p",null,"若刚完成配对,请退出并重新打开 App。需要更换配对时,点击下方「绑定家庭」,输入管理员生成的 8 位显示终端配对码。",-1)),e("button",{onClick:t[0]||(t[0]=s=>V(f).retry()),disabled:D.value},n(D.value?"正在连接…":"重试连接"),9,be)])):_("",!0),e("div",xe,[e("section",Ce,[(i(),c("svg",{viewBox:"0 0 440 440",role:"img","aria-label":`${o.value.hour}:${o.value.minute}:${o.value.second}`},[(i(),c(U,null,R(60,s=>e("g",{key:s,transform:`rotate(${s*6} 220 220)`},[e("line",{x1:"220",y1:s%5===0?29:32,x2:"220",y2:s%5===0?46:39,style:ie(s%5===0?{stroke:L(s/5)}:{}),class:Y(s%5===0?"hour-mark":"minute-mark")},null,14,Se)],8,De)),64)),(i(),c(U,null,R(12,s=>e("text",{key:"n"+s,x:220+148*Math.sin(s*Math.PI/6),y:220-148*Math.cos(s*Math.PI/6)+10,style:ie({fill:L(s)}),class:"clock-number"},n(s),13,Ee)),64)),t[4]||(t[4]=e("text",{x:"220",y:"140",class:"clock-word"},"家 · 在 此 刻",-1)),e("line",{x1:"220",y1:"231",x2:"220",y2:"127",class:"clock-hour",transform:`rotate(${x.value.hour} 220 220)`},null,8,Le),e("line",{x1:"220",y1:"234",x2:"220",y2:"91",class:"clock-minute",transform:`rotate(${x.value.minute} 220 220)`},null,8,Me),e("line",{x1:"220",y1:"247",x2:"220",y2:"65",class:"clock-second",transform:`rotate(${x.value.second} 220 220)`},null,8,$e),t[5]||(t[5]=e("circle",{cx:"220",cy:"220",r:"8",fill:"#a66645"},null,-1)),t[6]||(t[6]=e("circle",{cx:"220",cy:"220",r:"3",fill:"#fffaf0"},null,-1)),e("text",Fe,n(o.value.hour)+":"+n(o.value.minute),1),t[7]||(t[7]=e("text",{x:"220",y:"329",class:"clock-zone"},"北京时间",-1))],8,Te))]),e("section",qe,[e("div",Ie,n(N.value),1),e("h1",null,n(((z=r.value)==null?void 0:z.home.name)||"欢迎回家"),1),e("div",Ae,[B(n(o.value.year)+" 年 "+n(+o.value.month)+" 月 "+n(+o.value.day)+" 日 ",1),e("b",null,n(o.value.weekday),1)]),e("div",ze,[I.value?(i(),c("span",Be,"农历 "+n(I.value),1)):_("",!0),e("span",null,n(o.value.weekYear)+" 年 · 第 "+n(o.value.week)+" 周",1)])])]),e("section",Ue,[e("div",Re,[e("div",Pe,n(((G=u.value)==null?void 0:G.city)||((K=r.value)==null?void 0:K.home.city)||"本地")+" · 天气",1),e("div",Ne,[e("span",Ye,n((H=u.value)!=null&&H.available&&u.value.current.weather_code<3?"☀":"☁"),1),e("strong",null,[B(n((J=u.value)!=null&&J.available?y(u.value.current.temperature_2m):"—"),1),t[8]||(t[8]=e("small",null,"°",-1))]),e("div",null,[e("b",null,n((Q=u.value)!=null&&Q.available?V(ue)(u.value.current.weather_code):"天气更新中"),1),(W=u.value)!=null&&W.available?(i(),c("span",je,"体感 "+n(y(u.value.current.apparent_temperature))+"° · 湿度 "+n(y(u.value.current.relative_humidity_2m))+"%",1)):_("",!0)])]),e("div",Oe,n((X=u.value)!=null&&X.stale?"上次天气 · 待更新":(ee=u.value)!=null&&ee.available?"室外天气 · "+(u.value.current.time||"").slice(11,16)+" 更新":((te=u.value)==null?void 0:te.message)||"正在连接天气服务"),1)]),(ae=u.value)!=null&&ae.available?(i(),c("div",Ve,[(i(!0),c(U,null,R(u.value.days,(s,ce)=>(i(),c("div",{key:s.date},[e("span",null,n(["今天","明天","后天"][ce]),1),e("b",null,n(V(ue)(s.code)),1),e("span",null,n(y(s.low))+"° / "+n(y(s.high))+"°",1)]))),128))])):_("",!0)]),e("div",Ze,[e("section",Ge,[e("div",Ke,[t[9]||(t[9]=e("h2",null,"家中设备",-1)),e("span",null,n((ne=(se=r.value)==null?void 0:se.home.deviceCount)!=null?ne:"—")+" 台 · "+n((oe=(le=r.value)==null?void 0:le.home.spaces)!=null?oe:"—")+" 处区域",1)]),e("div",He,[(i(!0),c(U,null,R(F.value,s=>(i(),c("article",{key:s.id,class:"tv-device"},[e("div",Je,n(/电视|显示/.test(s.type)?"▣":/摄像/.test(s.type)?"◉":/路由|网关/.test(s.type)?"⌁":"◇"),1),e("div",null,[e("h3",null,n(s.name),1),e("p",null,n(s.location),1),e("span",{class:Y(["tv-status",s.status])},[t[10]||(t[10]=e("i",null,null,-1)),B(n(s.statusLabel),1)],2)])]))),128)),F.value.length?_("",!0):(i(),c("div",Qe,"设备接入后,会在这里与你见面。"))]),(((re=r.value)==null?void 0:re.devices.length)||0)>3?(i(),c("div",We,"设备分组自动轮换 · 每 15 秒")):_("",!0)]),e("section",Xe,[e("div",null,[t[11]||(t[11]=e("h2",null,"家人位置",-1)),E.value.length?_("",!0):(i(),c("p",et,"等待家人主动开启位置共享")),l.value.some(s=>s.position)?(i(),me(ye,{key:1,items:l.value,night:b.value,height:220},null,8,["items","night"])):_("",!0),E.value.length?(i(),c("div",tt,[(i(!0),c(U,null,R(E.value,s=>(i(),c("div",{key:s.id},[e("b",null,n(s.name),1),e("span",{class:Y({warning:s.status==="stale"})},n(M(s)),3),s.position?(i(),c("small",at,n(new Date(s.position.at*1e3).toLocaleTimeString("zh-CN",{hour:"2-digit",minute:"2-digit"}))+" 更新",1)):_("",!0)]))),128))])):_("",!0)]),E.value.length?_("",!0):(i(),c("span",st,"暂无共享位置"))])]),e("footer",nt,[e("span",{class:Y({warning:!!m.value})},[t[12]||(t[12]=e("i",null,null,-1)),B(n(O.value),1)],2),m.value?(i(),c("span",lt,n(m.value),1)):_("",!0),t[13]||(t[13]=e("span",null,"愿每个平常日,都有家的温度",-1)),t[14]||(t[14]=e("a",{href:"https://open-meteo.com/",target:"_blank",rel:"noreferrer"},"天气 Open-Meteo",-1))])])}}};ge(ot).mount("#app"); diff --git a/web/ui/index.html b/web/ui/index.html index 3e1b774..319cd92 100644 --- a/web/ui/index.html +++ b/web/ui/index.html @@ -1,6 +1,6 @@ -赵府 · 智能数字管家 +赵府 · 智能数字管家 - +
diff --git a/web/ui/tv.html b/web/ui/tv.html index e7b4fcd..be551fc 100644 --- a/web/ui/tv.html +++ b/web/ui/tv.html @@ -1,4 +1,4 @@ -赵府 · 家庭时光 +赵府 · 家庭时光